Skip to content

core/vm: in selfdestruct gas calculation, return early if there isn't enough gas to cover cold account access costs#33450

Merged
lightclient merged 2 commits into
ethereum:masterfrom
jwasinger:selfdestruct-cold-access-early-return
Jan 16, 2026
Merged

core/vm: in selfdestruct gas calculation, return early if there isn't enough gas to cover cold account access costs#33450
lightclient merged 2 commits into
ethereum:masterfrom
jwasinger:selfdestruct-cold-access-early-return

Conversation

@jwasinger

@jwasinger jwasinger commented Dec 18, 2025

Copy link
Copy Markdown
Contributor

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

… enough gas to cover cold account access costs
Comment thread core/vm/operations_acl.go Outdated
Comment thread core/vm/operations_acl.go
@rjl493456442

rjl493456442 commented Dec 19, 2025

Copy link
Copy Markdown
Member

Our gas calculation mechanism is somewhat awkward, in my opinion.

For stateless opcodes such as arithmetic operations, gas accounting is straightforward. However, gas calculation becomes significantly more complex once state is involved, such as with CALL. In these cases, we often need to determine how much gas is available and skip unnecessary state retrieval when the remaining gas is insufficient for performance reasons.

For SELFDESTRUCT, the required gas depends on state related information, and the target address must be tracked accordingly in BALs

Note: For call-related opcodes (CALL, CALLCODE, DELEGATECALL, STATICCALL), the target address is added to the access list (BAL) only if the gas checks (including memory expansion, access cost, and transfer cost) pass. If the operation fails due to insufficient gas before any state access, the target address must not be included.

For CALL* opcodes, the target address must not be included if the opcode is not actually executed, even if state has already been resolved during gas calculation. In such cases, we must explicitly filter out the related states from the BALs.

It's very hard to fully align the requirement of EIP-7928

Comment thread core/vm/operations_acl.go
@lightclient lightclient added this to the 1.17.0 milestone Jan 16, 2026
@lightclient lightclient merged commit b6fb79c into ethereum:master Jan 16, 2026
6 of 8 checks passed
@lightclient

Copy link
Copy Markdown
Member

Sorry, I should have shortened the title some.

gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 17, 2026
AnilChinchawale pushed a commit to XinFinOrg/XDPoSChain that referenced this pull request Jan 19, 2026
gballet pushed a commit to BZO95/go-ethereum that referenced this pull request May 21, 2026
… enough gas to cover cold account access costs (ethereum#33450)

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants