mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-17 03:42:46 +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:
@@ -2,8 +2,8 @@ use crate::common::{get_attestation_participation_flag_indices, get_attesting_in
|
||||
use std::mem;
|
||||
use std::sync::Arc;
|
||||
use types::{
|
||||
BeaconState, BeaconStateAltair, BeaconStateError as Error, ChainSpec, EthSpec, Fork,
|
||||
ParticipationFlags, PendingAttestation, RelativeEpoch, SyncCommittee, VList,
|
||||
BeaconState, BeaconStateAltair, BeaconStateError as Error, ChainSpec, EpochCache, EthSpec,
|
||||
Fork, ParticipationFlags, PendingAttestation, RelativeEpoch, SyncCommittee, VList,
|
||||
};
|
||||
|
||||
/// Translate the participation information from the epoch prior to the fork into Altair's format.
|
||||
@@ -104,6 +104,7 @@ pub fn upgrade_to_altair<E: EthSpec>(
|
||||
committee_caches: mem::take(&mut pre.committee_caches),
|
||||
pubkey_cache: mem::take(&mut pre.pubkey_cache),
|
||||
exit_cache: mem::take(&mut pre.exit_cache),
|
||||
epoch_cache: EpochCache::default(),
|
||||
});
|
||||
|
||||
// Fill in previous epoch participation from the pre state's pending attestations.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use std::mem;
|
||||
use types::{
|
||||
BeaconState, BeaconStateCapella, BeaconStateError as Error, ChainSpec, EthSpec, Fork, VList,
|
||||
BeaconState, BeaconStateCapella, BeaconStateError as Error, ChainSpec, EpochCache, EthSpec,
|
||||
Fork, VList,
|
||||
};
|
||||
|
||||
/// Transform a `Merge` state into an `Capella` state.
|
||||
@@ -66,6 +67,7 @@ pub fn upgrade_to_capella<E: EthSpec>(
|
||||
committee_caches: mem::take(&mut pre.committee_caches),
|
||||
pubkey_cache: mem::take(&mut pre.pubkey_cache),
|
||||
exit_cache: mem::take(&mut pre.exit_cache),
|
||||
epoch_cache: EpochCache::default(),
|
||||
});
|
||||
|
||||
*pre_state = post;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::mem;
|
||||
use types::{
|
||||
BeaconState, BeaconStateError as Error, BeaconStateMerge, ChainSpec, EthSpec,
|
||||
BeaconState, BeaconStateError as Error, BeaconStateMerge, ChainSpec, EpochCache, EthSpec,
|
||||
ExecutionPayloadHeaderMerge, Fork,
|
||||
};
|
||||
|
||||
@@ -63,6 +63,7 @@ pub fn upgrade_to_bellatrix<E: EthSpec>(
|
||||
committee_caches: mem::take(&mut pre.committee_caches),
|
||||
pubkey_cache: mem::take(&mut pre.pubkey_cache),
|
||||
exit_cache: mem::take(&mut pre.exit_cache),
|
||||
epoch_cache: EpochCache::default(),
|
||||
});
|
||||
|
||||
*pre_state = post;
|
||||
|
||||
Reference in New Issue
Block a user