mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-29 10:54:24 +00:00
Cleanup consensus/types re-exports (#8643)
Removes some of the temporary re-exports in `consensus/types`. I am doing this in multiple parts to keep each diff small. Co-Authored-By: Mac L <mjladson@pm.me>
This commit is contained in:
@@ -134,7 +134,7 @@ use tracing::{Span, debug, debug_span, error, info, info_span, instrument, trace
|
||||
use tree_hash::TreeHash;
|
||||
use types::blob_sidecar::FixedBlobSidecarList;
|
||||
use types::data_column_sidecar::ColumnIndex;
|
||||
use types::payload::BlockProductionVersion;
|
||||
use types::execution::BlockProductionVersion;
|
||||
use types::*;
|
||||
|
||||
pub type ForkChoiceError = fork_choice::Error<crate::ForkChoiceStoreError>;
|
||||
|
||||
@@ -219,7 +219,7 @@ pub enum BeaconChainError {
|
||||
UnableToPublish,
|
||||
UnableToBuildColumnSidecar(String),
|
||||
AvailabilityCheckError(AvailabilityCheckError),
|
||||
LightClientUpdateError(LightClientUpdateError),
|
||||
LightClientError(LightClientError),
|
||||
LightClientBootstrapError(String),
|
||||
UnsupportedFork,
|
||||
MilhouseError(MilhouseError),
|
||||
@@ -274,7 +274,7 @@ easy_from_to!(BlockReplayError, BeaconChainError);
|
||||
easy_from_to!(InconsistentFork, BeaconChainError);
|
||||
easy_from_to!(AvailabilityCheckError, BeaconChainError);
|
||||
easy_from_to!(EpochCacheError, BeaconChainError);
|
||||
easy_from_to!(LightClientUpdateError, BeaconChainError);
|
||||
easy_from_to!(LightClientError, BeaconChainError);
|
||||
easy_from_to!(MilhouseError, BeaconChainError);
|
||||
easy_from_to!(AttestationError, BeaconChainError);
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ use std::sync::Arc;
|
||||
use tokio::task::JoinHandle;
|
||||
use tracing::{Instrument, debug, debug_span, warn};
|
||||
use tree_hash::TreeHash;
|
||||
use types::payload::BlockProductionVersion;
|
||||
use types::execution::BlockProductionVersion;
|
||||
use types::*;
|
||||
|
||||
pub type PreparePayloadResult<E> = Result<BlockProposalContentsType<E>, BlockProductionError>;
|
||||
|
||||
@@ -4,8 +4,8 @@ use itertools::Itertools;
|
||||
use smallvec::SmallVec;
|
||||
use std::collections::HashMap;
|
||||
use tree_hash::{MerkleHasher, TreeHash, TreeHashType};
|
||||
use types::SlotData;
|
||||
use types::consts::altair::SYNC_COMMITTEE_SUBNET_COUNT;
|
||||
use types::slot_data::SlotData;
|
||||
use types::sync_committee_contribution::SyncContributionData;
|
||||
use types::{
|
||||
Attestation, AttestationData, AttestationRef, CommitteeIndex, EthSpec, Hash256, Slot,
|
||||
|
||||
@@ -7,10 +7,10 @@ use std::collections::HashMap;
|
||||
use std::marker::PhantomData;
|
||||
use tree_hash::TreeHash;
|
||||
use tree_hash_derive::TreeHash;
|
||||
use types::SlotData;
|
||||
use types::consts::altair::{
|
||||
SYNC_COMMITTEE_SUBNET_COUNT, TARGET_AGGREGATORS_PER_SYNC_SUBCOMMITTEE,
|
||||
};
|
||||
use types::slot_data::SlotData;
|
||||
use types::{
|
||||
Attestation, AttestationData, AttestationRef, EthSpec, Hash256, Slot, SyncCommitteeContribution,
|
||||
};
|
||||
|
||||
@@ -20,7 +20,7 @@ use std::collections::{HashMap, HashSet};
|
||||
use std::hash::Hash;
|
||||
use std::marker::PhantomData;
|
||||
use typenum::Unsigned;
|
||||
use types::slot_data::SlotData;
|
||||
use types::SlotData;
|
||||
use types::{Epoch, EthSpec, Hash256, Slot};
|
||||
|
||||
/// The maximum capacity of the `AutoPruningEpochContainer`.
|
||||
|
||||
@@ -48,8 +48,8 @@ use strum::AsRefStr;
|
||||
use tree_hash::TreeHash;
|
||||
use tree_hash_derive::TreeHash;
|
||||
use types::ChainSpec;
|
||||
use types::SlotData;
|
||||
use types::consts::altair::SYNC_COMMITTEE_SUBNET_COUNT;
|
||||
use types::slot_data::SlotData;
|
||||
use types::sync_committee::SyncCommitteeError;
|
||||
use types::{
|
||||
BeaconStateError, EthSpec, Hash256, SignedContributionAndProof, Slot,
|
||||
|
||||
@@ -68,8 +68,8 @@ use task_executor::{ShutdownReason, test_utils::TestRuntime};
|
||||
use tree_hash::TreeHash;
|
||||
use typenum::U4294967296;
|
||||
use types::data_column_custody_group::CustodyIndex;
|
||||
use types::execution::BlockProductionVersion;
|
||||
use types::indexed_attestation::IndexedAttestationBase;
|
||||
use types::payload::BlockProductionVersion;
|
||||
use types::test_utils::TestRandom;
|
||||
pub use types::test_utils::generate_deterministic_keypairs;
|
||||
use types::*;
|
||||
|
||||
@@ -47,8 +47,8 @@ use tracing::{Instrument, debug, debug_span, error, info, instrument, warn};
|
||||
use tree_hash::TreeHash;
|
||||
use types::beacon_block_body::KzgCommitments;
|
||||
use types::builder_bid::BuilderBid;
|
||||
use types::execution::BlockProductionVersion;
|
||||
use types::non_zero_usize::new_non_zero_usize;
|
||||
use types::payload::BlockProductionVersion;
|
||||
use types::{
|
||||
AbstractExecPayload, BlobsList, ExecutionPayloadDeneb, ExecutionRequests, KzgProofs,
|
||||
SignedBlindedBeaconBlock,
|
||||
|
||||
@@ -12,9 +12,7 @@ use eth2::types::{
|
||||
ValidatorsRequestBody,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
use types::{
|
||||
AttestationShufflingId, CommitteeCache, Error as BeaconStateError, EthSpec, RelativeEpoch,
|
||||
};
|
||||
use types::{AttestationShufflingId, BeaconStateError, CommitteeCache, EthSpec, RelativeEpoch};
|
||||
use warp::filters::BoxedFilter;
|
||||
use warp::{Filter, Reply};
|
||||
use warp_utils::query::multi_key_query;
|
||||
|
||||
@@ -16,7 +16,7 @@ use lighthouse_tracing::{SPAN_PRODUCE_BLOCK_V2, SPAN_PRODUCE_BLOCK_V3};
|
||||
use ssz::Encode;
|
||||
use std::sync::Arc;
|
||||
use tracing::instrument;
|
||||
use types::{payload::BlockProductionVersion, *};
|
||||
use types::{execution::BlockProductionVersion, *};
|
||||
use warp::{
|
||||
Reply,
|
||||
hyper::{Body, Response},
|
||||
|
||||
@@ -17,8 +17,8 @@ use std::collections::HashMap;
|
||||
use tokio::sync::mpsc::UnboundedSender;
|
||||
use tracing::{debug, error, warn};
|
||||
use types::{
|
||||
BeaconStateError, Epoch, EthSpec, SignedContributionAndProof, SyncCommitteeMessage, SyncDuty,
|
||||
SyncSubnetId, slot_data::SlotData,
|
||||
BeaconStateError, Epoch, EthSpec, SignedContributionAndProof, SlotData, SyncCommitteeMessage,
|
||||
SyncDuty, SyncSubnetId,
|
||||
};
|
||||
|
||||
/// The struct that is returned to the requesting HTTP client.
|
||||
|
||||
@@ -44,7 +44,7 @@ use std::convert::TryInto;
|
||||
use std::sync::Arc;
|
||||
use tokio::time::Duration;
|
||||
use tree_hash::TreeHash;
|
||||
use types::application_domain::ApplicationDomain;
|
||||
use types::ApplicationDomain;
|
||||
use types::{
|
||||
Domain, EthSpec, ExecutionBlockHash, Hash256, MainnetEthSpec, RelativeEpoch, SelectionProof,
|
||||
SignedRoot, SingleAttestation, Slot, attestation::AttestationBase,
|
||||
|
||||
@@ -39,8 +39,8 @@ use typenum::Unsigned;
|
||||
use types::{
|
||||
AbstractExecPayload, Attestation, AttestationData, AttesterSlashing, BeaconState,
|
||||
BeaconStateError, ChainSpec, Epoch, EthSpec, ProposerSlashing, SignedBeaconBlock,
|
||||
SignedBlsToExecutionChange, SignedVoluntaryExit, Slot, SyncAggregate,
|
||||
SyncCommitteeContribution, Validator, sync_aggregate::Error as SyncAggregateError,
|
||||
SignedBlsToExecutionChange, SignedVoluntaryExit, Slot, SyncAggregate, SyncAggregateError,
|
||||
SyncCommitteeContribution, Validator,
|
||||
};
|
||||
|
||||
type SyncContributions<E> = RwLock<HashMap<SyncAggregateId, Vec<SyncCommitteeContribution<E>>>>;
|
||||
|
||||
@@ -28,7 +28,7 @@ pub fn get_base_reward(
|
||||
validator_effective_balance: u64,
|
||||
base_reward_per_increment: BaseRewardPerIncrement,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<u64, Error> {
|
||||
) -> Result<u64, BeaconStateError> {
|
||||
validator_effective_balance
|
||||
.safe_div(spec.effective_balance_increment)?
|
||||
.safe_mul(base_reward_per_increment.as_u64())
|
||||
|
||||
@@ -107,7 +107,7 @@ pub mod attesting_indices_electra {
|
||||
for committee_index in committee_indices {
|
||||
let beacon_committee = committees
|
||||
.get(committee_index as usize)
|
||||
.ok_or(Error::NoCommitteeFound(committee_index))?;
|
||||
.ok_or(BeaconStateError::NoCommitteeFound(committee_index))?;
|
||||
|
||||
// This check is new to the spec's `process_attestation` in Electra.
|
||||
if committee_index >= committee_count_per_slot {
|
||||
|
||||
@@ -195,7 +195,7 @@ pub fn is_valid_genesis_state<E: EthSpec>(state: &BeaconState<E>, spec: &ChainSp
|
||||
pub fn process_activations<E: EthSpec>(
|
||||
state: &mut BeaconState<E>,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), BeaconStateError> {
|
||||
let (validators, balances, _) = state.validators_and_balances_and_progressive_balances_mut();
|
||||
let mut validators_iter = validators.iter_cow();
|
||||
while let Some((index, validator)) = validators_iter.next_cow() {
|
||||
@@ -203,7 +203,7 @@ pub fn process_activations<E: EthSpec>(
|
||||
let balance = balances
|
||||
.get(index)
|
||||
.copied()
|
||||
.ok_or(Error::BalancesOutOfBounds(index))?;
|
||||
.ok_or(BeaconStateError::BalancesOutOfBounds(index))?;
|
||||
validator.effective_balance = std::cmp::min(
|
||||
balance.safe_sub(balance.safe_rem(spec.effective_balance_increment)?)?,
|
||||
spec.max_effective_balance,
|
||||
|
||||
@@ -322,7 +322,7 @@ pub fn process_randao<E: EthSpec, Payload: AbstractExecPayload<E>>(
|
||||
pub fn process_eth1_data<E: EthSpec>(
|
||||
state: &mut BeaconState<E>,
|
||||
eth1_data: &Eth1Data,
|
||||
) -> Result<(), Error> {
|
||||
) -> Result<(), BeaconStateError> {
|
||||
if let Some(new_eth1_data) = get_new_eth1_data(state, eth1_data)? {
|
||||
*state.eth1_data_mut() = new_eth1_data;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use ethereum_hashing::hash_fixed;
|
||||
use types::{KzgCommitment, VERSIONED_HASH_VERSION_KZG, VersionedHash};
|
||||
use types::{VersionedHash, kzg_ext::KzgCommitment, kzg_ext::consts::VERSIONED_HASH_VERSION_KZG};
|
||||
|
||||
pub fn kzg_commitment_to_versioned_hash(kzg_commitment: &KzgCommitment) -> VersionedHash {
|
||||
let mut hashed_commitment = hash_fixed(&kzg_commitment.0);
|
||||
|
||||
@@ -114,10 +114,6 @@ pub mod blob_sidecar {
|
||||
};
|
||||
}
|
||||
|
||||
pub mod payload {
|
||||
pub use crate::execution::BlockProductionVersion;
|
||||
}
|
||||
|
||||
pub mod execution_requests {
|
||||
pub use crate::execution::{
|
||||
ConsolidationRequests, DepositRequests, ExecutionRequests, RequestType, WithdrawalRequests,
|
||||
@@ -135,10 +131,6 @@ pub mod data_column_custody_group {
|
||||
};
|
||||
}
|
||||
|
||||
pub mod sync_aggregate {
|
||||
pub use crate::sync_committee::SyncAggregateError as Error;
|
||||
}
|
||||
|
||||
pub mod light_client_update {
|
||||
pub use crate::light_client::consts::{
|
||||
CURRENT_SYNC_COMMITTEE_INDEX, CURRENT_SYNC_COMMITTEE_INDEX_ELECTRA, FINALIZED_ROOT_INDEX,
|
||||
@@ -153,10 +145,6 @@ pub mod sync_committee_contribution {
|
||||
};
|
||||
}
|
||||
|
||||
pub mod slot_data {
|
||||
pub use crate::core::SlotData;
|
||||
}
|
||||
|
||||
pub mod signed_aggregate_and_proof {
|
||||
pub use crate::attestation::SignedAggregateAndProofRefMut;
|
||||
}
|
||||
@@ -166,12 +154,3 @@ pub mod payload_attestation {
|
||||
PayloadAttestation, PayloadAttestationData, PayloadAttestationMessage,
|
||||
};
|
||||
}
|
||||
|
||||
pub mod application_domain {
|
||||
pub use crate::core::ApplicationDomain;
|
||||
}
|
||||
|
||||
// Temporary re-exports to maintain backwards compatibility for Lighthouse.
|
||||
pub use crate::kzg_ext::consts::VERSIONED_HASH_VERSION_KZG;
|
||||
pub use crate::light_client::LightClientError as LightClientUpdateError;
|
||||
pub use crate::state::BeaconStateError as Error;
|
||||
|
||||
@@ -21,7 +21,7 @@ use std::sync::Arc;
|
||||
use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};
|
||||
use task_executor::TaskExecutor;
|
||||
use tokio::time::sleep;
|
||||
use types::payload::BlockProductionVersion;
|
||||
use types::execution::BlockProductionVersion;
|
||||
use types::{
|
||||
Address, ChainSpec, EthSpec, ExecutionBlockHash, ExecutionPayload, ExecutionPayloadHeader,
|
||||
ForkName, Hash256, MainnetEthSpec, Slot, Uint256,
|
||||
|
||||
Reference in New Issue
Block a user