From b2b728dc3d8ab7cf743e1a31d03228828a375f80 Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Tue, 29 Oct 2024 13:41:14 -0700 Subject: [PATCH] Update initialize_beacon_state_from_eth1 --- consensus/state_processing/src/genesis.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/consensus/state_processing/src/genesis.rs b/consensus/state_processing/src/genesis.rs index 4450b99930..00f055e8c3 100644 --- a/consensus/state_processing/src/genesis.rs +++ b/consensus/state_processing/src/genesis.rs @@ -120,12 +120,22 @@ pub fn initialize_beacon_state_from_eth1( let post = upgrade_state_to_electra(&mut state, Epoch::new(0), Epoch::new(0), spec)?; state = post; - // TODO(electra): do we need to iterate over an empty pending_deposits list here and increase balance? - // in accordance with `initialize_beacon_state_from_eth1` function from the spec - // Remove intermediate Deneb fork from `state.fork`. state.fork_mut().previous_version = spec.electra_fork_version; + // iterate over an empty pending_deposits list here and increase balance + let pending_deposits = state.pending_deposits()?.clone(); + for pending_deposit in pending_deposits.into_iter() { + if let Some(validator_index) = state.pubkey_cache().get(&pending_deposit.pubkey) { + state + .balances_mut() + .get_mut(validator_index) + .ok_or(Error::UnknownValidator(validator_index))? + .safe_add(pending_deposit.amount)?; + } + } + *state.pending_deposits_mut()? = List::empty(); + // TODO(electra): think about this more and determine the best way to // do this. The spec tests will expect that the sync committees are // calculated using the electra value for MAX_EFFECTIVE_BALANCE when