Conversation
get_proof for Trieget_proof for Trie
mpaulucci
reviewed
Sep 19, 2024
| /// The proof will contain all the encoded nodes traversed until reaching the node where the path is stored (including this last node). | ||
| /// The proof will still be constructed even if the path is not stored in the trie, proving its absence. | ||
| #[allow(unused)] | ||
| pub fn get_proof(&self, path: &PathRLP) -> Result<Vec<Vec<u8>>, StoreError> { |
Collaborator
There was a problem hiding this comment.
would it make sense to return a vec of nodes instead, so that the type is more explicit? Then the caller can convert it trivially to vec of u8
Contributor
Author
There was a problem hiding this comment.
The encoding for the nodes is standard, the structure of the node itself is not, returning the nodes would mean exposing our internal node structure which is private and not relevant to the user
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Adding support for Trie::get_proof so we can use it in rpc endpoint etc_getProof
Description
Triemethodget_proofTrie::get_proofOther:
Replace
NodeHasherwithNodeEncoder, which behaves similarly, but instead of building up the node's hash, it builds up the node's encoded format, leaving the hashing to a later instanceAdd method
encode_rawfor all node variantsAdd
NodeHashmethodfrom_encoded_rawwhich will hash the encoded node returned by theNodeEncoderCloses None, but is needed in order to implement #291