diff --git a/crates/rbuilder/src/live_builder/config.rs b/crates/rbuilder/src/live_builder/config.rs index cd55f4b17..5b65ea189 100644 --- a/crates/rbuilder/src/live_builder/config.rs +++ b/crates/rbuilder/src/live_builder/config.rs @@ -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; @@ -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( diff --git a/crates/rbuilder/src/mev_boost/bloxroute_grpc.rs b/crates/rbuilder/src/mev_boost/bloxroute_grpc.rs index a1a238ede..273ede0d1 100644 --- a/crates/rbuilder/src/mev_boost/bloxroute_grpc.rs +++ b/crates/rbuilder/src/mev_boost/bloxroute_grpc.rs @@ -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 { @@ -35,8 +34,7 @@ pub enum DataVersion { } /// gRPC relay client type. -pub type GrpcRelayClient = - Arc>>; +pub type GrpcRelayClient = types::relay_client::RelayClient; impl From<&SubmitBlockRequest> for types::SubmitBlockRequest { fn from(value: &SubmitBlockRequest) -> Self { diff --git a/crates/rbuilder/src/mev_boost/mod.rs b/crates/rbuilder/src/mev_boost/mod.rs index dfca72228..26218ca8a 100644 --- a/crates/rbuilder/src/mev_boost/mod.rs +++ b/crates/rbuilder/src/mev_boost/mod.rs @@ -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 { let mut request = tonic::Request::new(bloxroute_grpc::types::SubmitBlockRequest::from( @@ -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()) } @@ -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 {