mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-21 04:06: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()
|
transfersValue = !stack.Back(2).IsZero()
|
||||||
)
|
)
|
||||||
|
|
||||||
if transfersValue && !evm.chainRules.IsEIP4762 {
|
if transfersValue {
|
||||||
gas += params.CallValueTransferGas
|
if evm.readOnly {
|
||||||
|
return 0, ErrWriteProtection
|
||||||
|
} else if !evm.chainRules.IsEIP4762 {
|
||||||
|
gas += params.CallValueTransferGas
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memoryGas, err := memoryGasCost(mem, memorySize)
|
memoryGas, err := memoryGasCost(mem, memorySize)
|
||||||
|
|
@ -452,11 +456,16 @@ func gasCallCodeStateless(evm *EVM, contract *Contract, stack *Stack, mem *Memor
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
var (
|
var (
|
||||||
gas uint64
|
gas uint64
|
||||||
overflow bool
|
overflow bool
|
||||||
|
transfersValue = !stack.Back(2).IsZero()
|
||||||
)
|
)
|
||||||
if stack.Back(2).Sign() != 0 && !evm.chainRules.IsEIP4762 {
|
if transfersValue {
|
||||||
gas += params.CallValueTransferGas
|
if evm.readOnly {
|
||||||
|
return 0, ErrWriteProtection
|
||||||
|
} else if !evm.chainRules.IsEIP4762 {
|
||||||
|
gas += params.CallValueTransferGas
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if gas, overflow = math.SafeAdd(gas, memoryGas); overflow {
|
if gas, overflow = math.SafeAdd(gas, memoryGas); overflow {
|
||||||
return 0, ErrGasUintOverflow
|
return 0, ErrGasUintOverflow
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue