Remove consensus/types re-exports (#8540)

There are certain crates which we re-export within `types` which creates a fragmented DevEx, where there are various ways to import the same crates.

```rust
// consensus/types/src/lib.rs
pub use bls::{
AggregatePublicKey, AggregateSignature, Error as BlsError, Keypair, PUBLIC_KEY_BYTES_LEN,
PublicKey, PublicKeyBytes, SIGNATURE_BYTES_LEN, SecretKey, Signature, SignatureBytes,
get_withdrawal_credentials,
};
pub use context_deserialize::{ContextDeserialize, context_deserialize};
pub use fixed_bytes::FixedBytesExtended;
pub use milhouse::{self, List, Vector};
pub use ssz_types::{BitList, BitVector, FixedVector, VariableList, typenum, typenum::Unsigned};
pub use superstruct::superstruct;
```

This PR removes these re-exports and makes it explicit that these types are imported from a non-`consensus/types` crate.


Co-Authored-By: Mac L <mjladson@pm.me>
This commit is contained in:
Mac L
2025-12-09 11:13:41 +04:00
committed by GitHub
parent 77d58437da
commit f3fd1f210b
213 changed files with 556 additions and 259 deletions

View File

@@ -24,11 +24,13 @@ educe = { workspace = true }
ethereum_hashing = { workspace = true }
ethereum_ssz = { workspace = true }
ethereum_ssz_derive = { workspace = true }
fixed_bytes = { workspace = true }
int_to_bytes = { workspace = true }
integer-sqrt = "0.1.5"
itertools = { workspace = true }
merkle_proof = { workspace = true }
metrics = { workspace = true }
milhouse = { workspace = true }
rand = { workspace = true }
rayon = { workspace = true }
safe_arith = { workspace = true }
@@ -37,6 +39,7 @@ ssz_types = { workspace = true }
test_random_derive = { path = "../../common/test_random_derive" }
tracing = { workspace = true }
tree_hash = { workspace = true }
typenum = { workspace = true }
types = { workspace = true }
[dev-dependencies]

View File

@@ -2,6 +2,7 @@ use types::*;
pub mod attesting_indices_base {
use crate::per_block_processing::errors::{AttestationInvalid as Invalid, BlockOperationError};
use ssz_types::{BitList, VariableList};
use types::*;
/// Convert `attestation` to (almost) indexed-verifiable form.
@@ -44,10 +45,10 @@ pub mod attesting_indices_base {
}
pub mod attesting_indices_electra {
use std::collections::HashSet;
use crate::per_block_processing::errors::{AttestationInvalid as Invalid, BlockOperationError};
use safe_arith::SafeArith;
use ssz_types::{BitList, BitVector, VariableList};
use std::collections::HashSet;
use types::*;
/// Compute an Electra IndexedAttestation given a list of committees.

View File

@@ -6,6 +6,7 @@ use crate::{
};
use safe_arith::SafeArith;
use std::cmp;
use typenum::Unsigned;
use types::{
consts::altair::{PROPOSER_WEIGHT, WEIGHT_DENOMINATOR},
*,

View File

@@ -2,12 +2,11 @@ use crate::common::altair::BaseRewardPerIncrement;
use crate::common::base::SqrtTotalActiveBalance;
use crate::common::{altair, base};
use crate::metrics;
use fixed_bytes::FixedBytesExtended;
use safe_arith::SafeArith;
use tracing::instrument;
use types::epoch_cache::{EpochCache, EpochCacheError, EpochCacheKey};
use types::{
ActivationQueue, BeaconState, ChainSpec, EthSpec, FixedBytesExtended, ForkName, Hash256,
};
use types::{ActivationQueue, BeaconState, ChainSpec, EthSpec, ForkName, Hash256};
/// Precursor to an `EpochCache`.
pub struct PreEpochCache {

View File

@@ -7,6 +7,7 @@ use crate::upgrade::{
upgrade_to_altair, upgrade_to_bellatrix, upgrade_to_capella, upgrade_to_deneb, upgrade_to_fulu,
upgrade_to_gloas,
};
use fixed_bytes::FixedBytesExtended;
use safe_arith::{ArithError, SafeArith};
use std::sync::Arc;
use tree_hash::TreeHash;

View File

@@ -5,6 +5,7 @@ use safe_arith::{ArithError, SafeArith, SafeArithIter};
use signature_sets::{block_proposal_signature_set, get_pubkey_from_state, randao_signature_set};
use std::borrow::Cow;
use tree_hash::TreeHash;
use typenum::Unsigned;
use types::*;
pub use self::verify_attester_slashing::{

View File

@@ -1,12 +1,12 @@
use crate::common::{altair::BaseRewardPerIncrement, decrease_balance, increase_balance};
use crate::per_block_processing::errors::{BlockProcessingError, SyncAggregateInvalid};
use crate::{VerifySignatures, signature_sets::sync_aggregate_signature_set};
use bls::PublicKeyBytes;
use safe_arith::SafeArith;
use std::borrow::Cow;
use typenum::Unsigned;
use types::consts::altair::{PROPOSER_WEIGHT, SYNC_REWARD_WEIGHT, WEIGHT_DENOMINATOR};
use types::{
BeaconState, BeaconStateError, ChainSpec, EthSpec, PublicKeyBytes, SyncAggregate, Unsigned,
};
use types::{BeaconState, BeaconStateError, ChainSpec, EthSpec, SyncAggregate};
pub fn process_sync_aggregate<E: EthSpec>(
state: &mut BeaconState<E>,

View File

@@ -5,8 +5,9 @@ use crate::common::{
slash_validator,
};
use crate::per_block_processing::errors::{BlockProcessingError, IntoWithIndex};
use ssz_types::FixedVector;
use typenum::U33;
use types::consts::altair::{PARTICIPATION_FLAG_WEIGHTS, PROPOSER_WEIGHT, WEIGHT_DENOMINATOR};
use types::typenum::U33;
pub fn process_operations<E: EthSpec, Payload: AbstractExecPayload<E>>(
state: &mut BeaconState<E>,

View File

@@ -2,17 +2,18 @@
//! validated individually, or alongside in others in a potentially cheaper bulk operation.
//!
//! This module exposes one function to extract each type of `SignatureSet` from a `BeaconBlock`.
use bls::SignatureSet;
use bls::{AggregateSignature, PublicKey, PublicKeyBytes, Signature, SignatureSet};
use ssz::DecodeError;
use std::borrow::Cow;
use tree_hash::TreeHash;
use typenum::Unsigned;
use types::{
AbstractExecPayload, AggregateSignature, AttesterSlashingRef, BeaconBlockRef, BeaconState,
BeaconStateError, ChainSpec, DepositData, Domain, Epoch, EthSpec, Fork, Hash256,
InconsistentFork, IndexedAttestation, IndexedAttestationRef, ProposerSlashing, PublicKey,
PublicKeyBytes, Signature, SignedAggregateAndProof, SignedBeaconBlock, SignedBeaconBlockHeader,
SignedBlsToExecutionChange, SignedContributionAndProof, SignedRoot, SignedVoluntaryExit,
SigningData, Slot, SyncAggregate, SyncAggregatorSelectionData, Unsigned,
AbstractExecPayload, AttesterSlashingRef, BeaconBlockRef, BeaconState, BeaconStateError,
ChainSpec, DepositData, Domain, Epoch, EthSpec, Fork, Hash256, InconsistentFork,
IndexedAttestation, IndexedAttestationRef, ProposerSlashing, SignedAggregateAndProof,
SignedBeaconBlock, SignedBeaconBlockHeader, SignedBlsToExecutionChange,
SignedContributionAndProof, SignedRoot, SignedVoluntaryExit, SigningData, Slot, SyncAggregate,
SyncAggregatorSelectionData,
};
pub type Result<T> = std::result::Result<T, Error>;

View File

@@ -11,7 +11,10 @@ use crate::{
per_block_processing::{process_operations, verify_exit::verify_exit},
};
use beacon_chain::test_utils::{BeaconChainHarness, EphemeralHarnessType};
use bls::{AggregateSignature, Keypair, PublicKeyBytes, Signature, SignatureBytes};
use fixed_bytes::FixedBytesExtended;
use ssz_types::Bitfield;
use ssz_types::VariableList;
use std::sync::{Arc, LazyLock};
use test_utils::generate_deterministic_keypairs;
use types::*;

View File

@@ -1,5 +1,6 @@
use super::errors::{BlockOperationError, DepositInvalid};
use crate::per_block_processing::signature_sets::deposit_pubkey_signature_message;
use bls::PublicKeyBytes;
use merkle_proof::verify_merkle_proof;
use safe_arith::SafeArith;
use tree_hash::TreeHash;

View File

@@ -1,5 +1,5 @@
use crate::EpochProcessingError;
use types::List;
use milhouse::List;
use types::beacon_state::BeaconState;
use types::eth_spec::EthSpec;
use types::participation_flags::ParticipationFlags;

View File

@@ -1,9 +1,10 @@
use super::base::{TotalBalances, ValidatorStatus, validator_statuses::InclusionInfo};
use crate::metrics;
use milhouse::List;
use std::sync::Arc;
use types::{
BeaconStateError, Epoch, EthSpec, List, ParticipationFlags, ProgressiveBalancesCache,
SyncCommittee, Validator,
BeaconStateError, Epoch, EthSpec, ParticipationFlags, ProgressiveBalancesCache, SyncCommittee,
Validator,
consts::altair::{TIMELY_HEAD_FLAG_INDEX, TIMELY_SOURCE_FLAG_INDEX, TIMELY_TARGET_FLAG_INDEX},
};

View File

@@ -1,4 +1,5 @@
use types::{BeaconStateError, EpochCacheError, InconsistentFork, milhouse};
use milhouse;
use types::{BeaconStateError, EpochCacheError, InconsistentFork};
#[derive(Debug, PartialEq)]
pub enum EpochProcessingError {

View File

@@ -1,7 +1,7 @@
use super::errors::EpochProcessingError;
use safe_arith::SafeArith;
use tree_hash::TreeHash;
use types::Unsigned;
use typenum::Unsigned;
use types::beacon_state::BeaconState;
use types::eth_spec::EthSpec;

View File

@@ -1,4 +1,5 @@
use types::{BeaconState, BeaconStateError, BitVector, Checkpoint, Epoch, EthSpec, Hash256};
use ssz_types::BitVector;
use types::{BeaconState, BeaconStateError, Checkpoint, Epoch, EthSpec, Hash256};
/// This is a subset of the `BeaconState` which is used to compute justification and finality
/// without modifying the `BeaconState`.

View File

@@ -1,8 +1,9 @@
use super::errors::EpochProcessingError;
use milhouse::List;
use safe_arith::SafeArith;
use typenum::Unsigned;
use types::beacon_state::BeaconState;
use types::eth_spec::EthSpec;
use types::{List, Unsigned};
pub fn process_eth1_data_reset<E: EthSpec>(
state: &mut BeaconState<E>,

View File

@@ -8,19 +8,20 @@ use crate::{
per_epoch_processing::{Delta, Error, ParticipationEpochSummary},
};
use itertools::izip;
use milhouse::{Cow, List, Vector};
use safe_arith::{SafeArith, SafeArithIter};
use std::cmp::{max, min};
use std::collections::{BTreeSet, HashMap};
use tracing::instrument;
use typenum::Unsigned;
use types::{
ActivationQueue, BeaconState, BeaconStateError, ChainSpec, Checkpoint, DepositData, Epoch,
EthSpec, ExitCache, ForkName, List, ParticipationFlags, PendingDeposit,
ProgressiveBalancesCache, RelativeEpoch, Unsigned, Validator, Vector,
EthSpec, ExitCache, ForkName, ParticipationFlags, PendingDeposit, ProgressiveBalancesCache,
RelativeEpoch, Validator,
consts::altair::{
NUM_FLAG_INDICES, PARTICIPATION_FLAG_WEIGHTS, TIMELY_HEAD_FLAG_INDEX,
TIMELY_TARGET_FLAG_INDEX, WEIGHT_DENOMINATOR,
},
milhouse::Cow,
};
pub struct SinglePassConfig {

View File

@@ -4,7 +4,8 @@ use crate::per_epoch_processing::{
single_pass::{SinglePassConfig, process_epoch_single_pass},
};
use safe_arith::{SafeArith, SafeArithIter};
use types::{BeaconState, ChainSpec, EthSpec, Unsigned};
use typenum::Unsigned;
use types::{BeaconState, ChainSpec, EthSpec};
/// Process slashings.
pub fn process_slashings<E: EthSpec>(

View File

@@ -3,6 +3,7 @@ use crate::upgrade::{
upgrade_to_electra, upgrade_to_fulu, upgrade_to_gloas,
};
use crate::{per_epoch_processing::EpochProcessingSummary, *};
use fixed_bytes::FixedBytesExtended;
use safe_arith::{ArithError, SafeArith};
use tracing::instrument;
use types::*;

View File

@@ -5,7 +5,8 @@
//! duplication and protect against some easy-to-make mistakes when performing state advances.
use crate::*;
use types::{BeaconState, ChainSpec, EthSpec, FixedBytesExtended, Hash256, Slot};
use fixed_bytes::FixedBytesExtended;
use types::{BeaconState, ChainSpec, EthSpec, Hash256, Slot};
#[derive(Debug, PartialEq)]
pub enum Error {

View File

@@ -2,11 +2,12 @@ use crate::common::update_progressive_balances_cache::initialize_progressive_bal
use crate::common::{
attesting_indices_base::get_attesting_indices, get_attestation_participation_flag_indices,
};
use milhouse::List;
use std::mem;
use std::sync::Arc;
use types::{
BeaconState, BeaconStateAltair, BeaconStateError as Error, ChainSpec, EpochCache, EthSpec,
Fork, List, ParticipationFlags, PendingAttestation, RelativeEpoch, SyncCommittee,
Fork, ParticipationFlags, PendingAttestation, RelativeEpoch, SyncCommittee,
};
/// Translate the participation information from the epoch prior to the fork into Altair's format.

View File

@@ -1,7 +1,8 @@
use milhouse::List;
use std::mem;
use types::{
BeaconState, BeaconStateCapella, BeaconStateError as Error, ChainSpec, EpochCache, EthSpec,
Fork, List,
Fork,
};
/// Transform a `Bellatrix` state into an `Capella` state.

View File

@@ -1,8 +1,7 @@
use milhouse::Vector;
use safe_arith::SafeArith;
use std::mem;
use types::{
BeaconState, BeaconStateError as Error, BeaconStateFulu, ChainSpec, EthSpec, Fork, Vector,
};
use types::{BeaconState, BeaconStateError as Error, BeaconStateFulu, ChainSpec, EthSpec, Fork};
/// Transform a `Electra` state into an `Fulu` state.
pub fn upgrade_to_fulu<E: EthSpec>(