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

@@ -834,9 +834,9 @@ impl BeaconNodeHttpClient {
/// `POST beacon/blocks`
///
/// Returns `Ok(None)` on a 404 error.
pub async fn post_beacon_blocks<T: EthSpec>(
pub async fn post_beacon_blocks<E: EthSpec>(
&self,
block_contents: &PublishBlockRequest<T>,
block_contents: &PublishBlockRequest<E>,
) -> Result<(), Error> {
let mut path = self.eth_path(V1)?;
@@ -854,9 +854,9 @@ impl BeaconNodeHttpClient {
/// `POST beacon/blocks`
///
/// Returns `Ok(None)` on a 404 error.
pub async fn post_beacon_blocks_ssz<T: EthSpec>(
pub async fn post_beacon_blocks_ssz<E: EthSpec>(
&self,
block_contents: &PublishBlockRequest<T>,
block_contents: &PublishBlockRequest<E>,
) -> Result<(), Error> {
let mut path = self.eth_path(V1)?;
@@ -879,9 +879,9 @@ impl BeaconNodeHttpClient {
/// `POST beacon/blinded_blocks`
///
/// Returns `Ok(None)` on a 404 error.
pub async fn post_beacon_blinded_blocks<T: EthSpec>(
pub async fn post_beacon_blinded_blocks<E: EthSpec>(
&self,
block: &SignedBlindedBeaconBlock<T>,
block: &SignedBlindedBeaconBlock<E>,
) -> Result<(), Error> {
let mut path = self.eth_path(V1)?;
@@ -899,9 +899,9 @@ impl BeaconNodeHttpClient {
/// `POST beacon/blinded_blocks`
///
/// Returns `Ok(None)` on a 404 error.
pub async fn post_beacon_blinded_blocks_ssz<T: EthSpec>(
pub async fn post_beacon_blinded_blocks_ssz<E: EthSpec>(
&self,
block: &SignedBlindedBeaconBlock<T>,
block: &SignedBlindedBeaconBlock<E>,
) -> Result<(), Error> {
let mut path = self.eth_path(V1)?;
@@ -958,9 +958,9 @@ impl BeaconNodeHttpClient {
}
/// `POST v2/beacon/blocks`
pub async fn post_beacon_blocks_v2<T: EthSpec>(
pub async fn post_beacon_blocks_v2<E: EthSpec>(
&self,
block_contents: &PublishBlockRequest<T>,
block_contents: &PublishBlockRequest<E>,
validation_level: Option<BroadcastValidation>,
) -> Result<(), Error> {
self.post_generic_with_consensus_version(
@@ -975,9 +975,9 @@ impl BeaconNodeHttpClient {
}
/// `POST v2/beacon/blocks`
pub async fn post_beacon_blocks_v2_ssz<T: EthSpec>(
pub async fn post_beacon_blocks_v2_ssz<E: EthSpec>(
&self,
block_contents: &PublishBlockRequest<T>,
block_contents: &PublishBlockRequest<E>,
validation_level: Option<BroadcastValidation>,
) -> Result<(), Error> {
self.post_generic_with_consensus_version_and_ssz_body(
@@ -992,9 +992,9 @@ impl BeaconNodeHttpClient {
}
/// `POST v2/beacon/blinded_blocks`
pub async fn post_beacon_blinded_blocks_v2<T: EthSpec>(
pub async fn post_beacon_blinded_blocks_v2<E: EthSpec>(
&self,
signed_block: &SignedBlindedBeaconBlock<T>,
signed_block: &SignedBlindedBeaconBlock<E>,
validation_level: Option<BroadcastValidation>,
) -> Result<(), Error> {
self.post_generic_with_consensus_version(
@@ -1009,9 +1009,9 @@ impl BeaconNodeHttpClient {
}
/// `POST v2/beacon/blinded_blocks`
pub async fn post_beacon_blinded_blocks_v2_ssz<T: EthSpec>(
pub async fn post_beacon_blinded_blocks_v2_ssz<E: EthSpec>(
&self,
signed_block: &SignedBlindedBeaconBlock<T>,
signed_block: &SignedBlindedBeaconBlock<E>,
validation_level: Option<BroadcastValidation>,
) -> Result<(), Error> {
self.post_generic_with_consensus_version_and_ssz_body(
@@ -1061,11 +1061,11 @@ impl BeaconNodeHttpClient {
/// `GET v2/beacon/blocks`
///
/// Returns `Ok(None)` on a 404 error.
pub async fn get_beacon_blocks<T: EthSpec>(
pub async fn get_beacon_blocks<E: EthSpec>(
&self,
block_id: BlockId,
) -> Result<
Option<ExecutionOptimisticFinalizedForkVersionedResponse<SignedBeaconBlock<T>>>,
Option<ExecutionOptimisticFinalizedForkVersionedResponse<SignedBeaconBlock<E>>>,
Error,
> {
let path = self.get_beacon_blocks_path(block_id)?;
@@ -1079,11 +1079,11 @@ impl BeaconNodeHttpClient {
/// `GET v1/beacon/blob_sidecars/{block_id}`
///
/// Returns `Ok(None)` on a 404 error.
pub async fn get_blobs<T: EthSpec>(
pub async fn get_blobs<E: EthSpec>(
&self,
block_id: BlockId,
indices: Option<&[u64]>,
) -> Result<Option<GenericResponse<BlobSidecarList<T>>>, Error> {
) -> Result<Option<GenericResponse<BlobSidecarList<E>>>, Error> {
let mut path = self.get_blobs_path(block_id)?;
if let Some(indices) = indices {
let indices_string = indices
@@ -1094,6 +1094,7 @@ impl BeaconNodeHttpClient {
path.query_pairs_mut()
.append_pair("indices", &indices_string);
}
let Some(response) = self.get_response(path, |b| b).await.optional()? else {
return Ok(None);
};
@@ -1104,11 +1105,11 @@ impl BeaconNodeHttpClient {
/// `GET v1/beacon/blinded_blocks/{block_id}`
///
/// Returns `Ok(None)` on a 404 error.
pub async fn get_beacon_blinded_blocks<T: EthSpec>(
pub async fn get_beacon_blinded_blocks<E: EthSpec>(
&self,
block_id: BlockId,
) -> Result<
Option<ExecutionOptimisticFinalizedForkVersionedResponse<SignedBlindedBeaconBlock<T>>>,
Option<ExecutionOptimisticFinalizedForkVersionedResponse<SignedBlindedBeaconBlock<E>>>,
Error,
> {
let path = self.get_beacon_blinded_blocks_path(block_id)?;
@@ -1122,10 +1123,10 @@ impl BeaconNodeHttpClient {
/// `GET v1/beacon/blocks` (LEGACY)
///
/// Returns `Ok(None)` on a 404 error.
pub async fn get_beacon_blocks_v1<T: EthSpec>(
pub async fn get_beacon_blocks_v1<E: EthSpec>(
&self,
block_id: BlockId,
) -> Result<Option<ForkVersionedResponse<SignedBeaconBlock<T>>>, Error> {
) -> Result<Option<ForkVersionedResponse<SignedBeaconBlock<E>>>, Error> {
let mut path = self.eth_path(V1)?;
path.path_segments_mut()
@@ -1140,11 +1141,11 @@ impl BeaconNodeHttpClient {
/// `GET beacon/blocks` as SSZ
///
/// Returns `Ok(None)` on a 404 error.
pub async fn get_beacon_blocks_ssz<T: EthSpec>(
pub async fn get_beacon_blocks_ssz<E: EthSpec>(
&self,
block_id: BlockId,
spec: &ChainSpec,
) -> Result<Option<SignedBeaconBlock<T>>, Error> {
) -> Result<Option<SignedBeaconBlock<E>>, Error> {
let path = self.get_beacon_blocks_path(block_id)?;
self.get_bytes_opt_accept_header(path, Accept::Ssz, self.timeouts.get_beacon_blocks_ssz)
@@ -1156,11 +1157,11 @@ impl BeaconNodeHttpClient {
/// `GET beacon/blinded_blocks/{block_id}` as SSZ
///
/// Returns `Ok(None)` on a 404 error.
pub async fn get_beacon_blinded_blocks_ssz<T: EthSpec>(
pub async fn get_beacon_blinded_blocks_ssz<E: EthSpec>(
&self,
block_id: BlockId,
spec: &ChainSpec,
) -> Result<Option<SignedBlindedBeaconBlock<T>>, Error> {
) -> Result<Option<SignedBlindedBeaconBlock<E>>, Error> {
let path = self.get_beacon_blinded_blocks_path(block_id)?;
self.get_bytes_opt_accept_header(path, Accept::Ssz, self.timeouts.get_beacon_blocks_ssz)
@@ -1193,10 +1194,10 @@ impl BeaconNodeHttpClient {
/// `GET beacon/blocks/{block_id}/attestations`
///
/// Returns `Ok(None)` on a 404 error.
pub async fn get_beacon_blocks_attestations<T: EthSpec>(
pub async fn get_beacon_blocks_attestations<E: EthSpec>(
&self,
block_id: BlockId,
) -> Result<Option<ExecutionOptimisticFinalizedResponse<Vec<Attestation<T>>>>, Error> {
) -> Result<Option<ExecutionOptimisticFinalizedResponse<Vec<Attestation<E>>>>, Error> {
let mut path = self.eth_path(V1)?;
path.path_segments_mut()
@@ -1210,9 +1211,9 @@ impl BeaconNodeHttpClient {
}
/// `POST beacon/pool/attestations`
pub async fn post_beacon_pool_attestations<T: EthSpec>(
pub async fn post_beacon_pool_attestations<E: EthSpec>(
&self,
attestations: &[Attestation<T>],
attestations: &[Attestation<E>],
) -> Result<(), Error> {
let mut path = self.eth_path(V1)?;
@@ -1229,11 +1230,11 @@ impl BeaconNodeHttpClient {
}
/// `GET beacon/pool/attestations?slot,committee_index`
pub async fn get_beacon_pool_attestations<T: EthSpec>(
pub async fn get_beacon_pool_attestations<E: EthSpec>(
&self,
slot: Option<Slot>,
committee_index: Option<u64>,
) -> Result<GenericResponse<Vec<Attestation<T>>>, Error> {
) -> Result<GenericResponse<Vec<Attestation<E>>>, Error> {
let mut path = self.eth_path(V1)?;
path.path_segments_mut()
@@ -1256,9 +1257,9 @@ impl BeaconNodeHttpClient {
}
/// `POST beacon/pool/attester_slashings`
pub async fn post_beacon_pool_attester_slashings<T: EthSpec>(
pub async fn post_beacon_pool_attester_slashings<E: EthSpec>(
&self,
slashing: &AttesterSlashing<T>,
slashing: &AttesterSlashing<E>,
) -> Result<(), Error> {
let mut path = self.eth_path(V1)?;
@@ -1275,9 +1276,9 @@ impl BeaconNodeHttpClient {
}
/// `GET beacon/pool/attester_slashings`
pub async fn get_beacon_pool_attester_slashings<T: EthSpec>(
pub async fn get_beacon_pool_attester_slashings<E: EthSpec>(
&self,
) -> Result<GenericResponse<Vec<AttesterSlashing<T>>>, Error> {
) -> Result<GenericResponse<Vec<AttesterSlashing<E>>>, Error> {
let mut path = self.eth_path(V1)?;
path.path_segments_mut()
@@ -1473,9 +1474,9 @@ impl BeaconNodeHttpClient {
}
/// `POST validator/contribution_and_proofs`
pub async fn post_validator_contribution_and_proofs<T: EthSpec>(
pub async fn post_validator_contribution_and_proofs<E: EthSpec>(
&self,
signed_contributions: &[SignedContributionAndProof<T>],
signed_contributions: &[SignedContributionAndProof<E>],
) -> Result<(), Error> {
let mut path = self.eth_path(V1)?;
@@ -1697,10 +1698,10 @@ impl BeaconNodeHttpClient {
}
/// `GET v2/debug/beacon/states/{state_id}`
pub async fn get_debug_beacon_states<T: EthSpec>(
pub async fn get_debug_beacon_states<E: EthSpec>(
&self,
state_id: StateId,
) -> Result<Option<ExecutionOptimisticFinalizedForkVersionedResponse<BeaconState<T>>>, Error>
) -> Result<Option<ExecutionOptimisticFinalizedForkVersionedResponse<BeaconState<E>>>, Error>
{
let path = self.get_debug_beacon_states_path(state_id)?;
self.get_opt(path).await
@@ -1708,11 +1709,11 @@ impl BeaconNodeHttpClient {
/// `GET debug/beacon/states/{state_id}`
/// `-H "accept: application/octet-stream"`
pub async fn get_debug_beacon_states_ssz<T: EthSpec>(
pub async fn get_debug_beacon_states_ssz<E: EthSpec>(
&self,
state_id: StateId,
spec: &ChainSpec,
) -> Result<Option<BeaconState<T>>, Error> {
) -> Result<Option<BeaconState<E>>, Error> {
let path = self.get_debug_beacon_states_path(state_id)?;
self.get_bytes_opt_accept_header(path, Accept::Ssz, self.timeouts.get_debug_beacon_states)
@@ -1782,33 +1783,33 @@ impl BeaconNodeHttpClient {
}
/// `GET v2/validator/blocks/{slot}`
pub async fn get_validator_blocks<T: EthSpec>(
pub async fn get_validator_blocks<E: EthSpec>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
graffiti: Option<&Graffiti>,
) -> Result<ForkVersionedResponse<FullBlockContents<T>>, Error> {
) -> Result<ForkVersionedResponse<FullBlockContents<E>>, Error> {
self.get_validator_blocks_modular(slot, randao_reveal, graffiti, SkipRandaoVerification::No)
.await
}
/// `GET v2/validator/blocks/{slot}`
pub async fn get_validator_blocks_modular<T: EthSpec>(
pub async fn get_validator_blocks_modular<E: EthSpec>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
graffiti: Option<&Graffiti>,
skip_randao_verification: SkipRandaoVerification,
) -> Result<ForkVersionedResponse<FullBlockContents<T>>, Error> {
) -> Result<ForkVersionedResponse<FullBlockContents<E>>, Error> {
let path = self
.get_validator_blocks_path::<T>(slot, randao_reveal, graffiti, skip_randao_verification)
.get_validator_blocks_path::<E>(slot, randao_reveal, graffiti, skip_randao_verification)
.await?;
self.get(path).await
}
/// returns `GET v2/validator/blocks/{slot}` URL path
pub async fn get_validator_blocks_path<T: EthSpec>(
pub async fn get_validator_blocks_path<E: EthSpec>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
@@ -1878,13 +1879,13 @@ impl BeaconNodeHttpClient {
}
/// `GET v3/validator/blocks/{slot}`
pub async fn get_validator_blocks_v3<T: EthSpec>(
pub async fn get_validator_blocks_v3<E: EthSpec>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
graffiti: Option<&Graffiti>,
builder_booster_factor: Option<u64>,
) -> Result<(JsonProduceBlockV3Response<T>, ProduceBlockV3Metadata), Error> {
) -> Result<(JsonProduceBlockV3Response<E>, ProduceBlockV3Metadata), Error> {
self.get_validator_blocks_v3_modular(
slot,
randao_reveal,
@@ -1896,14 +1897,14 @@ impl BeaconNodeHttpClient {
}
/// `GET v3/validator/blocks/{slot}`
pub async fn get_validator_blocks_v3_modular<T: EthSpec>(
pub async fn get_validator_blocks_v3_modular<E: EthSpec>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
graffiti: Option<&Graffiti>,
skip_randao_verification: SkipRandaoVerification,
builder_booster_factor: Option<u64>,
) -> Result<(JsonProduceBlockV3Response<T>, ProduceBlockV3Metadata), Error> {
) -> Result<(JsonProduceBlockV3Response<E>, ProduceBlockV3Metadata), Error> {
let path = self
.get_validator_blocks_v3_path(
slot,
@@ -1924,14 +1925,14 @@ impl BeaconNodeHttpClient {
.map_err(Error::InvalidHeaders)?;
if header_metadata.execution_payload_blinded {
let blinded_response = response
.json::<ForkVersionedResponse<BlindedBeaconBlock<T>,
.json::<ForkVersionedResponse<BlindedBeaconBlock<E>,
ProduceBlockV3Metadata>>()
.await?
.map_data(ProduceBlockV3Response::Blinded);
Ok((blinded_response, header_metadata))
} else {
let full_block_response= response
.json::<ForkVersionedResponse<FullBlockContents<T>,
.json::<ForkVersionedResponse<FullBlockContents<E>,
ProduceBlockV3Metadata>>()
.await?
.map_data(ProduceBlockV3Response::Full);
@@ -1947,14 +1948,14 @@ impl BeaconNodeHttpClient {
}
/// `GET v3/validator/blocks/{slot}` in ssz format
pub async fn get_validator_blocks_v3_ssz<T: EthSpec>(
pub async fn get_validator_blocks_v3_ssz<E: EthSpec>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
graffiti: Option<&Graffiti>,
builder_booster_factor: Option<u64>,
) -> Result<(ProduceBlockV3Response<T>, ProduceBlockV3Metadata), Error> {
self.get_validator_blocks_v3_modular_ssz::<T>(
) -> Result<(ProduceBlockV3Response<E>, ProduceBlockV3Metadata), Error> {
self.get_validator_blocks_v3_modular_ssz::<E>(
slot,
randao_reveal,
graffiti,
@@ -1965,14 +1966,14 @@ impl BeaconNodeHttpClient {
}
/// `GET v3/validator/blocks/{slot}` in ssz format
pub async fn get_validator_blocks_v3_modular_ssz<T: EthSpec>(
pub async fn get_validator_blocks_v3_modular_ssz<E: EthSpec>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
graffiti: Option<&Graffiti>,
skip_randao_verification: SkipRandaoVerification,
builder_booster_factor: Option<u64>,
) -> Result<(ProduceBlockV3Response<T>, ProduceBlockV3Metadata), Error> {
) -> Result<(ProduceBlockV3Response<E>, ProduceBlockV3Metadata), Error> {
let path = self
.get_validator_blocks_v3_path(
slot,
@@ -2023,13 +2024,13 @@ impl BeaconNodeHttpClient {
}
/// `GET v2/validator/blocks/{slot}` in ssz format
pub async fn get_validator_blocks_ssz<T: EthSpec>(
pub async fn get_validator_blocks_ssz<E: EthSpec>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
graffiti: Option<&Graffiti>,
) -> Result<Option<Vec<u8>>, Error> {
self.get_validator_blocks_modular_ssz::<T>(
self.get_validator_blocks_modular_ssz::<E>(
slot,
randao_reveal,
graffiti,
@@ -2039,7 +2040,7 @@ impl BeaconNodeHttpClient {
}
/// `GET v2/validator/blocks/{slot}` in ssz format
pub async fn get_validator_blocks_modular_ssz<T: EthSpec>(
pub async fn get_validator_blocks_modular_ssz<E: EthSpec>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
@@ -2047,7 +2048,7 @@ impl BeaconNodeHttpClient {
skip_randao_verification: SkipRandaoVerification,
) -> Result<Option<Vec<u8>>, Error> {
let path = self
.get_validator_blocks_path::<T>(slot, randao_reveal, graffiti, skip_randao_verification)
.get_validator_blocks_path::<E>(slot, randao_reveal, graffiti, skip_randao_verification)
.await?;
self.get_bytes_opt_accept_header(path, Accept::Ssz, self.timeouts.get_validator_block)
@@ -2055,12 +2056,12 @@ impl BeaconNodeHttpClient {
}
/// `GET v2/validator/blinded_blocks/{slot}`
pub async fn get_validator_blinded_blocks<T: EthSpec>(
pub async fn get_validator_blinded_blocks<E: EthSpec>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
graffiti: Option<&Graffiti>,
) -> Result<ForkVersionedResponse<BlindedBeaconBlock<T>>, Error> {
) -> Result<ForkVersionedResponse<BlindedBeaconBlock<E>>, Error> {
self.get_validator_blinded_blocks_modular(
slot,
randao_reveal,
@@ -2071,7 +2072,7 @@ impl BeaconNodeHttpClient {
}
/// returns `GET v1/validator/blinded_blocks/{slot}` URL path
pub async fn get_validator_blinded_blocks_path<T: EthSpec>(
pub async fn get_validator_blinded_blocks_path<E: EthSpec>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
@@ -2103,15 +2104,15 @@ impl BeaconNodeHttpClient {
}
/// `GET v1/validator/blinded_blocks/{slot}`
pub async fn get_validator_blinded_blocks_modular<T: EthSpec>(
pub async fn get_validator_blinded_blocks_modular<E: EthSpec>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
graffiti: Option<&Graffiti>,
skip_randao_verification: SkipRandaoVerification,
) -> Result<ForkVersionedResponse<BlindedBeaconBlock<T>>, Error> {
) -> Result<ForkVersionedResponse<BlindedBeaconBlock<E>>, Error> {
let path = self
.get_validator_blinded_blocks_path::<T>(
.get_validator_blinded_blocks_path::<E>(
slot,
randao_reveal,
graffiti,
@@ -2123,13 +2124,13 @@ impl BeaconNodeHttpClient {
}
/// `GET v2/validator/blinded_blocks/{slot}` in ssz format
pub async fn get_validator_blinded_blocks_ssz<T: EthSpec>(
pub async fn get_validator_blinded_blocks_ssz<E: EthSpec>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
graffiti: Option<&Graffiti>,
) -> Result<Option<Vec<u8>>, Error> {
self.get_validator_blinded_blocks_modular_ssz::<T>(
self.get_validator_blinded_blocks_modular_ssz::<E>(
slot,
randao_reveal,
graffiti,
@@ -2138,7 +2139,7 @@ impl BeaconNodeHttpClient {
.await
}
pub async fn get_validator_blinded_blocks_modular_ssz<T: EthSpec>(
pub async fn get_validator_blinded_blocks_modular_ssz<E: EthSpec>(
&self,
slot: Slot,
randao_reveal: &SignatureBytes,
@@ -2146,7 +2147,7 @@ impl BeaconNodeHttpClient {
skip_randao_verification: SkipRandaoVerification,
) -> Result<Option<Vec<u8>>, Error> {
let path = self
.get_validator_blinded_blocks_path::<T>(
.get_validator_blinded_blocks_path::<E>(
slot,
randao_reveal,
graffiti,
@@ -2179,11 +2180,11 @@ impl BeaconNodeHttpClient {
}
/// `GET validator/aggregate_attestation?slot,attestation_data_root`
pub async fn get_validator_aggregate_attestation<T: EthSpec>(
pub async fn get_validator_aggregate_attestation<E: EthSpec>(
&self,
slot: Slot,
attestation_data_root: Hash256,
) -> Result<Option<GenericResponse<Attestation<T>>>, Error> {
) -> Result<Option<GenericResponse<Attestation<E>>>, Error> {
let mut path = self.eth_path(V1)?;
path.path_segments_mut()
@@ -2203,10 +2204,10 @@ impl BeaconNodeHttpClient {
}
/// `GET validator/sync_committee_contribution`
pub async fn get_validator_sync_committee_contribution<T: EthSpec>(
pub async fn get_validator_sync_committee_contribution<E: EthSpec>(
&self,
sync_committee_data: &SyncContributionData,
) -> Result<Option<GenericResponse<SyncCommitteeContribution<T>>>, Error> {
) -> Result<Option<GenericResponse<SyncCommitteeContribution<E>>>, Error> {
let mut path = self.eth_path(V1)?;
path.path_segments_mut()
@@ -2298,9 +2299,9 @@ impl BeaconNodeHttpClient {
}
/// `POST validator/aggregate_and_proofs`
pub async fn post_validator_aggregate_and_proof<T: EthSpec>(
pub async fn post_validator_aggregate_and_proof<E: EthSpec>(
&self,
aggregates: &[SignedAggregateAndProof<T>],
aggregates: &[SignedAggregateAndProof<E>],
) -> Result<(), Error> {
let mut path = self.eth_path(V1)?;
@@ -2350,10 +2351,10 @@ impl BeaconNodeHttpClient {
}
/// `GET events?topics`
pub async fn get_events<T: EthSpec>(
pub async fn get_events<E: EthSpec>(
&self,
topic: &[EventTopic],
) -> Result<impl Stream<Item = Result<EventKind<T>, Error>>, Error> {
) -> Result<impl Stream<Item = Result<EventKind<E>, Error>>, Error> {
let mut path = self.eth_path(V1)?;
path.path_segments_mut()
.map_err(|()| Error::InvalidUrl(self.server.clone()))?

View File

@@ -39,12 +39,12 @@ four_byte_option_impl!(four_byte_option_hash256, Hash256);
/// Information returned by `peers` and `connected_peers`.
// TODO: this should be deserializable..
#[derive(Debug, Clone, Serialize)]
#[serde(bound = "T: EthSpec")]
pub struct Peer<T: EthSpec> {
#[serde(bound = "E: EthSpec")]
pub struct Peer<E: EthSpec> {
/// The Peer's ID
pub peer_id: String,
/// The PeerInfo associated with the peer.
pub peer_info: PeerInfo<T>,
pub peer_info: PeerInfo<E>,
}
/// The results of validators voting during an epoch.

View File

@@ -1064,25 +1064,25 @@ impl ForkVersionDeserialize for SseExtendedPayloadAttributes {
}
#[derive(PartialEq, Debug, Serialize, Clone)]
#[serde(bound = "T: EthSpec", untagged)]
pub enum EventKind<T: EthSpec> {
Attestation(Box<Attestation<T>>),
#[serde(bound = "E: EthSpec", untagged)]
pub enum EventKind<E: EthSpec> {
Attestation(Box<Attestation<E>>),
Block(SseBlock),
BlobSidecar(SseBlobSidecar),
FinalizedCheckpoint(SseFinalizedCheckpoint),
Head(SseHead),
VoluntaryExit(SignedVoluntaryExit),
ChainReorg(SseChainReorg),
ContributionAndProof(Box<SignedContributionAndProof<T>>),
ContributionAndProof(Box<SignedContributionAndProof<E>>),
LateHead(SseLateHead),
LightClientFinalityUpdate(Box<LightClientFinalityUpdate<T>>),
LightClientOptimisticUpdate(Box<LightClientOptimisticUpdate<T>>),
LightClientFinalityUpdate(Box<LightClientFinalityUpdate<E>>),
LightClientOptimisticUpdate(Box<LightClientOptimisticUpdate<E>>),
#[cfg(feature = "lighthouse")]
BlockReward(BlockReward),
PayloadAttributes(VersionedSsePayloadAttributes),
}
impl<T: EthSpec> EventKind<T> {
impl<E: EthSpec> EventKind<E> {
pub fn topic_name(&self) -> &str {
match self {
EventKind::Head(_) => "head",
@@ -1533,16 +1533,16 @@ pub type JsonProduceBlockV3Response<E> =
/// A wrapper over a [`BeaconBlock`] or a [`BlockContents`].
#[derive(Debug, Encode, Serialize, Deserialize)]
#[serde(untagged)]
#[serde(bound = "T: EthSpec")]
#[serde(bound = "E: EthSpec")]
#[ssz(enum_behaviour = "transparent")]
pub enum FullBlockContents<T: EthSpec> {
pub enum FullBlockContents<E: EthSpec> {
/// This is a full deneb variant with block and blobs.
BlockContents(BlockContents<T>),
BlockContents(BlockContents<E>),
/// This variant is for all pre-deneb full blocks.
Block(BeaconBlock<T>),
Block(BeaconBlock<E>),
}
pub type BlockContentsTuple<T> = (BeaconBlock<T>, Option<(KzgProofs<T>, BlobsList<T>)>);
pub type BlockContentsTuple<E> = (BeaconBlock<E>, Option<(KzgProofs<E>, BlobsList<E>)>);
// This value should never be used
fn dummy_consensus_version() -> ForkName {
@@ -1566,8 +1566,8 @@ pub struct ProduceBlockV3Metadata {
pub consensus_block_value: Uint256,
}
impl<T: EthSpec> FullBlockContents<T> {
pub fn new(block: BeaconBlock<T>, blob_data: Option<(KzgProofs<T>, BlobsList<T>)>) -> Self {
impl<E: EthSpec> FullBlockContents<E> {
pub fn new(block: BeaconBlock<E>, blob_data: Option<(KzgProofs<E>, BlobsList<E>)>) -> Self {
match blob_data {
Some((kzg_proofs, blobs)) => Self::BlockContents(BlockContents {
block,
@@ -1588,7 +1588,7 @@ impl<T: EthSpec> FullBlockContents<T> {
expected: slot_len,
})?;
let slot = Slot::from_ssz_bytes(slot_bytes)?;
let fork_at_slot = spec.fork_name_at_slot::<T>(slot);
let fork_at_slot = spec.fork_name_at_slot::<E>(slot);
Self::from_ssz_bytes_for_fork(bytes, fork_at_slot)
}
@@ -1606,8 +1606,8 @@ impl<T: EthSpec> FullBlockContents<T> {
let mut builder = ssz::SszDecoderBuilder::new(bytes);
builder.register_anonymous_variable_length_item()?;
builder.register_type::<KzgProofs<T>>()?;
builder.register_type::<BlobsList<T>>()?;
builder.register_type::<KzgProofs<E>>()?;
builder.register_type::<BlobsList<E>>()?;
let mut decoder = builder.build()?;
let block = decoder.decode_next_with(|bytes| {
@@ -1621,14 +1621,14 @@ impl<T: EthSpec> FullBlockContents<T> {
}
}
pub fn block(&self) -> &BeaconBlock<T> {
pub fn block(&self) -> &BeaconBlock<E> {
match self {
FullBlockContents::BlockContents(block_and_sidecars) => &block_and_sidecars.block,
FullBlockContents::Block(block) => block,
}
}
pub fn deconstruct(self) -> BlockContentsTuple<T> {
pub fn deconstruct(self) -> BlockContentsTuple<E> {
match self {
FullBlockContents::BlockContents(block_and_sidecars) => (
block_and_sidecars.block,
@@ -1645,14 +1645,14 @@ impl<T: EthSpec> FullBlockContents<T> {
fork: &Fork,
genesis_validators_root: Hash256,
spec: &ChainSpec,
) -> PublishBlockRequest<T> {
) -> PublishBlockRequest<E> {
let (block, maybe_blobs) = self.deconstruct();
let signed_block = block.sign(secret_key, fork, genesis_validators_root, spec);
PublishBlockRequest::new(Arc::new(signed_block), maybe_blobs)
}
}
impl<T: EthSpec> ForkVersionDeserialize for FullBlockContents<T> {
impl<E: EthSpec> ForkVersionDeserialize for FullBlockContents<E> {
fn deserialize_by_fork<'de, D: serde::Deserializer<'de>>(
value: serde_json::value::Value,
fork_name: ForkName,
@@ -1670,8 +1670,8 @@ impl<T: EthSpec> ForkVersionDeserialize for FullBlockContents<T> {
}
}
impl<T: EthSpec> Into<BeaconBlock<T>> for FullBlockContents<T> {
fn into(self) -> BeaconBlock<T> {
impl<E: EthSpec> Into<BeaconBlock<E>> for FullBlockContents<E> {
fn into(self) -> BeaconBlock<E> {
match self {
Self::BlockContents(block_and_sidecars) => block_and_sidecars.block,
Self::Block(block) => block,
@@ -1679,9 +1679,9 @@ impl<T: EthSpec> Into<BeaconBlock<T>> for FullBlockContents<T> {
}
}
pub type SignedBlockContentsTuple<T> = (
Arc<SignedBeaconBlock<T>>,
Option<(KzgProofs<T>, BlobsList<T>)>,
pub type SignedBlockContentsTuple<E> = (
Arc<SignedBeaconBlock<E>>,
Option<(KzgProofs<E>, BlobsList<E>)>,
);
fn parse_required_header<T>(
@@ -1733,17 +1733,17 @@ impl TryFrom<&HeaderMap> for ProduceBlockV3Metadata {
/// A wrapper over a [`SignedBeaconBlock`] or a [`SignedBlockContents`].
#[derive(Clone, Debug, Encode, Serialize, Deserialize)]
#[serde(untagged)]
#[serde(bound = "T: EthSpec")]
#[serde(bound = "E: EthSpec")]
#[ssz(enum_behaviour = "transparent")]
pub enum PublishBlockRequest<T: EthSpec> {
BlockContents(SignedBlockContents<T>),
Block(Arc<SignedBeaconBlock<T>>),
pub enum PublishBlockRequest<E: EthSpec> {
BlockContents(SignedBlockContents<E>),
Block(Arc<SignedBeaconBlock<E>>),
}
impl<T: EthSpec> PublishBlockRequest<T> {
impl<E: EthSpec> PublishBlockRequest<E> {
pub fn new(
block: Arc<SignedBeaconBlock<T>>,
blob_items: Option<(KzgProofs<T>, BlobsList<T>)>,
block: Arc<SignedBeaconBlock<E>>,
blob_items: Option<(KzgProofs<E>, BlobsList<E>)>,
) -> Self {
match blob_items {
Some((kzg_proofs, blobs)) => Self::BlockContents(SignedBlockContents {
@@ -1765,8 +1765,8 @@ impl<T: EthSpec> PublishBlockRequest<T> {
ForkName::Deneb | ForkName::Electra => {
let mut builder = ssz::SszDecoderBuilder::new(bytes);
builder.register_anonymous_variable_length_item()?;
builder.register_type::<KzgProofs<T>>()?;
builder.register_type::<BlobsList<T>>()?;
builder.register_type::<KzgProofs<E>>()?;
builder.register_type::<BlobsList<E>>()?;
let mut decoder = builder.build()?;
let block = decoder.decode_next_with(|bytes| {
@@ -1782,7 +1782,7 @@ impl<T: EthSpec> PublishBlockRequest<T> {
}
}
pub fn signed_block(&self) -> &Arc<SignedBeaconBlock<T>> {
pub fn signed_block(&self) -> &Arc<SignedBeaconBlock<E>> {
match self {
PublishBlockRequest::BlockContents(block_and_sidecars) => {
&block_and_sidecars.signed_block
@@ -1791,7 +1791,7 @@ impl<T: EthSpec> PublishBlockRequest<T> {
}
}
pub fn deconstruct(self) -> SignedBlockContentsTuple<T> {
pub fn deconstruct(self) -> SignedBlockContentsTuple<E> {
match self {
PublishBlockRequest::BlockContents(block_and_sidecars) => (
block_and_sidecars.signed_block,
@@ -1803,10 +1803,10 @@ impl<T: EthSpec> PublishBlockRequest<T> {
}
/// Converting from a `SignedBlindedBeaconBlock` into a full `SignedBlockContents`.
pub fn into_full_block_and_blobs<T: EthSpec>(
blinded_block: SignedBlindedBeaconBlock<T>,
maybe_full_payload_contents: Option<FullPayloadContents<T>>,
) -> Result<PublishBlockRequest<T>, String> {
pub fn into_full_block_and_blobs<E: EthSpec>(
blinded_block: SignedBlindedBeaconBlock<E>,
maybe_full_payload_contents: Option<FullPayloadContents<E>>,
) -> Result<PublishBlockRequest<E>, String> {
match maybe_full_payload_contents {
None => {
let signed_block = blinded_block
@@ -1838,9 +1838,9 @@ pub fn into_full_block_and_blobs<T: EthSpec>(
}
}
impl<T: EthSpec> TryFrom<Arc<SignedBeaconBlock<T>>> for PublishBlockRequest<T> {
impl<E: EthSpec> TryFrom<Arc<SignedBeaconBlock<E>>> for PublishBlockRequest<E> {
type Error = &'static str;
fn try_from(block: Arc<SignedBeaconBlock<T>>) -> Result<Self, Self::Error> {
fn try_from(block: Arc<SignedBeaconBlock<E>>) -> Result<Self, Self::Error> {
match *block {
SignedBeaconBlock::Base(_)
| SignedBeaconBlock::Altair(_)
@@ -1853,44 +1853,44 @@ impl<T: EthSpec> TryFrom<Arc<SignedBeaconBlock<T>>> for PublishBlockRequest<T> {
}
}
impl<T: EthSpec> From<SignedBlockContentsTuple<T>> for PublishBlockRequest<T> {
fn from(block_contents_tuple: SignedBlockContentsTuple<T>) -> Self {
impl<E: EthSpec> From<SignedBlockContentsTuple<E>> for PublishBlockRequest<E> {
fn from(block_contents_tuple: SignedBlockContentsTuple<E>) -> Self {
PublishBlockRequest::new(block_contents_tuple.0, block_contents_tuple.1)
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Encode)]
#[serde(bound = "T: EthSpec")]
pub struct SignedBlockContents<T: EthSpec> {
pub signed_block: Arc<SignedBeaconBlock<T>>,
pub kzg_proofs: KzgProofs<T>,
#[serde(bound = "E: EthSpec")]
pub struct SignedBlockContents<E: EthSpec> {
pub signed_block: Arc<SignedBeaconBlock<E>>,
pub kzg_proofs: KzgProofs<E>,
#[serde(with = "ssz_types::serde_utils::list_of_hex_fixed_vec")]
pub blobs: BlobsList<T>,
pub blobs: BlobsList<E>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Encode)]
#[serde(bound = "T: EthSpec")]
pub struct BlockContents<T: EthSpec> {
pub block: BeaconBlock<T>,
pub kzg_proofs: KzgProofs<T>,
#[serde(bound = "E: EthSpec")]
pub struct BlockContents<E: EthSpec> {
pub block: BeaconBlock<E>,
pub kzg_proofs: KzgProofs<E>,
#[serde(with = "ssz_types::serde_utils::list_of_hex_fixed_vec")]
pub blobs: BlobsList<T>,
pub blobs: BlobsList<E>,
}
impl<T: EthSpec> ForkVersionDeserialize for BlockContents<T> {
impl<E: EthSpec> ForkVersionDeserialize for BlockContents<E> {
fn deserialize_by_fork<'de, D: serde::Deserializer<'de>>(
value: serde_json::value::Value,
fork_name: ForkName,
) -> Result<Self, D::Error> {
#[derive(Deserialize)]
#[serde(bound = "T: EthSpec")]
struct Helper<T: EthSpec> {
#[serde(bound = "E: EthSpec")]
struct Helper<E: EthSpec> {
block: serde_json::Value,
kzg_proofs: KzgProofs<T>,
kzg_proofs: KzgProofs<E>,
#[serde(with = "ssz_types::serde_utils::list_of_hex_fixed_vec")]
blobs: BlobsList<T>,
blobs: BlobsList<E>,
}
let helper: Helper<T> = serde_json::from_value(value).map_err(serde::de::Error::custom)?;
let helper: Helper<E> = serde_json::from_value(value).map_err(serde::de::Error::custom)?;
Ok(Self {
block: BeaconBlock::deserialize_by_fork::<'de, D>(helper.block, fork_name)?,