Skip to content

perf(tempo): stamp version metadata in main.rs, not the tempo library - #9406

Open
Zygimantass wants to merge 2 commits into
mainfrom
perf/version-metadata-in-main
Open

Zygimantass wants to merge 2 commits into
mainfrom
perf/version-metadata-in-main

Conversation

@Zygimantass

Copy link
Copy Markdown
Member

Follow-up to #9378. The tempo library still expanded tempo_version_metadata!, so every new build time compiled the whole library again before the binary. main.rs now stamps it, and the library sets unstamped metadata for programs that embed it unless the binary already set its own.

Two fresh checkouts of this branch built with a shared compile cache: the second restored the tempo library and compiled only the binary (2.1 s, against 8.1 s + 2.1 s on main). tempo --version still shows the commit and build time.

The tempo library expanded tempo_version_metadata!, so every new build time compiled the whole library again before the binary. main.rs now stamps it; the library sets unstamped metadata for programs that embed it, unless the binary already set its own.
@tempoxyz-bot

tempoxyz-bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

👁️ Cyclops Security Review

✅ Reviewed 953c689 (latest) · Coverage: partial · no open findings · report
⚠️ Not checked: The reth bump to b6da923 replaces jsonrpsee-server's WebSocket backend: soketto is removed and tokio-tungstenite is added, and the frame, ping and close handling is rewritten. I could not complete a full review of the new transport for DoS
⚠️ Not checked: Dependency context is partial: vendoring available, Librarian unavailable (covered 0 of 40 requested; 71 of 111 changed dependencies not sent), Sem unavailable
⚠️ Not checked: Needs review: the staged dependency registry contains Reth at b6da9233775a0dc7de9df570a09f6507bcb842fb but not the previous locked revision 31d05e14329ec25e0d559f901502c959aa04ddd8. The manifest and lockfile updates therefore cannot be clea
⚠️ 2 more unchecked questions are listed in the report

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nothing blocking. The comments below are optional suggestions. There is no need to push a fix for them before merging.

Comment thread bin/tempo/src/lib.rs
Comment on lines +209 to +211
// The `tempo` binary stamps its version before it calls this. Expanding the stamp here would
// compile this library again whenever the build time changes.
tempo_node::init_unstamped_version_metadata();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 (optional) Programs that embed Tempo through tempo_main_with, including examples/programmatic-node, now report "unknown" commit, build time and profile. Today they report the real stamped values. The library used to expand tempo_version_metadata! with env vars from bin/tempo/build.rs, which also covers the lib target. It now falls back to init_unstamped_version_metadata. Fix: give embedders a way to keep stamped metadata without rebuilding the library on each build. Otherwise, state the regression in the PR description and in the tempo_main_with docs. Also show embedders how to call init_version_metadata themselves.

Why this was flagged

examples/programmatic-node/src/main.rs:51 calls tempo_main_with(overrides) without setting version metadata first, and that crate has no build.rs. On the base branch, bin/tempo/src/lib.rs expanded tempo_node::tempo_version_metadata!(), and the tempo package's build.rs set its env vars for the lib target too. Embedders therefore got the real SHA, build timestamp, features, profile and RETH_P2P_CLIENT_VERSION (tempo/v{ver}-{sha}/{triple}). After this change, crates/node/src/version.rs:17-33 sets every vergen field to "unknown" and long_version to only Version: {version}. It also sets p2p_client_version to tempo/v{version}/{os}, so --version output and the devp2p client id peers see lose the commit and target. No embedder can expand tempo_version_metadata! itself, because the VERGEN_*/RETH_* env vars exist only in Tempo's own build script. The PR description does not mention this behavior change, which the style skill requires.

Verification: Trigger: any program that calls tempo_main_with/tempo_main without calling init_version_metadata first. After the change, lib.rs:211 calls tempo_node::init_unstamped_version_metadata(). Effect: embedders' --version output and the client version their peers see both lose the commit and build details they had on the base.

/// For binaries without Tempo's build script, such as programs that embed the node.
pub fn init_unstamped_version_metadata() {
let version = env!("CARGO_PKG_VERSION");
let _ = try_init_version_metadata(RethCliVersionConsts {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 nit (optional): the result of try_init_version_metadata is discarded with let _ =. The style skill forbids that and says to ignore only the expected variant. Fix: match the Err case explicitly, with a comment that it means a binary already stamped metadata. Also build p2p_client_version from extra_data() instead of repeating its format! at line 30.

Why this was flagged

crates/node/src/version.rs:19 uses let _ = try_init_version_metadata(...). The tempo-rust-style skill says "Never discard a fallible result with .ok() or let _ =. Ignore only the specific variant you expect." Line 30 repeats format!("tempo/v{version}/{}", env::consts::OS), which is the body of extra_data() at line 74. That breaks the rule "When the same logic appears twice... extract one helper." Neither changes runtime behavior. Both are convention slips this diff introduces.

Verification: nit. Nothing changes at runtime. crates/node/src/version.rs:19 reads let _ = try_init_version_metadata(RethCliVersionConsts { ... });. .agents/skills/tempo-rust-style/SKILL.md:63 says "Never discard a fallible result with .ok() or let _ =." Line 30 builds the same string as the body of extra_data() at line 74. Line 30 could reuse extra_data().

/// its own with [`init_version_metadata`].
///
/// For binaries without Tempo's build script, such as programs that embed the node.
pub fn init_unstamped_version_metadata() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 nit (optional): no test covers the new guard that keeps a binary's stamped metadata when init_unstamped_version_metadata runs later. If that ever regresses, tempo --version loses its commit and build time without any test failing. The style skill requires a test for every new guard. Fix: add a test that calls init_version_metadata with a marker value and then init_unstamped_version_metadata(). It should assert that reth_node_core::version::version_metadata() still returns the marker.

Why this was flagged

crates/node/src/version.rs:17-33 adds a public function. It sets metadata only when none is set yet; that is the behaviour the PR depends on for bin/tempo/src/main.rs:19, which stamps first, and bin/tempo/src/lib.rs:211, which runs this function afterwards. The diff adds no test for that ordering or for the unstamped fallback values. .agents/skills/tempo-rust-style/SKILL.md:79 says "Every new branch, guard, error path, and access check gets a test in the same PR." Suppose a later change makes the function call init_version_metadata (which panics on a second set) or overwrite existing metadata. The release binary would then panic at startup or report "unknown" commit and build time, and no test would catch it.

Verification: The behavior is new: crates/node/src/version.rs:19 calls let _ = try_init_version_metadata(...), which sets the metadata only if none is set yet. crates/node/src/version.rs has no mod tests at all. If the ordering or the try-init semantics regress, tempo --version loses its commit and build time and no test catches it.

Picks up paradigmxyz/reth#28567, which stamps reth's version metadata in the binary instead of reth-node-core.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code review found no issues

No high-confidence issues detected in this change.

Still open from earlier reviews (3):

  • Unresolved: 3 minor or pre-existing.

This branch has not been deployed

No deployments
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