Skip to content

feat(node): override version metadata with morph-reth info#95

Merged
panos-xyz merged 4 commits intomainfrom
feat/version-metadata
Apr 16, 2026
Merged

feat(node): override version metadata with morph-reth info#95
panos-xyz merged 4 commits intomainfrom
feat/version-metadata

Conversation

@panos-xyz
Copy link
Copy Markdown
Contributor

@panos-xyz panos-xyz commented Apr 13, 2026

Summary

Add build.rs and src/version.rs to morph-node
Before this change, morph-reth --version reported the upstream reth fork's commit SHA and version:

Reth Version: 1.10.0-dev
Commit SHA: 1b0702546633c259306017717b2938f14adfe329   ← reth fork SHA
Build Timestamp: 2026-04-09T14:19:26Z

After this change:

Morph-Reth Version: 0.2.2
Commit SHA: <morph-reth SHA>                          ← morph-reth SHA
Build Timestamp: <actual build time>

Also bumps workspace version to 0.2.2.

Changes

  • crates/node/build.rs — runs vergen against morph-reth's own git repo
  • crates/node/src/version.rsinit_version_metadata() overrides reth defaults
  • crates/node/src/lib.rs — expose version module
  • crates/node/Cargo.toml — add reth-node-core, vergen, vergen-git2 deps
  • bin/morph-reth/src/main.rs — call init_version_metadata() at startup
  • Cargo.toml — bump to 0.2.2, add vergen workspace deps

Summary by CodeRabbit

  • New Features

    • Enhanced runtime version info: shows git commit, build timestamp, build profile, and richer client version details.
  • Chores

    • Bumped workspace version 0.2.1 → 0.2.2.
    • Added build-time versioning to emit compile-time metadata and expose version info at startup.
    • Updated deny list to ignore additional RustSec advisories (three entries).

Add build.rs and version.rs to morph-node so that --version reports
morph-reth's own version, commit SHA, and build timestamp instead of
the upstream reth fork's values. Also bump version to 0.2.2.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8887dbc2-f3c8-4e63-a2f9-1e2a51eca397

📥 Commits

Reviewing files that changed from the base of the PR and between 061be03 and 37841e8.

📒 Files selected for processing (1)
  • deny.toml
✅ Files skipped from review due to trivial changes (1)
  • deny.toml

📝 Walkthrough

Walkthrough

Adds a Cargo build script using vergen to emit compile-time version variables, exposes a new version module in crates/node, initializes morph-reth-specific version metadata at startup, bumps workspace version, and updates deny.toml.

Changes

Cohort / File(s) Summary
Workspace Manifest
Cargo.toml
Bumped workspace package version 0.2.10.2.2; added workspace-level vergen = "9.1.0" and vergen-git2 = "9.1.0".
Node crate manifest
crates/node/Cargo.toml
Added reth-node-core.workspace = true dependency and added [build-dependencies] entries for vergen.workspace = true and vergen-git2.workspace = true.
Build script
crates/node/build.rs
New build script that configures vergen/git2 emitters and emits multiple cargo:rustc-env variables (SHA short, version suffix, build profile, long/short version strings, P2P client version); errors on missing required envs.
Runtime version module
crates/node/src/version.rs, crates/node/src/lib.rs
New version module with version_metadata() and init_version_metadata() that construct and register RethCliVersionConsts from compile-time env vars; exported via pub mod version;.
Binary startup
bin/morph-reth/src/main.rs
Calls morph_node::version::init_version_metadata() at process startup (before signal handler and CLI parsing) to register morph-reth version metadata.
Security ignores
deny.toml
Extended advisories.ignore with additional RustSec entries (RUSTSEC-2026-0097, etc.).

Sequence Diagram(s)

sequenceDiagram
    participant Build as Build Script (vergen)
    participant Cargo as Cargo / Compiler
    participant Binary as morph-reth main
    participant Version as morph_node::version

    Build->>Cargo: emit cargo:rustc-env (MORPH_*, VERGEN_*)
    Note right of Cargo: env! macros bake values into binary
    Binary->>Version: init_version_metadata()
    Version->>Binary: populate global RethCliVersionConsts
    Binary->>Binary: continue signal setup & CLI parsing
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • chengwenxi
  • curryxbo

Poem

🐰 I nibble bytes and stamp the SHA,
I tuck the build time safe away,
A tiny hop, a version set,
The binary knows where it's been yet,
Hooray — the rabbit inks the play.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title clearly and accurately summarizes the main objective: overriding version metadata to display morph-reth's own version information instead of reth's defaults.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/version-metadata

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
crates/node/build.rs (1)

35-37: Avoid brittle OUT_DIR parsing for build profile.

Line 36 depends on a fixed path shape and can panic unexpectedly. Prefer reading profile directly from build-script env instead of slicing OUT_DIR.

