Custom binary wrapping reth works

This commit is contained in:
Antonio Antonino 2025-04-09 09:07:39 +02:00
parent 9cfc93b574
commit 8ee6c1c12d
No known key found for this signature in database
GPG Key ID: 70CC1DF6BCF7E76D
5 changed files with 53 additions and 11 deletions

View File

@ -1,5 +1,5 @@
[workspace]
members = ["node"]
members = ["evm/evm-node"]
resolver = "3"
[workspace.package]
@ -7,7 +7,12 @@ edition = "2024"
[workspace.dependencies]
# Internal
node = { path = "node" }
evm-node = { path = "evm/evm-node" }
# External
tokio = { version = "1.0" }
clap = { version = "4.5" }
futures-util = { version = "0.3" }
jsonrpsee = { version = "0.24" }
reth = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.8" }
reth-cli-commands = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.8" }
reth-node-ethereum = { git = "https://github.com/paradigmxyz/reth", tag = "v1.3.8" }

View File

@ -0,0 +1,11 @@
[package]
name = "evm-node"
edition = { workspace = true }
[dependencies]
clap = { workspace = true }
futures-util = { workspace = true }
jsonrpsee = { workspace = true }
reth = { workspace = true }
reth-cli-commands = { workspace = true }
reth-node-ethereum = { workspace = true }

View File

@ -0,0 +1,34 @@
use clap::Parser;
use futures_util::StreamExt;
use reth::{
builder::NodeHandle, chainspec::EthereumChainSpecParser, cli::Cli,
transaction_pool::TransactionPool,
};
use reth_cli_commands::node::NoArgs;
use reth_node_ethereum::node::EthereumNode;
fn main() {
Cli::<EthereumChainSpecParser, NoArgs>::parse()
.run(|builder, _| async move {
// launch the node
let NodeHandle {
node,
node_exit_future,
} = builder.node(EthereumNode::default()).launch().await?;
// create a new subscription to pending transactions
let mut pending_transactions = node.pool.new_pending_pool_transactions_listener();
// Spawn an async block to listen for validated transactions.
node.task_executor.spawn(Box::pin(async move {
// Waiting for new transactions
while let Some(event) = pending_transactions.next().await {
let tx = event.transaction;
println!("Transaction received: {:?}", tx.transaction);
}
}));
node_exit_future.await
})
.unwrap();
}

View File

@ -1,6 +0,0 @@
[package]
name = "node"
edition = { workspace = true }
[dependencies]
tokio = { workspace = true, features = ["full"] }

View File

@ -1,2 +0,0 @@
#[tokio::main]
async fn main() {}