mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-18 13:28:33 +00:00
Fix naive import, greedy aggregation
This commit is contained in:
@@ -6,7 +6,7 @@ use types::*;
|
||||
pub fn get_attesting_indices<T: EthSpec>(
|
||||
committee: &[usize],
|
||||
bitlist: &BitList<T::MaxValidatorsPerCommittee>,
|
||||
) -> Result<Vec<usize>, BeaconStateError> {
|
||||
) -> Result<Vec<u64>, BeaconStateError> {
|
||||
if bitlist.len() != committee.len() {
|
||||
return Err(BeaconStateError::InvalidBitfield);
|
||||
}
|
||||
@@ -15,7 +15,7 @@ pub fn get_attesting_indices<T: EthSpec>(
|
||||
|
||||
for (i, validator_index) in committee.iter().enumerate() {
|
||||
if let Ok(true) = bitlist.get(i) {
|
||||
indices.push(*validator_index)
|
||||
indices.push(*validator_index as u64)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,9 +14,7 @@ pub fn get_indexed_attestation<T: EthSpec>(
|
||||
let attesting_indices = get_attesting_indices::<T>(committee, &attestation.aggregation_bits)?;
|
||||
|
||||
Ok(IndexedAttestation {
|
||||
attesting_indices: VariableList::new(
|
||||
attesting_indices.into_iter().map(|x| x as u64).collect(),
|
||||
)?,
|
||||
attesting_indices: VariableList::new(attesting_indices)?,
|
||||
data: attestation.data.clone(),
|
||||
signature: attestation.signature.clone(),
|
||||
})
|
||||
|
||||
@@ -278,8 +278,8 @@ impl ValidatorStatuses {
|
||||
// Loop through the participating validator indices and update the status vec.
|
||||
for validator_index in attesting_indices {
|
||||
self.statuses
|
||||
.get_mut(validator_index)
|
||||
.ok_or(BeaconStateError::UnknownValidator(validator_index))?
|
||||
.get_mut(validator_index as usize)
|
||||
.ok_or(BeaconStateError::UnknownValidator(validator_index as usize))?
|
||||
.update(&status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ pub fn translate_participation<E: EthSpec>(
|
||||
for index in attesting_indices {
|
||||
for flag_index in &participation_flag_indices {
|
||||
epoch_participation
|
||||
.get_mut(index)
|
||||
.ok_or(Error::UnknownValidator(index))?
|
||||
.get_mut(index as usize)
|
||||
.ok_or(Error::UnknownValidator(index as usize))?
|
||||
.add_flag(*flag_index)?;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user