diff --git a/consensus/state_processing/src/per_epoch_processing/altair/participation_cache.rs b/consensus/state_processing/src/per_epoch_processing/altair/participation_cache.rs index fa5379a945..32f16961c1 100644 --- a/consensus/state_processing/src/per_epoch_processing/altair/participation_cache.rs +++ b/consensus/state_processing/src/per_epoch_processing/altair/participation_cache.rs @@ -32,6 +32,7 @@ pub enum Error { BeaconState(BeaconStateError), Arith(ArithError), InvalidValidatorIndex(usize), + InconsistentTotalActiveBalance { cached: u64, computed: u64 }, } impl From for Error { @@ -103,21 +104,18 @@ impl SingleEpochParticipationCache { .ok_or(Error::InvalidFlagIndex(flag_index)) } - /// Process an **active** validator, reading from the `state` with respect to the + /// Process an **active** validator, reading from the `epoch_participation` with respect to the /// `relative_epoch`. /// /// ## Errors /// - /// - The provided `state` **must** be Altair. An error will be returned otherwise. /// - An error will be returned if the `val_index` validator is inactive at the given /// `relative_epoch`. - fn process_active_validator( + fn process_active_validator( &mut self, val_index: usize, validator: &Validator, epoch_participation: &ParticipationFlags, - // FIXME(sproul): remove state argument - _state: &BeaconState, current_epoch: Epoch, relative_epoch: RelativeEpoch, ) -> Result<(), BeaconStateError> { @@ -269,7 +267,6 @@ impl ParticipationCache { val_index, val, curr_epoch_flags, - state, current_epoch, RelativeEpoch::Current, )?; @@ -282,7 +279,6 @@ impl ParticipationCache { val_index, val, prev_epoch_flags, - state, current_epoch, RelativeEpoch::Previous, )?; @@ -341,11 +337,14 @@ impl ParticipationCache { } // Sanity check total active balance. - // FIXME(sproul): assert - assert_eq!( - current_epoch_participation.total_active_balance.get(), - current_epoch_total_active_balance - ); + if current_epoch_participation.total_active_balance.get() + != current_epoch_total_active_balance + { + return Err(Error::InconsistentTotalActiveBalance { + cached: current_epoch_total_active_balance, + computed: current_epoch_participation.total_active_balance.get(), + }); + } Ok(Self { current_epoch, diff --git a/consensus/types/src/beacon_state/diff.rs b/consensus/types/src/beacon_state/diff.rs index b43cd78197..8bb88dfb9a 100644 --- a/consensus/types/src/beacon_state/diff.rs +++ b/consensus/types/src/beacon_state/diff.rs @@ -56,7 +56,6 @@ pub struct BeaconStateDiff { slashings: VectorDiff, // Attestations (genesis fork only) - // FIXME(sproul): do some clever diffing of prev against former current previous_epoch_attestations: Maybe, T::MaxPendingAttestations>>, current_epoch_attestations: