Skip to content

execution/commitment/trie, execution/state: clean up dead trie/HashBuilder code#21284

Merged
yperbasis merged 4 commits into
mainfrom
yperbasis/dead_trie_state_code
May 20, 2026
Merged

execution/commitment/trie, execution/state: clean up dead trie/HashBuilder code#21284
yperbasis merged 4 commits into
mainfrom
yperbasis/dead_trie_state_code

Conversation

@yperbasis

@yperbasis yperbasis commented May 19, 2026

Copy link
Copy Markdown
Member

Summary

Five self-contained cleanups in execution/commitment/trie and execution/state (−222 / +9):

  • execution/state/triedb_state.go — the TrieDbState.hashBuilder field was declared and initialised in four constructors (NewTrieDbState, Copy, WithNewBuffer, WithLastBuffer) but never read anywhere. Pure dead state — drop the field and the four trie.NewHashBuilder(false) call sites.
  • execution/commitment/trie/gen_struct_step.goGenStructStepOld is superseded by GenStructStepEx (the implementation that the public GenStructStep wraps) and has no callers in-tree. Drop it. The legacy HashCollector / StorageHashCollector function types existed only to type GenStructStepOld's signature and become orphan once GenStructStepOld goes; drop both.
  • Rename HashCollector2HashCollector, StorageHashCollector2StorageHashCollector. With the legacy types gone, the 2 suffix on the survivors is meaningless.
  • Inline GenStructStepEx into GenStructStep. The wrapper always called the extended form with retainProof=nil, cutoff=false, and no other caller used those parameters — cutoff was never even referenced in the body. Folding the constants in lets the retainIfProving closure and the proving branches drop out, and the two extra parameters disappear with them.
  • Drop the dead setProofElement integration in HashBuilder. Once the proof hook is gone from GenStructStep, nothing calls e.setProofElement(...) anymore, so HashBuilder.proofElement can never be non-nil. Remove the field, the setter, the interface method, and the now-unreachable if hb.proofElement != nil branches in leaf / accountLeaf / leafHashWithKeyVal / extensionHash / branchHash. The proofElement type and ProofRetainer machinery in retain_list.go stay (they are still exercised by their own tests directly).

Test plan

  • make erigon integration — clean
  • go build ./... — clean
  • make lint — 0 issues
  • go test -short -failfast ./execution/state/... ./execution/commitment/... — all green
  • CI

🤖 Generated with Claude Code

…ld and GenStructStepOld

Two small, self-contained dead-code removals:

- execution/state/triedb_state.go: the TrieDbState.hashBuilder field
  was declared and initialised in four constructors
  (NewTrieDbState / Copy / WithNewBuffer / WithLastBuffer) but never
  read anywhere — pure dead state. Drop the field and the four
  trie.NewHashBuilder(false) call sites.
- execution/commitment/trie/gen_struct_step.go: GenStructStepOld is
  superseded by GenStructStepEx (the implementation that the public
  GenStructStep wraps) and has no callers in-tree. Drop it. The
  legacy HashCollector / StorageHashCollector function types existed
  only to type GenStructStepOld's signature and are now also orphan;
  drop both. HashCollector2 / StorageHashCollector2 remain.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@yperbasis yperbasis marked this pull request as draft May 19, 2026 15:20
yperbasis and others added 2 commits May 19, 2026 17:22
…2 to drop the `2` suffix

Now that the legacy HashCollector/StorageHashCollector types are gone,
the `2` suffix on the surviving types is meaningless.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The GenStructStep wrapper always called GenStructStepEx with
retainProof=nil, cutoff=false, and no other caller used the extended
form. Inlining the body with those constants folded in lets the
retainIfProving closure and the `proving` branches drop out, and the
`cutoff` parameter — which was never even referenced in the body —
disappears too.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@yperbasis yperbasis changed the title execution/commitment/trie, execution/state: drop dead HashBuilder field and GenStructStepOld execution/commitment/trie, execution/state: clean up dead trie/HashBuilder code May 19, 2026
@yperbasis yperbasis requested a review from Copilot May 19, 2026 15:36
@yperbasis yperbasis marked this pull request as ready for review May 19, 2026 15:37

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 performs dead-code cleanup and API simplification in the execution trie/state layers by removing unused fields and pruning legacy/unused struct-generation helpers in execution/commitment/trie.

Changes:

  • Remove the unused TrieDbState.hashBuilder field and its constructor initializations.
  • Delete the legacy GenStructStepOld path and rename HashCollector2/StorageHashCollector2 to HashCollector/StorageHashCollector.
  • Inline GenStructStepEx into GenStructStep, dropping the extra proof/cutoff parameters and related branches.

Reviewed changes

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

File Description
execution/state/triedb_state.go Drops dead hashBuilder state from TrieDbState and removes unused initializations.
execution/commitment/trie/gen_struct_step.go Removes legacy APIs/types and simplifies GenStructStep by inlining the extended variant and pruning proof/cutoff logic.

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

Comment thread execution/commitment/trie/gen_struct_step.go
Comment thread execution/commitment/trie/gen_struct_step.go Outdated
…ashBuilder

After inlining GenStructStepEx into GenStructStep, nothing calls
setProofElement on the structInfoReceiver interface anymore, so the
HashBuilder.proofElement field and all `if hb.proofElement != nil`
branches in leaf / accountLeaf / leafHashWithKeyVal / extensionHash /
branchHash are unreachable. Drop the interface method, the field, the
setter, and the dead branches. The proofElement type and ProofRetainer
machinery in retain_list.go stay (they are still exercised by their own
tests directly).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

@Giulio2002 Giulio2002 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.

LGTM — straightforward dead-code cleanup and internal rename/inlining with no behavior change.

@yperbasis yperbasis added this pull request to the merge queue May 20, 2026
Merged via the queue into main with commit d6e0fb0 May 20, 2026
73 checks passed
@yperbasis yperbasis deleted the yperbasis/dead_trie_state_code branch May 20, 2026 07:56
yperbasis added a commit that referenced this pull request May 20, 2026
Two real conflicts, both fallout from prior moksha cleanups landing
on main via separate spinoff PRs while moksha's local versions of
those cleanups were still in flight:

1) execution/commitment/trie/gen_struct_step.go — main inlined
   GenStructStepEx into GenStructStep and dropped GenStructStepOld /
   the orphan HashCollector type aliases via #21284 (the spinoff
   originally cut from this branch). Moksha still had the
   pre-inlining layout. Took main's file as the base and re-applied
   moksha's "drop incarnation from structInfoReceiver" change:
   accountLeaf / accountLeafHash signatures lose `incarnation uint64`,
   GenStructStepAccountData loses its Incarnation field, the call
   sites in the inlined GenStructStep drop the argument.

2) execution/state/triedb_state.go — main dropped the dead
   TrieDbState.hashBuilder field via #21284. Moksha had concurrently
   dropped the dead incarnationMap field. Both removals are correct
   on the merged branch; resolution removes both struct fields and
   their four corresponding constructor inits (NewTrieDbState, Copy,
   WithNewBuffer, WithLastBuffer).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants