get_active_validator_indices() now has bound check (#1300)

This commit is contained in:
ethDreamer
2020-06-29 04:21:51 -04:00
committed by GitHub
parent 163fda2c26
commit 721323f045
4 changed files with 29 additions and 14 deletions

View File

@@ -52,9 +52,12 @@ pub fn initialize_beacon_state_from_eth1<T: EthSpec>(
///
/// Spec v0.12.1
pub fn is_valid_genesis_state<T: EthSpec>(state: &BeaconState<T>, spec: &ChainSpec) -> bool {
state.genesis_time >= spec.min_genesis_time
&& state.get_active_validator_indices(T::genesis_epoch()).len() as u64
>= spec.min_genesis_active_validator_count
state
.get_active_validator_indices(T::genesis_epoch(), spec)
.map_or(false, |active_validators| {
state.genesis_time >= spec.min_genesis_time
&& active_validators.len() as u64 >= spec.min_genesis_active_validator_count
})
}
/// Activate genesis validators, if their balance is acceptable.