mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 15:47:21 +00:00
add back static checks for selfdestruct/sstore and add extra gas check for selfdestruct stateless component
This commit is contained in:
parent
18fa37c3b5
commit
1746bafa28
1 changed files with 11 additions and 0 deletions
|
|
@ -28,6 +28,9 @@ import (
|
|||
|
||||
func makeGasSStoreFunc(clearingRefund uint64) gasFunc {
|
||||
return func(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) {
|
||||
if evm.readOnly {
|
||||
return 0, ErrWriteProtection
|
||||
}
|
||||
// If we fail the minimum gas availability invariant, fail (0)
|
||||
if contract.Gas <= params.SstoreSentryGasEIP2200 {
|
||||
return 0, errors.New("not enough gas for reentrancy sentry")
|
||||
|
|
@ -188,11 +191,19 @@ func makeSelfdestructGasFn(refundsEnabled bool) gasFunc {
|
|||
gas uint64
|
||||
address = common.Address(stack.peek().Bytes20())
|
||||
)
|
||||
if evm.readOnly {
|
||||
return 0, ErrWriteProtection
|
||||
}
|
||||
|
||||
if !evm.StateDB.AddressInAccessList(address) {
|
||||
// If the caller cannot afford the cost, this change will be rolled back
|
||||
evm.StateDB.AddAddressToAccessList(address)
|
||||
gas = params.ColdAccountAccessCostEIP2929
|
||||
}
|
||||
if contract.Gas < gas {
|
||||
return gas, nil
|
||||
}
|
||||
|
||||
// if empty and transfers value
|
||||
if evm.StateDB.Empty(address) && evm.StateDB.GetBalance(contract.Address()).Sign() != 0 {
|
||||
gas += params.CreateBySelfdestructGas
|
||||
|
|
|
|||
Loading…
Reference in a new issue