You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(evm-rpc): a refilled account's repeated selfdestruct is not a stale entry - #703
Fixes#681. Thanks to @pisqual for the report and the suggested rule.
Problem
findDefectiveSelfdestructs flagged every selfdestruct frame that repeats an earlier value movement as a possible stale-entry (a revm-based tracer reading an old journal entry). Ethereum mainnet block 26486365, tx 0x2bd9…e5f0, has a contract funded with the same amount before each of several selfdestructs. Frames 2/0, 3/0 and 4/0 repeat 1/0 and are genuine: the beneficiary's balance rises by exactly the sum of all five frame values. The block passes only if an opcode trace confirms them. Where the upstream serves neither the built-in opcode logger nor custom JS tracers, it is rejected on every retry, in every callFrameValidation mode.
Fix
A stale frame carries the newest journal entry. So if the executing account was credited after the matched movement, the credit is newer and the frame cannot be a stale copy of that movement. A repeat is now suspect only when:
the executing account was not credited after the matched movement, or
the movement is another account's (unchanged: a credit to the executor does not explain it).
Three kinds of frame do not count as credits, because counting them would let a genuinely stale frame through:
DELEGATECALL: tracers report the caller's value on it, but it never reaches the account the frame names;
CALLCODE: the value stays in the caller;
a call an account makes to itself: it changes no balance and records no journal entry. Credits undone by a failed frame already drop out of the movement list.
Tests
New fixture complete/mainnet-refilled-repeat.json: the transaction's call tree, its block header with only this transaction, and the beneficiary's balances before and after. The test checks that the frames sum to the balance change.
Guard tests, which pass on master and keep passing:
a repeat with no credit, or only a zero-value one, stays suspect;
so does a repeat after a DELEGATECALL/CALLCODE "credit", after a call the account makes to itself, after a credit undone by a failed frame, or after a credit to another account;
so does a repeat of another account's movement.
RPC level: the block is accepted in off and observe with no opcode trace available. On master it fails with the rejection from the issue.
mainnet-legitimate-repeat-reth.json (the same pattern, an earlier block) is no longer flagged. Its repair test now states the defect explicitly.
Every recorded defective frame from real nodes is still flagged.
The five behaviour tests fail on master and pass here; the full evm-rpc suite passes (668).
…le entry
The stale-entry check suspected every selfdestruct frame that repeats an
earlier value movement. A revm-based tracer misreports a frame with the newest
journal entry, so a movement of the executing account that was followed by a
credit to that account cannot be what a stale frame carries. A contract funded
with the same amount before each sweep repeats genuinely, and the block was
rejected on every retry wherever the upstream served no opcode trace to settle
it (Ethereum mainnet 26486365).
A repeat is now suspect only when the executing account was not credited after
the matched movement. DELEGATECALL and CALLCODE frames do not count as credits:
they report a value that never reaches the account they name. A repeat of
another account's movement stays suspect.
Reported in #681.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A transfer from an account to itself changes no balance and records no journal
entry, so a stale frame after it still reads the earlier movement. Counting it
as a credit let such a frame through.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The zero-value check misses padded encodings such as 0x00, allowing a stale SELFDESTRUCT to escape defect detection and opcode recovery without a refill.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Recognize padded zero hex values during SELFDESTRUCT recovery
evm/evm-rpc/src/verification.ts:2086
DebugFrame.value accepts arbitrary hex bytes (rpc-data.ts:597), including zero encoded as 0x00, but zeroValue only recognizes 0x0 and 0x. Consequently, E→B(v), O→E(0x00), then a stale SELFDESTRUCT reporting E→B(v) now returns no defect and skips opcode recovery despite no refill occurring. Recognize every all-zero hex encoding and add a padded-zero regression case.
Debug frame values are validated as hex bytes only, so zero can arrive as
`0x00`. Read as a nonzero value it counted as a credit and cleared a stale
frame of suspicion.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(With Claude): Re the review's "previously missed issue" (padded zero values): valid. DebugFrame.value is validated as hex bytes, so 0x00 can arrive, and with this PR it would have counted as a credit. Any all-zero hex now reads as zero, and the zero-credit guard test covers 0x0, 0x, 0x00 and 0x0000; it fails on 0x00 without the fix. Fixed in 38960a0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #681. Thanks to @pisqual for the report and the suggested rule.
Problem
findDefectiveSelfdestructsflagged every selfdestruct frame that repeats an earlier value movement as a possiblestale-entry(a revm-based tracer reading an old journal entry). Ethereum mainnet block 26486365, tx0x2bd9…e5f0, has a contract funded with the same amount before each of several selfdestructs. Frames 2/0, 3/0 and 4/0 repeat 1/0 and are genuine: the beneficiary's balance rises by exactly the sum of all five frame values. The block passes only if an opcode trace confirms them. Where the upstream serves neither the built-in opcode logger nor custom JS tracers, it is rejected on every retry, in everycallFrameValidationmode.Fix
A stale frame carries the newest journal entry. So if the executing account was credited after the matched movement, the credit is newer and the frame cannot be a stale copy of that movement. A repeat is now suspect only when:
Three kinds of frame do not count as credits, because counting them would let a genuinely stale frame through:
valueon it, but it never reaches the account the frame names;Tests
complete/mainnet-refilled-repeat.json: the transaction's call tree, its block header with only this transaction, and the beneficiary's balances before and after. The test checks that the frames sum to the balance change.offandobservewith no opcode trace available. On master it fails with the rejection from the issue.mainnet-legitimate-repeat-reth.json(the same pattern, an earlier block) is no longer flagged. Its repair test now states the defect explicitly.The five behaviour tests fail on master and pass here; the full
evm-rpcsuite passes (668).🤖 Generated with Claude Code