diff --git a/crates/rpc/rpc/src/eth/bundle.rs b/crates/rpc/rpc/src/eth/bundle.rs index dd8f75898bfe..ee1f648f92ed 100644 --- a/crates/rpc/rpc/src/eth/bundle.rs +++ b/crates/rpc/rpc/src/eth/bundle.rs @@ -26,7 +26,6 @@ use reth_rpc_eth_api::{ EthCallBundleApiServer, }; use reth_rpc_eth_types::{utils::recover_raw_transaction, EthApiError, RpcInvalidTransactionError}; - /// `Eth` bundle implementation. pub struct EthBundle { /// All nested fields bundled together. diff --git a/crates/rpc/rpc/src/eth/mod.rs b/crates/rpc/rpc/src/eth/mod.rs index 83db119f8804..99919110da7b 100644 --- a/crates/rpc/rpc/src/eth/mod.rs +++ b/crates/rpc/rpc/src/eth/mod.rs @@ -5,6 +5,7 @@ pub mod core; pub mod filter; pub mod helpers; pub mod pubsub; +pub mod sim_bundle; /// Implementation of `eth` namespace API. pub use bundle::EthBundle; diff --git a/crates/rpc/rpc/src/eth/sim_bundle.rs b/crates/rpc/rpc/src/eth/sim_bundle.rs new file mode 100644 index 000000000000..46dbb45d962e --- /dev/null +++ b/crates/rpc/rpc/src/eth/sim_bundle.rs @@ -0,0 +1,76 @@ +//! `Eth` Sim bundle implementation and helpers. + +use std::sync::Arc; + +use alloy_rpc_types_mev::{SendBundleRequest, SimBundleOverrides, SimBundleResponse}; +use jsonrpsee::core::RpcResult; +use reth_rpc_api::MevSimApiServer; +use reth_rpc_eth_api::helpers::{Call, EthTransactions, LoadPendingBlock}; +use reth_rpc_eth_types::EthApiError; +use reth_tasks::pool::BlockingTaskGuard; +use tracing::info; + +/// `Eth` sim bundle implementation. +pub struct EthSimBundle { + /// All nested fields bundled together. + inner: Arc>, +} + +impl EthSimBundle { + /// Create a new `EthSimBundle` instance. + pub fn new(eth_api: Eth, blocking_task_guard: BlockingTaskGuard) -> Self { + Self { inner: Arc::new(EthSimBundleInner { eth_api, blocking_task_guard }) } + } +} + +impl EthSimBundle +where + Eth: EthTransactions + LoadPendingBlock + Call + 'static, +{ + /// Simulates a bundle of transactions. + pub async fn sim_bundle( + &self, + request: SendBundleRequest, + overrides: SimBundleOverrides, + ) -> RpcResult { + info!("mev_simBundle called, request: {:?}, overrides: {:?}", request, overrides); + Err(EthApiError::Unsupported("mev_simBundle is not supported").into()) + } +} + +#[async_trait::async_trait] +impl MevSimApiServer for EthSimBundle +where + Eth: EthTransactions + LoadPendingBlock + Call + 'static, +{ + async fn sim_bundle( + &self, + request: SendBundleRequest, + overrides: SimBundleOverrides, + ) -> RpcResult { + Self::sim_bundle(self, request, overrides).await + } +} + +/// Container type for `EthSimBundle` internals +#[derive(Debug)] +struct EthSimBundleInner { + /// Access to commonly used code of the `eth` namespace + #[allow(dead_code)] + eth_api: Eth, + // restrict the number of concurrent tracing calls. + #[allow(dead_code)] + blocking_task_guard: BlockingTaskGuard, +} + +impl std::fmt::Debug for EthSimBundle { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.debug_struct("EthSimBundle").finish_non_exhaustive() + } +} + +impl Clone for EthSimBundle { + fn clone(&self) -> Self { + Self { inner: Arc::clone(&self.inner) } + } +}