Skip to content

Commit

Permalink
txpool: EIP-3860 should only apply to create transactions (#10610)
Browse files Browse the repository at this point in the history
Copy PR #10609 into `main`
  • Loading branch information
yperbasis authored Jun 4, 2024
1 parent 42006fa commit 64dac27
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
6 changes: 2 additions & 4 deletions erigon-lib/txpool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -833,10 +833,8 @@ func toBlobs(_blobs [][]byte) []gokzg4844.Blob {

func (p *TxPool) validateTx(txn *types.TxSlot, isLocal bool, stateCache kvcache.CacheView) txpoolcfg.DiscardReason {
isShanghai := p.isShanghai() || p.isAgra()
if isShanghai {
if txn.DataLen > fixedgas.MaxInitCodeSize {
return txpoolcfg.InitCodeTooLarge
}
if isShanghai && txn.Creation && txn.DataLen > fixedgas.MaxInitCodeSize {
return txpoolcfg.InitCodeTooLarge // EIP-3860
}
if txn.Type == types.BlobTxType {
if !p.isCancun() {
Expand Down
23 changes: 20 additions & 3 deletions erigon-lib/txpool/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -652,26 +652,43 @@ func TestShanghaiValidateTx(t *testing.T) {
expected txpoolcfg.DiscardReason
dataLen int
isShanghai bool
creation bool
}{
"no shanghai": {
expected: txpoolcfg.Success,
dataLen: 32,
isShanghai: false,
creation: true,
},
"shanghai within bounds": {
expected: txpoolcfg.Success,
dataLen: 32,
isShanghai: true,
creation: true,
},
"shanghai exactly on bound": {
"shanghai exactly on bound - create tx": {
expected: txpoolcfg.Success,
dataLen: fixedgas.MaxInitCodeSize,
isShanghai: true,
creation: true,
},
"shanghai one over bound": {
"shanghai one over bound - create tx": {
expected: txpoolcfg.InitCodeTooLarge,
dataLen: fixedgas.MaxInitCodeSize + 1,
isShanghai: true,
creation: true,
},
"shanghai exactly on bound - calldata tx": {
expected: txpoolcfg.Success,
dataLen: fixedgas.MaxInitCodeSize,
isShanghai: true,
creation: false,
},
"shanghai one over bound - calldata tx": {
expected: txpoolcfg.Success,
dataLen: fixedgas.MaxInitCodeSize + 1,
isShanghai: true,
creation: false,
},
}

Expand Down Expand Up @@ -708,7 +725,7 @@ func TestShanghaiValidateTx(t *testing.T) {
FeeCap: *uint256.NewInt(21000),
Gas: 500000,
SenderID: 0,
Creation: true,
Creation: test.creation,
}

txns := types.TxSlots{
Expand Down

0 comments on commit 64dac27

Please sign in to comment.