Skip to content
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

Implement compact encoding scheme for partial tries. #44

Merged
merged 3 commits into from
Dec 10, 2019

Conversation

jimpo
Copy link
Contributor

@jimpo jimpo commented Dec 5, 2019

As per module doc:

//! Compact encoding/decoding functions for partial Merkle-Patricia tries.
//!
//! A partial trie is a subset of the nodes in a complete trie, which can still be used to
//! perform authenticated lookups on a subset of keys. A naive encoding is the set of encoded nodes
//! in the partial trie. This, however, includes redundant hashes of other nodes in the partial
//! trie which could be computed directly. The compact encoding strips out all hash child
//! references to other nodes in the partial trie and replaces them with empty inline references,
//! indicating that the child reference is omitted. The nodes are then ordered in pre-order
//! traversal order so that the full nodes can be efficiently reconstructed recursively. Note that
//! hash references to nodes not in the partial trie are left intact. The compact encoding can be
//! expected to save roughly (n - 1) hashes in size where n is the number of nodes in the partial
//! trie.

@jimpo jimpo requested a review from cheme December 5, 2019 12:47
Copy link
Contributor

@cheme cheme left a comment

Choose a reason for hiding this comment

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

Looks good.
I put a few question or suggestion or just general self comment (I will put them in resolve status).
I did play a bit with the pr on jimpo/trie-codec...cheme:try_compact_proof .
I still did not look at the 'Extension' management (I only focused on the branch only case).

}
}
NodePlan::Branch { .. } => {
if child_prefix.len() <= self.prefix.len() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we could just debug_assert that (the function is only call with expect).

@jimpo jimpo requested a review from arkpar December 6, 2019 13:43
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