Repository navigation
Conversation
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
linera-version/api-hashes.jsonhad not changed since #2347 (2024-08-03), even though the RPC snapshot, the GraphQL schema and the WIT files all changed since —mainandtestnet_conwayshipped the same three hashes despite having different WIT files. Two things kept it that way:tests/up_to_date.rscomparedVersionInfo::get()againstVersionInfo::default(). The latter is baked in bybuild.rs, which calls the sametrace_get, so in a workspace checkout both sides were computed from the live files and the file was never consulted. The test could not fail.cargo run -p linera-version > linera-version/api-hashes.json, truncates the file before the binary starts, andtrace_getread it eagerly, so regenerating failed withJSON error: EOF while parsing a value at line 1 column 0.The deeper question is whether the file should exist. It is read only when the API source files cannot be found, which happens in exactly one situation:
trace_getrunscargo metadatafromlinera-version's own directory, and in a published crate that resolves the package standalone, withoutlinera-rpc,linera-sdkorlinera-service-graphql-clientin the graph. In that situation the recorded hashes are a constant of the release — a pure function ofcrate_version, which the peer already receives — so they carry no information. Worse, with one frozen file every registry build of every version reported the same triple, andis_compatible_withaccepts whenapi_hashes()match, so unrelated builds declared each other compatible. Missing information was being turned into a forged match.Proposal
Make the hashes
Option, absent when they cannot be computed, and delete the file.rpc_hash,graphql_hashandwit_hashbecomeOption<Hash>;ApiHashesfields becomeOption<String>.is_compatible_withrequires the hashes to be known before comparing them, so absent never means equal. It still falls through to the semver arm, which is the right answer for a build that cannot attest its own API surface.Displayandlinera wallet/query-validatoroutput printunknownfor an absent hash.rpc.protois unchanged.api-hashes.json,tests/up_to_date.rs, andsrc/main.rs, whose only purpose was regenerating the file.anyhowis no longer used by the crate.tests/compatibility.rscovering the rule the old test was meant to protect.This changes the BCS encoding of
RpcMessage::VersionInfoResponse(variant 22), so the format snapshot is updated. That is why this is not backported as-is: ontestnet_conwaythe same change would alter a wire format on a live network and flip the RPC hash, so #6819 keeps the file there and only makes it verified.Test Plan
cargo test -p linera-version— the new tests pin that identical known hashes still bridge a patch gap, and that unknown hashes never establish compatibility while leaving the semver arm intact.Packaged the crate and built it standalone, to reproduce a published-crate build:
Previously this reported the three constants from August 2024.
cargo check --workspace --all-targets, pinned-nightlycargo fmt,cargo clippy --all-targets --all-featuresonlinera-version/linera-rpc/linera-client,taplo fmt --checkandcargo macheteare clean.Release Plan
Links
testnet_conway, where the wire change is not acceptable.🤖 Generated with Claude Code