Skip to content

refactor(trie): simplify LazyTrieData with SortedTrieData container#21153

Closed
mattsse wants to merge 1 commit intomainfrom
mattsse/simplify-lazy-trie-data
Closed

refactor(trie): simplify LazyTrieData with SortedTrieData container#21153
mattsse wants to merge 1 commit intomainfrom
mattsse/simplify-lazy-trie-data

Conversation

@mattsse
Copy link
Collaborator

@mattsse mattsse commented Jan 17, 2026

Summary

Simplifies the LazyTrieData abstraction introduced in #21139.

Changes

  • Add SortedTrieData container bundling HashedPostStateSorted + TrieUpdatesSorted
  • Simplify LazyTrieData to use single Arc<OnceLock<SortedTrieData>> instead of two separate OnceLocks
  • Remove TrieDataCompute trait - use simple Arc<dyn Fn() -> SortedTrieData> instead
  • Remove unnecessary Default impl for LazyTrieData

The previous implementation had two separate OnceLock fields and a trait that was only implemented by one type. This consolidates everything into a simpler design while maintaining the same lazy evaluation semantics.

@mattsse mattsse requested a review from Rjected as a code owner January 17, 2026 02:45
@mattsse mattsse added the A-trie Related to Merkle Patricia Trie implementation label Jan 17, 2026
@github-project-automation github-project-automation bot moved this to Backlog in Reth Tracker Jan 17, 2026
@mattsse mattsse force-pushed the mattsse/simplify-lazy-trie-data branch from ea3499a to 5db33d8 Compare January 17, 2026 02:55
This refactor simplifies the lazy trie data abstraction introduced in
the previous PR:

- Create SortedTrieData container bundling HashedPostStateSorted and
  TrieUpdatesSorted together
- Simplify LazyTrieData to use single Arc<OnceLock<SortedTrieData>>
  instead of two separate OnceLocks
- Remove TrieDataCompute trait in favor of simple Arc<dyn Fn()>
- Remove Default impl for LazyTrieData (not needed)
- Update DeferredTrieData::to_lazy() to use closure-based deferred
  computation

The previous implementation was overly complex with:
- Two separate OnceLock fields that could be initialized independently
- A trait (TrieDataCompute) that was only implemented by one type
- Unnecessary Default implementation

This simplification makes the code easier to understand while
maintaining the same lazy evaluation semantics. The computation is
still deferred until first access, and clones share the cached state.
@mattsse mattsse force-pushed the mattsse/simplify-lazy-trie-data branch from 5db33d8 to 783ce91 Compare January 17, 2026 03:06
@mattsse
Copy link
Collaborator Author

mattsse commented Jan 17, 2026

Closing to redo as part of a broader revert of #21137

@mattsse mattsse closed this Jan 17, 2026
@github-project-automation github-project-automation bot moved this from Backlog to Done in Reth Tracker Jan 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-trie Related to Merkle Patricia Trie implementation

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant