From bde9e99d8d21ecbfea0c6f20e70d7201de282c08 Mon Sep 17 00:00:00 2001 From: hangleang Date: Sat, 21 Dec 2024 22:36:27 +0700 Subject: [PATCH] Update initial earliest_exit_epoch calculation format code resolved conflict --- helper_functions/src/fork.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/helper_functions/src/fork.rs b/helper_functions/src/fork.rs index 8c85bcd6..ccd8b509 100644 --- a/helper_functions/src/fork.rs +++ b/helper_functions/src/fork.rs @@ -546,19 +546,17 @@ pub fn upgrade_to_electra( epoch, }; - let mut earliest_exit_epoch = misc::compute_activation_exit_epoch::

(epoch); + // initial value of `earliest_exit_epoch` + let earliest_activation_epoch = misc::compute_activation_exit_epoch::

(epoch); - for exit_epoch in validators + let earliest_exit_epoch = validators .into_iter() .map(|validator| validator.exit_epoch) .filter(|exit_epoch| *exit_epoch != FAR_FUTURE_EPOCH) - { - if exit_epoch > earliest_exit_epoch { - earliest_exit_epoch = exit_epoch; - } - } - - earliest_exit_epoch += 1; + .fold(earliest_activation_epoch, |earliest, exit_epoch| { + earliest.max(exit_epoch) + }) + + 1; let mut post = ElectraBeaconState { // > Versioning @@ -607,7 +605,7 @@ pub fn upgrade_to_electra( exit_balance_to_consume: 0, earliest_exit_epoch, consolidation_balance_to_consume: 0, - earliest_consolidation_epoch: misc::compute_activation_exit_epoch::

(epoch), + earliest_consolidation_epoch: earliest_activation_epoch, pending_deposits: PersistentList::default(), pending_partial_withdrawals: PersistentList::default(), pending_consolidations: PersistentList::default(),