diff --git a/erigon-lib/txpool/pool.go b/erigon-lib/txpool/pool.go index 846a6b3e6be..d9ecdc0d051 100644 --- a/erigon-lib/txpool/pool.go +++ b/erigon-lib/txpool/pool.go @@ -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() { diff --git a/erigon-lib/txpool/pool_test.go b/erigon-lib/txpool/pool_test.go index 93878af5c87..6030ee6e03f 100644 --- a/erigon-lib/txpool/pool_test.go +++ b/erigon-lib/txpool/pool_test.go @@ -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, }, } @@ -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{