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

fix: Cache Sprout tree roots in tests #8741

Merged
merged 1 commit into from
Aug 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions zebra-state/src/service/finalized_state/zebra_db/arbitrary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ impl ZebraDb {
let sapling_anchors = self.db().cf_handle("sapling_anchors").unwrap();
let orchard_anchors = self.db().cf_handle("orchard_anchors").unwrap();

let sprout_tree = sprout::tree::NoteCommitmentTree::default();
// Calculate the root so we pass the tree with a cached root to the database. We need to do
// that because the database checks if the tree has a cached root.
sprout_tree.root();

for transaction in block.transactions.iter() {
// Sprout
for joinsplit in transaction.sprout_groth16_joinsplits() {
batch.zs_insert(
&sprout_anchors,
joinsplit.anchor,
sprout::tree::NoteCommitmentTree::default(),
);
batch.zs_insert(&sprout_anchors, joinsplit.anchor, sprout_tree.clone());
}

// Sapling
Expand Down
Loading