Skip to content

Conversation

@demosdemon
Copy link
Contributor

@demosdemon demosdemon commented Oct 14, 2025

TrieNode is a generic trait that abstracts over the behavior of nodes in a fixed-arity radix trie. This trait allows for different structures to represent tries while enabling similar operations on them.

TrieNode is merkle-aware, meaning it can represent nodes that are a mix of locally described children or children referenced by only their hash. This is accomplished through TrieEdgeState and is used later in proof verification.

The HashedTrieNode trait is for post-hashed nodes and is distinctly different from the hash described on TrieNode. This trait is intended to represent the computed hash of the node itself; whereas, the hash accessed via TrieNode is the hash of a child node as seen from its parent. While they are usually the same, they can differ during intermediate states of a trie or during proof verification when some information is incomplete.

KeyValueTrieRoot is an implementation of TrieNode that only represents a key-value store and is not merkleized. This is really a separate change and is a component of proof verification but is also needed here as it is used to test and verify the iterator.

@demosdemon demosdemon force-pushed the brandon.leblanc/trie-node-trait branch 2 times, most recently from e032c28 to 7947e5b Compare October 14, 2025 19:40
Base automatically changed from brandon.leblanc/hashable-shunt to main October 15, 2025 15:14
@demosdemon demosdemon force-pushed the brandon.leblanc/trie-node-trait branch from 7947e5b to 945becd Compare October 15, 2025 15:22
@demosdemon demosdemon marked this pull request as ready for review October 15, 2025 15:29
@demosdemon demosdemon requested a review from rkuris as a code owner October 15, 2025 15:29
demosdemon added a commit that referenced this pull request Oct 15, 2025
Key proofs are a sequence of trie nodes that follow a linear path
through the trie. This means we can reconstruct a narrow view of the
trie over that linear path. In this narrow view, each node can refer to
another full node or just its hash.

This resulting trie can (and will in an upcoming change) be hashed to
generate the same root hash. While merging with the key-value tries
from #1363 and #1365, we can iteratively verify the hash of each
layer and detect early if any node is incomplete.

The `Remote` edges can also point outside of the key range. We can use
these remote edges to identify holes in our overall trie and continue
synchronizing down those paths.
demosdemon added a commit that referenced this pull request Oct 15, 2025
Key proofs are a sequence of trie nodes that follow a linear path
through the trie. This means we can reconstruct a narrow view of the
trie over that linear path. In this narrow view, each node can refer to
another full node or just its hash.

This resulting trie can (and will in an upcoming change) be hashed to
generate the same root hash. While merging with the key-value tries
from #1363 and #1365, we can iteratively verify the hash of each
layer and detect early if any node is incomplete.

The `Remote` edges can also point outside of the key range. We can use
these remote edges to identify holes in our overall trie and continue
synchronizing down those paths.
demosdemon added a commit that referenced this pull request Oct 17, 2025
Key proofs are a sequence of trie nodes that follow a linear path
through the trie. This means we can reconstruct a narrow view of the
trie over that linear path. In this narrow view, each node can refer to
another full node or just its hash.

This resulting trie can (and will in an upcoming change) be hashed to
generate the same root hash. While merging with the key-value tries
from #1363 and #1365, we can iteratively verify the hash of each
layer and detect early if any node is incomplete.

The `Remote` edges can also point outside of the key range. We can use
these remote edges to identify holes in our overall trie and continue
synchronizing down those paths.
@demosdemon demosdemon force-pushed the brandon.leblanc/trie-node-trait branch from 945becd to c726158 Compare October 17, 2025 16:50
Comment on lines +165 to +171
pub fn fork(&mut self) -> PathGuard<'_> {
PathGuard::new(self.buf)
}
Copy link
Member

Choose a reason for hiding this comment

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

Why isn't this the clone implementation?

Copy link
Contributor Author

@demosdemon demosdemon Oct 29, 2025

Choose a reason for hiding this comment

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

Clone returns the same lifetime and the original type. This returns a new lifetime bound to self.

You also cannot Clone mutable references.

@demosdemon demosdemon force-pushed the brandon.leblanc/trie-node-trait branch from c726158 to cec42cb Compare October 29, 2025 16:16
demosdemon added a commit that referenced this pull request Oct 29, 2025
Key proofs are a sequence of trie nodes that follow a linear path
through the trie. This means we can reconstruct a narrow view of the
trie over that linear path. In this narrow view, each node can refer to
another full node or just its hash.

This resulting trie can (and will in an upcoming change) be hashed to
generate the same root hash. While merging with the key-value tries
from #1363 and #1365, we can iteratively verify the hash of each
layer and detect early if any node is incomplete.

The `Remote` edges can also point outside of the key range. We can use
these remote edges to identify holes in our overall trie and continue
synchronizing down those paths.
`TrieNode` is a generic trait that abstracts over the behavior of nodes
in a fixed-arity radix trie. This trait allows for different structures
to represent tries while enabling similar operations on them.

`TrieNode` is merkle-aware, meaning it can represent nodes that are a
mix of locally described children or children referenced by only their
hash. This is accomplished through `TrieEdgeState` and is used later in
proof verification.

The `HashedTrieNode` trait is for post-hashed nodes and is distinctly
different from the hash described on `TrieNode`. This trait is intended
to represent the computed hash of the node itself; whereas, the hash
accessed via `TrieNode` is the hash of a child node as seen from its
parent. While they are usually the same, they can differ during
intermediate states of a trie or during proof verification when some
information is incomplete.

`KeyValueTrieRoot` is an implementation of `TrieNode` that only
represents a key-value store and is not merkleized. This is really a
separate change and is a component of proof verification but is also
needed here as it is used to test and verify the iterator.
demosdemon added a commit that referenced this pull request Oct 29, 2025
Key proofs are a sequence of trie nodes that follow a linear path
through the trie. This means we can reconstruct a narrow view of the
trie over that linear path. In this narrow view, each node can refer to
another full node or just its hash.

This resulting trie can (and will in an upcoming change) be hashed to
generate the same root hash. While merging with the key-value tries
from #1363 and #1365, we can iteratively verify the hash of each
layer and detect early if any node is incomplete.

The `Remote` edges can also point outside of the key range. We can use
these remote edges to identify holes in our overall trie and continue
synchronizing down those paths.
@demosdemon demosdemon force-pushed the brandon.leblanc/trie-node-trait branch from cec42cb to 07d7fa5 Compare October 29, 2025 18:10
@demosdemon demosdemon enabled auto-merge (squash) October 29, 2025 18:12
@demosdemon demosdemon merged commit 2164262 into main Oct 29, 2025
39 of 41 checks passed
@demosdemon demosdemon deleted the brandon.leblanc/trie-node-trait branch October 29, 2025 18:16
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.

3 participants