|
|
|
@ -18,6 +18,7 @@ package vm |
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
"errors" |
|
|
|
|
"fmt" |
|
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
|
|
"github.com/ethereum/go-ethereum/common/math" |
|
|
|
@ -310,9 +311,12 @@ func gasCreateEip3860(evm *EVM, contract *Contract, stack *Stack, mem *Memory, m |
|
|
|
|
return 0, err |
|
|
|
|
} |
|
|
|
|
size, overflow := stack.Back(2).Uint64WithOverflow() |
|
|
|
|
if overflow || size > params.MaxInitCodeSize { |
|
|
|
|
if overflow { |
|
|
|
|
return 0, ErrGasUintOverflow |
|
|
|
|
} |
|
|
|
|
if size > params.MaxInitCodeSize { |
|
|
|
|
return 0, fmt.Errorf("%w: size %d", ErrMaxInitCodeSizeExceeded, size) |
|
|
|
|
} |
|
|
|
|
// Since size <= params.MaxInitCodeSize, these multiplication cannot overflow
|
|
|
|
|
moreGas := params.InitCodeWordGas * ((size + 31) / 32) |
|
|
|
|
if gas, overflow = math.SafeAdd(gas, moreGas); overflow { |
|
|
|
@ -326,9 +330,12 @@ func gasCreate2Eip3860(evm *EVM, contract *Contract, stack *Stack, mem *Memory, |
|
|
|
|
return 0, err |
|
|
|
|
} |
|
|
|
|
size, overflow := stack.Back(2).Uint64WithOverflow() |
|
|
|
|
if overflow || size > params.MaxInitCodeSize { |
|
|
|
|
if overflow { |
|
|
|
|
return 0, ErrGasUintOverflow |
|
|
|
|
} |
|
|
|
|
if size > params.MaxInitCodeSize { |
|
|
|
|
return 0, fmt.Errorf("%w: size %d", ErrMaxInitCodeSizeExceeded, size) |
|
|
|
|
} |
|
|
|
|
// Since size <= params.MaxInitCodeSize, these multiplication cannot overflow
|
|
|
|
|
moreGas := (params.InitCodeWordGas + params.Keccak256WordGas) * ((size + 31) / 32) |
|
|
|
|
if gas, overflow = math.SafeAdd(gas, moreGas); overflow { |
|
|
|
|