Implement tree states & hierarchical state DB

This commit is contained in:
Michael Sproul
2023-06-19 10:14:47 +10:00
parent 2bb62b7f7d
commit 23db089a7a
193 changed files with 6093 additions and 5925 deletions

View File

@@ -17,7 +17,7 @@ pub fn process_registry_updates<T: EthSpec>(
let current_epoch = state.current_epoch();
let is_ejectable = |validator: &Validator| {
validator.is_active_at(current_epoch)
&& validator.effective_balance <= spec.ejection_balance
&& validator.effective_balance() <= spec.ejection_balance
};
let indices_to_update: Vec<_> = state
.validators()
@@ -32,7 +32,7 @@ pub fn process_registry_updates<T: EthSpec>(
for index in indices_to_update {
let validator = state.get_validator_mut(index)?;
if validator.is_eligible_for_activation_queue(spec) {
validator.activation_eligibility_epoch = current_epoch.safe_add(1)?;
validator.mutable.activation_eligibility_epoch = current_epoch.safe_add(1)?;
}
if is_ejectable(validator) {
initiate_validator_exit(state, index, spec)?;
@@ -45,7 +45,7 @@ pub fn process_registry_updates<T: EthSpec>(
.iter()
.enumerate()
.filter(|(_, validator)| validator.is_eligible_for_activation(state, spec))
.sorted_by_key(|(index, validator)| (validator.activation_eligibility_epoch, *index))
.sorted_by_key(|(index, validator)| (validator.activation_eligibility_epoch(), *index))
.map(|(index, _)| index)
.collect_vec();
@@ -53,7 +53,7 @@ pub fn process_registry_updates<T: EthSpec>(
let churn_limit = state.get_churn_limit(spec)? as usize;
let delayed_activation_epoch = state.compute_activation_exit_epoch(current_epoch, spec)?;
for index in activation_queue.into_iter().take(churn_limit) {
state.get_validator_mut(index)?.activation_epoch = delayed_activation_epoch;
state.get_validator_mut(index)?.mutable.activation_epoch = delayed_activation_epoch;
}
Ok(())