state: Split journal_create's existed bool into two named functions#1609
Merged
Conversation
journal_create(addr, existed) selected between two unrelated reverts via a bool: for a create over a pre-existing account it resets nonce/code; for a new account it erases the account. Two of the three call sites (selfdestruct, the CALL path) passed a compile-time-constant false, so the new-account intent was hidden behind a dispatch flag, and create() carried a `new_acc_exists` local only to feed it. Split into journal_create(addr) and journal_new_account(addr); each emits the same JournalCreate entry it always did (existed = true / false respectively), so entry types and rollback are unchanged. selfdestruct and the CALL path call journal_new_account() directly; create() folds the choice into its existing find/insert branch and drops the local. Behavior unchanged; 1131 unit tests pass. Claude-Session: https://claude.ai/code/session_01TSG8vscXHutBP2NK4MU8q9
There was a problem hiding this comment.
Pull request overview
This PR improves clarity in the test-state journaling API by removing a boolean “dispatch flag” from State::journal_create() and replacing it with two explicitly named functions that encode the intended revert behavior (pre-existing-account create vs. brand-new-account insertion). This makes call sites in the Host implementation self-documenting and removes a local boolean used only to feed the old API.
Changes:
- Split
journal_create(addr, existed)intojournal_create(addr)(pre-existing account) andjournal_new_account(addr)(new account). - Update
Hostcall sites (selfdestruct,EVMC_CALLpath, andcreate()) to call the appropriate named function directly. - Simplify
Host::create()branching by folding the “existed” decision into the existingfind()/insert()control flow and removing the now-unneeded local.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/state/state.hpp | Replaces the boolean-parameter journaling API with two named methods and documents their revert semantics. |
| test/state/state.cpp | Implements the two journaling methods by emitting the same JournalCreate entries as before (existed = true/false). |
| test/state/host.cpp | Updates Host call sites to use the explicit journaling methods and simplifies create() control flow accordingly. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
journal_create(addr, existed) selected between two unrelated reverts via a bool: for a create over a pre-existing account it resets nonce/code; for a new account it erases the account. Two of the three call sites (selfdestruct, the CALL path) passed a compile-time-constant false, so the new-account intent was hidden behind a dispatch flag, and create() carried a
new_acc_existslocal only to feed it.Split into journal_create(addr) and journal_new_account(addr); each emits the same JournalCreate entry it always did (existed = true / false respectively), so entry types and rollback are unchanged. selfdestruct and the CALL path call journal_new_account() directly; create() folds the choice into its existing find/insert branch and drops the local.