Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions crates/node/builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ reth-cli-util.workspace = true
reth-config.workspace = true
reth-consensus-debug-client.workspace = true
reth-consensus.workspace = true
reth-db = { workspace = true, features = ["mdbx"], optional = true }
reth-db = { workspace = true, features = ["mdbx"] }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems okay, this is in the dep graph anyway

reth-db-api.workspace = true
reth-db-common.workspace = true
reth-downloaders.workspace = true
Expand Down Expand Up @@ -97,7 +97,6 @@ reth-evm-ethereum = { workspace = true, features = ["test-utils"] }
default = []
js-tracer = ["reth-rpc/js-tracer"]
test-utils = [
"dep:reth-db",
"reth-db/test-utils",
"reth-chain-state/test-utils",
"reth-chainspec/test-utils",
Expand All @@ -117,7 +116,7 @@ test-utils = [
"reth-primitives-traits/test-utils",
]
op = [
"reth-db?/op",
"reth-db/op",
"reth-db-api/op",
"reth-engine-local/op",
"reth-evm/op",
Expand Down
14 changes: 13 additions & 1 deletion crates/node/builder/src/node.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
use reth_db::DatabaseEnv;
// re-export the node api types
pub use reth_node_api::{FullNodeTypes, NodeTypes};

use crate::{components::NodeComponentsBuilder, rpc::RethRpcAddOns, NodeAdapter, NodeAddOns};
use crate::{
components::NodeComponentsBuilder, rpc::RethRpcAddOns, NodeAdapter, NodeAddOns, NodeHandle,
RethFullAdapter,
};
use reth_node_api::{EngineTypes, FullNodeComponents, PayloadTypes};
use reth_node_core::{
dirs::{ChainPath, DataDirPath},
Expand Down Expand Up @@ -208,3 +212,11 @@ impl<Node: FullNodeComponents, AddOns: NodeAddOns<Node>> DerefMut for FullNode<N
&mut self.add_ons_handle
}
}

/// Helper type alias to define [`FullNode`] for a given [`Node`].
pub type FullNodeFor<N, DB = Arc<DatabaseEnv>> =
FullNode<NodeAdapter<RethFullAdapter<DB, N>>, <N as Node<RethFullAdapter<DB, N>>>::AddOns>;

/// Helper type alias to define [`NodeHandle`] for a given [`Node`].
pub type NodeHandleFor<N, DB = Arc<DatabaseEnv>> =
NodeHandle<NodeAdapter<RethFullAdapter<DB, N>>, <N as Node<RethFullAdapter<DB, N>>>::AddOns>;
8 changes: 5 additions & 3 deletions examples/custom-inspector/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use reth_ethereum::{
interpreter::{interpreter::EthInterpreter, interpreter_types::Jumps, Interpreter},
},
},
node::{builder::NodeHandle, EthereumNode},
node::{builder::FullNodeFor, EthereumNode},
pool::TransactionPool,
rpc::api::eth::helpers::Call,
};
Expand All @@ -36,8 +36,10 @@ fn main() {
Cli::<EthereumChainSpecParser, RethCliTxpoolExt>::parse()
.run(|builder, args| async move {
// launch the node
let NodeHandle { node, node_exit_future } =
builder.node(EthereumNode::default()).launch().await?;
let handle = builder.node(EthereumNode::default()).launch().await?;

let node: FullNodeFor<EthereumNode> = handle.node;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these just for testing, because nothing changed here so we dont really need type hints here, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, this is just for testing

let node_exit_future = handle.node_exit_future;

// create a new subscription to pending transactions
let mut pending_transactions = node.pool.new_pending_pool_transactions_listener();
Expand Down
4 changes: 2 additions & 2 deletions examples/exex-subscription/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use jsonrpsee::{
};
use reth_ethereum::{
exex::{ExExContext, ExExEvent, ExExNotification},
node::{api::FullNodeComponents, EthereumNode},
node::{api::FullNodeComponents, builder::NodeHandleFor, EthereumNode},
};
use std::collections::HashMap;
use tokio::sync::{mpsc, oneshot};
Expand Down Expand Up @@ -178,7 +178,7 @@ fn main() -> eyre::Result<()> {

let rpc = StorageWatcherRpc::new(subscriptions_tx.clone());

let handle = builder
let handle: NodeHandleFor<EthereumNode> = builder
.node(EthereumNode::default())
.extend_rpc_modules(move |ctx| {
ctx.modules.merge_configured(StorageWatcherApiServer::into_rpc(rpc))?;
Expand Down
Loading