state: Replace create-revert erase with a nonexistent flag#1600
Open
chfast wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR changes the test State implementation to avoid erasing m_modified entries when reverting a new-account create, preserving pointer stability by marking such entries with a revertible Account::nonexistent flag (ignored by find()/build_diff() and resurrected in-place by insert()).
Changes:
- Add a revertible
Account::nonexistentflag and journal it viaJournalAccountFlags. - Rework create journaling: new-account creates journal a flags snapshot restoring
nonexistent=true; pre-existing-account creates journalJournalCreateand roll back by resetting nonce/code. - Teach
find()/insert()/build_diff()to treatnonexistentnodes as absent.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| test/state/state.hpp | Extends JournalAccountFlags with nonexistent and simplifies JournalCreate. |
| test/state/state.cpp | Implements nonexistent handling in build_diff(), insert(), find(), create journaling, and rollback. |
| test/state/account.hpp | Adds and documents the new Account::nonexistent flag. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+281
to
+285
| if (!inserted) | ||
| { | ||
| assert(it->second.nonexistent); | ||
| it->second = std::move(account); | ||
| } |
Comment on lines
291
to
292
| // TODO: Avoid double lookup (find+insert) and not cached initial state lookup for non-existent | ||
| // accounts. If we want to cache non-existent account we need a proper flag for it. |
Comment on lines
402
to
406
| auto& a = get(e.addr); | ||
| a.access_status = e.access_status; | ||
| a.nonexistent = e.nonexistent; | ||
| a.destructed = e.destructed; | ||
| a.erase_if_empty = e.erase_if_empty; |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1600 +/- ##
=======================================
Coverage 97.39% 97.40%
=======================================
Files 164 164
Lines 14653 14658 +5
Branches 3388 3391 +3
=======================================
+ Hits 14272 14277 +5
Misses 280 280
Partials 101 101
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
chfast
force-pushed
the
state/journal-nonexistent-flag
branch
from
July 16, 2026 19:58
842e702 to
9a1eae5
Compare
Reverting a new-account create erased it from m_modified -- the only element removal in the state library -- invalidating pointers into the map. Mark it with a revertible Account::nonexistent flag instead (reverted via JournalAccountFlags): find() returns nullptr for such a node (guaranteed absent from the initial state), insert() resurrects it in place, and build_diff() skips it. Nothing is erased from m_modified during a transaction, keeping journalled element pointers stable. JournalCreate drops its `existed` bool and now only resets nonce/code for a create over a pre-existing account. 1128 unit tests pass. Claude-Session: https://claude.ai/code/session_01TSG8vscXHutBP2NK4MU8q9
chfast
force-pushed
the
state/journal-nonexistent-flag
branch
from
July 17, 2026 17:17
9a1eae5 to
1590364
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.
Reverting a new-account create erased it from m_modified -- the only element removal in the state library -- invalidating pointers into the map. Mark it with a revertible Account::nonexistent flag instead (reverted via JournalAccountFlags): find() returns nullptr for such a node (guaranteed absent from the initial state), insert() resurrects it in place, and build_diff() skips it. Nothing is erased from m_modified during a transaction, keeping journalled element pointers stable. JournalCreate drops its
existedbool and now only resets nonce/code for a create over a pre-existing account.