Repository navigation
state: Replace State::find() with the nonexistent account flag - #1712
Merged
Merged
Conversation
Contributor
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1712 +/- ##
=======================================
Coverage 98.06% 98.06%
=======================================
Files 183 183
Lines 16915 16940 +25
Branches 3879 3873 -6
=======================================
+ Hits 16587 16613 +26
Misses 245 245
+ Partials 83 82 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Base automatically changed from
state/access-account-journal-order
to
master
September 15, 2026 07:32
chfast
force-pushed
the
state/nonexistent-account-flag
branch
4 times, most recently
from
October 7, 2026 09:43
cdfb329 to
0d4f740
Compare
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Consensus-sensitive account creation and rollback changes need execution-spec validation and final human review.
Review effort: Balanced
Findings: None
What changed in this PR
Refactors account lookup to use cached records with a nonexistent flag instead of nullable pointers.
Changes:
- Caches missing accounts and simplifies state and host lookups.
- Keeps cold accesses to absent accounts out of state diffs, partially addressing #1718.
- Clears reverted creation fields and adds invariant checks.
| File | Description |
|---|---|
| test/unittests/state_transition_touch_test.cpp | Tests absent-account access without diff entries. |
| test/state/state.hpp | Updates lookup and creation interfaces. |
| test/state/state.cpp | Implements cached misses, in-place creation, and rollback cleanup. |
| test/state/host.cpp | Uses reference-based lookups and warms absent accounts without creating them. |
| test/state/account.hpp | Clarifies account flags and remaining rollback limitations. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
find() returned nullptr for a missing account, so callers handled absence separately and nothing could be recorded about an account which does not exist. Return a reference always and let the nonexistent flag answer "does this account exist?". The miss is then cached, a cold access warms the account without creating it, and get_or_create(), touch() and get_or_insert() create an account in place by clearing the flag; this replaces insert() and journal_new_account(). Reverting to nonexistent also clears what a reverted CREATE left behind, now reachable through the reference. Only the state diff changes: an address which is only warmed no longer appears in it, neither as a no-op deletion of a missing account nor as an unchanged existing precompile.
chfast
force-pushed
the
state/nonexistent-account-flag
branch
from
October 7, 2026 11:08
0d4f740 to
73ff6aa
Compare
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.
State::find()returnednullptrfor a missing account, so everycaller split into two cases and nothing could be recorded about an
account which does not exist.
get()now always returnsAccount&andthe
nonexistentflag answers "does this account exist?".rather than once per access.
address which never existed no longer reaches the
StateDiffas ano-op deletion (part of state: build_diff() reports deletions for accounts that never existed #1718). The
access_nonexistenttest pinsthis.
get_or_create(),touch()andget_or_insert()create an accountin place by clearing the flag. This replaces
insert()andjournal_new_account().(nonce, code,
just_created,code_changed), now reachable throughthe reference. Asserts pin that a nonexistent account holds no change
and that the rollback restores the balance and the nonce before the
flags entry un-creates the account.
No consensus change. Only the state diff changes: an address which is
only warmed no longer appears in it, neither as a no-op deletion of a
missing account nor as an unchanged existing precompile. On the CodSpeed
benchmarks the instruction count is slightly lower overall; precompile
calls get a few percent faster from the cached miss.