Skip to content

Check linera-version's API hash cache in CI and make it regenerable - #6819

Open
ma2bd wants to merge 1 commit into
testnet_conwayfrom
ma2bd/version-api-hashes-ci-conway
Open

ma2bd wants to merge 1 commit into
testnet_conwayfrom
ma2bd/version-api-hashes-ci-conway

Conversation

@ma2bd

@ma2bd ma2bd commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

linera-version/api-hashes.json has not changed since #2347 (2024-08-03), even though the WIT files, the GraphQL schema and the RPC snapshot have all changed since — this branch and main ship the same three hashes despite having different WIT files. Two things kept it that way:

  • tests/up_to_date.rs compares VersionInfo::get() against VersionInfo::default(). The latter is baked in by build.rs, which calls the same trace_get, so in a workspace checkout both sides are computed from the live files and the file is never consulted. The test cannot fail.
  • The command it recommends, cargo run -p linera-version > linera-version/api-hashes.json, truncates the file before the binary starts, and trace_get reads it eagerly, so regenerating fails with JSON error: EOF while parsing a value at line 1 column 0.

The file is what a published crate reports, since cargo metadata resolves it standalone there, without the sibling packages the hashes are computed from. VersionInfo::is_compatible_with compares api_hashes() before falling back to semver, so stale values let two registry builds with different APIs consider each other compatible.

Proposal

  • Read the file only when a hash cannot be computed, instead of always. That is what it is for, and it makes the file writable from the tool's own output.
  • Compare the computed hashes against the file in tests/up_to_date.rs.
  • Add a check-outdated-api-hashes CI job, in the style of check-outdated-cli-md.
  • Terminate the generated JSON with a newline, and refresh the file with this branch's own hashes.

Relationship to #6818. On main the mechanism is being removed instead: the hashes become Option, absent when they cannot be computed, and the file is deleted — because in the only situation that reads it, the recorded hashes are a constant of the release and therefore carry nothing that crate_version does not. That change alters the BCS encoding of RpcMessage::VersionInfoResponse and flips the RPC hash, which is not acceptable on a deployed network in a patch release. So this branch keeps the file and only makes it correct and verified; this is the terminal state for the 0.15 line.

Test Plan

  • cargo test -p linera-version fails on the stale file before the refresh, reporting all three hashes, and passes after it.
  • cargo run -p linera-version > linera-version/api-hashes.json now succeeds and is idempotent; before this change it failed on the truncated file.
  • The new job's command, diff linera-version/api-hashes.json <(cargo run --locked -p linera-version), exits 0 on this branch.
  • No type or wire change: linera-rpc's format snapshot is untouched.
  • cargo fmt (pinned nightly-2025-04-03), cargo clippy --all-targets --all-features -p linera-version and taplo fmt --check are clean under Rust 1.86.

Release Plan

  • Nothing to do / These changes follow the usual release cycle.

Links

🤖 Generated with Claude Code

@ma2bd ma2bd changed the title Verify linera-version's API hash cache in CI and make it regenerable (backport of #6818) Check linera-version's API hash cache in CI and make it regenerable Sep 15, 2026

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.

1 participant