mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 02:12:33 +00:00
* Consensus changes
* EF tests
* lcli
* common and watch
* account manager
* cargo
* fork choice
* promise cache
* beacon chain
* interop genesis
* http api
* lighthouse
* op pool
* beacon chain misc
* parallel state cache
* store
* fix issues in store
* IT COMPILES
* Remove some unnecessary module qualification
* Revert Arced pubkey optimization (#5536)
* Merge remote-tracking branch 'origin/unstable' into tree-states-memory
* Fix caching, rebasing and some tests
* Remove unused deps
* Merge remote-tracking branch 'origin/unstable' into tree-states-memory
* Small cleanups
* Revert shuffling cache/promise cache changes
* Fix state advance bugs
* Fix shuffling tests
* Remove some resolved FIXMEs
* Remove StateProcessingStrategy
* Optimise withdrawals calculation
* Don't reorg if state cache is missed
* Remove inconsistent state func
* Fix beta compiler
* Rebase early, rebase often
* Fix state caching behaviour
* Update to milhouse release
* Fix on-disk consensus context format
* Merge remote-tracking branch 'origin/unstable' into tree-states-memory
* Squashed commit of the following:
commit 3a16649023
Author: Michael Sproul <michael@sigmaprime.io>
Date: Thu Apr 18 14:26:09 2024 +1000
Fix on-disk consensus context format
* Keep indexed attestations, thanks Sean
* Merge branch 'on-disk-consensus-context' into tree-states-memory
* Merge branch 'unstable' into tree-states-memory
* Address half of Sean's review
* More simplifications from Sean's review
* Cache state after get_advanced_hot_state
55 lines
2.2 KiB
Rust
55 lines
2.2 KiB
Rust
use crate::common::update_progressive_balances_cache::initialize_progressive_balances_cache;
|
|
use crate::epoch_cache::initialize_epoch_cache;
|
|
use types::{BeaconState, ChainSpec, EpochCacheError, EthSpec, Hash256, RelativeEpoch};
|
|
|
|
/// Mixin trait for the beacon state that provides operations on *all* caches.
|
|
///
|
|
/// The reason this trait exists here away from `BeaconState` itself is that some caches are
|
|
/// computed by functions in `state_processing`.
|
|
pub trait AllCaches {
|
|
/// Build all caches.
|
|
///
|
|
/// Note that this excludes milhouse's intrinsic tree-hash cache. That needs to be managed
|
|
/// separately.
|
|
fn build_all_caches(&mut self, spec: &ChainSpec) -> Result<(), EpochCacheError>;
|
|
|
|
/// Return true if all caches are built.
|
|
///
|
|
/// Note that this excludes milhouse's intrinsic tree-hash cache. That needs to be managed
|
|
/// separately.
|
|
fn all_caches_built(&self) -> bool;
|
|
}
|
|
|
|
impl<E: EthSpec> AllCaches for BeaconState<E> {
|
|
fn build_all_caches(&mut self, spec: &ChainSpec) -> Result<(), EpochCacheError> {
|
|
self.build_caches(spec)?;
|
|
initialize_epoch_cache(self, spec)?;
|
|
initialize_progressive_balances_cache(self, spec)?;
|
|
Ok(())
|
|
}
|
|
|
|
fn all_caches_built(&self) -> bool {
|
|
let current_epoch = self.current_epoch();
|
|
let Ok(epoch_cache_decision_block_root) =
|
|
self.proposer_shuffling_decision_root(Hash256::zero())
|
|
else {
|
|
return false;
|
|
};
|
|
self.get_total_active_balance_at_epoch(current_epoch)
|
|
.is_ok()
|
|
&& self.committee_cache_is_initialized(RelativeEpoch::Previous)
|
|
&& self.committee_cache_is_initialized(RelativeEpoch::Current)
|
|
&& self.committee_cache_is_initialized(RelativeEpoch::Next)
|
|
&& self
|
|
.progressive_balances_cache()
|
|
.is_initialized_at(current_epoch)
|
|
&& self.pubkey_cache().len() == self.validators().len()
|
|
&& self.exit_cache().check_initialized().is_ok()
|
|
&& self.slashings_cache_is_initialized()
|
|
&& self
|
|
.epoch_cache()
|
|
.check_validity(current_epoch, epoch_cache_decision_block_root)
|
|
.is_ok()
|
|
}
|
|
}
|