Skip to content

Commit

Permalink
Fix bug when pushing the Heartwood actiation block to the history tree
Browse files Browse the repository at this point in the history
  • Loading branch information
conradoplg committed Aug 3, 2021
1 parent 6bf9f71 commit 7481dba
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions zebra-state/src/service/finalized_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,10 @@ impl FinalizedState {
.activation_height(self.network)
.expect("Heartwood height is known");
match height.cmp(&heartwood_height) {
std::cmp::Ordering::Less => assert!(history_tree.is_none()),
std::cmp::Ordering::Less => assert!(
history_tree.is_none(),
"history tree must not exist pre-Heartwood"
),
std::cmp::Ordering::Equal => {
history_tree = Some(HistoryTree::from_block(
self.network,
Expand All @@ -377,12 +380,10 @@ impl FinalizedState {
&orchard_root,
)?);
}
std::cmp::Ordering::Greater => assert!(history_tree.is_some()),
}

// Add block to history tree if applicable
if let Some(history_tree) = &mut history_tree {
history_tree.push(block.clone(), &sapling_root, &orchard_root)?;
std::cmp::Ordering::Greater => history_tree
.as_mut()
.expect("history tree must exist Heartwood-onward")
.push(block.clone(), &sapling_root, &orchard_root)?,
}

// Compute the new anchors and index them
Expand Down

0 comments on commit 7481dba

Please sign in to comment.