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

@@ -65,6 +65,7 @@ test_random_derive = { path = "../../common/test_random_derive" }
tracing = { workspace = true }
tree_hash = { workspace = true }
tree_hash_derive = { workspace = true }
typenum = { workspace = true }
[dev-dependencies]
beacon_chain = { workspace = true }

View File

@@ -1,10 +1,11 @@
use criterion::{BatchSize, BenchmarkId, Criterion, black_box, criterion_group, criterion_main};
use fixed_bytes::FixedBytesExtended;
use milhouse::List;
use rayon::prelude::*;
use ssz::Encode;
use std::sync::Arc;
use types::{
BeaconState, Epoch, Eth1Data, EthSpec, FixedBytesExtended, Hash256, MainnetEthSpec, Validator,
BeaconState, Epoch, Eth1Data, EthSpec, Hash256, MainnetEthSpec, Validator,
test_utils::generate_deterministic_keypair,
};

View File

@@ -7,11 +7,12 @@ use fixed_bytes::FixedBytesExtended;
use serde::{Deserialize, Deserializer, Serialize};
use ssz::{Decode, DecodeError};
use ssz_derive::{Decode, Encode};
use ssz_types::{BitList, BitVector, FixedVector, VariableList, typenum::Unsigned};
use ssz_types::{BitList, BitVector, FixedVector, VariableList};
use superstruct::superstruct;
use test_random_derive::TestRandom;
use tree_hash::TreeHash;
use tree_hash_derive::TreeHash;
use typenum::Unsigned;
use crate::{
attestation::{AttestationBase, AttestationData, IndexedAttestationBase},

View File

@@ -5,7 +5,7 @@ use std::{
use safe_arith::SafeArith;
use serde::{Deserialize, Serialize};
use ssz_types::typenum::{
use typenum::{
U0, U1, U2, U4, U8, U16, U17, U32, U64, U128, U256, U512, U625, U1024, U2048, U4096, U8192,
U65536, U131072, U262144, U1048576, U16777216, U33554432, U134217728, U1073741824,
U1099511627776, UInt, Unsigned, bit::B0,
@@ -625,7 +625,7 @@ impl EthSpec for GnosisEthSpec {
#[cfg(test)]
mod test {
use crate::{EthSpec, GnosisEthSpec, MainnetEthSpec, MinimalEthSpec};
use ssz_types::typenum::Unsigned;
use typenum::Unsigned;
fn assert_valid_spec<E: EthSpec>() {
let spec = E::default_spec();

View File

@@ -1,5 +1,5 @@
use serde::{Deserialize, Serialize};
use ssz_types::typenum::Unsigned;
use typenum::Unsigned;
use crate::core::{ChainSpec, Epoch, EthSpec};

View File

@@ -1,9 +1,10 @@
use context_deserialize::context_deserialize;
use serde::{Deserialize, Serialize};
use ssz_derive::{Decode, Encode};
use ssz_types::{FixedVector, typenum::U33};
use ssz_types::FixedVector;
use test_random_derive::TestRandom;
use tree_hash_derive::TreeHash;
use typenum::U33;
use crate::{core::Hash256, deposit::DepositData, fork::ForkName, test_utils::TestRandom};

View File

@@ -165,14 +165,3 @@ pub mod application_domain {
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;
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;

View File

@@ -9,10 +9,10 @@ use ssz::{Decode, Encode};
use ssz_derive::Decode;
use ssz_derive::Encode;
use ssz_types::FixedVector;
use ssz_types::typenum::{U4, U5, U6, U7};
use superstruct::superstruct;
use test_random_derive::TestRandom;
use tree_hash_derive::TreeHash;
use typenum::{U4, U5, U6, U7};
use crate::{
block::SignedBlindedBeaconBlock,
@@ -574,7 +574,7 @@ fn compute_sync_committee_period_at_slot<E: EthSpec>(
mod tests {
use super::*;
use crate::light_client::consts::*;
use ssz_types::typenum::Unsigned;
use typenum::Unsigned;
// `ssz_tests!` can only be defined once per namespace
#[cfg(test)]

View File

@@ -13,13 +13,14 @@ use safe_arith::{ArithError, SafeArith};
use serde::{Deserialize, Deserializer, Serialize};
use ssz::{Decode, DecodeError, Encode, ssz_encode};
use ssz_derive::{Decode, Encode};
use ssz_types::{BitVector, FixedVector, typenum::Unsigned};
use ssz_types::{BitVector, FixedVector};
use superstruct::superstruct;
use swap_or_not_shuffle::compute_shuffled_index;
use test_random_derive::TestRandom;
use tracing::instrument;
use tree_hash::TreeHash;
use tree_hash_derive::TreeHash;
use typenum::Unsigned;
use crate::{
attestation::{

View File

@@ -56,6 +56,7 @@ impl<E: EthSpec> Iterator for BlockRootsIter<'_, E> {
#[cfg(test)]
mod test {
use crate::*;
use fixed_bytes::FixedBytesExtended;
type E = MinimalEthSpec;

View File

@@ -5,7 +5,7 @@ use ethereum_hashing::hash;
use safe_arith::{ArithError, SafeArith};
use serde::{Deserialize, Serialize};
use ssz::Encode;
use ssz_types::typenum::Unsigned;
use typenum::Unsigned;
use crate::{
core::{
@@ -112,8 +112,9 @@ impl From<Signature> for SyncSelectionProof {
#[cfg(test)]
mod test {
use super::*;
use crate::{FixedBytesExtended, MainnetEthSpec};
use crate::MainnetEthSpec;
use eth2_interop_keypairs::keypair;
use fixed_bytes::FixedBytesExtended;
#[test]
fn proof_sign_and_verify() {

View File

@@ -8,7 +8,7 @@ use std::{
use safe_arith::{ArithError, SafeArith};
use serde::{Deserialize, Serialize};
use ssz_types::typenum::Unsigned;
use typenum::Unsigned;
use crate::core::{EthSpec, consts::altair::SYNC_COMMITTEE_SUBNET_COUNT};

View File

@@ -1,5 +1,6 @@
use smallvec::smallvec;
use ssz_types::{BitList, BitVector, typenum::Unsigned};
use ssz_types::{BitList, BitVector};
use typenum::Unsigned;
use crate::test_utils::TestRandom;

View File

@@ -3,7 +3,8 @@ use std::{marker::PhantomData, sync::Arc};
use rand::{RngCore, SeedableRng};
use rand_xorshift::XorShiftRng;
use smallvec::{SmallVec, smallvec};
use ssz_types::{VariableList, typenum::Unsigned};
use ssz_types::VariableList;
use typenum::Unsigned;
pub fn test_random_instance<T: TestRandom>() -> T {
let mut rng = XorShiftRng::from_seed([0x42; 16]);