Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1412,10 +1412,10 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
///
/// Returns `(block_root, block_slot)`.
pub fn heads(&self) -> Vec<(Hash256, Slot)> {
self.canonical_head
.fork_choice_read_lock()
let fork_choice = self.canonical_head.fork_choice_read_lock();
fork_choice
.proto_array()
.heads_descended_from_finalization::<T::EthSpec>()
.heads_descended_from_finalization::<T::EthSpec>(fork_choice.finalized_checkpoint())
.iter()
.map(|node| (node.root, node.slot))
.collect()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ pub fn downgrade_from_v23<T: BeaconChainTypes>(

let heads = fork_choice
.proto_array()
.heads_descended_from_finalization::<T::EthSpec>();
.heads_descended_from_finalization::<T::EthSpec>(fork_choice.finalized_checkpoint());

let head_roots = heads.iter().map(|node| node.root).collect();
let head_slots = heads.iter().map(|node| node.slot).collect();
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/http_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3037,8 +3037,8 @@ pub fn serve<T: BeaconChainTypes>(
})
.collect::<Vec<_>>();
Ok(ForkChoice {
justified_checkpoint: proto_array.justified_checkpoint,
finalized_checkpoint: proto_array.finalized_checkpoint,
justified_checkpoint: beacon_fork_choice.justified_checkpoint(),
finalized_checkpoint: beacon_fork_choice.finalized_checkpoint(),
fork_choice_nodes,
})
})
Expand Down
4 changes: 2 additions & 2 deletions beacon_node/http_api/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3057,11 +3057,11 @@ impl ApiTester {

assert_eq!(
result.justified_checkpoint,
expected_proto_array.justified_checkpoint
beacon_fork_choice.justified_checkpoint()
);
assert_eq!(
result.finalized_checkpoint,
expected_proto_array.finalized_checkpoint
beacon_fork_choice.finalized_checkpoint()
);

let expected_fork_choice_nodes: Vec<ForkChoiceNode> = expected_proto_array
Expand Down
10 changes: 7 additions & 3 deletions consensus/fork_choice/src/fork_choice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ where
op: &InvalidationOperation,
) -> Result<(), Error<T::Error>> {
self.proto_array
.process_execution_payload_invalidation::<E>(op)
.process_execution_payload_invalidation::<E>(op, self.finalized_checkpoint())
.map_err(Error::FailedToProcessInvalidExecutionPayload)
}

Expand Down Expand Up @@ -908,6 +908,8 @@ where
unrealized_finalized_checkpoint: Some(unrealized_finalized_checkpoint),
},
current_slot,
self.justified_checkpoint(),
self.finalized_checkpoint(),
)?;

Ok(())
Expand Down Expand Up @@ -1288,7 +1290,7 @@ where
/// Return `true` if `block_root` is equal to the finalized checkpoint, or a known descendant of it.
pub fn is_finalized_checkpoint_or_descendant(&self, block_root: Hash256) -> bool {
self.proto_array
.is_finalized_checkpoint_or_descendant::<E>(block_root)
.is_finalized_checkpoint_or_descendant::<E>(block_root, self.finalized_checkpoint())
}

pub fn is_descendant(&self, ancestor_root: Hash256, descendant_root: Hash256) -> bool {
Expand Down Expand Up @@ -1508,7 +1510,9 @@ where
/// be instantiated again later.
pub fn to_persisted(&self) -> PersistedForkChoice {
PersistedForkChoice {
proto_array: self.proto_array().as_ssz_container(),
proto_array: self
.proto_array()
.as_ssz_container(self.justified_checkpoint(), self.finalized_checkpoint()),
queued_attestations: self.queued_attestations().to_vec(),
}
}
Expand Down
15 changes: 12 additions & 3 deletions consensus/proto_array/src/fork_choice_test_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,12 @@ impl ForkChoiceTestDefinition {
unrealized_finalized_checkpoint: None,
};
fork_choice
.process_block::<MainnetEthSpec>(block, slot)
.process_block::<MainnetEthSpec>(
block,
slot,
self.justified_checkpoint,
self.finalized_checkpoint,
)
.unwrap_or_else(|e| {
panic!(
"process_block op at index {} returned error: {:?}",
Expand Down Expand Up @@ -272,7 +277,10 @@ impl ForkChoiceTestDefinition {
}
};
fork_choice
.process_execution_payload_invalidation::<MainnetEthSpec>(&op)
.process_execution_payload_invalidation::<MainnetEthSpec>(
&op,
self.finalized_checkpoint,
)
.unwrap()
}
Operation::AssertWeight { block_root, weight } => assert_eq!(
Expand Down Expand Up @@ -305,7 +313,8 @@ fn get_checkpoint(i: u64) -> Checkpoint {
}

fn check_bytes_round_trip(original: &ProtoArrayForkChoice) {
let bytes = original.as_bytes();
// The checkpoint are ignored `ProtoArrayForkChoice::from_bytes` so any value is ok
let bytes = original.as_bytes(Checkpoint::default(), Checkpoint::default());
let decoded = ProtoArrayForkChoice::from_bytes(&bytes, original.balances.clone())
.expect("fork choice should decode from bytes");
assert!(
Expand Down
Loading