mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-15 10:52:43 +00:00
Tree states optimization using EpochCache (#4429)
* Relocate epoch cache to BeaconState * Optimize per block processing by pulling previous epoch & current epoch calculation up. * Revert `get_cow` change (no performance improvement) * Initialize `EpochCache` in epoch processing and load it from state when getting base rewards. * Initialize `EpochCache` at start of block processing if required. * Initialize `EpochCache` in `transition_blocks` if `exclude_cache_builds` is enabled * Fix epoch cache initialization logic * Remove FIXME comment. * Cache previous & current epochs in `consensus_context.rs`. * Move `get_base_rewards` from `ConsensusContext` to `BeaconState`. * Update Milhouse version
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
use super::{process_registry_updates, process_slashings, EpochProcessingSummary, Error};
|
||||
use crate::epoch_cache::initialize_epoch_cache;
|
||||
use crate::per_epoch_processing::{
|
||||
effective_balance_updates::process_effective_balance_updates,
|
||||
historical_roots_update::process_historical_roots_update,
|
||||
@@ -75,6 +76,7 @@ pub fn process_epoch<T: EthSpec>(
|
||||
|
||||
// Rotate the epoch caches to suit the epoch transition.
|
||||
state.advance_caches(spec)?;
|
||||
initialize_epoch_cache(state, state.next_epoch()?, spec)?;
|
||||
|
||||
Ok(EpochProcessingSummary::Altair {
|
||||
participation_cache,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use super::{process_registry_updates, process_slashings, EpochProcessingSummary, Error};
|
||||
use crate::epoch_cache::initialize_epoch_cache;
|
||||
use crate::per_epoch_processing::{
|
||||
effective_balance_updates::process_effective_balance_updates,
|
||||
historical_roots_update::process_historical_roots_update,
|
||||
@@ -69,6 +70,7 @@ pub fn process_epoch<T: EthSpec>(
|
||||
|
||||
// Rotate the epoch caches to suit the epoch transition.
|
||||
state.advance_caches(spec)?;
|
||||
initialize_epoch_cache(state, state.next_epoch()?, spec)?;
|
||||
|
||||
Ok(EpochProcessingSummary::Base {
|
||||
total_balances: validator_statuses.total_balances,
|
||||
|
||||
@@ -11,6 +11,7 @@ use crate::per_epoch_processing::{
|
||||
};
|
||||
use types::{BeaconState, ChainSpec, EthSpec, RelativeEpoch};
|
||||
|
||||
use crate::epoch_cache::initialize_epoch_cache;
|
||||
pub use historical_summaries_update::process_historical_summaries_update;
|
||||
|
||||
mod historical_summaries_update;
|
||||
@@ -71,6 +72,7 @@ pub fn process_epoch<T: EthSpec>(
|
||||
|
||||
// Rotate the epoch caches to suit the epoch transition.
|
||||
state.advance_caches(spec)?;
|
||||
initialize_epoch_cache(state, state.next_epoch()?, spec)?;
|
||||
|
||||
Ok(EpochProcessingSummary::Altair {
|
||||
participation_cache,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::per_epoch_processing::altair::participation_cache::Error as ParticipationCacheError;
|
||||
use types::{milhouse, BeaconStateError, InconsistentFork};
|
||||
use types::{milhouse, BeaconStateError, EpochCacheError, InconsistentFork};
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum EpochProcessingError {
|
||||
@@ -26,6 +26,7 @@ pub enum EpochProcessingError {
|
||||
InvalidFlagIndex(usize),
|
||||
ParticipationCache(ParticipationCacheError),
|
||||
MilhouseError(milhouse::Error),
|
||||
EpochCache(EpochCacheError),
|
||||
}
|
||||
|
||||
impl From<InclusionError> for EpochProcessingError {
|
||||
@@ -64,6 +65,12 @@ impl From<milhouse::Error> for EpochProcessingError {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<EpochCacheError> for EpochProcessingError {
|
||||
fn from(e: EpochCacheError) -> Self {
|
||||
EpochProcessingError::EpochCache(e)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum InclusionError {
|
||||
/// The validator did not participate in an attestation in this period.
|
||||
|
||||
Reference in New Issue
Block a user