refactor: move EIP-161 state clear into journal finalize#3444
Merged
rakita merged 3 commits intobluealloy:mainfrom Feb 26, 2026
Merged
refactor: move EIP-161 state clear into journal finalize#3444rakita merged 3 commits intobluealloy:mainfrom
rakita merged 3 commits intobluealloy:mainfrom
Conversation
rakita
reviewed
Feb 25, 2026
Remove `has_state_clear` flag from `CacheState` and `set_state_clear_flag` from `State<DB>`. The database layer now always applies post-EIP-161 commit semantics (empty touched accounts are destroyed). Pre-EIP-161 behavior is handled in `JournalInner::finalize()` which normalizes accounts before they reach the database: - Empty touched accounts that didn't exist: marked as Created (materialized) - Empty touched existing accounts: touch flag cleared (preserved) This eliminates the need for callers to configure state_clear per-block, making block executors work with any database without chainspec-aware setup. Co-authored-by: Arsenii Kulikov <klkvr@users.noreply.github.com> Amp-Thread-ID: https://ampcode.com/threads/T-019c969c-8b41-7096-a8f0-54662b4776bf Co-authored-by: Amp <amp@ampcode.com>
0e68f89 to
c014ffe
Compare
Merging this PR will improve performance by 4.72%
Performance Changes
Comparing |
Merged
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.
Summary
Move
has_state_clear/set_state_clear_flagout of the database layer (CacheState/State<DB>) and intoJournalInner::finalize(), where theSpecIdis already available.Motivation
set_state_clear_flagcouples the database layer to chainspec knowledge. Block executors need extra chainspec-aware setup before each block just to handle a deprecated pre-Spurious Dragon behavior. This prevents executors from working with arbitraryDatabaseimplementations without that setup.Changes
JournalInner::finalize(): normalize pre-EIP-161 empty touched accounts before returningEvmStateLoadedAsNotExisting→mark_created()(materialize)unmark_touch()(preserve)CacheState: removehas_state_clearfield,set_state_clear_flag(), and pre-EIP-161 branch inapply_account_state()— always uses post-EIP-161 semanticsState<DB>: removeset_state_clear_flag()StateBuilder: removewith_state_clearfield andwithout_state_clear()revmestatetest runner: removeset_state_clear_flagcallsZero perf impact for post-Spurious Dragon blocks (the
finalize()iteration is gated behind!spec.is_enabled_in(SPURIOUS_DRAGON)).Prompted by: arsenii