Warn on deploy when sources changed without a version bump - #84
Open
charlesHetterich wants to merge 2 commits into
Open
Warn on deploy when sources changed without a version bump#84charlesHetterich wants to merge 2 commits into
charlesHetterich wants to merge 2 commits into
Conversation
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.
What
cdm deployis idempotent by version: a crate whose Cargo.toml version is at or below the registry's latest is skipped asup-to-date. That silently masks the edit-the-code-forget-to-bump mistake. This PR closes that gap:source_hashin its metadata (besidestorage_layout): a deterministic blake2b-256 digest over the contract's source inputs. Rust crates hashCargo.toml+ everything undersrc/recursively; Solidity targets hash the source file plus its relatively-imported local.solfiles (reusing the existing import traversal; remapped/library imports are not followed). Files are sorted by root-relative path and each contributesblake2b(relpath \0 content)to the running digest, so write order never matters while renames and edits both change the hash.up-to-date, the pipeline recomputes the local hash and fetches the latest published metadata through the (new, optional) injected IPFS gateway. On mismatch it emits a new advisorycheck-source-driftevent; the CLI renders the row's marker as a yellowup-to-date!plus a warning line:@org/foo 1.0.0 is up-to-date on-chain but local sources differ — did you forget to bump the version?Why a source hash, not a bytecode hash
PolkaVM output is sensitive to the rustc / cargo-pvm-contract / SDK-revision combination — identical sources produce different blobs across toolchains, and heterogeneous toolchains across a team are the expected state. A bytecode comparison would fire on every toolchain skew and train people to ignore it. Hashing the source inputs is toolchain-independent by construction.
Never fatal, never noisy
The check is advisory only. A hash match, a publish that predates
source_hash, a missing/unreachable gateway, an older registry generation, or unreadable local sources all resolve to exactly today's behavior — a silentup-to-dateskip. Nothing on this path can fail or slow a deploy beyond the metadata fetch, and no status ever changes.Tests
source_hashlands in the published metadata; the warn path emitscheck-source-driftright aftercheck-up-to-datewith the differing pair; the silent paths (match / absent hash / gateway failure) emit nothing and stay non-fatal.Closes #82