mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-17 03:42:46 +00:00
Merge branch 'unstable' into vc-fallback
This commit is contained in:
@@ -30,10 +30,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;
|
||||
@@ -841,9 +839,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)?;
|
||||
|
||||
@@ -861,9 +859,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)?;
|
||||
|
||||
@@ -886,9 +884,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)?;
|
||||
|
||||
@@ -906,9 +904,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)?;
|
||||
|
||||
@@ -965,9 +963,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(
|
||||
@@ -982,9 +980,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(
|
||||
@@ -999,9 +997,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(
|
||||
@@ -1016,9 +1014,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(
|
||||
@@ -1068,11 +1066,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)?;
|
||||
@@ -1086,11 +1084,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
|
||||
@@ -1101,6 +1099,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);
|
||||
};
|
||||
@@ -1111,11 +1110,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)?;
|
||||
@@ -1129,10 +1128,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()
|
||||
@@ -1147,11 +1146,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)
|
||||
@@ -1163,11 +1162,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)
|
||||
@@ -1200,10 +1199,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()
|
||||
@@ -1217,9 +1216,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)?;
|
||||
|
||||
@@ -1236,11 +1235,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()
|
||||
@@ -1263,9 +1262,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)?;
|
||||
|
||||
@@ -1282,9 +1281,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()
|
||||
@@ -1480,9 +1479,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)?;
|
||||
|
||||
@@ -1704,10 +1703,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
|
||||
@@ -1715,11 +1714,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)
|
||||
@@ -1789,33 +1788,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,
|
||||
@@ -1885,13 +1884,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,
|
||||
@@ -1903,14 +1902,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,
|
||||
@@ -1931,14 +1930,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);
|
||||
@@ -1954,14 +1953,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,
|
||||
@@ -1972,14 +1971,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,
|
||||
@@ -2030,13 +2029,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,
|
||||
@@ -2046,7 +2045,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,
|
||||
@@ -2054,7 +2053,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)
|
||||
@@ -2062,12 +2061,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,
|
||||
@@ -2078,7 +2077,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,
|
||||
@@ -2110,15 +2109,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,
|
||||
@@ -2130,13 +2129,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,
|
||||
@@ -2145,7 +2144,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,
|
||||
@@ -2153,7 +2152,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,
|
||||
@@ -2186,11 +2185,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()
|
||||
@@ -2210,10 +2209,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()
|
||||
@@ -2263,7 +2262,7 @@ impl BeaconNodeHttpClient {
|
||||
pub async fn post_validator_liveness_epoch(
|
||||
&self,
|
||||
epoch: Epoch,
|
||||
indices: &Vec<u64>,
|
||||
indices: &[u64],
|
||||
) -> Result<GenericResponse<Vec<StandardLivenessResponseData>>, Error> {
|
||||
let mut path = self.eth_path(V1)?;
|
||||
|
||||
@@ -2273,8 +2272,12 @@ impl BeaconNodeHttpClient {
|
||||
.push("liveness")
|
||||
.push(&epoch.to_string());
|
||||
|
||||
self.post_with_timeout_and_response(path, indices, self.timeouts.liveness)
|
||||
.await
|
||||
self.post_with_timeout_and_response(
|
||||
path,
|
||||
&ValidatorIndexDataRef(indices),
|
||||
self.timeouts.liveness,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
/// `POST validator/duties/attester/{epoch}`
|
||||
@@ -2301,9 +2304,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)?;
|
||||
|
||||
@@ -2353,10 +2356,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.
|
||||
@@ -54,8 +54,6 @@ pub struct Peer<T: EthSpec> {
|
||||
pub struct GlobalValidatorInclusionData {
|
||||
/// The total effective balance of all active validators during the _current_ epoch.
|
||||
pub current_epoch_active_gwei: u64,
|
||||
/// The total effective balance of all active validators during the _previous_ epoch.
|
||||
pub previous_epoch_active_gwei: u64,
|
||||
/// The total effective balance of all validators who attested during the _current_ epoch and
|
||||
/// agreed with the state about the beacon block at the first slot of the _current_ epoch.
|
||||
pub current_epoch_target_attesting_gwei: u64,
|
||||
|
||||
@@ -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;
|
||||
@@ -282,7 +281,7 @@ pub struct FinalityCheckpointsData {
|
||||
pub finalized: Checkpoint,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)]
|
||||
#[serde(into = "String")]
|
||||
#[serde(try_from = "std::borrow::Cow<str>")]
|
||||
pub enum ValidatorId {
|
||||
@@ -1033,6 +1032,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"
|
||||
))),
|
||||
@@ -1062,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",
|
||||
@@ -1531,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 {
|
||||
@@ -1564,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,
|
||||
@@ -1586,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)
|
||||
}
|
||||
|
||||
@@ -1600,12 +1602,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| {
|
||||
@@ -1619,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,
|
||||
@@ -1643,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,
|
||||
@@ -1661,15 +1663,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,
|
||||
@@ -1677,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>(
|
||||
@@ -1710,12 +1712,12 @@ impl TryFrom<&HeaderMap> for ProduceBlockV3Metadata {
|
||||
})?;
|
||||
let execution_payload_value =
|
||||
parse_required_header(headers, EXECUTION_PAYLOAD_VALUE_HEADER, |s| {
|
||||
s.parse::<Uint256>()
|
||||
Uint256::from_dec_str(s)
|
||||
.map_err(|e| format!("invalid {EXECUTION_PAYLOAD_VALUE_HEADER}: {e:?}"))
|
||||
})?;
|
||||
let consensus_block_value =
|
||||
parse_required_header(headers, CONSENSUS_BLOCK_VALUE_HEADER, |s| {
|
||||
s.parse::<Uint256>()
|
||||
Uint256::from_dec_str(s)
|
||||
.map_err(|e| format!("invalid {CONSENSUS_BLOCK_VALUE_HEADER}: {e:?}"))
|
||||
})?;
|
||||
|
||||
@@ -1731,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 {
|
||||
@@ -1760,11 +1762,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| {
|
||||
@@ -1780,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
|
||||
@@ -1789,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,
|
||||
@@ -1801,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
|
||||
@@ -1836,59 +1838,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)?,
|
||||
@@ -1954,7 +1956,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