Skip to content

feat(cli): add verify-hash command to diff local WASM against on-chain - #823

Closed
davidugorji wants to merge 1 commit into
BCPathway:mainfrom
davidugorji:feat/700-cli-verify-hash
Closed

feat(cli): add verify-hash command to diff local WASM against on-chain#823
davidugorji wants to merge 1 commit into
BCPathway:mainfrom
davidugorji:feat/700-cli-verify-hash

Conversation

@davidugorji

Copy link
Copy Markdown
Contributor

Implements the verify-hash CLI utility.

Answers whether a deployed contract is actually running the code in the local build tree. The local side takes the SHA-256 of the raw .wasm bytes (exactly how Soroban derives its code hash); the on-chain side reads the contract instance ledger entry and walks to the referenced wasmHash, rather than trusting a hash cached in config. Exits non-zero on anything but a match.

Verdicts: match, mismatch, missing_local, missing_onchain, invalid.

Verification: tsc clean, 14/14 unit tests pass, and the local hash was cross-checked against sha256sum on the same artifact.

Closes #700

Adds a `bc-forge verify-hash` command that answers whether a deployed
contract is actually running the code in the local build tree.

The local side hashes the raw .wasm bytes with SHA-256, which is exactly
how Soroban derives the code hash it stores, so the two values are
directly comparable. Verified against sha256sum on the same artifact.

The on-chain side reads the contract instance ledger entry and walks
val -> instance -> executable to the referenced wasmHash, rather than
trusting a hash cached in .bc-forge.json, so the check reflects what the
network currently serves.

Distinct verdicts separate the failure modes an operator cares about:

- match           local build is what the network runs
- mismatch        contract runs different code than the local build
- missing_local   the build artifact was not found or is unreadable
- missing_onchain no instance entry, or a Stellar-asset contract with
                  no uploaded WASM
- invalid         malformed input or a failed RPC lookup

The command exits non-zero on anything other than a match so it can gate
a release pipeline.

Closes BCPathway#700
@davidugorji
davidugorji force-pushed the feat/700-cli-verify-hash branch from a53b4b0 to e430607 Compare August 26, 2026 15:24
@drips-wave

drips-wave Bot commented Aug 26, 2026

Copy link
Copy Markdown

@davidugorji Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@davidugorji

Copy link
Copy Markdown
Contributor Author

Superseded by #829, which bundles all four issues (#699, #700, #701, #759) into a single PR. Closing in favour of that one.

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.

[CLI] Utility: Verify contract WASM hashes

1 participant