Skip to content

Commit

Permalink
Merge branch 'main' into electra-epoch-processing
Browse files Browse the repository at this point in the history
  • Loading branch information
ralexstokes authored May 3, 2024
2 parents f949c62 + 5cf67a5 commit dbe389f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
13 changes: 8 additions & 5 deletions beacon-api-client/src/api_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use crate::{
CommitteeFilter, CommitteeSummary, ConnectionOrientation, CoordinateWithMetadata,
DepositContract, DepositSnapshot, FinalityCheckpoints, GenesisDetails, HealthStatus,
NetworkIdentity, PeerDescription, PeerState, PeerSummary, ProposerDuty, PublicKeyOrIndex,
RootData, StateId, SyncCommitteeDescriptor, SyncCommitteeDuty, SyncCommitteeSummary,
SyncStatus, Topic, ValidatorLiveness, ValidatorStatus, ValidatorSummary, Value,
VersionData, VersionedValue,
RootData, StateId, SubmitSignedBeaconBlock, SyncCommitteeDescriptor, SyncCommitteeDuty,
SyncCommitteeSummary, SyncStatus, Topic, ValidatorLiveness, ValidatorStatus,
ValidatorSummary, Value, VersionData, VersionedValue,
},
ApiError, Error,
};
Expand Down Expand Up @@ -66,6 +66,7 @@ pub trait ClientTypes: Clone {
type BeaconState: serde::Serialize + serde::de::DeserializeOwned;
type SignedAggregateAndProof: serde::Serialize;
type SignedBeaconBlock: serde::Serialize + serde::de::DeserializeOwned;
type Blob: serde::Serialize + serde::de::DeserializeOwned;
type BlobSidecar: serde::Serialize + serde::de::DeserializeOwned;
type LightClientBootstrap: serde::Serialize + serde::de::DeserializeOwned;
type LightClientUpdate: serde::Serialize + serde::de::DeserializeOwned;
Expand Down Expand Up @@ -349,17 +350,19 @@ impl<C: ClientTypes> Client<C> {
self.post("eth/v1/beacon/blocks", block).await
}

// NOTE: this only supports the `deneb` fork at the moment
// The message schema of `request` is different before `deneb`.
pub async fn post_signed_beacon_block_v2(
&self,
block: &C::SignedBeaconBlock,
request: SubmitSignedBeaconBlock<'_, C::SignedBeaconBlock, C::Blob>,
version: Version,
broadcast_validation: Option<BroadcastValidation>,
) -> Result<(), Error> {
let target = self.endpoint.join("eth/v2/beacon/blocks")?;
let mut request = self
.http
.post(target)
.json(block)
.json(&request)
.header(CONSENSUS_VERSION_HEADER, version.to_string());
if let Some(validation) = broadcast_validation {
request = request.query(&[("broadcast_validation", validation)]);
Expand Down
2 changes: 2 additions & 0 deletions beacon-api-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub mod presets {
type BeaconState = BeaconState;
type SignedAggregateAndProof = phase0::SignedAggregateAndProof;
type SignedBeaconBlock = SignedBeaconBlock;
type Blob = deneb::Blob;
type BlobSidecar = deneb::BlobSidecar;
type LightClientBootstrap = altair::LightClientBootstrap;
type LightClientUpdate = altair::LightClientUpdate;
Expand Down Expand Up @@ -93,6 +94,7 @@ pub mod presets {
type BeaconState = BeaconState;
type SignedAggregateAndProof = phase0::SignedAggregateAndProof;
type SignedBeaconBlock = SignedBeaconBlock;
type Blob = deneb::Blob;
type BlobSidecar = deneb::BlobSidecar;
type LightClientBootstrap = altair::LightClientBootstrap;
type LightClientUpdate = altair::LightClientUpdate;
Expand Down
12 changes: 12 additions & 0 deletions beacon-api-client/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::ApiError;
use ethereum_consensus::{
altair::networking::MetaData,
capella::Withdrawal,
deneb::polynomial_commitments::KzgProof,
networking::{Enr, Multiaddr, PeerId},
phase0::{Checkpoint, SignedBeaconBlockHeader, Validator},
primitives::{
Expand Down Expand Up @@ -473,6 +474,17 @@ pub struct SyncCommitteeDescriptor {
pub until_epoch: Epoch,
}

#[derive(Serialize)]
pub struct SubmitSignedBeaconBlock<'a, SignedBeaconBlock, Blob>
where
SignedBeaconBlock: serde::Serialize,
Blob: serde::Serialize,
{
pub signed_block: &'a SignedBeaconBlock,
pub kzg_proofs: Option<&'a [KzgProof]>,
pub blobs: Option<&'a [Blob]>,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct BeaconProposerRegistration {
#[serde(with = "crate::serde::as_str")]
Expand Down

0 comments on commit dbe389f

Please sign in to comment.