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

Add enable_cancellation flag to submit_bid() of blinded_block_relay #115

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
1 change: 1 addition & 0 deletions mev-rs/src/blinded_block_relayer/api/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ impl BlindedBlockRelayer for Client {
async fn submit_bid(
&self,
signed_submission: &SignedBidSubmission,
cancellation_enabled: bool,
ralexstokes marked this conversation as resolved.
Show resolved Hide resolved
) -> Result<SignedBidReceipt, Error> {
let response = self.api.http_post("/relay/v1/builder/blocks", signed_submission).await?;
Copy link
Owner

Choose a reason for hiding this comment

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

want to round this out on the client?

I really like that you added this to the server part

we can optionally add a query param according to the spec: https://flashbots.github.io/relay-specs/#/Builder/submitBlock

here's an example to add the param: https://github.com/ralexstokes/beacon-api-client/blob/d838d930f80fdfcadfe32147bcb2e805aec074bc/src/api_client.rs#L233

Copy link
Author

Choose a reason for hiding this comment

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

Yeah! Sounds like a great time.

Copy link
Author

@PatStiles PatStiles Aug 18, 2023

Choose a reason for hiding this comment

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

@ralexstokes BeaconApiClient doesn't publicly expose the underlying reqwest::Client. We'd need to upstream or create a new reqwest::Client to add an additional query parameter. Want to make sure I have the right idea before I continue.

Copy link
Owner

Choose a reason for hiding this comment

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

yeah good point...

do you want to make a PR to beacon-api-client to just make endpoint and client pub?

then you can update the dep here and just do it directly here, rather than use the exported functions on Client

I took a look but think this probably best rather than trying to make another POST method that also takes query params

Copy link
Author

Choose a reason for hiding this comment

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

Sounds good opened a pr ralexstokes/beacon-api-client#77

let receipt: ApiResult<SignedBidReceipt> = response.json().await.map_err(ApiError::from)?;
Expand Down
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, SignedBidReceipt, 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(enable_cancellation): Query<bool>,
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
Query(enable_cancellation): Query<bool>,
Query(with_cancellation): Query<bool>,

Json(signed_bid_submission): Json<SignedBidSubmission>,
) -> Result<Json<SignedBidReceipt>, Error> {
tracing::info!("handling bid submission");
Ok(Json(relayer.submit_bid(&signed_bid_submission).await?))
Ok(Json(relayer.submit_bid(&signed_bid_submission, enable_cancellation).await?))
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
Ok(Json(relayer.submit_bid(&signed_bid_submission, enable_cancellation).await?))
Ok(Json(relayer.submit_bid(&signed_bid_submission, with_cancellation).await?))

}

pub struct Server<R: BlindedBlockRelayer> {
Expand Down
1 change: 1 addition & 0 deletions mev-rs/src/blinded_block_relayer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ pub trait BlindedBlockRelayer {
async fn submit_bid(
&self,
signed_submission: &SignedBidSubmission,
enable_cancellations: bool,
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
enable_cancellations: bool,
with_cancellation: bool,

) -> Result<SignedBidReceipt, Error>;
}
Loading