Skip to content

Commit 6cbb853

Browse files
committed
refactor: update CheckMaxCodeSize to accept maxCodeSize parameter
1 parent 5d1a578 commit 6cbb853

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

execution/vm/common.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ func CheckMaxInitCodeSize(IsAmsterdam, IsShanghai bool, size uint64) error {
4545
}
4646

4747
// CheckMaxCodeSize checks the size of contract code against the protocol-defined limit.
48-
func CheckMaxCodeSize(rules *chain.Rules, size uint64) error {
48+
func CheckMaxCodeSize(rules *chain.Rules, maxCodeSize, size uint64) error {
4949
if rules.IsAmsterdam {
5050
if size > params.MaxCodeSizeAmsterdam {
5151
return fmt.Errorf("%w: code size %v limit %v", ErrMaxCodeSizeExceeded, size, params.MaxCodeSizeAmsterdam)
5252
}
5353
} else if rules.IsSpuriousDragon {
54-
if size > params.MaxCodeSize {
55-
return fmt.Errorf("%w: code size %v limit %v", ErrMaxCodeSizeExceeded, size, params.MaxCodeSize)
54+
if size > maxCodeSize {
55+
return fmt.Errorf("%w: code size %v limit %v", ErrMaxCodeSizeExceeded, size, maxCodeSize)
5656
}
5757
}
5858
return nil

execution/vm/evm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ func (evm *EVM) create(caller accounts.Address, codeAndHash *codeAndHash, gasRem
469469

470470
// EIP-170: Contract code size limit
471471
if err == nil {
472-
if sizeErr := CheckMaxCodeSize(evm.ChainRules(), uint64(len(ret))); sizeErr != nil {
472+
if sizeErr := CheckMaxCodeSize(evm.ChainRules(), uint64(evm.maxCodeSize()), uint64(len(ret))); sizeErr != nil {
473473
// Gnosis Chain prior to Shanghai didn't have EIP-170 enabled,
474474
// but EIP-3860 (part of Shanghai) requires EIP-170.
475475
if !evm.chainRules.IsAura || evm.config.HasEip3860(evm.chainRules) {

0 commit comments

Comments
 (0)