Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rpc): add cancellation param to submit_block rpc #119

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ members = ["bin/mev", "mev-boost-rs", "mev-relay-rs", "mev-build-rs", "mev-rs"]
default-members = ["bin/mev"]

[workspace.dependencies]
ethereum-consensus = { git = "https://github.com/ralexstokes/ethereum-consensus", rev = "2bcb975" }
beacon-api-client = { git = "https://github.com/ralexstokes/beacon-api-client", rev = "d838d93" }
ethereum-consensus = { git = "https://github.com/ralexstokes/ethereum-consensus", rev = "4d4e3fb" }
beacon-api-client = { git = "https://github.com/ralexstokes/beacon-api-client", rev = "cc6ff93" }
ssz_rs = "0.9.0"
10 changes: 7 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 @@ -24,8 +24,12 @@ impl BlindedBlockRelayer for Client {
}

// TODO support content types
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 = format!("/relay/v1/builder/blocks");
let target = self.api.endpoint.join(&path).map_err(ApiError::from)?;
let mut request = self.api.http.post(target);
if with_cancellations { request = request.query(&[("cancellations", with_cancellations)])};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like the api takes the value 1 instead of the boolean true

ref:
https://flashbots.github.io/relay-specs/#/Builder/submitBlock

let response = request.send().await.map_err(ApiError::from)?;
api_error_or_ok(response).await.map_err(From::from)
}
}
5 changes: 3 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,11 @@ async fn handle_get_proposal_schedule<R: BlindedBlockRelayer>(

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

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

// TODO: support cancellations?
async fn submit_bid(&self, signed_submission: &SignedBidSubmission) -> Result<(), Error>;
async fn submit_bid(&self, signed_submission: &SignedBidSubmission, with_cancellations: bool) -> Result<(), Error>;
}
Loading