Add API for posting bid

This commit is contained in:
Eitan Seri-Levi
2026-05-24 13:18:27 +03:00
parent 5045e8dd85
commit e4f137dc04
6 changed files with 310 additions and 10 deletions

View File

@@ -46,7 +46,10 @@ use ssz::{Decode, Encode};
use std::fmt;
use std::future::Future;
use std::time::Duration;
use types::{PayloadAttestationData, PayloadAttestationMessage, SignedProposerPreferences};
use types::{
PayloadAttestationData, PayloadAttestationMessage, SignedExecutionPayloadBid,
SignedProposerPreferences,
};
pub const V1: EndpointVersion = EndpointVersion(1);
pub const V2: EndpointVersion = EndpointVersion(2);
@@ -2838,6 +2841,78 @@ impl BeaconNodeHttpClient {
Ok(())
}
/// `POST v1/beacon/execution_payload_bid`
pub async fn post_beacon_execution_payload_bid<E: EthSpec>(
&self,
bid: &SignedExecutionPayloadBid<E>,
fork_name: ForkName,
) -> Result<(), Error> {
let mut path = self.eth_path(V1)?;
path.path_segments_mut()
.map_err(|()| Error::InvalidUrl(self.server.clone()))?
.push("beacon")
.push("execution_payload_bid");
self.post_generic_with_consensus_version(
path,
bid,
Some(self.timeouts.proposal),
fork_name,
)
.await?;
Ok(())
}
/// `POST v1/beacon/execution_payload_bid` with raw bytes (for testing invalid SSZ)
pub async fn post_beacon_execution_payload_bid_raw_ssz(
&self,
bytes: &[u8],
fork_name: ForkName,
) -> Result<(), Error> {
let mut path = self.eth_path(V1)?;
path.path_segments_mut()
.map_err(|()| Error::InvalidUrl(self.server.clone()))?
.push("beacon")
.push("execution_payload_bid");
self.post_generic_with_consensus_version_and_ssz_body(
path,
bytes.to_vec(),
Some(self.timeouts.proposal),
fork_name,
)
.await?;
Ok(())
}
/// `POST v1/beacon/execution_payload_bid` in SSZ format
pub async fn post_beacon_execution_payload_bid_ssz<E: EthSpec>(
&self,
bid: &SignedExecutionPayloadBid<E>,
fork_name: ForkName,
) -> Result<(), Error> {
let mut path = self.eth_path(V1)?;
path.path_segments_mut()
.map_err(|()| Error::InvalidUrl(self.server.clone()))?
.push("beacon")
.push("execution_payload_bid");
self.post_generic_with_consensus_version_and_ssz_body(
path,
bid.as_ssz_bytes(),
Some(self.timeouts.proposal),
fork_name,
)
.await?;
Ok(())
}
/// Path for `v1/beacon/execution_payload_envelope/{block_id}`
pub fn get_beacon_execution_payload_envelope_path(
&self,