Resolve some FIXMEs

This commit is contained in:
Michael Sproul
2022-12-08 16:06:07 +11:00
parent 57f1c03457
commit f113fbb8b5
2 changed files with 11 additions and 13 deletions

View File

@@ -32,6 +32,7 @@ pub enum Error {
BeaconState(BeaconStateError), BeaconState(BeaconStateError),
Arith(ArithError), Arith(ArithError),
InvalidValidatorIndex(usize), InvalidValidatorIndex(usize),
InconsistentTotalActiveBalance { cached: u64, computed: u64 },
} }
impl From<BeaconStateError> for Error { impl From<BeaconStateError> for Error {
@@ -103,21 +104,18 @@ impl SingleEpochParticipationCache {
.ok_or(Error::InvalidFlagIndex(flag_index)) .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`. /// `relative_epoch`.
/// ///
/// ## Errors /// ## 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 /// - An error will be returned if the `val_index` validator is inactive at the given
/// `relative_epoch`. /// `relative_epoch`.
fn process_active_validator<T: EthSpec>( fn process_active_validator(
&mut self, &mut self,
val_index: usize, val_index: usize,
validator: &Validator, validator: &Validator,
epoch_participation: &ParticipationFlags, epoch_participation: &ParticipationFlags,
// FIXME(sproul): remove state argument
_state: &BeaconState<T>,
current_epoch: Epoch, current_epoch: Epoch,
relative_epoch: RelativeEpoch, relative_epoch: RelativeEpoch,
) -> Result<(), BeaconStateError> { ) -> Result<(), BeaconStateError> {
@@ -269,7 +267,6 @@ impl ParticipationCache {
val_index, val_index,
val, val,
curr_epoch_flags, curr_epoch_flags,
state,
current_epoch, current_epoch,
RelativeEpoch::Current, RelativeEpoch::Current,
)?; )?;
@@ -282,7 +279,6 @@ impl ParticipationCache {
val_index, val_index,
val, val,
prev_epoch_flags, prev_epoch_flags,
state,
current_epoch, current_epoch,
RelativeEpoch::Previous, RelativeEpoch::Previous,
)?; )?;
@@ -341,11 +337,14 @@ impl ParticipationCache {
} }
// Sanity check total active balance. // Sanity check total active balance.
// FIXME(sproul): assert if current_epoch_participation.total_active_balance.get()
assert_eq!( != current_epoch_total_active_balance
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 { Ok(Self {
current_epoch, current_epoch,

View File

@@ -56,7 +56,6 @@ pub struct BeaconStateDiff<T: EthSpec> {
slashings: VectorDiff<u64, T::EpochsPerSlashingsVector>, slashings: VectorDiff<u64, T::EpochsPerSlashingsVector>,
// Attestations (genesis fork only) // Attestations (genesis fork only)
// FIXME(sproul): do some clever diffing of prev against former current
previous_epoch_attestations: previous_epoch_attestations:
Maybe<ResetListDiff<PendingAttestation<T>, T::MaxPendingAttestations>>, Maybe<ResetListDiff<PendingAttestation<T>, T::MaxPendingAttestations>>,
current_epoch_attestations: current_epoch_attestations: