Repository navigation
Feat/subtree roots - #165
Merged
Merged
Conversation
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.
Summary
Asking a node for a commitment's Merkle proof tells it which note is about to be spent.
This PR adds what a wallet needs to build the path itself, following Zcash's
GetSubtreeRootsmodel:already saw while scanning;
download for every wallet.
Pallet (
pallet-shielded-pool)get_subtree_roots(tree_id, start, count) -> Option<SubtreeRoots>:MAX_SUBTREE_ROOTS(4096, a quarter of a full tree's 2^14 blocks)level-
SUBTREE_LEVEL(6) roots of one tree;root), all read from one state;
the caller knows;
Nonefor a tree that does not exist yet.change once it is full.
sealed tree pruned under an earlier, higher cut. With the current cut
(
SealedTreePrunedBelowLevel = 6) the level-6 nodes are kept, so the rebuild is nothit. Worst case: 64 leaf reads per root, at most 4096 roots per call.
SubtreeRoots,SUBTREE_LEVEL,MAX_SUBTREE_ROOTS.Runtime API v4
ShieldedPoolRuntimeApi::get_subtree_roots, marked#[api_version(4)]; the runtimeimplements v4.
RPC (
fc-rpc-v2)privacy_getSubtreeRoots(tree_id, start, count)returnstree_id,level,tree_leaves,sealed,root,startandroots(0xhex, little-endian fieldelements).
ProofGateas the Merkle-proof RPCs: core-based slots and abounded queue.
invalid-params error.
Compatibility
@orbinum/protocol0.8.0 already shipsgetSubtreeRoots/parseSubtreeRoots/buildLocalPath.pallet-shielded-pool0.24.0,pallet-shielded-pool-runtime-api0.3.0.Tests
runtime_api_impl::tests::subtree_roots:cargo test -p pallet-shielded-pool(412) and-p fc-rpc-v2(44) pass; clippy with-D warningsand fmt are clean.Live verification
Against a dev node built from this code:
privacy_getSubtreeRootsplus the scanned block leaveswere identical to
privacy_getMerkleProofByCommitment:@orbinum/protocolend-to-end against the RPC: 8/8.