mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-17 21:08:32 +00:00
Add even more
This commit is contained in:
@@ -235,6 +235,10 @@ impl<'a, E: EthSpec, Payload: AbstractExecPayload<E>> BeaconBlockRef<'a, E, Payl
|
||||
}
|
||||
}
|
||||
|
||||
pub fn has_feature(self, feature: FeatureName) -> bool {
|
||||
self.fork_name_unchecked().has_feature(feature)
|
||||
}
|
||||
|
||||
/// Convenience accessor for the `body` as a `BeaconBlockBodyRef`.
|
||||
pub fn body(&self) -> BeaconBlockBodyRef<'a, E, Payload> {
|
||||
map_beacon_block_ref_into_beacon_block_body_ref!(&'a _, *self, |block, cons| cons(
|
||||
|
||||
@@ -263,6 +263,10 @@ impl<'a, E: EthSpec, Payload: AbstractExecPayload<E>> BeaconBlockBodyRef<'a, E,
|
||||
self.blob_kzg_commitments()
|
||||
.map_or(false, |blobs| !blobs.is_empty())
|
||||
}
|
||||
|
||||
pub fn has_feature(self, feature: FeatureName) -> bool {
|
||||
self.fork_name().has_feature(feature)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, E: EthSpec, Payload: AbstractExecPayload<E>> BeaconBlockBodyRef<'a, E, Payload> {
|
||||
|
||||
@@ -1579,16 +1579,14 @@ impl<E: EthSpec> BeaconState<E> {
|
||||
///
|
||||
/// Uses the current epoch committee cache, and will error if it isn't initialized.
|
||||
pub fn get_activation_churn_limit(&self, spec: &ChainSpec) -> Result<u64, Error> {
|
||||
Ok(match self {
|
||||
BeaconState::Base(_)
|
||||
| BeaconState::Altair(_)
|
||||
| BeaconState::Bellatrix(_)
|
||||
| BeaconState::Capella(_) => self.get_validator_churn_limit(spec)?,
|
||||
BeaconState::Deneb(_) | BeaconState::Electra(_) => std::cmp::min(
|
||||
if self.has_feature(FeatureName::Deneb) {
|
||||
Ok(std::cmp::min(
|
||||
spec.max_per_epoch_activation_churn_limit,
|
||||
self.get_validator_churn_limit(spec)?,
|
||||
),
|
||||
})
|
||||
))
|
||||
} else {
|
||||
Ok(self.get_validator_churn_limit(spec)?)
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns the `slot`, `index`, `committee_position` and `committee_len` for which a validator must produce an
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::{
|
||||
NUM_FLAG_INDICES, TIMELY_HEAD_FLAG_INDEX, TIMELY_SOURCE_FLAG_INDEX,
|
||||
TIMELY_TARGET_FLAG_INDEX,
|
||||
},
|
||||
BeaconState, BeaconStateError, ChainSpec, Epoch, EthSpec, ParticipationFlags,
|
||||
BeaconStateError, ChainSpec, Epoch, ParticipationFlags,
|
||||
};
|
||||
use arbitrary::Arbitrary;
|
||||
use safe_arith::SafeArith;
|
||||
@@ -282,15 +282,3 @@ impl ProgressiveBalancesCache {
|
||||
.ok_or(BeaconStateError::ProgressiveBalancesCacheNotInitialized)
|
||||
}
|
||||
}
|
||||
|
||||
/// `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,
|
||||
BeaconState::Altair(_)
|
||||
| BeaconState::Bellatrix(_)
|
||||
| BeaconState::Capella(_)
|
||||
| BeaconState::Deneb(_)
|
||||
| BeaconState::Electra(_) => true,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user