diff --git a/eth2/state_processing/src/per_epoch_processing.rs b/eth2/state_processing/src/per_epoch_processing.rs index c4d1c69a23..f1ca42eda8 100644 --- a/eth2/state_processing/src/per_epoch_processing.rs +++ b/eth2/state_processing/src/per_epoch_processing.rs @@ -163,7 +163,8 @@ pub fn process_crosslinks( let epoch = relative_epoch.into_epoch(state.current_epoch()); for offset in 0..state.get_epoch_committee_count(relative_epoch)? { let shard = (state.get_epoch_start_shard(relative_epoch)? + offset) % spec.shard_count; - let crosslink_committee = state.get_crosslink_committee(epoch, shard, spec)?; + let crosslink_committee = + state.get_crosslink_committee_for_shard(shard, relative_epoch)?; let winning_root = winning_root(state, shard, epoch, spec)?; diff --git a/eth2/state_processing/src/per_epoch_processing/get_attesting_indices.rs b/eth2/state_processing/src/per_epoch_processing/get_attesting_indices.rs index 379159f4ef..1526c54beb 100644 --- a/eth2/state_processing/src/per_epoch_processing/get_attesting_indices.rs +++ b/eth2/state_processing/src/per_epoch_processing/get_attesting_indices.rs @@ -8,13 +8,12 @@ pub fn get_attesting_indices_unsorted( state: &BeaconState, attestation_data: &AttestationData, bitfield: &Bitfield, - spec: &ChainSpec, ) -> Result, BeaconStateError> { - let committee = state.get_crosslink_committee( - attestation_data.target_epoch, - attestation_data.shard, - spec, - )?; + let target_relative_epoch = + RelativeEpoch::from_epoch(state.current_epoch(), attestation_data.target_epoch)?; + + let committee = + state.get_crosslink_committee_for_shard(attestation_data.shard, target_relative_epoch)?; if !verify_bitfield_length(&bitfield, committee.committee.len()) { return Err(BeaconStateError::InvalidBitfield); diff --git a/eth2/state_processing/src/per_epoch_processing/validator_statuses.rs b/eth2/state_processing/src/per_epoch_processing/validator_statuses.rs index 95cea17f49..169007154e 100644 --- a/eth2/state_processing/src/per_epoch_processing/validator_statuses.rs +++ b/eth2/state_processing/src/per_epoch_processing/validator_statuses.rs @@ -214,7 +214,7 @@ impl ValidatorStatuses { .chain(state.current_epoch_attestations.iter()) { let attesting_indices = - get_attesting_indices_unsorted(state, &a.data, &a.aggregation_bitfield, spec)?; + get_attesting_indices_unsorted(state, &a.data, &a.aggregation_bitfield)?; let mut status = ValidatorStatus::default(); diff --git a/eth2/state_processing/src/per_epoch_processing/winning_root.rs b/eth2/state_processing/src/per_epoch_processing/winning_root.rs index d64af31bbb..9a1da14d3f 100644 --- a/eth2/state_processing/src/per_epoch_processing/winning_root.rs +++ b/eth2/state_processing/src/per_epoch_processing/winning_root.rs @@ -77,7 +77,7 @@ pub fn winning_root( let mut winning_root = None; for (crosslink, attestations) in candidate_crosslink_map { let attesting_validator_indices = - get_unslashed_attesting_indices_unsorted(state, &attestations, spec)?; + get_unslashed_attesting_indices_unsorted(state, &attestations)?; let total_attesting_balance = state.get_total_balance(&attesting_validator_indices, spec)?; @@ -102,7 +102,6 @@ pub fn winning_root( pub fn get_unslashed_attesting_indices_unsorted( state: &BeaconState, attestations: &[&PendingAttestation], - spec: &ChainSpec, ) -> Result, BeaconStateError> { let mut output = HashSet::new(); for a in attestations { @@ -110,7 +109,6 @@ pub fn get_unslashed_attesting_indices_unsorted( state, &a.data, &a.aggregation_bitfield, - spec, )?); } Ok(output diff --git a/eth2/types/src/beacon_state.rs b/eth2/types/src/beacon_state.rs index f193b178fb..66375a1d2f 100644 --- a/eth2/types/src/beacon_state.rs +++ b/eth2/types/src/beacon_state.rs @@ -307,12 +307,12 @@ impl BeaconState { /// /// Spec v0.6.1 pub fn get_attestation_slot(&self, attestation_data: &AttestationData) -> Result { - let target_epoch = + let target_relative_epoch = RelativeEpoch::from_epoch(self.current_epoch(), attestation_data.target_epoch)?; - let cc = self - .get_crosslink_committee_for_shard(attestation_data.shard, target_epoch)? - .ok_or_else(|| Error::NoCommitteeForShard)?; + let cc = + self.get_crosslink_committee_for_shard(attestation_data.shard, target_relative_epoch)?; + Ok(cc.slot) } @@ -361,25 +361,14 @@ impl BeaconState { &self, shard: u64, relative_epoch: RelativeEpoch, - ) -> Result, Error> { + ) -> Result { let cache = self.cache(relative_epoch)?; - Ok(cache.get_crosslink_committee_for_shard(shard)) - } + let committee = cache + .get_crosslink_committee_for_shard(shard) + .ok_or_else(|| Error::NoCommitteeForShard)?; - /// Return the crosslink committeee for `shard` in `epoch`. - /// - /// Note: Utilizes the cache and will fail if the appropriate cache is not initialized. - /// - /// Spec v0.6.1 - pub fn get_crosslink_committee( - &self, - epoch: Epoch, - shard: u64, - spec: &ChainSpec, - ) -> Result<&CrosslinkCommittee, Error> { - drop((epoch, shard, spec)); - unimplemented!() + Ok(committee) } /// Returns the beacon proposer index for the `slot` in the given `relative_epoch`.