Skip to content

state: Split journal_create's existed bool into two named functions#1609

Merged
chfast merged 1 commit into
masterfrom
state/journal_create_split
Jul 22, 2026
Merged

state: Split journal_create's existed bool into two named functions#1609
chfast merged 1 commit into
masterfrom
state/journal_create_split

Conversation

@chfast

@chfast chfast commented Jul 22, 2026

Copy link
Copy Markdown
Member

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.

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) into journal_create(addr) (pre-existing account) and journal_new_account(addr) (new account).
  • Update Host call sites (selfdestruct, EVMC_CALL path, and create()) to call the appropriate named function directly.
  • Simplify Host::create() branching by folding the “existed” decision into the existing find()/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.

@chfast
chfast merged commit 8892453 into master Jul 22, 2026
22 checks passed
@chfast
chfast deleted the state/journal_create_split branch July 22, 2026 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants