mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-03-21 10:28:10 +00:00
core/vm: fix readonly in selfdestruct
This commit is contained in:
parent
df01c668b0
commit
93ffca2571
1 changed files with 7 additions and 0 deletions
|
|
@ -649,6 +649,9 @@ func gasCall8037(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memory
|
|||
}
|
||||
|
||||
func gasSelfdestruct8037(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (GasCosts, error) {
|
||||
if evm.readOnly {
|
||||
return GasCosts{}, ErrWriteProtection
|
||||
}
|
||||
var (
|
||||
gas GasCosts
|
||||
address = common.Address(stack.peek().Bytes20())
|
||||
|
|
@ -658,6 +661,10 @@ func gasSelfdestruct8037(evm *EVM, contract *Contract, stack *Stack, mem *Memory
|
|||
evm.StateDB.AddAddressToAccessList(address)
|
||||
gas.RegularGas = params.ColdAccountAccessCostEIP2929
|
||||
}
|
||||
// Check we have enough regular gas before we add the address to the BAL
|
||||
if contract.Gas.RegularGas < gas.RegularGas {
|
||||
return gas, nil
|
||||
}
|
||||
// if empty and transfers value
|
||||
if evm.StateDB.Empty(address) && evm.StateDB.GetBalance(contract.Address()).Sign() != 0 {
|
||||
gas.StateGas += params.AccountCreationSize * evm.Context.CostPerGasByte
|
||||
|
|
|
|||
Loading…
Reference in a new issue