From 01039546cb40b00926d49af3ed2088d3fce08341 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Mon, 27 May 2019 17:46:05 +1000 Subject: [PATCH] state_processing: sort attester slashing indices This will be "to spec" if eth2.0-specs#1126 is merged --- .../verify_attester_slashing.rs | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/eth2/state_processing/src/per_block_processing/verify_attester_slashing.rs b/eth2/state_processing/src/per_block_processing/verify_attester_slashing.rs index 9f99feeaee..7b227900aa 100644 --- a/eth2/state_processing/src/per_block_processing/verify_attester_slashing.rs +++ b/eth2/state_processing/src/per_block_processing/verify_attester_slashing.rs @@ -1,6 +1,6 @@ use super::errors::{AttesterSlashingInvalid as Invalid, AttesterSlashingValidationError as Error}; use super::verify_indexed_attestation::verify_indexed_attestation; -use std::collections::HashSet; +use std::collections::BTreeSet; use types::*; /// Indicates if an `AttesterSlashing` is valid to be included in a block in the current epoch of the given @@ -67,13 +67,18 @@ where let attestation_1 = &attester_slashing.attestation_1; let attestation_2 = &attester_slashing.attestation_2; - let mut attesting_indices_1 = HashSet::new(); - attesting_indices_1.extend(attestation_1.custody_bit_0_indices.clone()); - attesting_indices_1.extend(attestation_1.custody_bit_1_indices.clone()); - - let mut attesting_indices_2 = HashSet::new(); - attesting_indices_2.extend(attestation_2.custody_bit_0_indices.clone()); - attesting_indices_2.extend(attestation_2.custody_bit_1_indices.clone()); + let attesting_indices_1 = attestation_1 + .custody_bit_0_indices + .iter() + .chain(&attestation_1.custody_bit_1_indices) + .cloned() + .collect::>(); + let attesting_indices_2 = attestation_2 + .custody_bit_0_indices + .iter() + .chain(&attestation_2.custody_bit_1_indices) + .cloned() + .collect::>(); let mut slashable_indices = vec![];