Skip to content

Commit

Permalink
txpool: EIP-3860 should only apply to create transactions (#10609)
Browse files Browse the repository at this point in the history
This fixes Issue #10607
  • Loading branch information
yperbasis authored Jun 4, 2024
1 parent 5bbcc7a commit 9471c44
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 @@ -835,10 +835,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 @@ -645,26 +645,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 @@ -700,7 +717,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 9471c44

Please sign in to comment.