Skip to content

chore(trie): Stateful DatabaseTrieWitness #16900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

emhane
Copy link
Collaborator

@emhane emhane commented Jun 18, 2025

Closes #15481

@emhane emhane added the C-enhancement New feature or request label Jun 18, 2025
@emhane emhane added the D-good-first-issue Nice and easy! A great choice to get started label Jun 18, 2025
@emhane emhane requested a review from joshieDo as a code owner June 18, 2025 13:53
@emhane emhane added A-db Related to the database A-trie Related to Merkle Patricia Trie implementation labels Jun 18, 2025
@github-project-automation github-project-automation bot moved this to Backlog in Reth Tracker Jun 18, 2025
@emhane emhane added C-debt A clean up/refactor of existing code and removed C-enhancement New feature or request labels Jun 18, 2025
@emhane emhane enabled auto-merge June 18, 2025 16:20
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

@Rjected do we still need/want this?

Copy link
Member

@Rjected Rjected left a comment

Choose a reason for hiding this comment

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

@Rjected do we still need/want this?

This would be nice, although the other PRs for this refactor had issues with cyclic deps that I think we should address with some reorganization first. One question about why this needs a FnOnce mainly, and another comment about removing generics from one of the new fns

Comment on lines +58 to 70
/// Applies given operation on and sets the trie cursor factory.
pub fn with_trie_cursor_factory<TF, F>(self, f: F) -> TrieWitness<TF, H>
where
F: FnOnce(T) -> TF,
{
TrieWitness {
trie_cursor_factory,
trie_cursor_factory: f(self.trie_cursor_factory),
hashed_cursor_factory: self.hashed_cursor_factory,
prefix_sets: self.prefix_sets,
always_include_root_node: self.always_include_root_node,
witness: self.witness,
}
}
Copy link
Member

Choose a reason for hiding this comment

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

why did we have to make this method into one that requires a FnOnce?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

see commit at HEAD^, uglier syntax

/// Set the hashed cursor factory.
pub fn with_hashed_cursor_factory<HF>(self, hashed_cursor_factory: HF) -> TrieWitness<T, HF> {
/// Applies given operation on and sets the hashed cursor factory.
pub fn with_hashed_cursor_factory<HF, F>(self, f: F) -> TrieWitness<T, HF>
Copy link
Member

Choose a reason for hiding this comment

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

same q here for FnOnce

Comment on lines +110 to +117
/// Constructs a new instance from given database transaction.
pub fn from_tx<'a, TX>(tx: &'a TX) -> Self
where
T: From<&'a TX>,
H: From<&'a TX>,
{
Self::new(T::from(tx), H::from(tx))
}
Copy link
Member

Choose a reason for hiding this comment

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

could we make this a method on TrieWitness<DatabaseTrieCursorFactory<..>, DatabaseHashedCursorFactory<..>> instead of making this fully generic with From?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

cyclic dep issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-db Related to the database A-trie Related to Merkle Patricia Trie implementation C-debt A clean up/refactor of existing code D-good-first-issue Nice and easy! A great choice to get started
Projects
Status: Backlog
Development

Successfully merging this pull request may close these issues.

Make DatabaseTrieWitness stateful
3 participants