@@ -18,7 +18,6 @@ package vm
1818
1919import (
2020 "errors"
21- "fmt"
2221
2322 "github.com/ethereum/go-ethereum/common"
2423 "github.com/ethereum/go-ethereum/common/math"
@@ -318,10 +317,10 @@ func gasCreateEip3860(evm *EVM, contract *Contract, stack *Stack, mem *Memory, m
318317 if overflow {
319318 return 0 , ErrGasUintOverflow
320319 }
321- if size > params . MaxInitCodeSize {
322- return 0 , fmt . Errorf ( "%w: size %d" , ErrMaxInitCodeSizeExceeded , size )
320+ if err := CheckMaxInitCodeSize ( & evm . chainRules , size ); err != nil {
321+ return 0 , err
323322 }
324- // Since size <= params.MaxInitCodeSize , these multiplication cannot overflow
323+ // Since size <= the protocol-defined maximum initcode size limit , these multiplication cannot overflow
325324 moreGas := params .InitCodeWordGas * ((size + 31 ) / 32 )
326325 if gas , overflow = math .SafeAdd (gas , moreGas ); overflow {
327326 return 0 , ErrGasUintOverflow
@@ -337,10 +336,10 @@ func gasCreate2Eip3860(evm *EVM, contract *Contract, stack *Stack, mem *Memory,
337336 if overflow {
338337 return 0 , ErrGasUintOverflow
339338 }
340- if size > params . MaxInitCodeSize {
341- return 0 , fmt . Errorf ( "%w: size %d" , ErrMaxInitCodeSizeExceeded , size )
339+ if err := CheckMaxInitCodeSize ( & evm . chainRules , size ); err != nil {
340+ return 0 , err
342341 }
343- // Since size <= params.MaxInitCodeSize , these multiplication cannot overflow
342+ // Since size <= the protocol-defined maximum initcode size limit , these multiplication cannot overflow
344343 moreGas := (params .InitCodeWordGas + params .Keccak256WordGas ) * ((size + 31 ) / 32 )
345344 if gas , overflow = math .SafeAdd (gas , moreGas ); overflow {
346345 return 0 , ErrGasUintOverflow
0 commit comments