From f7a43b7f5f3672824dd97b36bf21735bfc766d67 Mon Sep 17 00:00:00 2001 From: teor Date: Tue, 21 Nov 2023 18:38:26 +1000 Subject: [PATCH] Get the latest history tree not the tip height history tree --- .../src/service/finalized_state/zebra_db/chain.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/zebra-state/src/service/finalized_state/zebra_db/chain.rs b/zebra-state/src/service/finalized_state/zebra_db/chain.rs index 706950c5bee..b1d6e818846 100644 --- a/zebra-state/src/service/finalized_state/zebra_db/chain.rs +++ b/zebra-state/src/service/finalized_state/zebra_db/chain.rs @@ -59,11 +59,10 @@ impl ZebraDb { let mut history_tree: Option> = self.db.zs_get(&history_tree_cf, &()); if history_tree.is_none() { - let tip_height = self - .finalized_tip_height() - .expect("just checked for an empty database"); - - history_tree = self.db.zs_get(&history_tree_cf, &tip_height); + // In Zebra 1.4.0 and later, we only update the history tip tree when it has changed (for every block after heartwood). + // But 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. + history_tree = self.db.zs_last_key_value(&history_tree_cf); } history_tree.unwrap_or_default()