Skip to content

Commit 4f8d4be

Browse files
committed
Reject attestations to blocks prior to the split (#7084)
Squashed commit of the following: commit 0a53a24 Merge: 5c56a83 27aabe8 Author: Michael Sproul <[email protected]> Date: Tue Mar 18 16:28:25 2025 +1100 Merge branch 'release-v7.0.0' into reject-attestations-prior-to-split commit 5c56a83 Merge: fb9e049 3a555f5 Author: Eitan Seri-Levi <[email protected]> Date: Thu Mar 13 00:29:08 2025 -0600 Merge branch 'release-v7.0.0' into reject-attestations-prior-to-split commit fb9e049 Merge: f121c4a 9c4fc6e Author: Eitan Seri-Levi <[email protected]> Date: Wed Mar 12 10:35:38 2025 -0600 Merge branch 'release-v7.0.0' into reject-attestations-prior-to-split commit f121c4a Author: Eitan Seri-Levi <[email protected]> Date: Tue Mar 11 11:00:40 2025 -0600 lump into commit b8d2a8c Author: Eitan Seri-Levi <[email protected]> Date: Tue Mar 11 10:58:46 2025 -0600 add is descendant to fork-choice commit 72ef42b Author: Eitan Seri-Levi <[email protected]> Date: Tue Mar 11 10:53:16 2025 -0600 fix descent from split check commit 9d2ebf7 Author: Eitan Seri-Levi <[email protected]> Date: Tue Mar 11 10:46:00 2025 -0600 remove unused error variant, lump finalization check into commit 21478e5 Author: Eitan Seri-Levi <[email protected]> Date: Mon Mar 10 15:25:13 2025 -0600 remove unneeded error variant commit efaab87 Author: Eitan Seri-Levi <[email protected]> Date: Sat Mar 8 11:25:49 2025 -0700 fix test commit b911048 Author: Eitan Seri-Levi <[email protected]> Date: Wed Mar 5 23:42:46 2025 -0700 Reject attestations on gossip that attest to blocks prior to the current split point
1 parent 42e1443 commit 4f8d4be

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

beacon_node/beacon_chain/src/attestation_verification.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,6 +1128,12 @@ fn verify_head_block_is_known<T: BeaconChainTypes>(
11281128
}
11291129
}
11301130

1131+
if !verify_attestation_is_finalized_checkpoint_or_descendant(attestation.data(), chain) {
1132+
return Err(Error::HeadBlockFinalized {
1133+
beacon_block_root: attestation.data().beacon_block_root,
1134+
});
1135+
}
1136+
11311137
Ok(block)
11321138
} else if chain.is_pre_finalization_block(attestation.data().beacon_block_root)? {
11331139
Err(Error::HeadBlockFinalized {
@@ -1361,6 +1367,29 @@ pub fn verify_committee_index<E: EthSpec>(attestation: AttestationRef<E>) -> Res
13611367
Ok(())
13621368
}
13631369

1370+
fn verify_attestation_is_finalized_checkpoint_or_descendant<T: BeaconChainTypes>(
1371+
attestation_data: &AttestationData,
1372+
chain: &BeaconChain<T>,
1373+
) -> bool {
1374+
// If we have a split block newer than finalization then we also ban attestations which are not
1375+
// descended from that split block. It's important not to try checking `is_descendant` if
1376+
// finality is ahead of the split and the split block has been pruned, as `is_descendant` will
1377+
// return `false` in this case.
1378+
let fork_choice = chain.canonical_head.fork_choice_read_lock();
1379+
let attestation_block_root = attestation_data.beacon_block_root;
1380+
let finalized_slot = fork_choice
1381+
.finalized_checkpoint()
1382+
.epoch
1383+
.start_slot(T::EthSpec::slots_per_epoch());
1384+
let split = chain.store.get_split_info();
1385+
let is_descendant_from_split_block = split.slot == 0
1386+
|| split.slot <= finalized_slot
1387+
|| fork_choice.is_descendant(split.block_root, attestation_block_root);
1388+
1389+
fork_choice.is_finalized_checkpoint_or_descendant(attestation_block_root)
1390+
&& is_descendant_from_split_block
1391+
}
1392+
13641393
/// Assists in readability.
13651394
type CommitteesPerSlot = u64;
13661395

0 commit comments

Comments
 (0)