Use E for EthSpec globally (#5264)

* Use `E` for `EthSpec` globally

* Fix tests

* Merge branch 'unstable' into e-ethspec

* Merge branch 'unstable' into e-ethspec

# Conflicts:
#	beacon_node/execution_layer/src/engine_api.rs
#	beacon_node/execution_layer/src/engine_api/http.rs
#	beacon_node/execution_layer/src/engine_api/json_structures.rs
#	beacon_node/execution_layer/src/test_utils/handle_rpc.rs
#	beacon_node/store/src/partial_beacon_state.rs
#	consensus/types/src/beacon_block.rs
#	consensus/types/src/beacon_block_body.rs
#	consensus/types/src/beacon_state.rs
#	consensus/types/src/config_and_preset.rs
#	consensus/types/src/execution_payload.rs
#	consensus/types/src/execution_payload_header.rs
#	consensus/types/src/light_client_optimistic_update.rs
#	consensus/types/src/payload.rs
#	lcli/src/parse_ssz.rs
This commit is contained in:
Mac L
2024-04-03 02:12:25 +11:00
committed by GitHub
parent f8fdb71f50
commit 969d12dc6f
230 changed files with 2743 additions and 2792 deletions

View File

@@ -91,11 +91,11 @@ pub struct Ping {
variant_attributes(derive(Clone, Debug, PartialEq, Serialize),)
)]
#[derive(Clone, Debug, PartialEq)]
pub struct MetadataRequest<T: EthSpec> {
_phantom_data: PhantomData<T>,
pub struct MetadataRequest<E: EthSpec> {
_phantom_data: PhantomData<E>,
}
impl<T: EthSpec> MetadataRequest<T> {
impl<E: EthSpec> MetadataRequest<E> {
pub fn new_v1() -> Self {
Self::V1(MetadataRequestV1 {
_phantom_data: PhantomData,
@@ -114,22 +114,22 @@ impl<T: EthSpec> MetadataRequest<T> {
variants(V1, V2),
variant_attributes(
derive(Encode, Decode, Clone, Debug, PartialEq, Serialize),
serde(bound = "T: EthSpec", deny_unknown_fields),
serde(bound = "E: EthSpec", deny_unknown_fields),
)
)]
#[derive(Clone, Debug, PartialEq, Serialize)]
#[serde(bound = "T: EthSpec")]
pub struct MetaData<T: EthSpec> {
#[serde(bound = "E: EthSpec")]
pub struct MetaData<E: EthSpec> {
/// A sequential counter indicating when data gets modified.
pub seq_number: u64,
/// The persistent attestation subnet bitfield.
pub attnets: EnrAttestationBitfield<T>,
pub attnets: EnrAttestationBitfield<E>,
/// The persistent sync committee bitfield.
#[superstruct(only(V2))]
pub syncnets: EnrSyncCommitteeBitfield<T>,
pub syncnets: EnrSyncCommitteeBitfield<E>,
}
impl<T: EthSpec> MetaData<T> {
impl<E: EthSpec> MetaData<E> {
/// Returns a V1 MetaData response from self.
pub fn metadata_v1(&self) -> Self {
match self {
@@ -373,31 +373,31 @@ impl BlobsByRootRequest {
// Collection of enums and structs used by the Codecs to encode/decode RPC messages
#[derive(Debug, Clone, PartialEq)]
pub enum RPCResponse<T: EthSpec> {
pub enum RPCResponse<E: EthSpec> {
/// A HELLO message.
Status(StatusMessage),
/// A response to a get BLOCKS_BY_RANGE request. A None response signifies the end of the
/// batch.
BlocksByRange(Arc<SignedBeaconBlock<T>>),
BlocksByRange(Arc<SignedBeaconBlock<E>>),
/// A response to a get BLOCKS_BY_ROOT request.
BlocksByRoot(Arc<SignedBeaconBlock<T>>),
BlocksByRoot(Arc<SignedBeaconBlock<E>>),
/// A response to a get BLOBS_BY_RANGE request
BlobsByRange(Arc<BlobSidecar<T>>),
BlobsByRange(Arc<BlobSidecar<E>>),
/// A response to a get LIGHT_CLIENT_BOOTSTRAP request.
LightClientBootstrap(Arc<LightClientBootstrap<T>>),
LightClientBootstrap(Arc<LightClientBootstrap<E>>),
/// A response to a get BLOBS_BY_ROOT request.
BlobsByRoot(Arc<BlobSidecar<T>>),
BlobsByRoot(Arc<BlobSidecar<E>>),
/// A PONG response to a PING request.
Pong(Ping),
/// A response to a META_DATA request.
MetaData(MetaData<T>),
MetaData(MetaData<E>),
}
/// Indicates which response is being terminated by a stream termination response.
@@ -419,9 +419,9 @@ pub enum ResponseTermination {
/// The structured response containing a result/code indicating success or failure
/// and the contents of the response
#[derive(Debug, Clone)]
pub enum RPCCodedResponse<T: EthSpec> {
pub enum RPCCodedResponse<E: EthSpec> {
/// The response is a successful.
Success(RPCResponse<T>),
Success(RPCResponse<E>),
Error(RPCResponseErrorCode, ErrorType),
@@ -448,7 +448,7 @@ pub enum RPCResponseErrorCode {
Unknown,
}
impl<T: EthSpec> RPCCodedResponse<T> {
impl<E: EthSpec> RPCCodedResponse<E> {
/// Used to encode the response in the codec.
pub fn as_u8(&self) -> Option<u8> {
match self {
@@ -515,7 +515,7 @@ impl RPCResponseErrorCode {
}
use super::Protocol;
impl<T: EthSpec> RPCResponse<T> {
impl<E: EthSpec> RPCResponse<E> {
pub fn protocol(&self) -> Protocol {
match self {
RPCResponse::Status(_) => Protocol::Status,
@@ -550,7 +550,7 @@ impl std::fmt::Display for StatusMessage {
}
}
impl<T: EthSpec> std::fmt::Display for RPCResponse<T> {
impl<E: EthSpec> std::fmt::Display for RPCResponse<E> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
RPCResponse::Status(status) => write!(f, "{}", status),
@@ -575,7 +575,7 @@ impl<T: EthSpec> std::fmt::Display for RPCResponse<T> {
}
}
impl<T: EthSpec> std::fmt::Display for RPCCodedResponse<T> {
impl<E: EthSpec> std::fmt::Display for RPCCodedResponse<E> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
RPCCodedResponse::Success(res) => write!(f, "{}", res),