diff --git a/core/vm/evm.go b/core/vm/evm.go index e6d1648901..8ec032cff4 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -495,8 +495,14 @@ func (evm *EVM) create(caller ContractRef, codeAndHash *codeAndHash, gas uint64, ret, err := evm.interpreter.PreRun(contract, nil, false, nil) // Check whether the max code size has been exceeded, assign err if the case. - if err == nil && evm.chainRules.IsEIP158 && len(ret) > params.MaxCodeSize { - err = ErrMaxCodeSizeExceeded + if err == nil && evm.chainRules.IsEIP158 { + if evm.chainConfig.Bor != nil && evm.chainConfig.Bor.IsAhmedabad(evm.Context.BlockNumber) { + if len(ret) > params.MaxCodeSizePostAhmedabad { + err = ErrMaxCodeSizeExceeded + } + } else if len(ret) > params.MaxCodeSize { + err = ErrMaxCodeSizeExceeded + } } // Reject code starting with 0xEF if EIP-3541 is enabled. diff --git a/params/config.go b/params/config.go index 963a00b120..f8f7e005da 100644 --- a/params/config.go +++ b/params/config.go @@ -618,6 +618,7 @@ type BorConfig struct { DelhiBlock *big.Int `json:"delhiBlock"` // Delhi switch block (nil = no fork, 0 = already on delhi) IndoreBlock *big.Int `json:"indoreBlock"` // Indore switch block (nil = no fork, 0 = already on indore) StateSyncConfirmationDelay map[string]uint64 `json:"stateSyncConfirmationDelay"` // StateSync Confirmation Delay, in seconds, to calculate `to` + AhmedabadBlock *big.Int `json:"ahmedabadBlock"` // Ahmedabad switch block (nil = no fork, 0 = already on ahmedabad) } // String implements the stringer interface, returning the consensus engine details. @@ -657,6 +658,10 @@ func (c *BorConfig) CalculateStateSyncDelay(number uint64) uint64 { return borKeyValueConfigHelper(c.StateSyncConfirmationDelay, number) } +func (c *BorConfig) IsAhmedabad(number *big.Int) bool { + return isBlockForked(c.AhmedabadBlock, number) +} + // // TODO: modify this function once the block number is finalized // func (c *BorConfig) IsNapoli(number *big.Int) bool { // if c.NapoliBlock != nil { diff --git a/params/protocol_params.go b/params/protocol_params.go index 204439c21c..7f66ce4d21 100644 --- a/params/protocol_params.go +++ b/params/protocol_params.go @@ -133,8 +133,9 @@ const ( DefaultBaseFeeChangeDenominator = 8 // Bounds the amount the base fee can change between blocks. DefaultElasticityMultiplier = 2 // Bounds the maximum gas limit an EIP-1559 block may have. - 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