Skip to content

Commit 9426cd0

Browse files
authored
feat(cli): refactor cli utils out to reduce binary clutter (#234)
1 parent b953513 commit 9426cd0

File tree

8 files changed

+44
-10
lines changed

8 files changed

+44
-10
lines changed

Cargo.lock

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ codegen-units = 1
5151

5252
[workspace.dependencies]
5353
# internal
54+
base-reth-cli = { path = "crates/cli" }
5455
base-reth-metering = { path = "crates/metering" }
5556
base-reth-test-utils = { path = "crates/test-utils" }
5657
base-reth-flashblocks-rpc = { path = "crates/flashblocks-rpc" }

bin/node/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ workspace = true
1414

1515
[dependencies]
1616
# internal
17+
base-reth-cli.workspace = true
1718
base-reth-runner.workspace = true
1819

1920
# reth
20-
reth.workspace = true
2121
reth-optimism-node.workspace = true
2222
reth-optimism-cli.workspace = true
2323
reth-cli-util.workspace = true

bin/node/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
55

66
pub mod cli;
7-
pub mod version;
87

98
use base_reth_runner::BaseNodeLauncher;
109

@@ -13,7 +12,7 @@ static ALLOC: reth_cli_util::allocator::Allocator = reth_cli_util::allocator::ne
1312

1413
fn main() {
1514
// Step 1: Initialize versioning so logs / telemetry report the right build info.
16-
version::Version::init();
15+
base_reth_cli::Version::init();
1716

1817
// Step 2: Parse CLI arguments and hand execution to the Optimism node runner.
1918
use clap::Parser;

crates/cli/Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "base-reth-cli"
3+
version.workspace = true
4+
edition.workspace = true
5+
rust-version.workspace = true
6+
license.workspace = true
7+
homepage.workspace = true
8+
repository.workspace = true
9+
description = "CLI Utilities"
10+
11+
[lints]
12+
workspace = true
13+
14+
[dependencies]
15+
reth.workspace = true

crates/cli/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# CLI Utilities for Base Reth
2+
3+
Contains a set of utilities for the Base Reth node CLI.

crates/cli/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#![doc = include_str!("../README.md")]
2+
#![doc(issue_tracker_base_url = "https://github.com/base/node-reth/issues/")]
3+
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
4+
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
5+
6+
mod version;
7+
pub use version::Version;
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ use reth::version::{
44
RethCliVersionConsts, default_reth_version_metadata, try_init_version_metadata,
55
};
66

7-
/// The client version string for the Base Reth node.
8-
pub const NODE_RETH_CLIENT_VERSION: &str = concat!("base/v", env!("CARGO_PKG_VERSION"));
9-
107
/// Encapsulates versioning.
11-
#[derive(Debug, Clone)]
8+
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
129
pub struct Version;
1310

1411
impl Version {
12+
/// The client version string for the Base Reth node.
13+
pub const NODE_RETH_CLIENT_VERSION: &str = concat!("base/v", env!("CARGO_PKG_VERSION"));
14+
1515
/// Initializes the versioning for the Base Reth node.
1616
///
1717
/// ### Panics
@@ -29,12 +29,14 @@ impl Version {
2929
.into(),
3030
p2p_client_version: format!(
3131
"{}/{}",
32-
default_version_metadata.p2p_client_version, NODE_RETH_CLIENT_VERSION
32+
default_version_metadata.p2p_client_version,
33+
Self::NODE_RETH_CLIENT_VERSION
3334
)
3435
.into(),
3536
extra_data: format!(
3637
"{}/{}",
37-
default_version_metadata.extra_data, NODE_RETH_CLIENT_VERSION
38+
default_version_metadata.extra_data,
39+
Self::NODE_RETH_CLIENT_VERSION
3840
)
3941
.into(),
4042
..default_version_metadata

0 commit comments

Comments
 (0)