Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Fix the limit for TX pool contract creation size #1345

Merged
merged 4 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions state/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion txpool/txpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
8 changes: 4 additions & 4 deletions txpool/txpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand Down