mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-30 03:14:25 +00:00
Merge remote-tracking branch 'origin/unstable' into tree-states
This commit is contained in:
@@ -29,10 +29,8 @@ pub use reqwest::{StatusCode, Url};
|
||||
pub use sensitive_url::{SensitiveError, SensitiveUrl};
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
use ssz::Encode;
|
||||
use std::convert::TryFrom;
|
||||
use std::fmt;
|
||||
use std::future::Future;
|
||||
use std::iter::Iterator;
|
||||
use std::path::PathBuf;
|
||||
use std::time::Duration;
|
||||
use store::fork_versioned_response::ExecutionOptimisticFinalizedForkVersionedResponse;
|
||||
@@ -836,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)?;
|
||||
|
||||
@@ -856,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)?;
|
||||
|
||||
@@ -881,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)?;
|
||||
|
||||
@@ -901,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)?;
|
||||
|
||||
@@ -960,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(
|
||||
@@ -977,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(
|
||||
@@ -994,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(
|
||||
@@ -1011,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(
|
||||
@@ -1063,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)?;
|
||||
@@ -1081,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
|
||||
@@ -1096,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);
|
||||
};
|
||||
@@ -1106,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)?;
|
||||
@@ -1124,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()
|
||||
@@ -1142,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)
|
||||
@@ -1158,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)
|
||||
@@ -1195,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()
|
||||
@@ -1212,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)?;
|
||||
|
||||
@@ -1231,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()
|
||||
@@ -1258,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)?;
|
||||
|
||||
@@ -1277,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()
|
||||
@@ -1475,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)?;
|
||||
|
||||
@@ -1699,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
|
||||
@@ -1710,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)
|
||||
@@ -1784,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,
|
||||
@@ -1880,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,
|
||||
@@ -1898,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,
|
||||
@@ -1926,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);
|
||||
@@ -1949,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,
|
||||
@@ -1967,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,
|
||||
@@ -2025,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,
|
||||
@@ -2041,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,
|
||||
@@ -2049,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)
|
||||
@@ -2057,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,
|
||||
@@ -2073,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,
|
||||
@@ -2105,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,
|
||||
@@ -2125,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,
|
||||
@@ -2140,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,
|
||||
@@ -2148,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,
|
||||
@@ -2181,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()
|
||||
@@ -2205,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()
|
||||
@@ -2300,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)?;
|
||||
|
||||
@@ -2352,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()))?
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -12,7 +12,6 @@ use serde::{Deserialize, Deserializer, Serialize};
|
||||
use serde_json::Value;
|
||||
use ssz::{Decode, DecodeError};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use std::convert::TryFrom;
|
||||
use std::fmt::{self, Display};
|
||||
use std::str::{from_utf8, FromStr};
|
||||
use std::sync::Arc;
|
||||
@@ -1034,6 +1033,9 @@ impl ForkVersionDeserialize for SsePayloadAttributes {
|
||||
ForkName::Deneb => serde_json::from_value(value)
|
||||
.map(Self::V3)
|
||||
.map_err(serde::de::Error::custom),
|
||||
ForkName::Electra => serde_json::from_value(value)
|
||||
.map(Self::V3)
|
||||
.map_err(serde::de::Error::custom),
|
||||
ForkName::Base | ForkName::Altair => Err(serde::de::Error::custom(format!(
|
||||
"SsePayloadAttributes deserialization for {fork_name} not implemented"
|
||||
))),
|
||||
@@ -1063,25 +1065,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",
|
||||
@@ -1532,16 +1534,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 {
|
||||
@@ -1565,8 +1567,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,
|
||||
@@ -1587,7 +1589,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)
|
||||
}
|
||||
|
||||
@@ -1601,12 +1603,12 @@ impl<T: EthSpec> FullBlockContents<T> {
|
||||
BeaconBlock::from_ssz_bytes_for_fork(bytes, fork_name)
|
||||
.map(|block| FullBlockContents::Block(block))
|
||||
}
|
||||
ForkName::Deneb => {
|
||||
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| {
|
||||
@@ -1620,14 +1622,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,
|
||||
@@ -1644,14 +1646,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,
|
||||
@@ -1662,15 +1664,15 @@ impl<T: EthSpec> ForkVersionDeserialize for FullBlockContents<T> {
|
||||
BeaconBlock::deserialize_by_fork::<'de, D>(value, fork_name)?,
|
||||
))
|
||||
}
|
||||
ForkName::Deneb => Ok(FullBlockContents::BlockContents(
|
||||
ForkName::Deneb | ForkName::Electra => Ok(FullBlockContents::BlockContents(
|
||||
BlockContents::deserialize_by_fork::<'de, D>(value, fork_name)?,
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
@@ -1678,9 +1680,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>(
|
||||
@@ -1732,17 +1734,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 {
|
||||
@@ -1761,11 +1763,11 @@ impl<T: EthSpec> PublishBlockRequest<T> {
|
||||
SignedBeaconBlock::from_ssz_bytes_for_fork(bytes, fork_name)
|
||||
.map(|block| PublishBlockRequest::Block(Arc::new(block)))
|
||||
}
|
||||
ForkName::Deneb => {
|
||||
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| {
|
||||
@@ -1781,7 +1783,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
|
||||
@@ -1790,7 +1792,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,
|
||||
@@ -1802,10 +1804,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
|
||||
@@ -1837,59 +1839,59 @@ 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(_)
|
||||
| SignedBeaconBlock::Merge(_)
|
||||
| SignedBeaconBlock::Capella(_) => Ok(PublishBlockRequest::Block(block)),
|
||||
SignedBeaconBlock::Deneb(_) => {
|
||||
Err("deneb block contents cannot be fully constructed from just the signed block")
|
||||
}
|
||||
SignedBeaconBlock::Deneb(_) | SignedBeaconBlock::Electra(_) => Err(
|
||||
"post-Deneb block contents cannot be fully constructed from just the signed block",
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)?,
|
||||
@@ -1955,7 +1957,7 @@ impl<E: EthSpec> ForkVersionDeserialize for FullPayloadContents<E> {
|
||||
ForkName::Merge | ForkName::Capella => serde_json::from_value(value)
|
||||
.map(Self::Payload)
|
||||
.map_err(serde::de::Error::custom),
|
||||
ForkName::Deneb => serde_json::from_value(value)
|
||||
ForkName::Deneb | ForkName::Electra => serde_json::from_value(value)
|
||||
.map(Self::PayloadAndBlobs)
|
||||
.map_err(serde::de::Error::custom),
|
||||
ForkName::Base | ForkName::Altair => Err(serde::de::Error::custom(format!(
|
||||
|
||||
Reference in New Issue
Block a user