diff --git a/core/vm/evm.go b/core/vm/evm.go index 2ce7ee887fa..e65557b4c8f 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -421,7 +421,7 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gasRemainin ret, err = run(evm, contract, nil, false) // EIP-170: Contract code size limit - if err == nil && evm.chainRules.IsSpuriousDragon && len(ret) > params.MaxCodeSize { + if err == nil && evm.chainRules.IsSpuriousDragon && len(ret) > evm.maxCodeSize() { // Gnosis Chain prior to Shanghai didn't have EIP-170 enabled, // but EIP-3860 (part of Shanghai) requires EIP-170. if !evm.chainRules.IsAura || evm.config.HasEip3860(evm.chainRules) { @@ -462,6 +462,13 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gasRemainin return ret, address, contract.Gas, err } +func (evm *EVM) maxCodeSize() int { + if evm.chainConfig.Bor != nil && evm.chainConfig.Bor.IsAhmedabad(evm.Context.BlockNumber) { + return params.MaxCodeSizePostAhmedabad + } + return params.MaxCodeSize +} + // Create creates a new contract using code as deployment code. // DESCRIBED: docs/programmers_guide/guide.md#nonce func (evm *EVM) Create(caller ContractRef, code []byte, gasRemaining uint64, endowment *uint256.Int, bailout bool) (ret []byte, contractAddr libcommon.Address, leftOverGas uint64, err error) { diff --git a/erigon-lib/chain/chain_config.go b/erigon-lib/chain/chain_config.go index b02068b123f..9c61e3cc351 100644 --- a/erigon-lib/chain/chain_config.go +++ b/erigon-lib/chain/chain_config.go @@ -98,6 +98,7 @@ type BorConfig interface { GetAgraBlock() *big.Int IsNapoli(num uint64) bool GetNapoliBlock() *big.Int + IsAhmedabad(number uint64) bool } func (c *Config) String() string { diff --git a/params/protocol_params.go b/params/protocol_params.go index d760de8658d..c41e75d18e6 100644 --- a/params/protocol_params.go +++ b/params/protocol_params.go @@ -127,8 +127,9 @@ const ( ElasticityMultiplier = 2 // Bounds the maximum gas limit an EIP-1559 block may have. InitialBaseFee = 1000000000 // Initial base fee for EIP-1559 blocks. - MaxCodeSize = 24576 // Maximum bytecode to permit for a contract - MaxInitCodeSize = 2 * MaxCodeSize // Maximum initcode to permit in a creation transaction and create instructions + MaxCodeSize = 24576 // Maximum bytecode to permit for a contract + MaxCodeSizePostAhmedabad = 32768 // Maximum bytecode to permit for a contract post Ahmedabad hard fork (bor / polygon pos) (32KB) + MaxInitCodeSize = 2 * MaxCodeSize // Maximum initcode to permit in a creation transaction and create instructions // Precompiled contract gas prices diff --git a/polygon/bor/borcfg/bor_config.go b/polygon/bor/borcfg/bor_config.go index 6c02f069b82..db24874d745 100644 --- a/polygon/bor/borcfg/bor_config.go +++ b/polygon/bor/borcfg/bor_config.go @@ -25,6 +25,7 @@ type BorConfig struct { IndoreBlock *big.Int `json:"indoreBlock"` // Indore switch block (nil = no fork, 0 = already on Indore) AgraBlock *big.Int `json:"agraBlock"` // Agra switch block (nil = no fork, 0 = already on Agra) NapoliBlock *big.Int `json:"napoliBlock"` // Napoli switch block (nil = no fork, 0 = already on Napoli) + AhmedabadBlock *big.Int `json:"ahmedabadBlock"` // Ahmedabad switch block (nil = no fork, 0 = already on Ahmedabad) StateSyncConfirmationDelay map[string]uint64 `json:"stateSyncConfirmationDelay"` // StateSync Confirmation Delay, in seconds, to calculate `to` sprints sprints @@ -130,6 +131,10 @@ func (c *BorConfig) IsNapoli(num uint64) bool { return isForked(c.NapoliBlock, num) } +func (c *BorConfig) IsAhmedabad(number uint64) bool { + return isForked(c.AhmedabadBlock, number) +} + func (c *BorConfig) GetNapoliBlock() *big.Int { return c.NapoliBlock }