From cab1852ef9757ea29b4f8e00c5640c3571667d48 Mon Sep 17 00:00:00 2001 From: refcell Date: Thu, 4 Dec 2025 13:15:36 -0500 Subject: [PATCH] feat(cli): refactor cli utils out to reduce binary clutter --- Cargo.lock | 9 ++++++++- Cargo.toml | 1 + bin/node/Cargo.toml | 2 +- bin/node/src/main.rs | 3 +-- crates/cli/Cargo.toml | 15 +++++++++++++++ crates/cli/README.md | 3 +++ crates/cli/src/lib.rs | 7 +++++++ {bin/node => crates/cli}/src/version.rs | 14 ++++++++------ 8 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 crates/cli/Cargo.toml create mode 100644 crates/cli/README.md create mode 100644 crates/cli/src/lib.rs rename {bin/node => crates/cli}/src/version.rs (72%) diff --git a/Cargo.lock b/Cargo.lock index 87a3d269..1895e95c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1540,6 +1540,13 @@ dependencies = [ "tokio", ] +[[package]] +name = "base-reth-cli" +version = "0.2.1" +dependencies = [ + "reth", +] + [[package]] name = "base-reth-flashblocks-rpc" version = "0.2.1" @@ -1630,9 +1637,9 @@ dependencies = [ name = "base-reth-node" version = "0.2.1" dependencies = [ + "base-reth-cli", "base-reth-runner", "clap", - "reth", "reth-cli-util", "reth-optimism-cli", "reth-optimism-node", diff --git a/Cargo.toml b/Cargo.toml index a405a61f..d58558ce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,6 +51,7 @@ codegen-units = 1 [workspace.dependencies] # internal +base-reth-cli = { path = "crates/cli" } base-reth-metering = { path = "crates/metering" } base-reth-test-utils = { path = "crates/test-utils" } base-reth-flashblocks-rpc = { path = "crates/flashblocks-rpc" } diff --git a/bin/node/Cargo.toml b/bin/node/Cargo.toml index 5117202a..298d097c 100644 --- a/bin/node/Cargo.toml +++ b/bin/node/Cargo.toml @@ -14,10 +14,10 @@ workspace = true [dependencies] # internal +base-reth-cli.workspace = true base-reth-runner.workspace = true # reth -reth.workspace = true reth-optimism-node.workspace = true reth-optimism-cli.workspace = true reth-cli-util.workspace = true diff --git a/bin/node/src/main.rs b/bin/node/src/main.rs index c74b853e..ffd984a9 100644 --- a/bin/node/src/main.rs +++ b/bin/node/src/main.rs @@ -4,7 +4,6 @@ #![cfg_attr(not(test), warn(unused_crate_dependencies))] pub mod cli; -pub mod version; use base_reth_runner::BaseNodeLauncher; @@ -13,7 +12,7 @@ static ALLOC: reth_cli_util::allocator::Allocator = reth_cli_util::allocator::ne fn main() { // Step 1: Initialize versioning so logs / telemetry report the right build info. - version::Version::init(); + base_reth_cli::Version::init(); // Step 2: Parse CLI arguments and hand execution to the Optimism node runner. use clap::Parser; diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml new file mode 100644 index 00000000..3680b617 --- /dev/null +++ b/crates/cli/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "base-reth-cli" +version.workspace = true +edition.workspace = true +rust-version.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true +description = "CLI Utilities" + +[lints] +workspace = true + +[dependencies] +reth.workspace = true diff --git a/crates/cli/README.md b/crates/cli/README.md new file mode 100644 index 00000000..1b35a8f1 --- /dev/null +++ b/crates/cli/README.md @@ -0,0 +1,3 @@ +# CLI Utilities for Base Reth + +Contains a set of utilities for the Base Reth node CLI. diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs new file mode 100644 index 00000000..0f1115dd --- /dev/null +++ b/crates/cli/src/lib.rs @@ -0,0 +1,7 @@ +#![doc = include_str!("../README.md")] +#![doc(issue_tracker_base_url = "https://github.com/base/node-reth/issues/")] +#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] +#![cfg_attr(not(test), warn(unused_crate_dependencies))] + +mod version; +pub use version::Version; diff --git a/bin/node/src/version.rs b/crates/cli/src/version.rs similarity index 72% rename from bin/node/src/version.rs rename to crates/cli/src/version.rs index 34d6d051..3ae33aed 100644 --- a/bin/node/src/version.rs +++ b/crates/cli/src/version.rs @@ -4,14 +4,14 @@ use reth::version::{ RethCliVersionConsts, default_reth_version_metadata, try_init_version_metadata, }; -/// The client version string for the Base Reth node. -pub const NODE_RETH_CLIENT_VERSION: &str = concat!("base/v", env!("CARGO_PKG_VERSION")); - /// Encapsulates versioning. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, Copy, Eq, PartialEq)] pub struct Version; impl Version { + /// The client version string for the Base Reth node. + pub const NODE_RETH_CLIENT_VERSION: &str = concat!("base/v", env!("CARGO_PKG_VERSION")); + /// Initializes the versioning for the Base Reth node. /// /// ### Panics @@ -29,12 +29,14 @@ impl Version { .into(), p2p_client_version: format!( "{}/{}", - default_version_metadata.p2p_client_version, NODE_RETH_CLIENT_VERSION + default_version_metadata.p2p_client_version, + Self::NODE_RETH_CLIENT_VERSION ) .into(), extra_data: format!( "{}/{}", - default_version_metadata.extra_data, NODE_RETH_CLIENT_VERSION + default_version_metadata.extra_data, + Self::NODE_RETH_CLIENT_VERSION ) .into(), ..default_version_metadata