zebra
zebra copied to clipboard
De-duplicate note commitment trees in the finalized and non-finalized state
Motivation
Zebra stores duplicates of each Sprout note commitment tree, and after #3563, it also stores duplicates of each Sapling and Orchard note commitment tree.
This is a RAM, disk space, and speed optimisation.
Major Optimisations
-
[ ] #4766
-
[ ] #4721
-
[ ] #4784
-
Only store the first non-finalized sprout/sapling/orchard anchor in each identical series of anchors, and access them as in #4784. This needs a full sync performance test.
-
Use
TransactionIndex
for the value inChain.tx_by_hash
(after #3152 merges)
Minor Cleanups
These cleanups are optional.
-
Remove the non-finalized
Chain.{sapling, orchard}_note_commitment_tree
variables, and look them up inChain.{sapling, orchard}_trees_by_height
using the maximum chain height. -
Change the non-finalized
Chain.sprout_note_commitment_tree
tosprout::Root
. Look up the actual note commitment tree inChain.sprout_trees_by_anchor
. -
Change the finalized
sprout_note_commitment_tree
to a key of()
and a value ofsprout::Root
. Look up the actual note commitment tree insprout_anchors
.
Related Work
Follow-Up From:
- #3563
Hey team! Please add your planning poker estimate with ZenHub @conradoplg @dconnolly @jvff @oxarbitrage @teor2345 @upbqdn
We confirmed that this ticket is optional in https://github.com/ZcashFoundation/zebra/pull/3818#discussion_r823141591
We kept this open because note commitment trees are the most CPU-intensive work that we do.
I think we've finished the urgent parts of this ticket now.