|
|
@ -18,6 +18,7 @@ package vm |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"errors" |
|
|
|
"errors" |
|
|
|
|
|
|
|
"fmt" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
|
"github.com/ethereum/go-ethereum/common/math" |
|
|
|
"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 |
|
|
|
return 0, err |
|
|
|
} |
|
|
|
} |
|
|
|
size, overflow := stack.Back(2).Uint64WithOverflow() |
|
|
|
size, overflow := stack.Back(2).Uint64WithOverflow() |
|
|
|
if overflow || size > params.MaxInitCodeSize { |
|
|
|
if overflow { |
|
|
|
return 0, ErrGasUintOverflow |
|
|
|
return 0, ErrGasUintOverflow |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if size > params.MaxInitCodeSize { |
|
|
|
|
|
|
|
return 0, fmt.Errorf("%w: size %d", ErrMaxInitCodeSizeExceeded, size) |
|
|
|
|
|
|
|
} |
|
|
|
// Since size <= params.MaxInitCodeSize, these multiplication cannot overflow
|
|
|
|
// Since size <= params.MaxInitCodeSize, these multiplication cannot overflow
|
|
|
|
moreGas := params.InitCodeWordGas * ((size + 31) / 32) |
|
|
|
moreGas := params.InitCodeWordGas * ((size + 31) / 32) |
|
|
|
if gas, overflow = math.SafeAdd(gas, moreGas); overflow { |
|
|
|
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 |
|
|
|
return 0, err |
|
|
|
} |
|
|
|
} |
|
|
|
size, overflow := stack.Back(2).Uint64WithOverflow() |
|
|
|
size, overflow := stack.Back(2).Uint64WithOverflow() |
|
|
|
if overflow || size > params.MaxInitCodeSize { |
|
|
|
if overflow { |
|
|
|
return 0, ErrGasUintOverflow |
|
|
|
return 0, ErrGasUintOverflow |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if size > params.MaxInitCodeSize { |
|
|
|
|
|
|
|
return 0, fmt.Errorf("%w: size %d", ErrMaxInitCodeSizeExceeded, size) |
|
|
|
|
|
|
|
} |
|
|
|
// Since size <= params.MaxInitCodeSize, these multiplication cannot overflow
|
|
|
|
// Since size <= params.MaxInitCodeSize, these multiplication cannot overflow
|
|
|
|
moreGas := (params.InitCodeWordGas + params.Keccak256WordGas) * ((size + 31) / 32) |
|
|
|
moreGas := (params.InitCodeWordGas + params.Keccak256WordGas) * ((size + 31) / 32) |
|
|
|
if gas, overflow = math.SafeAdd(gas, moreGas); overflow { |
|
|
|
if gas, overflow = math.SafeAdd(gas, moreGas); overflow { |
|
|
|