Skip to content

Commit

Permalink
Ensure best justified is finalized descendent
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhauner committed Jun 29, 2022
1 parent cbd8237 commit aa44285
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions consensus/fork_choice/src/fork_choice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1070,14 +1070,18 @@ where
}

if store.best_justified_checkpoint().epoch > store.justified_checkpoint().epoch {
store
.set_justified_checkpoint(*store.best_justified_checkpoint())
.map_err(Error::ForkChoiceStoreError)?;
let store = &self.fc_store;
if self.is_descendant_of_finalized(store.best_justified_checkpoint().root) {
let store = &mut self.fc_store;
store
.set_justified_checkpoint(*store.best_justified_checkpoint())
.map_err(Error::ForkChoiceStoreError)?;
}
}

// Update store.justified_checkpoint if a better unrealized justified checkpoint is known
let unrealized_justified_checkpoint = *store.unrealized_justified_checkpoint();
let unrealized_finalized_checkpoint = *store.unrealized_finalized_checkpoint();
let unrealized_justified_checkpoint = *self.fc_store.unrealized_justified_checkpoint();
let unrealized_finalized_checkpoint = *self.fc_store.unrealized_finalized_checkpoint();
self.update_checkpoints(
unrealized_justified_checkpoint,
unrealized_finalized_checkpoint,
Expand Down

0 comments on commit aa44285

Please sign in to comment.