Skip to content

commitment: preserve account load flags across storage folds - #22604

Merged
taratorio merged 1 commit into
mainfrom
agent/commitment-preserve-account-load-flags
Jul 20, 2026
Merged

commitment: preserve account load flags across storage folds#22604
taratorio merged 1 commit into
mainfrom
agent/commitment-preserve-account-load-flags

Conversation

@taratorio

Copy link
Copy Markdown
Member

Cherry-pick of #22603 onto main, without its prerequisite PR chain.

Preserves account load flags when folding storage subtrees in the hashed Patricia trie, preventing BAL-provided account values from being overwritten by stale state-reader values during ModeUpdate.

Validation

  • go test ./execution/commitment -run '^TestModeUpdatePreservesAccountAcrossStorageFold$' -count=1
  • make lint (two consecutive clean runs)
  • make erigon integration

@taratorio
taratorio enabled auto-merge July 20, 2026 10:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 cherry-picks a fix in the execution/commitment hashed Hex-Patricia trie folding logic to preserve account “loaded” flags when folding storage subtrees. This prevents ModeUpdate from re-loading (and potentially overwriting) BAL-provided account fields with stale state-reader values during storage collapses, and adds a regression test to lock in the behavior.

Changes:

  • Preserve existing account-load flags when folding nodes in the storage portion of the hashed keyspace (fillFromLowerCell).
  • Add a regression test that reproduces the “account updated + storage fold” pattern and asserts ModeUpdate matches ModeDirect.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
execution/commitment/hex_patricia_hashed.go Adjusts fold propagation to merge (rather than overwrite) load flags when folding storage-depth nodes.
execution/commitment/hex_patricia_hashed_test.go Adds a regression test ensuring ModeUpdate preserves account data across a storage fold and matches ModeDirect root output.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread execution/commitment/hex_patricia_hashed_test.go
Comment thread execution/commitment/hex_patricia_hashed_test.go
Comment thread execution/commitment/hex_patricia_hashed_test.go
@taratorio
taratorio force-pushed the agent/commitment-preserve-account-load-flags branch from 0b98403 to 8ae5ccd Compare July 20, 2026 11:04
@taratorio
taratorio added this pull request to the merge queue Jul 20, 2026

@mh0lt mh0lt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approve — and empirically confirmed against a real consensus failure.

This fixes a pre-existing wrong-trie-root bug on the --experimental.bal (BAL-driven parallel commitment) path that I had independently root-caused on glamsterdam-devnet-6 at block 70097 (BAL-driven root 248a318a… vs correct e4e83f65…; reproduced on both main and #22409). My instrumentation pinned the divergence to the ModeUpdate fold: fold(197 updates)→248a vs incremental(227)→e4e8 on the same computeIsolated path — and, tellingly, re-emitting the "missing" account leaves at the changeset level was a no-op, which pointed at exactly this: the corruption is the trie-compute loaded flag, not a missing update. When a storage row (lowDepth > 64) folds up into an account cell, the old cell.loaded = lowCell.loaded clobbered cellLoadAccount, so the account looked unloaded and its BAL-provided value got overwritten by a stale state-reader read → wrong root. Merging the flags (addFlag) is correct and minimal.

Validation: built main + #22495 + this PR, ran with --experimental.bal + parallel commitment against a datadir at block 70096 on glamsterdam-devnet-6. It executed cleanly through 70097 and on to head 145030 with zero wrong-trie-root / BAL-mismatch events (previously it halted at 70097). So this resolves the bug end-to-end.

Context for #22409: it inherits this on its next merge-from-main; no conflict (does not touch hex_patricia_hashed.go). LGTM.

Merged via the queue into main with commit ce872ea Jul 20, 2026
94 checks passed
@taratorio
taratorio deleted the agent/commitment-preserve-account-load-flags branch July 20, 2026 12:45
taratorio added a commit that referenced this pull request Jul 22, 2026
Cherry-pick of #22603 onto `main`, without its prerequisite PR chain.

Preserves account load flags when folding storage subtrees in the hashed
Patricia trie, preventing BAL-provided account values from being
overwritten by stale state-reader values during `ModeUpdate`.

## Validation

- `go test ./execution/commitment -run
'^TestModeUpdatePreservesAccountAcrossStorageFold$' -count=1`
- `make lint` (two consecutive clean runs)
- `make erigon integration`
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.

4 participants