Skip to content

Commit 4e958a9

Browse files
authored
Refactor consensus/types (#7827)
Organize and categorize `consensus/types` into modules based on their relation to key consensus structures/concepts. This is a precursor to a sensible public interface. While this refactor is very opinionated, I am open to suggestions on module names, or type groupings if my current ones are inappropriate. Co-Authored-By: Mac L <[email protected]>
1 parent 51d0336 commit 4e958a9

File tree

167 files changed

+2115
-1749
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+2115
-1749
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ slashing_protection = { path = "validator_client/slashing_protection" }
227227
slot_clock = { path = "common/slot_clock" }
228228
smallvec = { version = "1.11.2", features = ["arbitrary"] }
229229
snap = "1"
230-
ssz_types = { version = "0.14.0", features = ["context_deserialize"] }
230+
ssz_types = { version = "0.14.0", features = ["context_deserialize", "runtime_types"] }
231231
state_processing = { path = "consensus/state_processing" }
232232
store = { path = "beacon_node/store" }
233233
strum = { version = "0.24", features = ["derive"] }

beacon_node/beacon_chain/src/attester_cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::ops::Range;
1717
use types::{
1818
BeaconState, BeaconStateError, ChainSpec, Checkpoint, Epoch, EthSpec, FixedBytesExtended,
1919
Hash256, RelativeEpoch, Slot,
20-
attestation::Error as AttestationError,
20+
attestation::AttestationError,
2121
beacon_state::{
2222
compute_committee_index_in_epoch, compute_committee_range_in_epoch, epoch_committee_count,
2323
},

beacon_node/beacon_chain/src/beacon_chain.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ use crate::{
7474
AvailabilityPendingExecutedBlock, BeaconChainError, BeaconForkChoiceStore, BeaconSnapshot,
7575
CachedHead, metrics,
7676
};
77+
use eth2::beacon_response::ForkVersionedResponse;
7778
use eth2::types::{
7879
EventKind, SseBlobSidecar, SseBlock, SseDataColumnSidecar, SseExtendedPayloadAttributes,
7980
};

beacon_node/beacon_chain/src/data_availability_checker/overflow_lru_cache.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use crate::{BeaconChainTypes, BlockProcessStatus};
1212
use lighthouse_tracing::SPAN_PENDING_COMPONENTS;
1313
use lru::LruCache;
1414
use parking_lot::{MappedRwLockReadGuard, RwLock, RwLockReadGuard, RwLockWriteGuard};
15+
use ssz_types::{RuntimeFixedVector, RuntimeVariableList};
1516
use std::cmp::Ordering;
1617
use std::num::NonZeroUsize;
1718
use std::sync::Arc;
@@ -20,8 +21,7 @@ use types::beacon_block_body::KzgCommitments;
2021
use types::blob_sidecar::BlobIdentifier;
2122
use types::{
2223
BlobSidecar, BlockImportSource, ChainSpec, ColumnIndex, DataColumnSidecar,
23-
DataColumnSidecarList, Epoch, EthSpec, Hash256, RuntimeFixedVector, RuntimeVariableList,
24-
SignedBeaconBlock,
24+
DataColumnSidecarList, Epoch, EthSpec, Hash256, SignedBeaconBlock,
2525
};
2626

2727
#[derive(Clone)]

beacon_node/beacon_chain/src/sync_committee_verification.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ use tree_hash_derive::TreeHash;
4949
use types::ChainSpec;
5050
use types::consts::altair::SYNC_COMMITTEE_SUBNET_COUNT;
5151
use types::slot_data::SlotData;
52-
use types::sync_committee::Error as SyncCommitteeError;
52+
use types::sync_committee::SyncCommitteeError;
5353
use types::{
5454
AggregateSignature, BeaconStateError, EthSpec, Hash256, SignedContributionAndProof, Slot,
5555
SyncCommitteeContribution, SyncCommitteeMessage, SyncSelectionProof, SyncSubnetId,

beacon_node/beacon_chain/src/test_utils.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ use rand::seq::SliceRandom;
4646
use rayon::prelude::*;
4747
use sensitive_url::SensitiveUrl;
4848
use slot_clock::{SlotClock, TestingSlotClock};
49+
use ssz_types::RuntimeVariableList;
4950
use state_processing::per_block_processing::compute_timestamp_at_slot;
5051
use state_processing::state_advance::complete_state_advance;
5152
use std::borrow::Cow;

beacon_node/execution_layer/src/test_utils/mock_builder.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::test_utils::{DEFAULT_BUILDER_PAYLOAD_VALUE_WEI, DEFAULT_JWT_SECRET};
22
use crate::{Config, ExecutionLayer, PayloadAttributes, PayloadParameters};
33
use bytes::Bytes;
4+
use eth2::beacon_response::ForkVersionedResponse;
45
use eth2::types::PublishBlockRequest;
56
use eth2::types::{
67
BlobsBundle, BlockId, BroadcastValidation, EndpointVersion, EventKind, EventTopic,
@@ -31,9 +32,9 @@ use types::builder_bid::{
3132
};
3233
use types::{
3334
Address, BeaconState, ChainSpec, Epoch, EthSpec, ExecPayload, ExecutionPayload,
34-
ExecutionPayloadHeaderRefMut, ExecutionRequests, ForkName, ForkVersionDecode,
35-
ForkVersionedResponse, Hash256, PublicKeyBytes, Signature, SignedBlindedBeaconBlock,
36-
SignedRoot, SignedValidatorRegistrationData, Slot, Uint256,
35+
ExecutionPayloadHeaderRefMut, ExecutionRequests, ForkName, ForkVersionDecode, Hash256,
36+
PublicKeyBytes, Signature, SignedBlindedBeaconBlock, SignedRoot,
37+
SignedValidatorRegistrationData, Slot, Uint256,
3738
};
3839
use types::{ExecutionBlockHash, SecretKey};
3940
use warp::reply::{self, Reply};

beacon_node/http_api/src/block_id.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use crate::version::inconsistent_fork_rejection;
22
use crate::{ExecutionOptimistic, state_id::checkpoint_slot_and_execution_optimistic};
33
use beacon_chain::kzg_utils::reconstruct_blobs;
44
use beacon_chain::{BeaconChain, BeaconChainError, BeaconChainTypes, WhenSlotSkipped};
5+
use eth2::beacon_response::{ExecutionOptimisticFinalizedMetadata, UnversionedResponse};
56
use eth2::types::BlockId as CoreBlockId;
67
use eth2::types::DataColumnIndicesQuery;
78
use eth2::types::{BlobIndicesQuery, BlobWrapper, BlobsVersionedHashesQuery};
@@ -10,8 +11,7 @@ use std::str::FromStr;
1011
use std::sync::Arc;
1112
use types::{
1213
BlobSidecarList, DataColumnSidecarList, EthSpec, FixedBytesExtended, ForkName, Hash256,
13-
SignedBeaconBlock, SignedBlindedBeaconBlock, Slot, UnversionedResponse,
14-
beacon_response::ExecutionOptimisticFinalizedMetadata,
14+
SignedBeaconBlock, SignedBlindedBeaconBlock, Slot,
1515
};
1616
use warp::Rejection;
1717

beacon_node/http_api/src/light_client.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ use crate::version::{
33
beacon_response,
44
};
55
use beacon_chain::{BeaconChain, BeaconChainError, BeaconChainTypes};
6+
use eth2::beacon_response::BeaconResponse;
67
use eth2::types::{
78
self as api_types, LightClientUpdate, LightClientUpdateResponseChunk,
89
LightClientUpdateResponseChunkInner, LightClientUpdatesQuery,
910
};
1011
use ssz::Encode;
1112
use std::sync::Arc;
12-
use types::{BeaconResponse, EthSpec, ForkName, Hash256, LightClientBootstrap};
13+
use types::{EthSpec, ForkName, Hash256, LightClientBootstrap};
1314
use warp::{
1415
Rejection,
1516
hyper::{Body, Response},

0 commit comments

Comments
 (0)