mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat: exex crate (#7506)
This commit is contained in:
15
Cargo.lock
generated
15
Cargo.lock
generated
@ -6454,6 +6454,19 @@ dependencies = [
|
|||||||
"reth-primitives",
|
"reth-primitives",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "reth-exex"
|
||||||
|
version = "0.2.0-beta.5"
|
||||||
|
dependencies = [
|
||||||
|
"reth-config",
|
||||||
|
"reth-node-api",
|
||||||
|
"reth-node-core",
|
||||||
|
"reth-primitives",
|
||||||
|
"reth-provider",
|
||||||
|
"reth-tasks",
|
||||||
|
"tokio",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "reth-interfaces"
|
name = "reth-interfaces"
|
||||||
version = "0.2.0-beta.5"
|
version = "0.2.0-beta.5"
|
||||||
@ -6690,6 +6703,7 @@ dependencies = [
|
|||||||
"reth-blockchain-tree",
|
"reth-blockchain-tree",
|
||||||
"reth-config",
|
"reth-config",
|
||||||
"reth-db",
|
"reth-db",
|
||||||
|
"reth-exex",
|
||||||
"reth-interfaces",
|
"reth-interfaces",
|
||||||
"reth-network",
|
"reth-network",
|
||||||
"reth-node-api",
|
"reth-node-api",
|
||||||
@ -6784,6 +6798,7 @@ dependencies = [
|
|||||||
"reth-db",
|
"reth-db",
|
||||||
"reth-ethereum-payload-builder",
|
"reth-ethereum-payload-builder",
|
||||||
"reth-evm-ethereum",
|
"reth-evm-ethereum",
|
||||||
|
"reth-exex",
|
||||||
"reth-network",
|
"reth-network",
|
||||||
"reth-node-api",
|
"reth-node-api",
|
||||||
"reth-node-builder",
|
"reth-node-builder",
|
||||||
|
|||||||
11
Cargo.toml
11
Cargo.toml
@ -11,6 +11,7 @@ members = [
|
|||||||
"crates/etl/",
|
"crates/etl/",
|
||||||
"crates/evm/",
|
"crates/evm/",
|
||||||
"crates/evm-ethereum/",
|
"crates/evm-ethereum/",
|
||||||
|
"crates/exex/",
|
||||||
"crates/interfaces/",
|
"crates/interfaces/",
|
||||||
"crates/metrics/",
|
"crates/metrics/",
|
||||||
"crates/metrics/metrics-derive/",
|
"crates/metrics/metrics-derive/",
|
||||||
@ -217,6 +218,7 @@ reth-ethereum-payload-builder = { path = "crates/payload/ethereum" }
|
|||||||
reth-etl = { path = "crates/etl" }
|
reth-etl = { path = "crates/etl" }
|
||||||
reth-evm = { path = "crates/evm" }
|
reth-evm = { path = "crates/evm" }
|
||||||
reth-evm-ethereum = { path = "crates/evm-ethereum" }
|
reth-evm-ethereum = { path = "crates/evm-ethereum" }
|
||||||
|
reth-exex = { path = "crates/exex" }
|
||||||
reth-optimism-payload-builder = { path = "crates/payload/optimism" }
|
reth-optimism-payload-builder = { path = "crates/payload/optimism" }
|
||||||
reth-interfaces = { path = "crates/interfaces" }
|
reth-interfaces = { path = "crates/interfaces" }
|
||||||
reth-ipc = { path = "crates/rpc/ipc" }
|
reth-ipc = { path = "crates/rpc/ipc" }
|
||||||
@ -252,8 +254,13 @@ reth-trie = { path = "crates/trie" }
|
|||||||
reth-trie-parallel = { path = "crates/trie-parallel" }
|
reth-trie-parallel = { path = "crates/trie-parallel" }
|
||||||
|
|
||||||
# revm
|
# revm
|
||||||
revm = { version = "8.0.0", features = ["std", "secp256k1"], default-features = false }
|
revm = { version = "8.0.0", features = [
|
||||||
revm-primitives = { version = "3.1.0", features = ["std"], default-features = false }
|
"std",
|
||||||
|
"secp256k1",
|
||||||
|
], default-features = false }
|
||||||
|
revm-primitives = { version = "3.1.0", features = [
|
||||||
|
"std",
|
||||||
|
], default-features = false }
|
||||||
revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "5baa6b3" }
|
revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "5baa6b3" }
|
||||||
|
|
||||||
# eth
|
# eth
|
||||||
|
|||||||
21
crates/exex/Cargo.toml
Normal file
21
crates/exex/Cargo.toml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
[package]
|
||||||
|
name = "reth-exex"
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
rust-version.workspace = true
|
||||||
|
license.workspace = true
|
||||||
|
homepage.workspace = true
|
||||||
|
repository.workspace = true
|
||||||
|
description = "Execution extensions for Reth"
|
||||||
|
|
||||||
|
[lints]
|
||||||
|
workspace = true
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
reth-config.workspace = true
|
||||||
|
reth-node-api.workspace = true
|
||||||
|
reth-node-core.workspace = true
|
||||||
|
reth-primitives.workspace = true
|
||||||
|
reth-provider.workspace = true
|
||||||
|
reth-tasks.workspace = true
|
||||||
|
tokio.workspace = true
|
||||||
44
crates/exex/src/context.rs
Normal file
44
crates/exex/src/context.rs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
use reth_node_api::FullNodeTypes;
|
||||||
|
use reth_node_core::{
|
||||||
|
dirs::{ChainPath, DataDirPath},
|
||||||
|
node_config::NodeConfig,
|
||||||
|
};
|
||||||
|
use reth_primitives::Head;
|
||||||
|
use reth_provider::CanonStateNotification;
|
||||||
|
use reth_tasks::TaskExecutor;
|
||||||
|
use tokio::sync::mpsc::{Receiver, Sender};
|
||||||
|
|
||||||
|
use crate::ExExEvent;
|
||||||
|
|
||||||
|
/// Captures the context that an ExEx has access to.
|
||||||
|
#[derive(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,
|
||||||
|
/// Channel used to send [`ExExEvent`]s to the rest of the node.
|
||||||
|
///
|
||||||
|
/// # Important
|
||||||
|
///
|
||||||
|
/// The exex should emit a `FinishedHeight` whenever a processed block is safe to prune.
|
||||||
|
/// Additionally, the exex can pre-emptively emit a `FinishedHeight` event to specify what
|
||||||
|
/// blocks to receive notifications for.
|
||||||
|
pub events: Sender<ExExEvent>,
|
||||||
|
/// Channel to receive [`CanonStateNotification`]s on state transitions.
|
||||||
|
///
|
||||||
|
/// # Important
|
||||||
|
///
|
||||||
|
/// Once a `CanonStateNotification` is sent over the channel, it is considered delivered by the
|
||||||
|
/// node.
|
||||||
|
pub notifications: Receiver<CanonStateNotification>,
|
||||||
|
// TODO(alexey): add pool, payload builder, anything else?
|
||||||
|
}
|
||||||
13
crates/exex/src/event.rs
Normal file
13
crates/exex/src/event.rs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
use reth_primitives::BlockNumber;
|
||||||
|
|
||||||
|
/// 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),
|
||||||
|
}
|
||||||
16
crates/exex/src/lib.rs
Normal file
16
crates/exex/src/lib.rs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
//! Execution extensions.
|
||||||
|
//!
|
||||||
|
//! TBD
|
||||||
|
#![doc(
|
||||||
|
html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
|
||||||
|
html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
|
||||||
|
issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
|
||||||
|
)]
|
||||||
|
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
||||||
|
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
|
||||||
|
|
||||||
|
mod context;
|
||||||
|
pub use context::*;
|
||||||
|
|
||||||
|
mod event;
|
||||||
|
pub use event::*;
|
||||||
@ -16,6 +16,7 @@ workspace = true
|
|||||||
reth-auto-seal-consensus.workspace = true
|
reth-auto-seal-consensus.workspace = true
|
||||||
reth-beacon-consensus.workspace = true
|
reth-beacon-consensus.workspace = true
|
||||||
reth-blockchain-tree.workspace = true
|
reth-blockchain-tree.workspace = true
|
||||||
|
reth-exex.workspace = true
|
||||||
reth-provider.workspace = true
|
reth-provider.workspace = true
|
||||||
reth-revm.workspace = true
|
reth-revm.workspace = true
|
||||||
reth-db.workspace = true
|
reth-db.workspace = true
|
||||||
|
|||||||
@ -7,7 +7,7 @@ use crate::{
|
|||||||
ComponentsBuilder, FullNodeComponents, FullNodeComponentsAdapter, NodeComponents,
|
ComponentsBuilder, FullNodeComponents, FullNodeComponentsAdapter, NodeComponents,
|
||||||
NodeComponentsBuilder, PoolBuilder,
|
NodeComponentsBuilder, PoolBuilder,
|
||||||
},
|
},
|
||||||
exex::{BoxedLaunchExEx, ExExContext},
|
exex::BoxedLaunchExEx,
|
||||||
hooks::NodeHooks,
|
hooks::NodeHooks,
|
||||||
node::FullNode,
|
node::FullNode,
|
||||||
rpc::{RethRpcServerHandles, RpcContext, RpcHooks},
|
rpc::{RethRpcServerHandles, RpcContext, RpcHooks},
|
||||||
@ -28,6 +28,7 @@ use reth_db::{
|
|||||||
test_utils::{create_test_rw_db, TempDatabase},
|
test_utils::{create_test_rw_db, TempDatabase},
|
||||||
DatabaseEnv,
|
DatabaseEnv,
|
||||||
};
|
};
|
||||||
|
use reth_exex::ExExContext;
|
||||||
use reth_interfaces::p2p::either::EitherDownloader;
|
use reth_interfaces::p2p::either::EitherDownloader;
|
||||||
use reth_network::{NetworkBuilder, NetworkConfig, NetworkEvents, NetworkHandle};
|
use reth_network::{NetworkBuilder, NetworkConfig, NetworkEvents, NetworkHandle};
|
||||||
use reth_node_api::{FullNodeTypes, FullNodeTypesAdapter, NodeTypes};
|
use reth_node_api::{FullNodeTypes, FullNodeTypesAdapter, NodeTypes};
|
||||||
|
|||||||
@ -25,49 +25,14 @@
|
|||||||
//! `block_number >= 0`.
|
//! `block_number >= 0`.
|
||||||
//!
|
//!
|
||||||
//! [`Future`]: std::future::Future
|
//! [`Future`]: std::future::Future
|
||||||
//! [`ExExContext`]: crate::exex::ExExContext
|
//! [`ExExContext`]: reth_exex::ExExContext
|
||||||
//! [`CanonStateNotification`]: reth_provider::CanonStateNotification
|
//! [`CanonStateNotification`]: reth_provider::CanonStateNotification
|
||||||
|
|
||||||
use crate::FullNodeTypes;
|
use crate::FullNodeTypes;
|
||||||
use futures::{future::BoxFuture, FutureExt};
|
use futures::{future::BoxFuture, FutureExt};
|
||||||
use reth_node_core::{
|
use reth_exex::ExExContext;
|
||||||
dirs::{ChainPath, DataDirPath},
|
|
||||||
node_config::NodeConfig,
|
|
||||||
};
|
|
||||||
use reth_primitives::{BlockNumber, Head};
|
|
||||||
use reth_tasks::TaskExecutor;
|
|
||||||
use std::future::Future;
|
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.
|
/// A trait for launching an ExEx.
|
||||||
trait LaunchExEx<Node: FullNodeTypes>: Send {
|
trait LaunchExEx<Node: FullNodeTypes>: Send {
|
||||||
/// Launches the ExEx.
|
/// Launches the ExEx.
|
||||||
|
|||||||
@ -31,5 +31,5 @@ serde.workspace = true
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
reth-db.workspace = true
|
reth-db.workspace = true
|
||||||
|
reth-exex.workspace = true
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
use futures::future;
|
use futures::future;
|
||||||
use reth_db::test_utils::create_test_rw_db;
|
use reth_db::test_utils::create_test_rw_db;
|
||||||
use reth_node_builder::{exex::ExExContext, FullNodeTypes, NodeBuilder, NodeConfig};
|
use reth_exex::ExExContext;
|
||||||
|
use reth_node_builder::{FullNodeTypes, NodeBuilder, NodeConfig};
|
||||||
use reth_node_ethereum::EthereumNode;
|
use reth_node_ethereum::EthereumNode;
|
||||||
use std::{
|
use std::{
|
||||||
future::Future,
|
future::Future,
|
||||||
|
|||||||
Reference in New Issue
Block a user