feat: exex crate (#7506)

This commit is contained in:
Oliver Nordbjerg
2024-04-08 14:20:07 +02:00
committed by GitHub
parent f5073e6542
commit 8c89d9ca85
11 changed files with 126 additions and 42 deletions

View File

@ -16,6 +16,7 @@ workspace = true
reth-auto-seal-consensus.workspace = true
reth-beacon-consensus.workspace = true
reth-blockchain-tree.workspace = true
reth-exex.workspace = true
reth-provider.workspace = true
reth-revm.workspace = true
reth-db.workspace = true

View File

@ -7,7 +7,7 @@ use crate::{
ComponentsBuilder, FullNodeComponents, FullNodeComponentsAdapter, NodeComponents,
NodeComponentsBuilder, PoolBuilder,
},
exex::{BoxedLaunchExEx, ExExContext},
exex::BoxedLaunchExEx,
hooks::NodeHooks,
node::FullNode,
rpc::{RethRpcServerHandles, RpcContext, RpcHooks},
@ -28,6 +28,7 @@ use reth_db::{
test_utils::{create_test_rw_db, TempDatabase},
DatabaseEnv,
};
use reth_exex::ExExContext;
use reth_interfaces::p2p::either::EitherDownloader;
use reth_network::{NetworkBuilder, NetworkConfig, NetworkEvents, NetworkHandle};
use reth_node_api::{FullNodeTypes, FullNodeTypesAdapter, NodeTypes};

View File

@ -25,49 +25,14 @@
//! `block_number >= 0`.
//!
//! [`Future`]: std::future::Future
//! [`ExExContext`]: crate::exex::ExExContext
//! [`ExExContext`]: reth_exex::ExExContext
//! [`CanonStateNotification`]: reth_provider::CanonStateNotification
use crate::FullNodeTypes;
use futures::{future::BoxFuture, FutureExt};
use reth_node_core::{
dirs::{ChainPath, DataDirPath},
node_config::NodeConfig,
};
use reth_primitives::{BlockNumber, Head};
use reth_tasks::TaskExecutor;
use reth_exex::ExExContext;
use std::future::Future;
/// Events emitted by an ExEx.
#[derive(Debug)]
pub enum ExExEvent {
/// Highest block processed by the ExEx.
///
/// The ExEx must guarantee that it will not require all earlier blocks in the future, meaning
/// that Reth is allowed to prune them.
///
/// On reorgs, it's possible for the height to go down.
FinishedHeight(BlockNumber),
}
/// Captures the context that an ExEx has access to.
#[derive(Clone, Debug)]
pub struct ExExContext<Node: FullNodeTypes> {
/// The current head of the blockchain at launch.
pub head: Head,
/// The configured provider to interact with the blockchain.
pub provider: Node::Provider,
/// The task executor of the node.
pub task_executor: TaskExecutor,
/// The data dir of the node.
pub data_dir: ChainPath<DataDirPath>,
/// The config of the node
pub config: NodeConfig,
/// The loaded node config
pub reth_config: reth_config::Config,
// TODO(alexey): add pool, payload builder, anything else?
}
/// A trait for launching an ExEx.
trait LaunchExEx<Node: FullNodeTypes>: Send {
/// Launches the ExEx.