mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-20 11:46:44 +00:00
add static guards to call/callcode gas handler stateless components
This commit is contained in:
parent
cfaa550295
commit
fb5a848e48
1 changed files with 15 additions and 6 deletions
|
|
@ -380,8 +380,12 @@ func gasCallStateless(evm *EVM, contract *Contract, stack *Stack, mem *Memory, m
|
|||
transfersValue = !stack.Back(2).IsZero()
|
||||
)
|
||||
|
||||
if transfersValue && !evm.chainRules.IsEIP4762 {
|
||||
gas += params.CallValueTransferGas
|
||||
if transfersValue {
|
||||
if evm.readOnly {
|
||||
return 0, ErrWriteProtection
|
||||
} else if !evm.chainRules.IsEIP4762 {
|
||||
gas += params.CallValueTransferGas
|
||||
}
|
||||
}
|
||||
|
||||
memoryGas, err := memoryGasCost(mem, memorySize)
|
||||
|
|
@ -452,11 +456,16 @@ func gasCallCodeStateless(evm *EVM, contract *Contract, stack *Stack, mem *Memor
|
|||
return 0, err
|
||||
}
|
||||
var (
|
||||
gas uint64
|
||||
overflow bool
|
||||
gas uint64
|
||||
overflow bool
|
||||
transfersValue = !stack.Back(2).IsZero()
|
||||
)
|
||||
if stack.Back(2).Sign() != 0 && !evm.chainRules.IsEIP4762 {
|
||||
gas += params.CallValueTransferGas
|
||||
if transfersValue {
|
||||
if evm.readOnly {
|
||||
return 0, ErrWriteProtection
|
||||
} else if !evm.chainRules.IsEIP4762 {
|
||||
gas += params.CallValueTransferGas
|
||||
}
|
||||
}
|
||||
if gas, overflow = math.SafeAdd(gas, memoryGas); overflow {
|
||||
return 0, ErrGasUintOverflow
|
||||
|
|
|
|||
Loading…
Reference in a new issue