diff --git a/eth2/types/src/beacon_state/attestation_participants.rs b/eth2/types/src/beacon_state/attestation_participants.rs index f70f131ce6..28d3ed4a97 100644 --- a/eth2/types/src/beacon_state/attestation_participants.rs +++ b/eth2/types/src/beacon_state/attestation_participants.rs @@ -18,14 +18,19 @@ impl BeaconState { attestations: &[&PendingAttestation], spec: &ChainSpec, ) -> Result, Error> { - attestations.iter().try_fold(vec![], |mut acc, a| { - acc.append(&mut self.get_attestation_participants( - &a.data, - &a.aggregation_bitfield, - spec, - )?); - Ok(acc) - }) + let mut all_participants = attestations + .iter() + .try_fold::<_, _, Result, Error>>(vec![], |mut acc, a| { + acc.append(&mut self.get_attestation_participants( + &a.data, + &a.aggregation_bitfield, + spec, + )?); + Ok(acc) + })?; + all_participants.sort_unstable(); + all_participants.dedup(); + Ok(all_participants) } // TODO: analyse for efficiency improvments. This implementation is naive.