Closed mpguerra closed 3 years ago
After studying the librustzcash implementation, I'm not sure what is the best approach here. I'm writing it down just to make it clearer but we can discuss it further in chat
librustzcash only provides a mechanism to create a MMR tree from a vector of MMR peaks and to add/delete nodes to it. But it is not intended to be used as a data structure to keep around.
zcash uses it like this, from what I could gather, when e.g. there is a new block to be added:
We could certainly use the same approach, but librustzcash will solve only part of the problem.
Therefore, we need to decide what will be our approach in order for us to proceed on this issue...
To be more concrete, regarding the tasks in the issue:
To be more concrete, regarding the tasks in the issue:
* Create a MMR data type: build it from what? A vector of MMR peaks? Directly from (cache) state? * Adding a new block to a zcash_history MMR: (depending on the above) how to get the MMR? A cached MMR, or build it from a peak vector, or from cached state? * etc...
In general, we want to do the easiest thing that lets us to #2134 and #2135. But we can definitely chat about the details.
Part of this (only the wrapper) was implemented in https://github.com/ZcashFoundation/zebra/pull/2227
Another part (keeping track of what needs to be persisted) will be implemented in a separate PR (should we split the issue too?)
Part of this (only the wrapper) was implemented in #2227
👍
Another part (keeping track of what needs to be persisted) will be implemented in a separate PR (should we split the issue too?)
I moved the remaining persistent state task to #2134, which deals with the finalized state. So we can close this ticket when #2227 merges.
Is your feature request related to a problem? Please describe.
Part of the work to implement ZIP-221 will involve integrating the history merkle mountain range (MMR) from librustzcash into Zebra.
The goal of this PR is to provide a Zebra-specific API for #2134 and #2135 with tests. (But we want to implement the state changes in #2134 and #2135 in separate PRs.)
Describe the solution you'd like
[ ] Create a
zebra_chain::primitives::zcash_history
module[ ] Create a
zebra_chain::primitives::zcash_history
MMR data type:HashMap<u32, Entry>
Make functions for:
NodeData
from a ZebraBlock
zebra_chain::primitives::zcash_primitives
for the similar code for transactionszcash_history
MMR -Tree::new
Tree::append_leaf
Tree::truncate_leaf
Tree::root_node().data().hash()
Write tests for:
BLOCKS
test vectorsAdditional context
See https://github.com/zcashfoundation/zebra/issues/2091#issuecomment-832311598 for more details