Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Polygon] Bor: PIP-30: increased max code size limit to 32KB [For Erigon-2] #11811

Merged
merged 1 commit into from
Aug 30, 2024
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
9 changes: 8 additions & 1 deletion core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions erigon-lib/chain/chain_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions params/protocol_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions polygon/bor/borcfg/bor_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
Loading