mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 11:41:51 +00:00
Update Rust Edition to 2024 (#7766)
* #7749 Thanks @dknopik and @michaelsproul for your help!
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use crate::{
|
||||
per_block_processing, per_epoch_processing::EpochProcessingSummary, per_slot_processing,
|
||||
BlockProcessingError, BlockSignatureStrategy, ConsensusContext, SlotProcessingError,
|
||||
VerifyBlockRoot,
|
||||
VerifyBlockRoot, per_block_processing, per_epoch_processing::EpochProcessingSummary,
|
||||
per_slot_processing,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use std::iter::Peekable;
|
||||
@@ -193,12 +193,11 @@ where
|
||||
}
|
||||
|
||||
// Otherwise try to source a root from the previous block.
|
||||
if let Some(prev_i) = i.checked_sub(1) {
|
||||
if let Some(prev_block) = blocks.get(prev_i) {
|
||||
if prev_block.slot() == slot {
|
||||
return Ok(prev_block.state_root());
|
||||
}
|
||||
}
|
||||
if let Some(prev_i) = i.checked_sub(1)
|
||||
&& let Some(prev_block) = blocks.get(prev_i)
|
||||
&& prev_block.slot() == slot
|
||||
{
|
||||
return Ok(prev_block.state_root());
|
||||
}
|
||||
|
||||
self.state_root_miss = true;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
use integer_sqrt::IntegerSquareRoot;
|
||||
use smallvec::SmallVec;
|
||||
use types::{AttestationData, BeaconState, ChainSpec, EthSpec};
|
||||
use types::{
|
||||
BeaconStateError as Error,
|
||||
consts::altair::{
|
||||
NUM_FLAG_INDICES, TIMELY_HEAD_FLAG_INDEX, TIMELY_SOURCE_FLAG_INDEX,
|
||||
TIMELY_TARGET_FLAG_INDEX,
|
||||
},
|
||||
BeaconStateError as Error,
|
||||
};
|
||||
use types::{AttestationData, BeaconState, ChainSpec, EthSpec};
|
||||
|
||||
/// Get the participation flags for a valid attestation.
|
||||
///
|
||||
|
||||
@@ -118,10 +118,10 @@ pub mod attesting_indices_electra {
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter_map(|(i, &index)| {
|
||||
if let Ok(aggregation_bit_index) = committee_offset.safe_add(i) {
|
||||
if aggregation_bits.get(aggregation_bit_index).unwrap_or(false) {
|
||||
return Some(index as u64);
|
||||
}
|
||||
if let Ok(aggregation_bit_index) = committee_offset.safe_add(i)
|
||||
&& aggregation_bits.get(aggregation_bit_index).unwrap_or(false)
|
||||
{
|
||||
return Some(index as u64);
|
||||
}
|
||||
None
|
||||
})
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::common::update_progressive_balances_cache::update_progressive_balances_on_slashing;
|
||||
use crate::{
|
||||
ConsensusContext,
|
||||
common::{decrease_balance, increase_balance, initiate_validator_exit},
|
||||
per_block_processing::errors::BlockProcessingError,
|
||||
ConsensusContext,
|
||||
};
|
||||
use safe_arith::SafeArith;
|
||||
use std::cmp;
|
||||
|
||||
@@ -7,8 +7,8 @@ use crate::{BlockProcessingError, EpochProcessingError};
|
||||
use metrics::set_gauge;
|
||||
use tracing::instrument;
|
||||
use types::{
|
||||
is_progressive_balances_enabled, BeaconState, BeaconStateError, ChainSpec, Epoch,
|
||||
EpochTotalBalances, EthSpec, ParticipationFlags, ProgressiveBalancesCache, Validator,
|
||||
BeaconState, BeaconStateError, ChainSpec, Epoch, EpochTotalBalances, EthSpec,
|
||||
ParticipationFlags, ProgressiveBalancesCache, Validator, is_progressive_balances_enabled,
|
||||
};
|
||||
|
||||
/// Initializes the `ProgressiveBalancesCache` if it is unbuilt.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::EpochCacheError;
|
||||
use crate::common::{attesting_indices_base, attesting_indices_electra};
|
||||
use crate::per_block_processing::errors::{AttestationInvalid, BlockOperationError};
|
||||
use crate::EpochCacheError;
|
||||
use std::collections::{hash_map::Entry, HashMap};
|
||||
use std::collections::{HashMap, hash_map::Entry};
|
||||
use tree_hash::TreeHash;
|
||||
use types::{
|
||||
AbstractExecPayload, AttestationRef, BeaconState, BeaconStateError, ChainSpec, Epoch, EthSpec,
|
||||
|
||||
@@ -37,12 +37,12 @@ pub use genesis::{
|
||||
process_activations,
|
||||
};
|
||||
pub use per_block_processing::{
|
||||
block_signature_verifier, errors::BlockProcessingError, per_block_processing, signature_sets,
|
||||
BlockSignatureStrategy, BlockSignatureVerifier, VerifyBlockRoot, VerifySignatures,
|
||||
block_signature_verifier, errors::BlockProcessingError, per_block_processing, signature_sets,
|
||||
};
|
||||
pub use per_epoch_processing::{
|
||||
errors::EpochProcessingError, process_epoch as per_epoch_processing,
|
||||
};
|
||||
pub use per_slot_processing::{per_slot_processing, Error as SlotProcessingError};
|
||||
pub use per_slot_processing::{Error as SlotProcessingError, per_slot_processing};
|
||||
pub use types::{EpochCache, EpochCacheError, EpochCacheKey};
|
||||
pub use verify_operation::{SigVerifiedOp, TransformPersist, VerifyOperation, VerifyOperationAt};
|
||||
|
||||
@@ -7,23 +7,23 @@ use std::sync::LazyLock;
|
||||
pub static PARTICIPATION_PREV_EPOCH_HEAD_ATTESTING_GWEI_TOTAL: LazyLock<Result<IntGauge>> =
|
||||
LazyLock::new(|| {
|
||||
try_create_int_gauge(
|
||||
"beacon_participation_prev_epoch_head_attesting_gwei_total",
|
||||
"Total effective balance (gwei) of validators who attested to the head in the previous epoch"
|
||||
)
|
||||
"beacon_participation_prev_epoch_head_attesting_gwei_total",
|
||||
"Total effective balance (gwei) of validators who attested to the head in the previous epoch",
|
||||
)
|
||||
});
|
||||
pub static PARTICIPATION_PREV_EPOCH_TARGET_ATTESTING_GWEI_TOTAL: LazyLock<Result<IntGauge>> =
|
||||
LazyLock::new(|| {
|
||||
try_create_int_gauge(
|
||||
"beacon_participation_prev_epoch_target_attesting_gwei_total",
|
||||
"Total effective balance (gwei) of validators who attested to the target in the previous epoch"
|
||||
)
|
||||
"beacon_participation_prev_epoch_target_attesting_gwei_total",
|
||||
"Total effective balance (gwei) of validators who attested to the target in the previous epoch",
|
||||
)
|
||||
});
|
||||
pub static PARTICIPATION_PREV_EPOCH_SOURCE_ATTESTING_GWEI_TOTAL: LazyLock<Result<IntGauge>> =
|
||||
LazyLock::new(|| {
|
||||
try_create_int_gauge(
|
||||
"beacon_participation_prev_epoch_source_attesting_gwei_total",
|
||||
"Total effective balance (gwei) of validators who attested to the source in the previous epoch"
|
||||
)
|
||||
"beacon_participation_prev_epoch_source_attesting_gwei_total",
|
||||
"Total effective balance (gwei) of validators who attested to the source in the previous epoch",
|
||||
)
|
||||
});
|
||||
pub static PARTICIPATION_CURRENT_EPOCH_TOTAL_ACTIVE_GWEI_TOTAL: LazyLock<Result<IntGauge>> =
|
||||
LazyLock::new(|| {
|
||||
@@ -63,7 +63,7 @@ pub static PARTICIPATION_PREV_EPOCH_TARGET_ATTESTING_GWEI_PROGRESSIVE_TOTAL: Laz
|
||||
> = LazyLock::new(|| {
|
||||
try_create_int_gauge(
|
||||
"beacon_participation_prev_epoch_target_attesting_gwei_progressive_total",
|
||||
"Progressive total effective balance (gwei) of validators who attested to the target in the previous epoch"
|
||||
"Progressive total effective balance (gwei) of validators who attested to the target in the previous epoch",
|
||||
)
|
||||
});
|
||||
pub static PARTICIPATION_CURR_EPOCH_TARGET_ATTESTING_GWEI_PROGRESSIVE_TOTAL: LazyLock<
|
||||
@@ -71,6 +71,6 @@ pub static PARTICIPATION_CURR_EPOCH_TARGET_ATTESTING_GWEI_PROGRESSIVE_TOTAL: Laz
|
||||
> = LazyLock::new(|| {
|
||||
try_create_int_gauge(
|
||||
"beacon_participation_curr_epoch_target_attesting_gwei_progressive_total",
|
||||
"Progressive total effective balance (gwei) of validators who attested to the target in the current epoch"
|
||||
"Progressive total effective balance (gwei) of validators who attested to the target in the current epoch",
|
||||
)
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::common::{altair::BaseRewardPerIncrement, decrease_balance, increase_balance};
|
||||
use crate::per_block_processing::errors::{BlockProcessingError, SyncAggregateInvalid};
|
||||
use crate::{signature_sets::sync_aggregate_signature_set, VerifySignatures};
|
||||
use crate::{VerifySignatures, signature_sets::sync_aggregate_signature_set};
|
||||
use safe_arith::SafeArith;
|
||||
use std::borrow::Cow;
|
||||
use types::consts::altair::{PROPOSER_WEIGHT, SYNC_REWARD_WEIGHT, WEIGHT_DENOMINATOR};
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
use super::signature_sets::{Error as SignatureSetError, *};
|
||||
use crate::per_block_processing::errors::{AttestationInvalid, BlockOperationError};
|
||||
use crate::{ConsensusContext, ContextError};
|
||||
use bls::{verify_signature_sets, PublicKey, PublicKeyBytes, SignatureSet};
|
||||
use bls::{PublicKey, PublicKeyBytes, SignatureSet, verify_signature_sets};
|
||||
use std::borrow::Cow;
|
||||
use types::{
|
||||
AbstractExecPayload, BeaconState, BeaconStateError, ChainSpec, EthSpec, Hash256,
|
||||
@@ -324,17 +324,17 @@ where
|
||||
&mut self,
|
||||
block: &'a SignedBeaconBlock<E, Payload>,
|
||||
) -> Result<()> {
|
||||
if let Ok(sync_aggregate) = block.message().body().sync_aggregate() {
|
||||
if let Some(signature_set) = sync_aggregate_signature_set(
|
||||
if let Ok(sync_aggregate) = block.message().body().sync_aggregate()
|
||||
&& let Some(signature_set) = sync_aggregate_signature_set(
|
||||
&self.decompressor,
|
||||
sync_aggregate,
|
||||
block.slot(),
|
||||
block.parent_root(),
|
||||
self.state,
|
||||
self.spec,
|
||||
)? {
|
||||
self.sets.push(signature_set);
|
||||
}
|
||||
)?
|
||||
{
|
||||
self.sets.push(signature_set);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use ethereum_hashing::hash_fixed;
|
||||
use types::{KzgCommitment, VersionedHash, VERSIONED_HASH_VERSION_KZG};
|
||||
use types::{KzgCommitment, VERSIONED_HASH_VERSION_KZG, VersionedHash};
|
||||
|
||||
pub fn kzg_commitment_to_versioned_hash(kzg_commitment: &KzgCommitment) -> VersionedHash {
|
||||
let mut hashed_commitment = hash_fixed(&kzg_commitment.0);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use super::*;
|
||||
use crate::VerifySignatures;
|
||||
use crate::common::{
|
||||
get_attestation_participation_flag_indices, increase_balance, initiate_validator_exit,
|
||||
slash_validator,
|
||||
};
|
||||
use crate::per_block_processing::errors::{BlockProcessingError, IntoWithIndex};
|
||||
use crate::VerifySignatures;
|
||||
use types::consts::altair::{PARTICIPATION_FLAG_WEIGHTS, PROPOSER_WEIGHT, WEIGHT_DENOMINATOR};
|
||||
use types::typenum::U33;
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@ use crate::per_block_processing::errors::{
|
||||
DepositInvalid, HeaderInvalid, IndexedAttestationInvalid, IntoWithIndex,
|
||||
ProposerSlashingInvalid,
|
||||
};
|
||||
use crate::{per_block_processing, BlockReplayError, BlockReplayer};
|
||||
use crate::{BlockReplayError, BlockReplayer, per_block_processing};
|
||||
use crate::{
|
||||
per_block_processing::{process_operations, verify_exit::verify_exit},
|
||||
BlockSignatureStrategy, ConsensusContext, VerifyBlockRoot, VerifySignatures,
|
||||
per_block_processing::{process_operations, verify_exit::verify_exit},
|
||||
};
|
||||
use beacon_chain::test_utils::{BeaconChainHarness, EphemeralHarnessType};
|
||||
use ssz_types::Bitfield;
|
||||
@@ -717,10 +717,10 @@ async fn invalid_attester_slashing_not_slashable() {
|
||||
|
||||
let mut attester_slashing = harness.make_attester_slashing(vec![1, 2]);
|
||||
match &mut attester_slashing {
|
||||
AttesterSlashing::Base(ref mut attester_slashing) => {
|
||||
AttesterSlashing::Base(attester_slashing) => {
|
||||
attester_slashing.attestation_1 = attester_slashing.attestation_2.clone();
|
||||
}
|
||||
AttesterSlashing::Electra(ref mut attester_slashing) => {
|
||||
AttesterSlashing::Electra(attester_slashing) => {
|
||||
attester_slashing.attestation_1 = attester_slashing.attestation_2.clone();
|
||||
}
|
||||
}
|
||||
@@ -752,10 +752,10 @@ async fn invalid_attester_slashing_1_invalid() {
|
||||
|
||||
let mut attester_slashing = harness.make_attester_slashing(vec![1, 2]);
|
||||
match &mut attester_slashing {
|
||||
AttesterSlashing::Base(ref mut attester_slashing) => {
|
||||
AttesterSlashing::Base(attester_slashing) => {
|
||||
attester_slashing.attestation_1.attesting_indices = VariableList::from(vec![2, 1]);
|
||||
}
|
||||
AttesterSlashing::Electra(ref mut attester_slashing) => {
|
||||
AttesterSlashing::Electra(attester_slashing) => {
|
||||
attester_slashing.attestation_1.attesting_indices = VariableList::from(vec![2, 1]);
|
||||
}
|
||||
}
|
||||
@@ -790,10 +790,10 @@ async fn invalid_attester_slashing_2_invalid() {
|
||||
|
||||
let mut attester_slashing = harness.make_attester_slashing(vec![1, 2]);
|
||||
match &mut attester_slashing {
|
||||
AttesterSlashing::Base(ref mut attester_slashing) => {
|
||||
AttesterSlashing::Base(attester_slashing) => {
|
||||
attester_slashing.attestation_2.attesting_indices = VariableList::from(vec![2, 1]);
|
||||
}
|
||||
AttesterSlashing::Electra(ref mut attester_slashing) => {
|
||||
AttesterSlashing::Electra(attester_slashing) => {
|
||||
attester_slashing.attestation_2.attesting_indices = VariableList::from(vec![2, 1]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::errors::{AttestationInvalid as Invalid, BlockOperationError};
|
||||
use super::VerifySignatures;
|
||||
use crate::per_block_processing::is_valid_indexed_attestation;
|
||||
use super::errors::{AttestationInvalid as Invalid, BlockOperationError};
|
||||
use crate::ConsensusContext;
|
||||
use crate::per_block_processing::is_valid_indexed_attestation;
|
||||
use safe_arith::SafeArith;
|
||||
use types::*;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use super::errors::{BlockOperationError, BlsExecutionChangeInvalid as Invalid};
|
||||
use crate::per_block_processing::signature_sets::bls_execution_change_signature_set;
|
||||
use crate::VerifySignatures;
|
||||
use crate::per_block_processing::signature_sets::bls_execution_change_signature_set;
|
||||
use ethereum_hashing::hash;
|
||||
use types::*;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::errors::{BlockOperationError, ExitInvalid};
|
||||
use crate::per_block_processing::{
|
||||
signature_sets::{exit_signature_set, get_pubkey_from_state},
|
||||
VerifySignatures,
|
||||
signature_sets::{exit_signature_set, get_pubkey_from_state},
|
||||
};
|
||||
use safe_arith::SafeArith;
|
||||
use types::*;
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::common::update_progressive_balances_cache::{
|
||||
initialize_progressive_balances_cache, update_progressive_balances_on_epoch_transition,
|
||||
};
|
||||
use crate::epoch_cache::initialize_epoch_cache;
|
||||
use crate::per_epoch_processing::single_pass::{process_epoch_single_pass, SinglePassConfig};
|
||||
use crate::per_epoch_processing::single_pass::{SinglePassConfig, process_epoch_single_pass};
|
||||
use crate::per_epoch_processing::{
|
||||
capella::process_historical_summaries_update,
|
||||
historical_roots_update::process_historical_roots_update,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::per_epoch_processing::single_pass::{process_epoch_single_pass, SinglePassConfig};
|
||||
use crate::EpochProcessingError;
|
||||
use crate::per_epoch_processing::single_pass::{SinglePassConfig, process_epoch_single_pass};
|
||||
use types::beacon_state::BeaconState;
|
||||
use types::chain_spec::ChainSpec;
|
||||
use types::eth_spec::EthSpec;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::per_epoch_processing::Error;
|
||||
use crate::per_epoch_processing::{
|
||||
weigh_justification_and_finalization, JustificationAndFinalizationState,
|
||||
JustificationAndFinalizationState, weigh_justification_and_finalization,
|
||||
};
|
||||
use safe_arith::SafeArith;
|
||||
use types::{BeaconState, EthSpec};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::EpochProcessingError;
|
||||
use types::List;
|
||||
use types::beacon_state::BeaconState;
|
||||
use types::eth_spec::EthSpec;
|
||||
use types::participation_flags::ParticipationFlags;
|
||||
use types::List;
|
||||
|
||||
pub fn process_participation_flag_updates<E: EthSpec>(
|
||||
state: &mut BeaconState<E>,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::per_epoch_processing::{
|
||||
single_pass::{process_epoch_single_pass, SinglePassConfig},
|
||||
Error,
|
||||
single_pass::{SinglePassConfig, process_epoch_single_pass},
|
||||
};
|
||||
use types::consts::altair::PARTICIPATION_FLAG_WEIGHTS;
|
||||
use types::{BeaconState, ChainSpec, EthSpec};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use super::{process_registry_updates, process_slashings, EpochProcessingSummary, Error};
|
||||
use super::{EpochProcessingSummary, Error, process_registry_updates, process_slashings};
|
||||
use crate::epoch_cache::initialize_epoch_cache;
|
||||
use crate::per_epoch_processing::{
|
||||
effective_balance_updates::process_effective_balance_updates,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::per_epoch_processing::base::TotalBalances;
|
||||
use crate::per_epoch_processing::Error;
|
||||
use crate::per_epoch_processing::base::TotalBalances;
|
||||
use crate::per_epoch_processing::{
|
||||
weigh_justification_and_finalization, JustificationAndFinalizationState,
|
||||
JustificationAndFinalizationState, weigh_justification_and_finalization,
|
||||
};
|
||||
use safe_arith::SafeArith;
|
||||
use types::{BeaconState, ChainSpec, EthSpec};
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use crate::common::{
|
||||
base::{get_base_reward, SqrtTotalActiveBalance},
|
||||
base::{SqrtTotalActiveBalance, get_base_reward},
|
||||
decrease_balance, increase_balance,
|
||||
};
|
||||
use crate::per_epoch_processing::{
|
||||
base::{TotalBalances, ValidatorStatus, ValidatorStatuses},
|
||||
Delta, Error,
|
||||
base::{TotalBalances, ValidatorStatus, ValidatorStatuses},
|
||||
};
|
||||
use safe_arith::SafeArith;
|
||||
use types::{BeaconState, ChainSpec, EthSpec};
|
||||
@@ -190,16 +190,15 @@ fn get_attestation_deltas<E: EthSpec>(
|
||||
.combine(inactivity_penalty_delta)?;
|
||||
}
|
||||
|
||||
if let ProposerRewardCalculation::Include = proposer_reward {
|
||||
if let Some((proposer_index, proposer_delta)) = proposer_delta {
|
||||
if include_validator_delta(proposer_index) {
|
||||
deltas
|
||||
.get_mut(proposer_index)
|
||||
.ok_or(Error::ValidatorStatusesInconsistent)?
|
||||
.inclusion_delay_delta
|
||||
.combine(proposer_delta)?;
|
||||
}
|
||||
}
|
||||
if let ProposerRewardCalculation::Include = proposer_reward
|
||||
&& let Some((proposer_index, proposer_delta)) = proposer_delta
|
||||
&& include_validator_delta(proposer_index)
|
||||
{
|
||||
deltas
|
||||
.get_mut(proposer_index)
|
||||
.ok_or(Error::ValidatorStatusesInconsistent)?
|
||||
.inclusion_delay_delta
|
||||
.combine(proposer_delta)?;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::errors::EpochProcessingError;
|
||||
use crate::per_epoch_processing::single_pass::{process_epoch_single_pass, SinglePassConfig};
|
||||
use crate::per_epoch_processing::single_pass::{SinglePassConfig, process_epoch_single_pass};
|
||||
use safe_arith::SafeArith;
|
||||
use types::beacon_state::BeaconState;
|
||||
use types::chain_spec::ChainSpec;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use super::base::{validator_statuses::InclusionInfo, TotalBalances, ValidatorStatus};
|
||||
use super::base::{TotalBalances, ValidatorStatus, validator_statuses::InclusionInfo};
|
||||
use crate::metrics;
|
||||
use std::sync::Arc;
|
||||
use types::{
|
||||
consts::altair::{TIMELY_HEAD_FLAG_INDEX, TIMELY_SOURCE_FLAG_INDEX, TIMELY_TARGET_FLAG_INDEX},
|
||||
BeaconStateError, Epoch, EthSpec, List, ParticipationFlags, ProgressiveBalancesCache,
|
||||
SyncCommittee, Validator,
|
||||
consts::altair::{TIMELY_HEAD_FLAG_INDEX, TIMELY_SOURCE_FLAG_INDEX, TIMELY_TARGET_FLAG_INDEX},
|
||||
};
|
||||
|
||||
/// Provides a summary of validator participation during the epoch.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use types::{milhouse, BeaconStateError, EpochCacheError, InconsistentFork};
|
||||
use types::{BeaconStateError, EpochCacheError, InconsistentFork, milhouse};
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum EpochProcessingError {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use super::errors::EpochProcessingError;
|
||||
use safe_arith::SafeArith;
|
||||
use tree_hash::TreeHash;
|
||||
use types::Unsigned;
|
||||
use types::beacon_state::BeaconState;
|
||||
use types::eth_spec::EthSpec;
|
||||
use types::Unsigned;
|
||||
|
||||
pub fn process_historical_roots_update<E: EthSpec>(
|
||||
state: &mut BeaconState<E>,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::per_epoch_processing::single_pass::{process_epoch_single_pass, SinglePassConfig};
|
||||
use crate::per_epoch_processing::single_pass::{SinglePassConfig, process_epoch_single_pass};
|
||||
use crate::{common::initiate_validator_exit, per_epoch_processing::Error};
|
||||
use safe_arith::SafeArith;
|
||||
use types::{BeaconState, ChainSpec, EthSpec, Validator};
|
||||
|
||||
@@ -3,7 +3,7 @@ use crate::{
|
||||
decrease_balance, increase_balance,
|
||||
update_progressive_balances_cache::initialize_progressive_balances_cache,
|
||||
},
|
||||
epoch_cache::{initialize_epoch_cache, PreEpochCache},
|
||||
epoch_cache::{PreEpochCache, initialize_epoch_cache},
|
||||
per_block_processing::is_valid_deposit_signature,
|
||||
per_epoch_processing::{Delta, Error, ParticipationEpochSummary},
|
||||
};
|
||||
@@ -13,14 +13,14 @@ use std::cmp::{max, min};
|
||||
use std::collections::{BTreeSet, HashMap};
|
||||
use tracing::instrument;
|
||||
use types::{
|
||||
ActivationQueue, BeaconState, BeaconStateError, ChainSpec, Checkpoint, DepositData, Epoch,
|
||||
EthSpec, ExitCache, ForkName, List, ParticipationFlags, PendingDeposit,
|
||||
ProgressiveBalancesCache, RelativeEpoch, Unsigned, Validator, Vector,
|
||||
consts::altair::{
|
||||
NUM_FLAG_INDICES, PARTICIPATION_FLAG_WEIGHTS, TIMELY_HEAD_FLAG_INDEX,
|
||||
TIMELY_TARGET_FLAG_INDEX, WEIGHT_DENOMINATOR,
|
||||
},
|
||||
milhouse::Cow,
|
||||
ActivationQueue, BeaconState, BeaconStateError, ChainSpec, Checkpoint, DepositData, Epoch,
|
||||
EthSpec, ExitCache, ForkName, List, ParticipationFlags, PendingDeposit,
|
||||
ProgressiveBalancesCache, RelativeEpoch, Unsigned, Validator, Vector,
|
||||
};
|
||||
|
||||
pub struct SinglePassConfig {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::common::decrease_balance;
|
||||
use crate::per_epoch_processing::{
|
||||
single_pass::{process_epoch_single_pass, SinglePassConfig},
|
||||
Error,
|
||||
single_pass::{SinglePassConfig, process_epoch_single_pass},
|
||||
};
|
||||
use safe_arith::{SafeArith, SafeArithIter};
|
||||
use types::{BeaconState, ChainSpec, EthSpec, Unsigned};
|
||||
|
||||
@@ -42,7 +42,7 @@ async fn runs_without_error() {
|
||||
mod release_tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
per_slot_processing::per_slot_processing, EpochProcessingError, SlotProcessingError,
|
||||
EpochProcessingError, SlotProcessingError, per_slot_processing::per_slot_processing,
|
||||
};
|
||||
use beacon_chain::test_utils::{AttestationStrategy, BlockStrategy};
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::VerifySignatures;
|
||||
use crate::per_block_processing::{
|
||||
errors::{
|
||||
AttesterSlashingValidationError, BlsExecutionChangeValidationError, ExitValidationError,
|
||||
@@ -6,18 +7,17 @@ use crate::per_block_processing::{
|
||||
verify_attester_slashing, verify_bls_to_execution_change, verify_exit,
|
||||
verify_proposer_slashing,
|
||||
};
|
||||
use crate::VerifySignatures;
|
||||
use arbitrary::Arbitrary;
|
||||
use derivative::Derivative;
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
use ssz::{Decode, Encode};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use std::marker::PhantomData;
|
||||
use test_random_derive::TestRandom;
|
||||
use types::{
|
||||
test_utils::TestRandom, AttesterSlashing, AttesterSlashingBase, AttesterSlashingOnDisk,
|
||||
AttesterSlashingRefOnDisk, BeaconState, ChainSpec, Epoch, EthSpec, Fork, ForkVersion,
|
||||
ProposerSlashing, SignedBlsToExecutionChange, SignedVoluntaryExit,
|
||||
AttesterSlashing, AttesterSlashingBase, AttesterSlashingOnDisk, AttesterSlashingRefOnDisk,
|
||||
BeaconState, ChainSpec, Epoch, EthSpec, Fork, ForkVersion, ProposerSlashing,
|
||||
SignedBlsToExecutionChange, SignedVoluntaryExit, test_utils::TestRandom,
|
||||
};
|
||||
|
||||
const MAX_FORKS_VERIFIED_AGAINST: usize = 2;
|
||||
@@ -260,11 +260,12 @@ impl<E: EthSpec> VerifyOperation<E> for ProposerSlashing {
|
||||
#[allow(clippy::arithmetic_side_effects)]
|
||||
fn verification_epochs(&self) -> SmallVec<[Epoch; MAX_FORKS_VERIFIED_AGAINST]> {
|
||||
// Only need a single epoch because the slots of the two headers must be equal.
|
||||
smallvec![self
|
||||
.signed_header_1
|
||||
.message
|
||||
.slot
|
||||
.epoch(E::slots_per_epoch())]
|
||||
smallvec![
|
||||
self.signed_header_1
|
||||
.message
|
||||
.slot
|
||||
.epoch(E::slots_per_epoch())
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -417,8 +418,8 @@ impl TransformPersist for SignedBlsToExecutionChange {
|
||||
mod test {
|
||||
use super::*;
|
||||
use types::{
|
||||
test_utils::{SeedableRng, TestRandom, XorShiftRng},
|
||||
MainnetEthSpec,
|
||||
test_utils::{SeedableRng, TestRandom, XorShiftRng},
|
||||
};
|
||||
|
||||
type E = MainnetEthSpec;
|
||||
|
||||
Reference in New Issue
Block a user