Update state_processing

This commit is contained in:
Michael Sproul
2021-11-25 17:32:18 +11:00
parent 1b4dad0d76
commit 238ac98d7c
18 changed files with 107 additions and 20 deletions

View File

@@ -1,6 +1,6 @@
use crate::per_epoch_processing::Error;
use safe_arith::{SafeArith, SafeArithIter};
use types::{BeaconState, BeaconStateError, ChainSpec, EthSpec, Unsigned};
use types::{BeaconState, BeaconStateError, ChainSpec, EthSpec, GetValidatorMut, Unsigned};
/// Process slashings.
pub fn process_slashings<T: EthSpec>(
@@ -16,7 +16,8 @@ pub fn process_slashings<T: EthSpec>(
std::cmp::min(sum_slashings.safe_mul(slashing_multiplier)?, total_balance);
let (validators, balances) = state.validators_and_balances_mut();
for (index, validator) in validators.iter().enumerate() {
for index in 0..validators.len() {
let validator = validators.get_validator(index)?;
if validator.slashed
&& epoch.safe_add(T::EpochsPerSlashingsVector::to_u64().safe_div(2)?)?
== validator.withdrawable_epoch