Repository navigation
fix(build-info): 移除对外构建时间字段 - #853
nekomoto911 wants to merge 2 commits into
Conversation
shadow-rs stamps BUILD_TIME with the wall clock (in the builder's local timezone) unless SOURCE_DATE_EPOCH is set, so every rebuild of the same commit embeds a different timestamp and yields a different sha256. That rules out verifying a release binary by rebuilding its tag. Default SOURCE_DATE_EPOCH to `git log -1 --format=%ct` in the build script. An explicit SOURCE_DATE_EPOCH still takes precedence, and builds without git (e.g. docker builds without .git) keep the old wall-clock behaviour. `build_time` in `--version` and the build_info metric now reports the commit time in UTC. This only removes the timestamp; a byte-identical rebuild still needs a matching toolchain, source path and build environment.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5a9fb6fd21
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if std::env::var_os("SOURCE_DATE_EPOCH").is_none() { | ||
| if let Some(epoch) = head_commit_epoch() { |
There was a problem hiding this comment.
Track the resolved Git ref before caching its timestamp
When an incremental build advances the current branch without changing this crate (for example, git pull followed by cargo build), .git/HEAD remains ref: refs/heads/<branch> and only the referenced file changes. Because the script watches ../../.git/HEAD but not the resolved ref, Cargo does not rerun it under Cargo's documented rerun-if-changed behavior, so this block retains the previous commit's epoch rather than the new HEAD time. Watch the resolved ref/packed refs (including worktree Git dirs), or otherwise ensure HEAD changes rerun the script.
AGENTS.md reference: AGENTS.md:L12-L12
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 63f430415f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| pub const BUILD_COMMIT_HASH: &str = "build_commit_hash"; | ||
| pub const BUILD_TAG: &str = "build_tag"; | ||
| pub const BUILD_TIME: &str = "build_time"; | ||
| pub const BUILD_OS: &str = "build_os"; |
There was a problem hiding this comment.
Preserve build_time in exported build metadata
Removing this key makes every build_information!() caller omit build_time: gravity_node --version and gravity_cli --version format this map directly, the node logger and telemetry API forward it, and node_metrics.rs now also removes the corresponding Prometheus label. Thus releases built from this commit no longer provide the timestamp that the change promises to pin to the HEAD commit, while consumers of the existing CLI/telemetry schema see a compatibility break. Keep the field and populate it deterministically rather than deleting it; rebuilding and inspecting gravity_node --version is a minimal validation.
AGENTS.md reference: AGENTS.md:L5-L6
Useful? React with 👍 / 👎.
问题与改动
本仓库的构建信息把实际编译时间作为
build_time暴露给版本详情、启动日志、遥测等调用方,并把它作为gravity_node_build_info的标签。这个时间会随重新编译变化,给产物引入与源码版本无关的差异。本次直接移除该字段:
build-info::BUILD_TIME常量及build_time映射项。BUILD_DATE覆盖入口,避免环境变量重新插入字段。gravity_node_build_info中的build_time标签及其对应值。SOURCE_DATE_EPOCH默认设为 Git 提交时间的方案。版本号、提交哈希等其余构建信息继续保留。兼容性与范围
这是有意的接口变更:读取
build_time的脚本和依赖该监控标签的查询需要同步调整;直接引用build-info::BUILD_TIME的 Rust 使用方也需要更新。普通指标名称保持不变。本次修改仅覆盖本仓库共享的构建信息和节点指标。依赖
gravity-aptos自己提供的节点检查服务/system_information仍使用独立的构建信息;本次没有更改该依赖。shadow-rs仍可生成内部时间常量,本次不宣称完整二进制已经能够逐字节复现。验证
build_time失败,再在删除后通过;测试同时覆盖设置BUILD_DATE后字段仍然缺失,并保留原有提交哈希、分支和标签覆盖断言。cargo test --locked -p build-info。cargo clippy --locked -p build-info --all-targets -- -D warnings。cargo +nightly-2026-09-05 fmt --all -- --check。build_time、其余身份标签仍对应正确的值。本地没有构建或运行完整节点。Cargo 仍报告已有的未使用
tonic补丁和工具链最低版本配置不一致提示;本次没有修改这些配置。评审
评审等级为 L2,因为本次删除对外字段和监控标签。两路独立只读评审分别检查调用路径与遗漏,以及指标标签匹配、兼容性和回滚影响。