Repository navigation
perf(node-core): stamp version metadata in the binaries - #28567
Zygimantass wants to merge 5 commits into
Conversation
👁️ Cyclops Security Review✅ Reviewed c655999 (latest) · Coverage: partial ·
|
|
Informational: reth-node-core keeps smolgen's unused `build` feature after dropping Build The PR removes the only use of smolgen::Build from reth-node-core's build script but leaves the Valid? React with 👍 / 👎. |
Moves the git SHA, describe, features, profile and target triple out of reth-node-core's build script, with the timestamp, into a build script of each binary (reth and reth-bb) through the new reth-node-version-build crate. reth-node-core no longer rebuilds, with everything above it, on every commit.
| pub fn version_metadata() -> &'static RethCliVersionConsts { | ||
| VERSION_METADATA.get_or_init(default_reth_version_metadata) | ||
| VERSION_METADATA.get_or_init(unknown_version_metadata) | ||
| } | ||
|
|
||
| /// default reth version metadata using compile-time env! macros. | ||
| pub fn default_reth_version_metadata() -> RethCliVersionConsts { | ||
| /// Version metadata without anything a build script stamps: the package version and `unknown` | ||
| /// for the rest. | ||
| pub fn unknown_version_metadata() -> RethCliVersionConsts { | ||
| let version = env!("CARGO_PKG_VERSION"); | ||
| let unknown = || Cow::Borrowed("unknown"); | ||
| RethCliVersionConsts { | ||
| name_client: Cow::Borrowed("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!("RETH_SHORT_VERSION")), | ||
| long_version: Cow::Owned(format!( | ||
| "{}\n{}\n{}\n{}\n{}", | ||
| env!("RETH_LONG_VERSION_0"), | ||
| env!("RETH_LONG_VERSION_1"), | ||
| env!("RETH_LONG_VERSION_2"), | ||
| env!("RETH_LONG_VERSION_3"), | ||
| env!("RETH_LONG_VERSION_4"), | ||
| )), | ||
|
|
||
| build_profile_name: Cow::Borrowed(env!("RETH_BUILD_PROFILE")), | ||
| p2p_client_version: Cow::Borrowed(env!("RETH_P2P_CLIENT_VERSION")), | ||
| cargo_pkg_version: Cow::Borrowed(version), | ||
| vergen_git_sha_long: unknown(), | ||
| vergen_git_sha: unknown(), | ||
| vergen_build_timestamp: unknown(), | ||
| vergen_cargo_target_triple: unknown(), | ||
| vergen_cargo_features: unknown(), | ||
| short_version: Cow::Borrowed(version), | ||
| long_version: Cow::Owned(format!("Version: {version}")), | ||
| build_profile_name: unknown(), | ||
| p2p_client_version: Cow::Owned(format!("reth/v{version}/{}", std::env::consts::OS)), | ||
| extra_data: Cow::Owned(default_extra_data()), | ||
| } | ||
| } |
There was a problem hiding this comment.
Low: Node-core version fallback drops git SHA, triple and P2P identity downstream
Removing reth-node-core's build script made version_metadata() fall back to all-"unknown" metadata. Every node binary that does not add the new build.rs and call try_init_version_metadata now reports commit "unknown" in engine_getClientVersionV1. Database ClientVersion records, metrics build info and the default devp2p identity lose the SHA, triple and profile as well.
Full finding
Removing reth-node-core's build script made version_metadata() fall back to all-"unknown" metadata. Every node binary that does not add the new build.rs and call try_init_version_metadata now reports commit "unknown" in engine_getClientVersionV1. Database ClientVersion records, metrics build info and the default devp2p identity lose the SHA, triple and profile as well.
First reported at 912f01d; recheck at this head: still present.
Valid? React with 👍 / 👎.
Moves all version metadata (git SHA and describe, features, profile, target triple and build timestamp) out of
reth-node-core's build script into a build script in each binary,rethandreth-bb, through a newreth-node-version-buildcrate. Binaries set it at startup withtry_init_version_metadata(reth_version_metadata!()).--versionoutput is unchanged, except that Build Features now lists the binary's features.The metadata changes with every commit, and the timestamp with every build. Stamped into
reth-node-core, it gave every crate that depends on it new output: incremental and shared build caches (sccache and the like) miss all of them. Now only the binaries change.Downstream binaries that don't set version metadata get the package version and
unknownfor the rest; they can callreth_node_version_build::emit_version_metadatafrom their build script and set it the same way.Migration
Breaking for downstream binaries built on
reth-node-core:default_reth_version_metadata()is renamed tounknown_version_metadata(), and it no longer carries stamped values. Apart from the package version, every field isunknown.reth-node-coredoesn't stamp version metadata any more. A binary that never callstry_init_version_metadata, or that builds on the default metadata, now reportsunknownfor git SHA, build timestamp, target triple, features and profile (--version, the P2P client version,web3_clientVersion).To keep real values, stamp the metadata in the binary itself:
Binaries that already build their own
RethCliVersionConstsfrom their own build script don't need to change anything.