From 879cdf5b5a99c44f8b5ff1880fadff2fa9474e7f Mon Sep 17 00:00:00 2001 From: Victor Castell Date: Thu, 30 Mar 2023 17:48:45 +0200 Subject: [PATCH] Fix the limit for TX pool contract creation size (#1345) * Fix the limit for TX pool contract creation size The limit should be double the size of contract code size. --- state/executor.go | 1 + txpool/txpool.go | 2 +- txpool/txpool_test.go | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/state/executor.go b/state/executor.go index a9ff0c5c93..a4f8d932e0 100644 --- a/state/executor.go +++ b/state/executor.go @@ -20,6 +20,7 @@ import ( const ( SpuriousDragonMaxCodeSize = 24576 + TxPoolMaxInitCodeSize = 2 * SpuriousDragonMaxCodeSize TxGas uint64 = 21000 // Per transaction not creating a contract TxGasContractCreation uint64 = 53000 // Per transaction that creates a contract diff --git a/txpool/txpool.go b/txpool/txpool.go index e48a2a4af2..d9d3b13102 100644 --- a/txpool/txpool.go +++ b/txpool/txpool.go @@ -616,7 +616,7 @@ func (p *TxPool) validateTx(tx *types.Transaction) error { return ErrSmartContractRestricted } - if p.forks.EIP158 && len(tx.Input) > state.SpuriousDragonMaxCodeSize { + if p.forks.EIP158 && len(tx.Input) > state.TxPoolMaxInitCodeSize { return runtime.ErrMaxCodeSizeExceeded } } diff --git a/txpool/txpool_test.go b/txpool/txpool_test.go index 996d6780b7..2e203621c7 100644 --- a/txpool/txpool_test.go +++ b/txpool/txpool_test.go @@ -1750,12 +1750,12 @@ func TestPermissionSmartContractDeployment(t *testing.T) { ) }) - t.Run("Input larger then the MaxInitCodeSize", func(t *testing.T) { + t.Run("Input larger than the TxPoolMaxInitCodeSize", func(t *testing.T) { t.Parallel() pool := setupPool() pool.forks.EIP158 = true - input := make([]byte, state.SpuriousDragonMaxCodeSize+1) + input := make([]byte, state.TxPoolMaxInitCodeSize+1) _, err := rand.Read(input) require.NoError(t, err) @@ -1769,12 +1769,12 @@ func TestPermissionSmartContractDeployment(t *testing.T) { ) }) - t.Run("Input the same as MaxInitCodeSize", func(t *testing.T) { + t.Run("Input the same as TxPoolMaxInitCodeSize", func(t *testing.T) { t.Parallel() pool := setupPool() pool.forks.EIP158 = true - input := make([]byte, state.SpuriousDragonMaxCodeSize) + input := make([]byte, state.TxPoolMaxInitCodeSize) _, err := rand.Read(input) require.NoError(t, err)