Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions mev-build-rs/src/reth_builder/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,11 @@ impl<Pool, Client> Builder<Pool, Client> {
self.state.lock().unwrap().cancels.remove(id);
}

pub async fn submit_bid(&self, id: &BuildIdentifier) -> Result<(), Error> {
pub async fn submit_bid(
&self,
id: &BuildIdentifier,
with_cancellations: bool,
) -> Result<(), Error> {
let build = self.build_for(id).ok_or_else(|| Error::MissingBuild(id.clone()))?;

let context = &build.context;
Expand All @@ -292,7 +296,7 @@ impl<Pool, Client> Builder<Pool, Client> {
let block_hash = &signed_submission.message.block_hash;
let value = &signed_submission.message.value;
tracing::info!(id = %id, relay = ?relay, slot, %parent_hash, %block_hash, ?value, %builder_payment, "submitting bid");
match relay.submit_bid(&signed_submission).await {
match relay.submit_bid(&signed_submission, with_cancellations).await {
Ok(_) => tracing::info!(%id, ?relay, "successfully submitted bid"),
Err(err) => {
tracing::warn!(%err, %id,?relay, "error submitting bid");
Expand Down
2 changes: 1 addition & 1 deletion mev-build-rs/src/reth_builder/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl<
loop {
match bidder.bid_for(&build).await {
Ok(Some(bid)) => {
if let Err(err) = builder.submit_bid(&id).await {
if let Err(err) = builder.submit_bid(&id, false).await {
tracing::warn!(id = %id, slot=?build.context.slot, err = %err, "error submitting bid for build");
}
match bid {
Expand Down
16 changes: 13 additions & 3 deletions mev-rs/src/blinded_block_relayer/api/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
types::{ProposerSchedule, SignedBidSubmission},
Error,
};
use beacon_api_client::{api_error_or_ok, mainnet::Client as BeaconApiClient};
use beacon_api_client::{api_error_or_ok, mainnet::Client as BeaconApiClient, Error as ApiError};

/// A `Client` for a service implementing the Relay APIs.
#[derive(Clone)]
Expand All @@ -23,8 +23,18 @@ impl BlindedBlockRelayer for Client {
self.api.get("/relay/v1/builder/validators").await.map_err(From::from)
}

async fn submit_bid(&self, signed_submission: &SignedBidSubmission) -> Result<(), Error> {
let response = self.api.http_post("/relay/v1/builder/blocks", signed_submission).await?;
async fn submit_bid(
&self,
signed_submission: &SignedBidSubmission,
with_cancellations: bool,
) -> Result<(), Error> {
let path = "/relay/v1/builder/blocks";
let target = self.api.endpoint.join(&path).map_err(ApiError::from)?;
let mut request = self.api.http.post(target).json(signed_submission);
if with_cancellations {
request = request.query(&[("cancellations", "1")])
};
let response = request.send().await.map_err(ApiError::from)?;
api_error_or_ok(response).await.map_err(From::from)
}
}
6 changes: 4 additions & 2 deletions mev-rs/src/blinded_block_relayer/api/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
types::{ProposerSchedule, SignedBidSubmission},
};
use axum::{
extract::{Json, State},
extract::{Json, Query, State},
routing::{get, post, IntoMakeService},
Router,
};
Expand All @@ -24,10 +24,12 @@ async fn handle_get_proposal_schedule<R: BlindedBlockRelayer>(

async fn handle_submit_bid<R: BlindedBlockRelayer>(
State(relayer): State<R>,
Query(with_cancellations): Query<String>,
Json(signed_bid_submission): Json<SignedBidSubmission>,
) -> Result<(), Error> {
tracing::info!("handling bid submission");
relayer.submit_bid(&signed_bid_submission).await
let with_cancellations = with_cancellations == "1";
relayer.submit_bid(&signed_bid_submission, with_cancellations).await
}

pub struct Server<R: BlindedBlockRelayer> {
Expand Down
6 changes: 5 additions & 1 deletion mev-rs/src/blinded_block_relayer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@ use async_trait::async_trait;
pub trait BlindedBlockRelayer {
async fn get_proposal_schedule(&self) -> Result<Vec<ProposerSchedule>, Error>;

async fn submit_bid(&self, signed_submission: &SignedBidSubmission) -> Result<(), Error>;
async fn submit_bid(
&self,
signed_submission: &SignedBidSubmission,
with_cancellations: bool,
) -> Result<(), Error>;
}
8 changes: 6 additions & 2 deletions mev-rs/src/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ impl BlindedBlockRelayer for Relay {
self.relayer.get_proposal_schedule().await
}

async fn submit_bid(&self, signed_submission: &SignedBidSubmission) -> Result<(), Error> {
self.relayer.submit_bid(signed_submission).await
async fn submit_bid(
&self,
signed_submission: &SignedBidSubmission,
with_cancellations: bool,
) -> Result<(), Error> {
self.relayer.submit_bid(signed_submission, with_cancellations).await
}
}

Expand Down