core/vm: in selfdestruct gas calculation, return early if there isn't enough gas to cover cold account access costs (#33450)
Some checks are pending
/ Linux Build (push) Waiting to run
/ Linux Build (arm) (push) Waiting to run
/ Keeper Build (push) Waiting to run
/ Windows Build (push) Waiting to run
/ Docker Image (push) Waiting to run

There's no need to perform the subsequent state access on the target if
we already know that we are out of gas.

This aligns the state access behavior of selfdestruct with EIP-7928
This commit is contained in:
jwasinger 2026-01-16 23:37:12 +09:00 committed by GitHub
parent 23c3498836
commit b6fb79cdf9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -236,6 +236,10 @@ func makeSelfdestructGasFn(refundsEnabled bool) gasFunc {
// 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 {