Skip to content

Commit 23ea148

Browse files
committed
Fix fork choice error message (#4122)
## Issue Addressed NA ## Proposed Changes Ensures that we log the values of the *head* block rather than the *justified* block. ## Additional Info NA
1 parent 0616e01 commit 23ea148

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

consensus/fork_choice/src/fork_choice.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,10 @@ where
799799

800800
// If block is from past epochs, try to update store's justified & finalized checkpoints right away
801801
if block.slot().epoch(E::slots_per_epoch()) < current_slot.epoch(E::slots_per_epoch()) {
802-
self.pull_up_store_checkpoints()?;
802+
self.pull_up_store_checkpoints(
803+
unrealized_justified_checkpoint,
804+
unrealized_finalized_checkpoint,
805+
)?;
803806
}
804807

805808
(
@@ -1159,15 +1162,21 @@ where
11591162

11601163
// Update the justified/finalized checkpoints based upon the
11611164
// best-observed unrealized justification/finality.
1162-
self.pull_up_store_checkpoints()?;
1165+
let unrealized_justified_checkpoint = *self.fc_store.unrealized_justified_checkpoint();
1166+
let unrealized_finalized_checkpoint = *self.fc_store.unrealized_finalized_checkpoint();
1167+
self.pull_up_store_checkpoints(
1168+
unrealized_justified_checkpoint,
1169+
unrealized_finalized_checkpoint,
1170+
)?;
11631171

11641172
Ok(())
11651173
}
11661174

1167-
fn pull_up_store_checkpoints(&mut self) -> Result<(), Error<T::Error>> {
1168-
// Update store.justified_checkpoint if a better unrealized justified checkpoint is known
1169-
let unrealized_justified_checkpoint = *self.fc_store.unrealized_justified_checkpoint();
1170-
let unrealized_finalized_checkpoint = *self.fc_store.unrealized_finalized_checkpoint();
1175+
fn pull_up_store_checkpoints(
1176+
&mut self,
1177+
unrealized_justified_checkpoint: Checkpoint,
1178+
unrealized_finalized_checkpoint: Checkpoint,
1179+
) -> Result<(), Error<T::Error>> {
11711180
self.update_checkpoints(
11721181
unrealized_justified_checkpoint,
11731182
unrealized_finalized_checkpoint,

consensus/proto_array/src/proto_array.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -665,9 +665,9 @@ impl ProtoArray {
665665
start_root: *justified_root,
666666
justified_checkpoint: self.justified_checkpoint,
667667
finalized_checkpoint: self.finalized_checkpoint,
668-
head_root: justified_node.root,
669-
head_justified_checkpoint: justified_node.justified_checkpoint,
670-
head_finalized_checkpoint: justified_node.finalized_checkpoint,
668+
head_root: best_node.root,
669+
head_justified_checkpoint: best_node.justified_checkpoint,
670+
head_finalized_checkpoint: best_node.finalized_checkpoint,
671671
})));
672672
}
673673

0 commit comments

Comments
 (0)