Proposed refactor
-    let out_dir = env::var("OUT_DIR").unwrap();
-    let profile = out_dir.rsplit(std::path::MAIN_SEPARATOR).nth(3).unwrap();
+    let profile = env::var("PROFILE")?;
     println!("cargo:rustc-env=MORPH_BUILD_PROFILE={profile}");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/node/build.rs` around lines 35 - 37, The current build script parses
OUT_DIR into `profile` using `out_dir.rsplit(...).nth(3)` which is brittle and
can panic; change the logic to read the build profile from the `PROFILE`
environment variable (use `env::var("PROFILE")`) and fall back to a sensible
default if missing, then use that value in the
`println!("cargo:rustc-env=MORPH_BUILD_PROFILE={profile}")` call instead of the
parsed `profile` from `out_dir`; update references to the `out_dir` and
`profile` variables accordingly and remove the fragile rsplit usage.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@crates/node/build.rs`:
- Around line 35-37: The current build script parses OUT_DIR into `profile`
using `out_dir.rsplit(...).nth(3)` which is brittle and can panic; change the
logic to read the build profile from the `PROFILE` environment variable (use
`env::var("PROFILE")`) and fall back to a sensible default if missing, then use
that value in the `println!("cargo:rustc-env=MORPH_BUILD_PROFILE={profile}")`
call instead of the parsed `profile` from `out_dir`; update references to the
`out_dir` and `profile` variables accordingly and remove the fragile rsplit
usage.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: aa2b4556-3665-49f9-a1e3-da86a216701b

📥 Commits

Reviewing files that changed from the base of the PR and between c957148 and 9583ba0.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (6)
  • Cargo.toml
  • bin/morph-reth/src/main.rs
  • crates/node/Cargo.toml
  • crates/node/build.rs
  • crates/node/src/lib.rs
  • crates/node/src/version.rs

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
crates/node/build.rs (2)

40-41: Avoid parsing OUT_DIR to get build profile

Line 41 depends on Cargo path shape and can panic. Prefer PROFILE, which Cargo already provides for build scripts.

Proposed refactor
-    let out_dir = env::var("OUT_DIR").unwrap();
-    let profile = out_dir.rsplit(std::path::MAIN_SEPARATOR).nth(3).unwrap();
+    let profile = env::var("PROFILE")?;
     println!("cargo:rustc-env=MORPH_BUILD_PROFILE={profile}");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/node/build.rs` around lines 40 - 41, The build script currently
derives the Cargo build profile by parsing OUT_DIR (env::var("OUT_DIR") and the
local variable profile), which relies on Cargo's directory layout and can panic;
change it to read the PROFILE environment variable provided to build scripts
(env::var("PROFILE")) and use that value in place of the parsed profile so you
no longer depend on splitting OUT_DIR; update any uses of the local profile
variable accordingly and handle the Result (e.g., unwrap_or or expect)
consistently.

29-39: Use one short-SHA length consistently

Line 29 uses 7 chars, but Line 38 exports 8 chars. This can produce inconsistent metadata across fields.

Proposed cleanup
-    let sha_short = &sha[0..7];
+    let sha_short = &sha[..8];
@@
-    println!("cargo:rustc-env=VERGEN_GIT_SHA_SHORT={}", &sha[..8]);
+    println!("cargo:rustc-env=VERGEN_GIT_SHA_SHORT={sha_short}");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/node/build.rs` around lines 29 - 39, The code slices the git SHA with
two different lengths (sha_short = &sha[0..7] but prints &sha[..8]), causing
inconsistent metadata; update the logic to compute a single sha_short and reuse
it everywhere (use sha_short for the not_on_tag comparison and for the
VERGEN_GIT_SHA_SHORT export) so both checks/outputs use the identical substring,
and ensure any format! or println! references (e.g., VERGEN_GIT_DESCRIBE check,
MORPH_VERSION_SUFFIX calculation, and VERGEN_GIT_SHA_SHORT export) refer to that
single sha_short symbol.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@crates/node/build.rs`:
- Around line 40-41: The build script currently derives the Cargo build profile
by parsing OUT_DIR (env::var("OUT_DIR") and the local variable profile), which
relies on Cargo's directory layout and can panic; change it to read the PROFILE
environment variable provided to build scripts (env::var("PROFILE")) and use
that value in place of the parsed profile so you no longer depend on splitting
OUT_DIR; update any uses of the local profile variable accordingly and handle
the Result (e.g., unwrap_or or expect) consistently.
- Around line 29-39: The code slices the git SHA with two different lengths
(sha_short = &sha[0..7] but prints &sha[..8]), causing inconsistent metadata;
update the logic to compute a single sha_short and reuse it everywhere (use
sha_short for the not_on_tag comparison and for the VERGEN_GIT_SHA_SHORT export)
so both checks/outputs use the identical substring, and ensure any format! or
println! references (e.g., VERGEN_GIT_DESCRIBE check, MORPH_VERSION_SUFFIX
calculation, and VERGEN_GIT_SHA_SHORT export) refer to that single sha_short
symbol.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5f5d76ed-4c7e-48ba-8f88-d006c1550208

📥 Commits

Reviewing files that changed from the base of the PR and between 9583ba0 and 061be03.

📒 Files selected for processing (3)
  • crates/node/build.rs
  • crates/node/src/version.rs
  • deny.toml
✅ Files skipped from review due to trivial changes (1)
  • deny.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/node/src/version.rs

@panos-xyz panos-xyz merged commit a8e046d into main Apr 16, 2026
14 checks passed
@panos-xyz panos-xyz deleted the feat/version-metadata branch April 16, 2026 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants