Fix ups and Clippy

This commit is contained in:
Michael Sproul
2023-01-17 15:57:34 +11:00
parent 2b84597525
commit 5ce14c8dce
22 changed files with 92 additions and 79 deletions

View File

@@ -5,7 +5,6 @@ use crate::validator::ValidatorTrait;
use crate::*;
use compare_fields::CompareFields;
use compare_fields_derive::CompareFields;
use derivative::Derivative;
use ethereum_hashing::hash;
use int_to_bytes::{int_to_bytes4, int_to_bytes8};
use metastruct::{metastruct, NumFields};
@@ -1711,6 +1710,7 @@ impl<T: EthSpec, GenericValidator: ValidatorTrait> BeaconState<T, GenericValidat
))
}
#[allow(clippy::integer_arithmetic)]
pub fn apply_pending_mutations(&mut self) -> Result<(), Error> {
match self {
Self::Base(inner) => {
@@ -1754,6 +1754,7 @@ impl<T: EthSpec, GenericValidator: ValidatorTrait> BeaconState<T, GenericValidat
// 2. Get all `BeaconState` leaves.
let mut leaves = vec![];
#[allow(clippy::integer_arithmetic)]
match self {
BeaconState::Base(state) => {
map_beacon_state_base_fields!(state, |_, field| {

View File

@@ -6,12 +6,9 @@ use beacon_chain::types::{
BeaconStateMerge, ChainSpec, Domain, Epoch, EthSpec, FixedVector, Hash256, Keypair,
MainnetEthSpec, MinimalEthSpec, RelativeEpoch, Slot,
};
use safe_arith::SafeArith;
use ssz::{Decode, Encode};
use state_processing::per_slot_processing;
use ssz::Encode;
use std::ops::Mul;
use swap_or_not_shuffle::compute_shuffled_index;
use tree_hash::TreeHash;
pub const MAX_VALIDATOR_COUNT: usize = 129;
pub const SLOT_OFFSET: Slot = Slot::new(1);

View File

@@ -246,7 +246,7 @@ impl ChainSpec {
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 slot_fork = self.fork_name_at_slot::<E>(slot);
(slot_fork != prev_slot_fork).then(|| slot_fork)
(slot_fork != prev_slot_fork).then_some(slot_fork)
}
/// Returns the fork version for a named fork.

View File

@@ -19,6 +19,7 @@ pub struct LightClientFinalityUpdate<T: EthSpec> {
/// The last `BeaconBlockHeader` from the last attested finalized block (end of epoch).
pub finalized_header: BeaconBlockHeader,
/// Merkle proof attesting finalized header.
#[test_random(default)]
pub finality_branch: FixedVector<Hash256, FinalizedRootProofLen>,
/// current sync aggreggate
pub sync_aggregate: SyncAggregate<T>,

View File

@@ -26,6 +26,7 @@ pub const NEXT_SYNC_COMMITTEE_PROOF_LEN: usize = 5;
#[derive(Debug, PartialEq, Clone)]
pub enum Error {
SszTypesError(ssz_types::Error),
MilhouseError(milhouse::Error),
BeaconStateError(beacon_state::Error),
ArithError(ArithError),
AltairForkNotActive,
@@ -52,6 +53,12 @@ impl From<ArithError> for Error {
}
}
impl From<milhouse::Error> for Error {
fn from(e: milhouse::Error) -> Error {
Error::MilhouseError(e)
}
}
/// A LightClientUpdate is the update we request solely to either complete the bootstraping process,
/// or to sync up to the last committee period, we need to have one ready for each ALTAIR period
/// we go over, note: there is no need to keep all of the updates from [ALTAIR_PERIOD, CURRENT_PERIOD].

View File

@@ -98,11 +98,20 @@ impl Validator {
self.mutable.activation_epoch
}
#[inline]
pub fn activation_epoch_mut(&mut self) -> &mut Epoch {
&mut self.mutable.activation_epoch
}
#[inline]
pub fn exit_epoch(&self) -> Epoch {
self.mutable.exit_epoch
}
pub fn exit_epoch_mut(&mut self) -> &mut Epoch {
&mut self.mutable.exit_epoch
}
#[inline]
pub fn withdrawable_epoch(&self) -> Epoch {
self.mutable.withdrawable_epoch