Skip to content

Commit

Permalink
Look for the most recent sprout tree height if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
teor2345 authored Nov 21, 2023
1 parent 2116ab7 commit cfd2db8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions zebra-state/src/service/finalized_state/zebra_db/shielded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,10 @@ impl ZebraDb {
self.db.zs_get(&sprout_tree_cf, &());

if sprout_tree.is_none() {
let tip_height = self
.finalized_tip_height()
.expect("just checked for an empty database");

sprout_tree = self.db.zs_get(&sprout_tree_cf, &tip_height);
// In Zebra 1.4.0 and later, we don't update the sprout tip tree unless it is changed.
// And we write with a `()` key, not a height key.
// So we need to look for the most recent update height if the `()` key has never been written.
sprout_tree = self.db.zs_last_key_value(&sprout_tree_cf);

Check failure on line 115 in zebra-state/src/service/finalized_state/zebra_db/shielded.rs

View workflow job for this annotation

GitHub Actions / Build and Deploy Zebra Internal Docs

mismatched types

Check failure on line 115 in zebra-state/src/service/finalized_state/zebra_db/shielded.rs

View workflow job for this annotation

GitHub Actions / Test stable on ubuntu-latest

mismatched types

Check failure on line 115 in zebra-state/src/service/finalized_state/zebra_db/shielded.rs

View workflow job for this annotation

GitHub Actions / Test beta on ubuntu-latest

mismatched types

Check failure on line 115 in zebra-state/src/service/finalized_state/zebra_db/shielded.rs

View workflow job for this annotation

GitHub Actions / Check Cargo.lock is up to date

mismatched types

Check failure on line 115 in zebra-state/src/service/finalized_state/zebra_db/shielded.rs

View workflow job for this annotation

GitHub Actions / Clippy (stable) Results

mismatched types

error[E0308]: mismatched types --> zebra-state/src/service/finalized_state/zebra_db/shielded.rs:115:27 | 108 | let mut sprout_tree: Option<Arc<sprout::tree::NoteCommitmentTree>> = | --------------------------------------------- expected due to this type ... 115 | sprout_tree = self.db.zs_last_key_value(&sprout_tree_cf); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Option<Arc<NoteCommitmentTree>>`, found `Option<(_, _)>` | = note: expected enum `std::option::Option<std::sync::Arc<zebra_chain::sprout::tree::NoteCommitmentTree>>` found enum `std::option::Option<(_, _)>`

Check failure on line 115 in zebra-state/src/service/finalized_state/zebra_db/shielded.rs

View workflow job for this annotation

GitHub Actions / Clippy (stable) Results

mismatched types

error[E0308]: mismatched types --> zebra-state/src/service/finalized_state/zebra_db/shielded.rs:115:27 | 108 | let mut sprout_tree: Option<Arc<sprout::tree::NoteCommitmentTree>> = | --------------------------------------------- expected due to this type ... 115 | sprout_tree = self.db.zs_last_key_value(&sprout_tree_cf); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Option<Arc<NoteCommitmentTree>>`, found `Option<(_, _)>` | = note: expected enum `std::option::Option<std::sync::Arc<zebra_chain::sprout::tree::NoteCommitmentTree>>` found enum `std::option::Option<(_, _)>`
}

sprout_tree.expect("Sprout note commitment tree must exist if there is a finalized tip")
Expand Down

0 comments on commit cfd2db8

Please sign in to comment.