diff --git a/eth2/state_processing/src/common/convert_to_indexed.rs b/eth2/state_processing/src/common/convert_to_indexed.rs index 5492252f7..1854d32d1 100644 --- a/eth2/state_processing/src/common/convert_to_indexed.rs +++ b/eth2/state_processing/src/common/convert_to_indexed.rs @@ -1,10 +1,10 @@ -use super::get_attesting_indices; +use super::{get_attesting_indices, get_attesting_indices_unsorted}; use itertools::{Either, Itertools}; use types::*; /// Convert `attestation` to (almost) indexed-verifiable form. /// -/// Spec v0.6.1 +/// Spec v0.6.3 pub fn convert_to_indexed( state: &BeaconState, attestation: &Attestation, @@ -12,6 +12,10 @@ pub fn convert_to_indexed( let attesting_indices = get_attesting_indices(state, &attestation.data, &attestation.aggregation_bitfield)?; + // We verify the custody bitfield by calling `get_attesting_indices_unsorted` and throwing + // away the result. This avoids double-sorting - the partition below takes care of the ordering. + get_attesting_indices_unsorted(state, &attestation.data, &attestation.custody_bitfield)?; + let (custody_bit_0_indices, custody_bit_1_indices) = attesting_indices.into_iter().enumerate().partition_map( |(committee_idx, validator_idx)| match attestation.custody_bitfield.get(committee_idx) {