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
13 changes: 7 additions & 6 deletions crates/rbuilder/src/live_builder/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ use std::{
sync::Arc,
time::Duration,
};
use tokio::sync::Mutex as TokioMutex;
use tokio_util::sync::CancellationToken;
use tracing::{info, warn};
use url::Url;
Expand Down Expand Up @@ -301,11 +300,13 @@ impl L1Config {
.unwrap_or(DEFAULT_CAN_IGNORE_GAS_LIMIT),
);
if let Some(grpc_url) = relay_config.grpc_url.clone() {
let grpc_client = Arc::new(TokioMutex::new(
bloxroute_grpc::types::relay_client::RelayClient::new(
tonic::transport::Endpoint::try_from(grpc_url)?.connect_lazy(),
),
));
let grpc_client = bloxroute_grpc::types::relay_client::RelayClient::new(
tonic::transport::Endpoint::try_from(grpc_url)?
.keep_alive_while_idle(true)
.keep_alive_timeout(Duration::from_secs(12))
.connect_lazy(),
);

client = client.with_grpc_client(grpc_client);
}
Self::create_relay_sub_objects(
Expand Down
4 changes: 1 addition & 3 deletions crates/rbuilder/src/mev_boost/bloxroute_grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use alloy_rpc_types_beacon::{
};
use alloy_rpc_types_engine::{ExecutionPayloadV1, ExecutionPayloadV2, ExecutionPayloadV3};
use rbuilder_primitives::mev_boost::SubmitBlockRequest;
use std::sync::Arc;

/// Bloxroute gRPC types.
pub mod types {
Expand All @@ -35,8 +34,7 @@ pub enum DataVersion {
}

/// gRPC relay client type.
pub type GrpcRelayClient =
Arc<tokio::sync::Mutex<types::relay_client::RelayClient<tonic::transport::Channel>>>;
pub type GrpcRelayClient = types::relay_client::RelayClient<tonic::transport::Channel>;

impl From<&SubmitBlockRequest> for types::SubmitBlockRequest {
fn from(value: &SubmitBlockRequest) -> Self {
Expand Down
14 changes: 6 additions & 8 deletions crates/rbuilder/src/mev_boost/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ impl RelayClient {
/// Send gRPC submit block request to bloxroute.
async fn call_bloxroute_grpc_submit_block(
&self,
client: &GrpcRelayClient,
mut client: GrpcRelayClient,
submission: &SubmitBlockRequestWithMetadata,
) -> Result<bloxroute_grpc::types::SubmitBlockResponse, SubmitBlockErr> {
let mut request = tonic::Request::new(bloxroute_grpc::types::SubmitBlockRequest::from(
Expand Down Expand Up @@ -859,12 +859,7 @@ impl RelayClient {
.map_err(|_| SubmitBlockErr::InvalidHeader)?,
);

let response = client
.lock()
.await
.submit_block(request)
.await
.map_err(Box::new)?;
let response = client.submit_block(request).await.map_err(Box::new)?;
Ok(response.into_inner())
}

Expand All @@ -881,7 +876,10 @@ impl RelayClient {
// If gRPC client is available, attempt to submit with it.
// TODO: support submitting to rproxy gRPC
if let Some(client) = &self.grpc_client {
match self.call_bloxroute_grpc_submit_block(client, data).await {
match self
.call_bloxroute_grpc_submit_block(client.clone(), data)
.await
{
Ok(response) => {
let status = response.code.try_into().unwrap_or(u16::MAX);
return if status == tonic::Code::Ok as u16 {
Expand Down
Loading