From 7cb1375bd227e6bca19542453301ec07d5030c7e Mon Sep 17 00:00:00 2001 From: Victor Castell Date: Wed, 29 Mar 2023 15:38:04 +0200 Subject: [PATCH 1/4] 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 | 2 +- 3 files changed, 3 insertions(+), 2 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..a7ea3fe323 100644 --- a/txpool/txpool_test.go +++ b/txpool/txpool_test.go @@ -1774,7 +1774,7 @@ func TestPermissionSmartContractDeployment(t *testing.T) { pool := setupPool() pool.forks.EIP158 = true - input := make([]byte, state.SpuriousDragonMaxCodeSize) + input := make([]byte, state.TxPoolMaxInitCodeSize) _, err := rand.Read(input) require.NoError(t, err) From 90d98221ebcd8c2d4891410e96d21542bc8c16a6 Mon Sep 17 00:00:00 2001 From: Victor Castell Date: Wed, 29 Mar 2023 16:08:39 +0200 Subject: [PATCH 2/4] Fix test --- txpool/txpool_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/txpool/txpool_test.go b/txpool/txpool_test.go index a7ea3fe323..4d0dd5db94 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 then 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) From 9d762e8ee11a214a032543508ee7a9b1ee4c825f Mon Sep 17 00:00:00 2001 From: Victor Castell Date: Wed, 29 Mar 2023 16:09:09 +0200 Subject: [PATCH 3/4] Typo --- txpool/txpool_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/txpool/txpool_test.go b/txpool/txpool_test.go index 4d0dd5db94..0b85c76a16 100644 --- a/txpool/txpool_test.go +++ b/txpool/txpool_test.go @@ -1769,7 +1769,7 @@ 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 From 5adec779fe7766cadce478c0941e3f104071f8fd Mon Sep 17 00:00:00 2001 From: Victor Castell Date: Thu, 30 Mar 2023 10:21:11 +0200 Subject: [PATCH 4/4] Update txpool/txpool_test.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Stefan Negovanović <93934272+Stefan-Ethernal@users.noreply.github.com> --- txpool/txpool_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/txpool/txpool_test.go b/txpool/txpool_test.go index 0b85c76a16..2e203621c7 100644 --- a/txpool/txpool_test.go +++ b/txpool/txpool_test.go @@ -1750,7 +1750,7 @@ func TestPermissionSmartContractDeployment(t *testing.T) { ) }) - t.Run("Input larger then the TxPoolMaxInitCodeSize", func(t *testing.T) { + t.Run("Input larger than the TxPoolMaxInitCodeSize", func(t *testing.T) { t.Parallel() pool := setupPool() pool.forks.EIP158 = true