From 0502f086c2da2ce6f04a57461d1547e93616d488 Mon Sep 17 00:00:00 2001 From: EchoAlice Date: Mon, 6 May 2024 09:52:33 -0600 Subject: [PATCH] Implement `process_epoch`. Remove unnessesary const generics from `process_pending_consolidations` --- .../src/electra/epoch_processing.rs | 60 ++++++++++++++++++- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/ethereum-consensus/src/electra/epoch_processing.rs b/ethereum-consensus/src/electra/epoch_processing.rs index 01102f396..ffcf7bd1e 100644 --- a/ethereum-consensus/src/electra/epoch_processing.rs +++ b/ethereum-consensus/src/electra/epoch_processing.rs @@ -4,9 +4,63 @@ use crate::electra::{ get_activation_exit_churn_limit, get_active_balance, initiate_validator_exit, is_eligible_for_activation_queue, switch_to_compounding_validator, }, - increase_balance, is_active_validator, is_eligible_for_activation, BeaconState, Context, Error, + increase_balance, is_active_validator, is_eligible_for_activation, + process_effective_balance_updates, process_eth1_data_reset, + process_historical_summaries_update, process_inactivity_updates, + process_justification_and_finalization, process_participation_flag_updates, + process_randao_mixes_reset, process_rewards_and_penalties, process_slashings, + process_slashings_reset, process_sync_committee_updates, BeaconState, Context, Error, }; +pub fn process_epoch< + const SLOTS_PER_HISTORICAL_ROOT: usize, + const HISTORICAL_ROOTS_LIMIT: usize, + const ETH1_DATA_VOTES_BOUND: usize, + const VALIDATOR_REGISTRY_LIMIT: usize, + const EPOCHS_PER_HISTORICAL_VECTOR: usize, + const EPOCHS_PER_SLASHINGS_VECTOR: usize, + const MAX_VALIDATORS_PER_COMMITTEE: usize, + const SYNC_COMMITTEE_SIZE: usize, + const BYTES_PER_LOGS_BLOOM: usize, + const MAX_EXTRA_DATA_BYTES: usize, + const PENDING_BALANCE_DEPOSITS_LIMIT: usize, + const PENDING_PARTIAL_WITHDRAWALS_LIMIT: usize, + const PENDING_CONSOLIDATIONS_LIMIT: usize, +>( + state: &mut BeaconState< + SLOTS_PER_HISTORICAL_ROOT, + HISTORICAL_ROOTS_LIMIT, + ETH1_DATA_VOTES_BOUND, + VALIDATOR_REGISTRY_LIMIT, + EPOCHS_PER_HISTORICAL_VECTOR, + EPOCHS_PER_SLASHINGS_VECTOR, + MAX_VALIDATORS_PER_COMMITTEE, + SYNC_COMMITTEE_SIZE, + BYTES_PER_LOGS_BLOOM, + MAX_EXTRA_DATA_BYTES, + PENDING_BALANCE_DEPOSITS_LIMIT, + PENDING_PARTIAL_WITHDRAWALS_LIMIT, + PENDING_CONSOLIDATIONS_LIMIT, + >, + context: &Context, +) -> Result<(), Error> { + process_justification_and_finalization(state, context)?; + process_inactivity_updates(state, context)?; + process_rewards_and_penalties(state, context)?; + process_registry_updates(state, context)?; + process_slashings(state, context)?; + process_eth1_data_reset(state, context); + process_pending_balance_deposits(state, context)?; + process_pending_consolidations(state, context)?; + process_effective_balance_updates(state, context); + process_slashings_reset(state, context); + process_randao_mixes_reset(state, context); + process_historical_summaries_update(state, context)?; + process_participation_flag_updates(state)?; + process_sync_committee_updates(state, context)?; + Ok(()) +} + pub fn process_registry_updates< const SLOTS_PER_HISTORICAL_ROOT: usize, const HISTORICAL_ROOTS_LIMIT: usize, @@ -138,8 +192,8 @@ pub fn process_pending_consolidations< const PENDING_BALANCE_DEPOSITS_LIMIT: usize, const PENDING_PARTIAL_WITHDRAWALS_LIMIT: usize, const PENDING_CONSOLIDATIONS_LIMIT: usize, - const MAX_VALIDATORS_PER_SLOT: usize, - const MAX_COMMITTEES_PER_SLOT: usize, + // const MAX_VALIDATORS_PER_SLOT: usize, + // const MAX_COMMITTEES_PER_SLOT: usize, >( state: &mut BeaconState< SLOTS_PER_HISTORICAL_ROOT,