Skip to content

Commit 06c05d0

Browse files
committed
fix: adding the missing three validations on the head checkpoint
1 parent 504bf1f commit 06c05d0

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

  • crates/common/consensus/lean/src

crates/common/consensus/lean/src/state.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -556,23 +556,27 @@ pub fn attestation_data_matches_chain(
556556
historical_block_hashes: &[B256],
557557
attestation_data: AttestationData,
558558
) -> anyhow::Result<bool> {
559-
if attestation_data.source.root == B256::ZERO || attestation_data.target.root == B256::ZERO {
559+
if attestation_data.source.root == B256::ZERO
560+
|| attestation_data.target.root == B256::ZERO
561+
|| attestation_data.head.root == B256::ZERO
562+
{
560563
return Ok(false);
561564
}
562565

563566
let source_slot = attestation_data.source.slot as usize;
564567
let target_slot = attestation_data.target.slot as usize;
568+
let head_slot = attestation_data.head.slot as usize;
565569

566-
if source_slot >= historical_block_hashes.len() {
567-
return Ok(false);
568-
}
569-
570-
if target_slot >= historical_block_hashes.len() {
570+
if source_slot >= historical_block_hashes.len()
571+
|| target_slot >= historical_block_hashes.len()
572+
|| head_slot >= historical_block_hashes.len()
573+
{
571574
return Ok(false);
572575
}
573576

574577
let matches = attestation_data.source.root == historical_block_hashes[source_slot]
575-
&& attestation_data.target.root == historical_block_hashes[target_slot];
578+
&& attestation_data.target.root == historical_block_hashes[target_slot]
579+
&& attestation_data.head.root == historical_block_hashes[head_slot];
576580

577581
Ok(matches)
578582
}

0 commit comments

Comments
 (0)