Skip to content
This repository was archived by the owner on Jan 9, 2026. It is now read-only.

Commit 2c4d906

Browse files
authored
docs(trie): document MDBX ordering assumptions in TrieWalker and Trie… (paradigmxyz#17906)
1 parent a89646f commit 2c4d906

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

crates/trie/trie/src/node_iter.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ struct SeekedHashedEntry<V> {
4343
result: Option<(B256, V)>,
4444
}
4545

46-
/// An iterator over existing intermediate branch nodes and updated leaf nodes.
46+
/// Iterates over trie nodes for hash building.
47+
///
48+
/// This iterator depends on the ordering guarantees of [`TrieCursor`],
49+
/// and additionally uses hashed cursor lookups when operating on storage tries.
4750
#[derive(Debug)]
4851
pub struct TrieNodeIter<C, H: HashedCursor> {
4952
/// The walker over intermediate nodes.

crates/trie/trie/src/trie_cursor/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ pub trait TrieCursorFactory {
3535
) -> Result<Self::StorageTrieCursor, DatabaseError>;
3636
}
3737

38-
/// A cursor for navigating a trie that works with both Tables and `DupSort` tables.
38+
/// A cursor for traversing stored trie nodes. The cursor must iterate over keys in
39+
/// lexicographical order.
3940
#[auto_impl::auto_impl(&mut, Box)]
4041
pub trait TrieCursor: Send + Sync {
4142
/// Move the cursor to the key and return if it is an exact match.

crates/trie/trie/src/walker.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ use tracing::{instrument, trace};
1010
#[cfg(feature = "metrics")]
1111
use crate::metrics::WalkerMetrics;
1212

13-
/// `TrieWalker` is a structure that enables traversal of a Merkle trie.
14-
/// It allows moving through the trie in a depth-first manner, skipping certain branches
15-
/// if they have not changed.
13+
/// Traverses the trie in lexicographic order.
14+
///
15+
/// This iterator depends on the ordering guarantees of [`TrieCursor`].
1616
#[derive(Debug)]
1717
pub struct TrieWalker<C> {
1818
/// A mutable reference to a trie cursor instance used for navigating the trie.

0 commit comments

Comments
 (0)