mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-15 10:52:43 +00:00
Implement activation queue cache
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
use crate::{common::initiate_validator_exit, per_epoch_processing::Error};
|
||||
use itertools::Itertools;
|
||||
use safe_arith::SafeArith;
|
||||
use types::{BeaconState, ChainSpec, EthSpec, Validator};
|
||||
|
||||
@@ -40,19 +39,16 @@ pub fn process_registry_updates<T: EthSpec>(
|
||||
}
|
||||
|
||||
// Queue validators eligible for activation and not dequeued for activation prior to finalized epoch
|
||||
let activation_queue = state
|
||||
.validators()
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_, validator)| validator.is_eligible_for_activation(state, spec))
|
||||
.sorted_by_key(|(index, validator)| (validator.activation_eligibility_epoch(), *index))
|
||||
.map(|(index, _)| index)
|
||||
.collect_vec();
|
||||
|
||||
// Dequeue validators for activation up to churn limit
|
||||
let churn_limit = state.get_churn_limit(spec)? as usize;
|
||||
|
||||
let epoch_cache = state.epoch_cache().clone();
|
||||
let activation_queue = epoch_cache
|
||||
.activation_queue()?
|
||||
.get_validators_eligible_for_activation(state.finalized_checkpoint().epoch, churn_limit);
|
||||
|
||||
let delayed_activation_epoch = state.compute_activation_exit_epoch(current_epoch, spec)?;
|
||||
for index in activation_queue.into_iter().take(churn_limit) {
|
||||
for index in activation_queue {
|
||||
state.get_validator_mut(index)?.mutable.activation_epoch = delayed_activation_epoch;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user