mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-03 21:04:28 +00:00
Ensure non-zero bits for each committee bitfield comprising an aggregate (#6603)
* add new validation
This commit is contained in:
@@ -103,14 +103,14 @@ pub mod attesting_indices_electra {
|
|||||||
|
|
||||||
let committee_count_per_slot = committees.len() as u64;
|
let committee_count_per_slot = committees.len() as u64;
|
||||||
let mut participant_count = 0;
|
let mut participant_count = 0;
|
||||||
for index in committee_indices {
|
for committee_index in committee_indices {
|
||||||
let beacon_committee = committees
|
let beacon_committee = committees
|
||||||
.get(index as usize)
|
.get(committee_index as usize)
|
||||||
.ok_or(Error::NoCommitteeFound(index))?;
|
.ok_or(Error::NoCommitteeFound(committee_index))?;
|
||||||
|
|
||||||
// This check is new to the spec's `process_attestation` in Electra.
|
// This check is new to the spec's `process_attestation` in Electra.
|
||||||
if index >= committee_count_per_slot {
|
if committee_index >= committee_count_per_slot {
|
||||||
return Err(BeaconStateError::InvalidCommitteeIndex(index));
|
return Err(BeaconStateError::InvalidCommitteeIndex(committee_index));
|
||||||
}
|
}
|
||||||
participant_count.safe_add_assign(beacon_committee.committee.len() as u64)?;
|
participant_count.safe_add_assign(beacon_committee.committee.len() as u64)?;
|
||||||
let committee_attesters = beacon_committee
|
let committee_attesters = beacon_committee
|
||||||
@@ -127,6 +127,12 @@ pub mod attesting_indices_electra {
|
|||||||
})
|
})
|
||||||
.collect::<HashSet<u64>>();
|
.collect::<HashSet<u64>>();
|
||||||
|
|
||||||
|
// Require at least a single non-zero bit for each attesting committee bitfield.
|
||||||
|
// This check is new to the spec's `process_attestation` in Electra.
|
||||||
|
if committee_attesters.is_empty() {
|
||||||
|
return Err(BeaconStateError::EmptyCommittee);
|
||||||
|
}
|
||||||
|
|
||||||
attesting_indices.extend(committee_attesters);
|
attesting_indices.extend(committee_attesters);
|
||||||
committee_offset.safe_add_assign(beacon_committee.committee.len())?;
|
committee_offset.safe_add_assign(beacon_committee.committee.len())?;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ pub enum Error {
|
|||||||
UnknownValidator(usize),
|
UnknownValidator(usize),
|
||||||
UnableToDetermineProducer,
|
UnableToDetermineProducer,
|
||||||
InvalidBitfield,
|
InvalidBitfield,
|
||||||
|
EmptyCommittee,
|
||||||
ValidatorIsWithdrawable,
|
ValidatorIsWithdrawable,
|
||||||
ValidatorIsInactive {
|
ValidatorIsInactive {
|
||||||
val_index: usize,
|
val_index: usize,
|
||||||
|
|||||||
Reference in New Issue
Block a user