Repository navigation
fix(inspect): finalize journal on error to prevent EIP-2929 warm set leak - #3780
Merged
Merged
Conversation
`InspectEvm::inspect_tx` (and its sibling inspect/system-call/commit variants) used `self.X(tx)?` to short-circuit before calling `finalize()`. On error the handler calls `discard_tx`, which reverts account values but keeps the entries in the state map and increments `transaction_id`, so the EIP-2929 warm set and touched accounts leaked into the next transaction. This mirrors the same latent bug in `ExecuteEvm::transact_commit` and `ExecuteEvm::replay`. Fix all of them to finalize the journal on the error path, matching the existing correct pattern in `ExecuteEvm::transact` and `transact_many`. Adds regression tests asserting the journal is empty after a failed `inspect_tx` / `inspect_tx_commit`. Closes bluealloy#3779
Contributor
Author
|
Received.Kyrin
|
rakita
reviewed
Jun 29, 2026
Merging this PR will not alter performance
Comparing Footnotes
|
This was referenced Jun 24, 2026
Closed
Closed
Closed
3 tasks done
RealiCZ
added a commit
to megaeth-labs/revm
that referenced
this pull request
Sep 16, 2026
…n error to prevent EIP-2929 warm set leak (bluealloy#3780)
43 tasks done
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Closes #3779
InspectEvm::inspect_tx(and its sibling inspect/system-call/commit variants) usedself.X(tx)?to short-circuit before callingfinalize(). On error the handler callsdiscard_tx, which reverts account values but keeps the entries in the state map andincrements
transaction_id, so the EIP-2929 warm set and touched accounts leaked intothe next transaction.
The same latent bug also existed in
ExecuteEvm::transact_commitandExecuteEvm::replay.Solution
Fix all affected functions to finalize the journal on the error path, matching the existing
correct pattern in
ExecuteEvm::transactandtransact_many:crates/inspector/src/inspect.rs(8 functions): theExecResultAndState-returningvariants use "capture
Result→finalize()unconditionally →?"; the_commitvariants use
.inspect_err(|_| { let _ = self.finalize(); }).crates/handler/src/api.rs:transact_commit(inspect_err pattern) andreplay(
.inspect_err(...).map(...)chain).replay_commitis fixed transitively viareplay.Each modified function documents the error-path behavior under a
# Outcome of Errorsection.
Testing
Added two regression tests (
test_inspect_tx_finalizes_journal_on_errorandtest_inspect_tx_commit_finalizes_journal_on_error) that trigger a nonce-mismatchInvalidTransaction(a state-dependent error raised afterload_accountswarms thecaller/coinbase) and assert the journal state is empty afterwards.
Verified both tests fail on the unfixed code (
found 1 leftover accounts) and passafter the fix — confirming they genuinely reproduce the leak.
All checks green:
cargo fmt --all --check,cargo clippy --all-targets,cargo test -p revm-inspector -p revm-handler(19 passed),typos.