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
26 changes: 14 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace.package]
version = "0.2.1"
version = "0.2.2"
edition = "2024"
rust-version = "1.88"
license = "MIT OR Apache-2.0"
Expand Down Expand Up @@ -175,6 +175,8 @@ tokio-stream = "0.1.17"
tokio-util = "0.7.16"
tracing = "0.1.41"
tracing-subscriber = "0.3.22"
vergen = "9.1.0"
vergen-git2 = "9.1.0"
criterion = "0.7.0"
test-case = "3"
pyroscope = "0.5.8"
Expand Down
4 changes: 4 additions & 0 deletions bin/morph-reth/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ use std::sync::Arc;
use tracing::info;

fn main() {
// Override reth's default version info with morph-reth's own version,
// commit SHA, and build timestamp. Must be called before CLI parsing.
morph_node::version::init_version_metadata();

// Install signal handler for segmentation faults
sigsegv_handler::install();

Expand Down
5 changes: 5 additions & 0 deletions crates/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ morph-txpool.workspace = true

# Reth dependencies
reth-db.workspace = true
reth-node-core.workspace = true
reth-chainspec.workspace = true
reth-engine-local.workspace = true
reth-engine-tree.workspace = true
Expand Down Expand Up @@ -67,6 +68,10 @@ alloy-rlp = { workspace = true, optional = true }
alloy-signer = { workspace = true, optional = true }
alloy-signer-local = { workspace = true, optional = true }

[build-dependencies]
vergen.workspace = true
vergen-git2.workspace = true

[dev-dependencies]
tokio = { workspace = true, features = ["full"] }
reth-db = { workspace = true, features = ["test-utils"] }
Expand Down
70 changes: 70 additions & 0 deletions crates/node/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#![allow(missing_docs)]

use std::{env, error::Error};
use vergen::{BuildBuilder, CargoBuilder, Emitter};
use vergen_git2::Git2Builder;

fn main() -> Result<(), Box<dyn Error>> {
let mut emitter = Emitter::default();

let build_builder = BuildBuilder::default().build_timestamp(true).build()?;
emitter.add_instructions(&build_builder)?;

let cargo_builder = CargoBuilder::default()
.features(true)
.target_triple(true)
.build()?;
emitter.add_instructions(&cargo_builder)?;

let git_builder = Git2Builder::default()
.describe(false, true, None)
.dirty(true)
.sha(false)
.build()?;
emitter.add_instructions(&git_builder)?;

emitter.emit_and_set()?;

let sha = env::var("VERGEN_GIT_SHA")?;
let sha_short = &sha[0..7];

let is_dirty = env::var("VERGEN_GIT_DIRTY")? == "true";
// if not on a tag: v0.2.1-4-gabcdef1
// if on a tag: v0.2.1
let not_on_tag = env::var("VERGEN_GIT_DESCRIBE")?.ends_with(&format!("-g{sha_short}"));
let version_suffix = if is_dirty || not_on_tag { "-dev" } else { "" };

println!("cargo:rustc-env=MORPH_VERSION_SUFFIX={version_suffix}");
println!("cargo:rustc-env=VERGEN_GIT_SHA_SHORT={}", &sha[..8]);

let out_dir = env::var("OUT_DIR").unwrap();
let profile = out_dir.rsplit(std::path::MAIN_SEPARATOR).nth(3).unwrap();
println!("cargo:rustc-env=MORPH_BUILD_PROFILE={profile}");

let pkg_version = env!("CARGO_PKG_VERSION");

// Short: "0.2.1 (c957148)"
println!("cargo:rustc-env=MORPH_SHORT_VERSION={pkg_version}{version_suffix} ({sha_short})");

// Long version lines (matches reth's RETH_LONG_VERSION_* naming so we can reuse
// RethCliVersionConsts without patching upstream)
println!("cargo:rustc-env=MORPH_LONG_VERSION_0=Version: {pkg_version}{version_suffix}");
println!("cargo:rustc-env=MORPH_LONG_VERSION_1=Commit SHA: {sha}");
println!(
"cargo:rustc-env=MORPH_LONG_VERSION_2=Build Timestamp: {}",
env::var("VERGEN_BUILD_TIMESTAMP")?
);
println!(
"cargo:rustc-env=MORPH_LONG_VERSION_3=Build Features: {}",
env::var("VERGEN_CARGO_FEATURES")?
);
println!("cargo:rustc-env=MORPH_LONG_VERSION_4=Build Profile: {profile}");

// P2P client version: morph-reth/v0.2.1-c957148/x86_64-unknown-linux-gnu
println!(
"cargo:rustc-env=MORPH_P2P_CLIENT_VERSION=morph-reth/v{pkg_version}-{sha_short}/{}",
env::var("VERGEN_CARGO_TARGET_TRIPLE")?
);

Ok(())
}
1 change: 1 addition & 0 deletions crates/node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub mod node;
#[cfg(feature = "test-utils")]
pub mod test_utils;
pub mod validator;
pub mod version;

// Re-export main node types
pub use add_ons::MorphAddOns;
Expand Down
46 changes: 46 additions & 0 deletions crates/node/src/version.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//! Morph-Reth version metadata.
//!
//! Overrides reth's default version info so `--version` reports morph-reth's
//! own version, commit SHA, and build timestamp instead of the upstream reth
//! fork's values.

use reth_node_core::version::{RethCliVersionConsts, try_init_version_metadata};
use std::{borrow::Cow, env};

/// Initialise global version metadata for Morph-Reth.
///
/// Must be called once at startup, before any CLI parsing.
pub fn init_version_metadata() {
try_init_version_metadata(version_metadata())
.expect("Version metadata initialised more than once");
}

/// Build the [`RethCliVersionConsts`] for morph-reth using compile-time env vars
/// emitted by `build.rs`.
pub fn version_metadata() -> RethCliVersionConsts {
RethCliVersionConsts {
name_client: Cow::Borrowed("Morph-Reth"),
cargo_pkg_version: Cow::Borrowed(env!("CARGO_PKG_VERSION")),
vergen_git_sha_long: Cow::Borrowed(env!("VERGEN_GIT_SHA")),
vergen_git_sha: Cow::Borrowed(env!("VERGEN_GIT_SHA_SHORT")),
vergen_build_timestamp: Cow::Borrowed(env!("VERGEN_BUILD_TIMESTAMP")),
vergen_cargo_target_triple: Cow::Borrowed(env!("VERGEN_CARGO_TARGET_TRIPLE")),
vergen_cargo_features: Cow::Borrowed(env!("VERGEN_CARGO_FEATURES")),
short_version: Cow::Borrowed(env!("MORPH_SHORT_VERSION")),
long_version: Cow::Owned(format!(
"{}\n{}\n{}\n{}\n{}",
env!("MORPH_LONG_VERSION_0"),
env!("MORPH_LONG_VERSION_1"),
env!("MORPH_LONG_VERSION_2"),
env!("MORPH_LONG_VERSION_3"),
env!("MORPH_LONG_VERSION_4"),
)),
build_profile_name: Cow::Borrowed(env!("MORPH_BUILD_PROFILE")),
p2p_client_version: Cow::Borrowed(env!("MORPH_P2P_CLIENT_VERSION")),
extra_data: Cow::Owned(format!(
"morph-reth/v{}/{}",
env!("CARGO_PKG_VERSION"),
env::consts::OS
)),
}
}
7 changes: 7 additions & 0 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ ignore = [
# https://rustsec.org/advisories/RUSTSEC-2026-0002 lru 0.12.x unsound IterMut
# pinned by reth fork at 0.12.5, fix requires 0.16.3 (semver-incompatible)
"RUSTSEC-2026-0002",
# https://rustsec.org/advisories/RUSTSEC-2026-0097 rand unsound with custom logger
# pinned transitively via reth; no fix available upstream yet
"RUSTSEC-2026-0097",
# https://rustsec.org/advisories/RUSTSEC-2026-0098 rustls-webpki URI name constraints
"RUSTSEC-2026-0098",
# https://rustsec.org/advisories/RUSTSEC-2026-0099 rustls-webpki wildcard name constraints
"RUSTSEC-2026-0099",
]

# This section is considered when running `cargo deny check bans`.
Expand Down
Loading