Merge remote-tracking branch 'sigp/epoch-single-pass' into tree-states

This commit is contained in:
dapplion
2024-02-23 11:36:02 +08:00
parent 20f53e7769
commit a5d3408c59
21 changed files with 127 additions and 112 deletions

View File

@@ -115,7 +115,6 @@ pub enum Error {
SszTypesError(ssz_types::Error),
TreeHashCacheNotInitialized,
NonLinearTreeHashCacheHistory,
ParticipationCacheError(String),
ProgressiveBalancesCacheNotInitialized,
ProgressiveBalancesCacheInconsistent,
TreeHashCacheSkippedSlot {
@@ -1593,7 +1592,7 @@ impl<T: EthSpec> BeaconState<T> {
))
}
pub fn compute_total_active_balance(
pub fn compute_total_active_balance_slow(
&self,
epoch: Epoch,
spec: &ChainSpec,
@@ -1661,7 +1660,7 @@ impl<T: EthSpec> BeaconState<T> {
epoch: Epoch,
spec: &ChainSpec,
) -> Result<(), Error> {
let total_active_balance = self.compute_total_active_balance(epoch, spec)?;
let total_active_balance = self.compute_total_active_balance_slow(epoch, spec)?;
*self.total_active_balance_mut() = Some((epoch, total_active_balance));
Ok(())
}

View File

@@ -283,7 +283,7 @@ impl ProgressiveBalancesCache {
}
}
/// `ProgressiveBalancesCache` is only enabled from `Altair` as it requires `ParticipationCache`.
/// `ProgressiveBalancesCache` is only enabled from `Altair` as it uses Altair-specific logic.
pub fn is_progressive_balances_enabled<E: EthSpec>(state: &BeaconState<E>) -> bool {
match state {
BeaconState::Base(_) => false,

View File

@@ -3,6 +3,7 @@ use rpds::HashTrieMapSync as HashTrieMap;
type ValidatorIndex = usize;
#[allow(clippy::len_without_is_empty)]
#[derive(Debug, PartialEq, Clone, Default)]
pub struct PubkeyCache {
/// Maintain the number of keys added to the map. It is not sufficient to just use the

View File

@@ -326,12 +326,6 @@ impl ChainSpec {
}
}
/// For a given `BeaconState`, return the inactivity penalty quotient associated with its variant.
// FIXME(sproul): delete once unused
pub fn inactivity_penalty_quotient_for_state<T: EthSpec>(&self, state: &BeaconState<T>) -> u64 {
self.inactivity_penalty_quotient_for_fork(state.fork_name_unchecked())
}
pub fn inactivity_penalty_quotient_for_fork(&self, fork_name: ForkName) -> u64 {
match fork_name {
ForkName::Base => self.inactivity_penalty_quotient,