mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-17 21:08:32 +00:00
Merge remote-tracking branch 'origin/unstable' into tree-states
This commit is contained in:
@@ -1888,15 +1888,27 @@ impl<T: EthSpec> BeaconState<T> {
|
||||
|
||||
/// Passing `previous_epoch` to this function rather than computing it internally provides
|
||||
/// a tangible speed improvement in state processing.
|
||||
pub fn is_eligible_validator(&self, previous_epoch: Epoch, val: &Validator) -> bool {
|
||||
val.is_active_at(previous_epoch)
|
||||
|| (val.slashed() && previous_epoch + Epoch::new(1) < val.withdrawable_epoch())
|
||||
pub fn is_eligible_validator(
|
||||
&self,
|
||||
previous_epoch: Epoch,
|
||||
val: &Validator,
|
||||
) -> Result<bool, Error> {
|
||||
Ok(val.is_active_at(previous_epoch)
|
||||
|| (val.slashed()
|
||||
&& previous_epoch.safe_add(Epoch::new(1))? < val.withdrawable_epoch()))
|
||||
}
|
||||
|
||||
/// Passing `previous_epoch` to this function rather than computing it internally provides
|
||||
/// a tangible speed improvement in state processing.
|
||||
pub fn is_in_inactivity_leak(&self, previous_epoch: Epoch, spec: &ChainSpec) -> bool {
|
||||
(previous_epoch - self.finalized_checkpoint().epoch) > spec.min_epochs_to_inactivity_penalty
|
||||
pub fn is_in_inactivity_leak(
|
||||
&self,
|
||||
previous_epoch: Epoch,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<bool, safe_arith::ArithError> {
|
||||
Ok(
|
||||
(previous_epoch.safe_sub(self.finalized_checkpoint().epoch)?)
|
||||
> spec.min_epochs_to_inactivity_penalty,
|
||||
)
|
||||
}
|
||||
|
||||
/// Get the `SyncCommittee` associated with the next slot. Useful because sync committees
|
||||
@@ -1926,7 +1938,7 @@ impl<T: EthSpec> BeaconState<T> {
|
||||
}
|
||||
|
||||
// FIXME(sproul): missing eth1 data votes, they would need a ResetListDiff
|
||||
#[allow(clippy::integer_arithmetic)]
|
||||
#[allow(clippy::arithmetic_side_effects)]
|
||||
pub fn rebase_on(&mut self, base: &Self, spec: &ChainSpec) -> Result<(), Error> {
|
||||
// Required for macros (which use type-hints internally).
|
||||
type GenericValidator = Validator;
|
||||
@@ -2031,7 +2043,7 @@ impl<T: EthSpec, GenericValidator: ValidatorTrait> BeaconState<T, GenericValidat
|
||||
pub const NUM_FIELDS_POW2: usize = BeaconStateMerge::<T>::NUM_FIELDS.next_power_of_two();
|
||||
|
||||
/// Specialised deserialisation method that uses the `ChainSpec` as context.
|
||||
#[allow(clippy::integer_arithmetic)]
|
||||
#[allow(clippy::arithmetic_side_effects)]
|
||||
pub fn from_ssz_bytes(bytes: &[u8], spec: &ChainSpec) -> Result<Self, ssz::DecodeError> {
|
||||
// Slot is after genesis_time (u64) and genesis_validators_root (Hash256).
|
||||
let slot_start = <u64 as Decode>::ssz_fixed_len() + <Hash256 as Decode>::ssz_fixed_len();
|
||||
@@ -2054,7 +2066,7 @@ impl<T: EthSpec, GenericValidator: ValidatorTrait> BeaconState<T, GenericValidat
|
||||
))
|
||||
}
|
||||
|
||||
#[allow(clippy::integer_arithmetic)]
|
||||
#[allow(clippy::arithmetic_side_effects)]
|
||||
pub fn apply_pending_mutations(&mut self) -> Result<(), Error> {
|
||||
match self {
|
||||
Self::Base(inner) => {
|
||||
@@ -2104,7 +2116,7 @@ impl<T: EthSpec, GenericValidator: ValidatorTrait> BeaconState<T, GenericValidat
|
||||
|
||||
// 2. Get all `BeaconState` leaves.
|
||||
let mut leaves = vec![];
|
||||
#[allow(clippy::integer_arithmetic)]
|
||||
#[allow(clippy::arithmetic_side_effects)]
|
||||
match self {
|
||||
BeaconState::Base(state) => {
|
||||
map_beacon_state_base_fields!(state, |_, field| {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#![allow(clippy::integer_arithmetic)]
|
||||
#![allow(clippy::arithmetic_side_effects)]
|
||||
|
||||
use super::BeaconState;
|
||||
use crate::*;
|
||||
|
||||
@@ -260,7 +260,7 @@ impl ChainSpec {
|
||||
|
||||
/// Return the name of the fork activated at `slot`, if any.
|
||||
pub fn fork_activated_at_slot<E: EthSpec>(&self, slot: Slot) -> Option<ForkName> {
|
||||
let prev_slot_fork = self.fork_name_at_slot::<E>(slot - 1);
|
||||
let prev_slot_fork = self.fork_name_at_slot::<E>(slot.saturating_sub(Slot::new(1)));
|
||||
let slot_fork = self.fork_name_at_slot::<E>(slot);
|
||||
(slot_fork != prev_slot_fork).then_some(slot_fork)
|
||||
}
|
||||
@@ -468,7 +468,7 @@ impl ChainSpec {
|
||||
epoch.safe_add(1)?.safe_add(self.max_seed_lookahead)
|
||||
}
|
||||
|
||||
#[allow(clippy::integer_arithmetic)]
|
||||
#[allow(clippy::arithmetic_side_effects)]
|
||||
pub const fn attestation_subnet_prefix_bits(&self) -> u32 {
|
||||
let attestation_subnet_count_bits = self.attestation_subnet_count.ilog2();
|
||||
self.attestation_subnet_extra_bits as u32 + attestation_subnet_count_bits
|
||||
|
||||
@@ -109,7 +109,7 @@ impl<T: EthSpec> ExecutionPayload<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::integer_arithmetic)]
|
||||
#[allow(clippy::arithmetic_side_effects)]
|
||||
/// Returns the maximum size of an execution payload.
|
||||
pub fn max_execution_payload_merge_size() -> usize {
|
||||
// Fixed part
|
||||
@@ -120,7 +120,7 @@ impl<T: EthSpec> ExecutionPayload<T> {
|
||||
+ (T::max_transactions_per_payload() * (ssz::BYTES_PER_LENGTH_OFFSET + T::max_bytes_per_transaction()))
|
||||
}
|
||||
|
||||
#[allow(clippy::integer_arithmetic)]
|
||||
#[allow(clippy::arithmetic_side_effects)]
|
||||
/// Returns the maximum size of an execution payload.
|
||||
pub fn max_execution_payload_capella_size() -> usize {
|
||||
// Fixed part
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#![cfg_attr(
|
||||
not(test),
|
||||
deny(
|
||||
clippy::integer_arithmetic,
|
||||
clippy::arithmetic_side_effects,
|
||||
clippy::disallowed_methods,
|
||||
clippy::indexing_slicing
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#![allow(clippy::integer_arithmetic)]
|
||||
#![allow(clippy::arithmetic_side_effects)]
|
||||
|
||||
use crate::{Hash256, ParticipationFlags, Unsigned, VariableList};
|
||||
use cached_tree_hash::{int_log, CacheArena, CachedTreeHash, Error, TreeHashCache};
|
||||
|
||||
@@ -72,7 +72,7 @@ impl SubnetId {
|
||||
.into())
|
||||
}
|
||||
|
||||
#[allow(clippy::integer_arithmetic)]
|
||||
#[allow(clippy::arithmetic_side_effects)]
|
||||
/// Computes the set of subnets the node should be subscribed to during the current epoch,
|
||||
/// along with the first epoch in which these subscriptions are no longer valid.
|
||||
pub fn compute_subnets_for_epoch<T: EthSpec>(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#![allow(clippy::integer_arithmetic)]
|
||||
#![allow(clippy::arithmetic_side_effects)]
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ pub trait TestRandom {
|
||||
|
||||
impl<T> TestRandom for PhantomData<T> {
|
||||
fn random_for_test(_rng: &mut impl RngCore) -> Self {
|
||||
PhantomData::default()
|
||||
PhantomData
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user