Skip to content

Commit

Permalink
Merge of #6603
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Dec 19, 2024
2 parents 5022398 + a3aefc8 commit b576003
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
16 changes: 11 additions & 5 deletions consensus/state_processing/src/common/get_attesting_indices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ pub mod attesting_indices_electra {

let committee_count_per_slot = committees.len() as u64;
let mut participant_count = 0;
for index in committee_indices {
for committee_index in committee_indices {
let beacon_committee = committees
.get(index as usize)
.ok_or(Error::NoCommitteeFound(index))?;
.get(committee_index as usize)
.ok_or(Error::NoCommitteeFound(committee_index))?;

// This check is new to the spec's `process_attestation` in Electra.
if index >= committee_count_per_slot {
return Err(BeaconStateError::InvalidCommitteeIndex(index));
if committee_index >= committee_count_per_slot {
return Err(BeaconStateError::InvalidCommitteeIndex(committee_index));
}
participant_count.safe_add_assign(beacon_committee.committee.len() as u64)?;
let committee_attesters = beacon_committee
Expand All @@ -127,6 +127,12 @@ pub mod attesting_indices_electra {
})
.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);
committee_offset.safe_add_assign(beacon_committee.committee.len())?;
}
Expand Down
1 change: 1 addition & 0 deletions consensus/types/src/beacon_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub enum Error {
UnknownValidator(usize),
UnableToDetermineProducer,
InvalidBitfield,
EmptyCommittee,
ValidatorIsWithdrawable,
ValidatorIsInactive {
val_index: usize,
Expand Down

0 comments on commit b576003

Please sign in to comment.