diff --git a/crates/exex/src/context.rs b/crates/exex/src/context.rs index 69b48f14e..619679e85 100644 --- a/crates/exex/src/context.rs +++ b/crates/exex/src/context.rs @@ -1,4 +1,4 @@ -use reth_node_api::FullNodeTypes; +use reth_node_api::FullNodeComponents; use reth_node_core::{ dirs::{ChainPath, DataDirPath}, node_config::NodeConfig, @@ -12,7 +12,7 @@ use crate::ExExEvent; /// Captures the context that an ExEx has access to. #[derive(Debug)] -pub struct ExExContext { +pub struct ExExContext { /// The current head of the blockchain at launch. pub head: Head, /// The configured provider to interact with the blockchain. @@ -25,6 +25,8 @@ pub struct ExExContext { pub config: NodeConfig, /// The loaded node config pub reth_config: reth_config::Config, + /// The transaction pool of the node. + pub pool: Node::Pool, /// Channel used to send [`ExExEvent`]s to the rest of the node. /// /// # Important diff --git a/crates/node-builder/src/builder.rs b/crates/node-builder/src/builder.rs index 77f7c67af..2c387161f 100644 --- a/crates/node-builder/src/builder.rs +++ b/crates/node-builder/src/builder.rs @@ -610,6 +610,7 @@ where data_dir: data_dir.clone(), config: config.clone(), reth_config: reth_config.clone(), + pool: transaction_pool.clone(), events, notifications, }; diff --git a/crates/node-builder/src/exex.rs b/crates/node-builder/src/exex.rs index ff2d0f84a..ae9ace8cd 100644 --- a/crates/node-builder/src/exex.rs +++ b/crates/node-builder/src/exex.rs @@ -1,11 +1,11 @@ //! Types for launching execution extensions (ExEx). -use crate::FullNodeTypes; use futures::{future::BoxFuture, FutureExt}; use reth_exex::ExExContext; +use reth_node_api::FullNodeComponents; use std::future::Future; /// A trait for launching an ExEx. -trait LaunchExEx: Send { +trait LaunchExEx: Send { /// Launches the ExEx. /// /// The ExEx should be able to run independently and emit events on the channels provided in @@ -19,7 +19,7 @@ trait LaunchExEx: Send { type BoxExEx = BoxFuture<'static, eyre::Result<()>>; /// A version of [LaunchExEx] that returns a boxed future. Makes the trait object-safe. -pub(crate) trait BoxedLaunchExEx: Send { +pub(crate) trait BoxedLaunchExEx: Send { fn launch(self: Box, ctx: ExExContext) -> BoxFuture<'static, eyre::Result>; } @@ -30,7 +30,7 @@ pub(crate) trait BoxedLaunchExEx: Send { impl BoxedLaunchExEx for E where E: LaunchExEx + Send + 'static, - Node: FullNodeTypes, + Node: FullNodeComponents, { fn launch( self: Box, @@ -48,7 +48,7 @@ where /// resolving to an ExEx. impl LaunchExEx for F where - Node: FullNodeTypes, + Node: FullNodeComponents, F: FnOnce(ExExContext) -> Fut + Send, Fut: Future> + Send, E: Future> + Send, diff --git a/crates/node-ethereum/tests/it/exex.rs b/crates/node-ethereum/tests/it/exex.rs index b1f7a92f7..bbab6d9dc 100644 --- a/crates/node-ethereum/tests/it/exex.rs +++ b/crates/node-ethereum/tests/it/exex.rs @@ -1,7 +1,8 @@ use futures::future; use reth_db::test_utils::create_test_rw_db; use reth_exex::ExExContext; -use reth_node_builder::{FullNodeTypes, NodeBuilder, NodeConfig}; +use reth_node_api::FullNodeComponents; +use reth_node_builder::{NodeBuilder, NodeConfig}; use reth_node_ethereum::EthereumNode; use std::{ future::Future, @@ -9,11 +10,14 @@ use std::{ task::{Context, Poll}, }; -struct DummyExEx { +struct DummyExEx { _ctx: ExExContext, } -impl Future for DummyExEx { +impl Future for DummyExEx +where + Node: FullNodeComponents, +{ type Output = eyre::Result<()>; fn poll(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll { diff --git a/examples/exex/minimal/src/main.rs b/examples/exex/minimal/src/main.rs index 410a4a4ea..ff71a71ac 100644 --- a/examples/exex/minimal/src/main.rs +++ b/examples/exex/minimal/src/main.rs @@ -1,6 +1,6 @@ use futures::Future; -use reth::builder::FullNodeTypes; use reth_exex::ExExContext; +use reth_node_api::FullNodeComponents; use reth_node_ethereum::EthereumNode; use reth_provider::CanonStateNotification; @@ -8,7 +8,7 @@ use reth_provider::CanonStateNotification; /// /// During initialization you can wait for resources you need to be up for the ExEx to function, /// like a database connection. -async fn exex_init( +async fn exex_init( ctx: ExExContext, ) -> eyre::Result>> { Ok(exex(ctx)) @@ -18,7 +18,7 @@ async fn exex_init( /// /// This ExEx just prints out whenever a state transition happens, either a new chain segment being /// added, or a chain segment being re-orged. -async fn exex(mut ctx: ExExContext) -> eyre::Result<()> { +async fn exex(mut ctx: ExExContext) -> eyre::Result<()> { while let Some(notification) = ctx.notifications.recv().await { match ¬ification { CanonStateNotification::Commit { new } => { diff --git a/examples/exex/op-bridge/src/main.rs b/examples/exex/op-bridge/src/main.rs index 84f2d47b1..6f7dd6d60 100644 --- a/examples/exex/op-bridge/src/main.rs +++ b/examples/exex/op-bridge/src/main.rs @@ -1,7 +1,7 @@ use alloy_sol_types::{sol, SolEventInterface}; use futures::Future; -use reth::builder::FullNodeTypes; use reth_exex::{ExExContext, ExExEvent}; +use reth_node_api::FullNodeComponents; use reth_node_ethereum::EthereumNode; use reth_primitives::{Log, SealedBlockWithSenders, TransactionSigned}; use reth_provider::Chain; @@ -14,7 +14,7 @@ use crate::L1StandardBridge::{ETHBridgeFinalized, ETHBridgeInitiated, L1Standard /// Initializes the ExEx. /// /// Opens up a SQLite database and creates the tables (if they don't exist). -async fn init( +async fn init( ctx: ExExContext, mut connection: Connection, ) -> eyre::Result>> { @@ -88,7 +88,7 @@ fn create_tables(connection: &mut Connection) -> rusqlite::Result<()> { /// An example of ExEx that listens to ETH bridging events from OP Stack chains /// and stores deposits and withdrawals in a SQLite database. -async fn op_bridge_exex( +async fn op_bridge_exex( mut ctx: ExExContext, connection: Connection, ) -> eyre::Result<()> {