Skip to content

Commit ec45999

Browse files
committed
chec attester is member of the committee
1 parent 40a1f5c commit ec45999

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

beacon_node/beacon_chain/src/attestation_verification.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -965,19 +965,31 @@ impl<'a, T: BeaconChainTypes> IndexedUnaggregatedAttestation<'a, T> {
965965

966966
let indexed_attestation = attestation.to_indexed(fork_name);
967967

968+
// Check that the attester is a member of the committee and return `committees_per_slot` which
969+
// is used in `verify_middle_checks` to calculate the expected `subnet_id`
968970
let committees_per_slot = chain
969971
.with_committee_cache(
970972
attestation.data.target.root,
971973
attestation_epoch,
972974
|committee_cache, _| {
973-
if committee_cache
975+
let Some(beacon_committee) = committee_cache
974976
.get_beacon_committee(attestation.data.slot, attestation.committee_index)
975-
.is_none()
976-
{
977+
else {
977978
return Ok(Err(Error::NoCommitteeForSlotAndIndex {
978979
slot: attestation.data.slot,
979980
index: attestation.committee_index,
980981
}));
982+
};
983+
984+
if !beacon_committee
985+
.committee
986+
.contains(&(attestation.attester_index as usize))
987+
{
988+
return Ok(Err(Error::AttesterNotInCommittee {
989+
attester_index: attestation.attester_index,
990+
committee_index: attestation.committee_index,
991+
slot: attestation.data.slot,
992+
}));
981993
}
982994

983995
Ok(Ok(committee_cache.committees_per_slot()))

0 commit comments

Comments
 (0)