core/vm: abort the selfdestruct gas measurement if gas is not enough

This commit is contained in:
Gary Rong 2026-01-19 11:01:55 +08:00
parent 933bcc7d2b
commit ad46a8f802

View file

@ -237,8 +237,10 @@ func makeSelfdestructGasFn(refundsEnabled bool) gasFunc {
evm.StateDB.AddAddressToAccessList(address)
gas = params.ColdAccountAccessCostEIP2929
// Terminate the gas measurement if the leftover gas is not sufficient,
// it can effectively prevent accessing the states in the following steps
if contract.Gas < gas {
return gas, nil
return 0, ErrOutOfGas
}
}
// if empty and transfers value