mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 18:32:42 +00:00
drop initiate validator ordering optimization
This commit is contained in:
@@ -8,12 +8,12 @@ pub fn initiate_validator_exit<E: EthSpec>(
|
||||
index: usize,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), Error> {
|
||||
// We do things in a slightly different order to the spec here. Instead of immediately checking
|
||||
// whether the validator has already exited, we instead prepare the exit cache and compute the
|
||||
// cheap-to-calculate values from that. *Then* we look up the validator a single time in the
|
||||
// validator tree (expensive), make the check and mutate as appropriate. Compared to the spec
|
||||
// ordering, this saves us from looking up the validator in the validator registry multiple
|
||||
// times.
|
||||
let validator = state.get_validator_cow(index)?;
|
||||
|
||||
// Return if the validator already initiated exit
|
||||
if validator.exit_epoch != spec.far_future_epoch {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// Ensure the exit cache is built.
|
||||
state.build_exit_cache(spec)?;
|
||||
@@ -36,14 +36,7 @@ pub fn initiate_validator_exit<E: EthSpec>(
|
||||
exit_queue_epoch
|
||||
};
|
||||
|
||||
let validator = state.get_validator_cow(index)?;
|
||||
|
||||
// Return if the validator already initiated exit
|
||||
if validator.exit_epoch != spec.far_future_epoch {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let validator = validator.into_mut()?;
|
||||
let validator = state.get_validator_mut(index)?;
|
||||
validator.exit_epoch = exit_queue_epoch;
|
||||
validator.withdrawable_epoch =
|
||||
exit_queue_epoch.safe_add(spec.min_validator_withdrawability_delay)?;
|
||||
|
||||
Reference in New Issue
Block a user