Repository navigation
fix: ctg upgrade WASM hash parsing and the embedded-VK flow, found on testnet - #307
Merged
Merged
Conversation
For a WASM the network has not seen, stellar contract upload logs the transaction hash on stderr before printing the WASM hash on stdout. uploadWasm parsed the first 64-hex token of the combined output, so every new upload was compared against the transaction hash and ctg upgrade failed with CAATINGA_UPLOAD_FAILED after a successful upload. Read stdout, and make parseWasmHash take the last hash. Adds a real CLI 27 fixture.
ctg zk invoke --embed-vk against a verifier deployed with the placeholder vk.rs now reports CAATINGA_ZK_EMBED_VK_UNSUPPORTED with a redeploy hint instead of a raw VM trap. ctg zk build --embed-vk points at ctg deploy verifier --upgrade (the verifier has no in-place upgrade entrypoint) and reminds to re-prove after a dev setup. ctg status shows an imported ceremony as imported/verified instead of claiming it was audited.
The verifier scaffold has no upgrade(new_wasm_hash), so ctg upgrade cannot enable embedded VK in place, and a dev ceremony build changes the keys.
Read the local vk.rs to tell a never-generated key (run zk build --embed-vk first) from a stale deployment (redeploy only), and say "most likely" since any contract panic surfaces as the same trap.
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
Before releasing 3.13.0 I ran the ZK flow end to end as a user would: four fresh projects in
ctg-teste-release/, built from currentmainwith local@caatinga/*packages, against testnet. Unit tests and the smoke job never exercisectg upgradeor embedded VK on a live network, and that is where three real problems were hiding.Behavior
ctg upgradefailed on every new WASM (pre-existing, not ZK-specific). For a WASM the network has not seen,stellar contract uploadlogs the transaction hash on stderr before printing the WASM hash on stdout.uploadWasmtook the first 64-hex token of the combined output, compared the transaction hash with the local WASM hash, and failed withCAATINGA_UPLOAD_FAILEDafter the upload had succeeded. Verified: the reported863bf98e…is aSUCCESStestnet transaction. The hash is now read from stdout, andparseWasmHashtakes the last hash in mixed output. Adds the real CLI 27 output as a fixture.upgrade(new_wasm_hash), so thectg upgrade verifierpath documented in feat(zk): MPC ceremony import, embedded VK and protocol pre-flight #304 is impossible. It takes a new instance (ctg deploy verifier --upgrade, newcontractId). Also,ctg zk buildon a dev ceremony generates new keys, so the old proof stops verifying andctg zk provemust run again; that step was missing from the docs. Docs, tutorial, cheatsheet, the unreleased feat(zk): MPC ceremony import, embedded VK and protocol pre-flight #304 changeset and thezk build --embed-vkmessages are corrected.zk buildnow reminds you to re-prove after a dev setup.ctg zk invoke --embed-vkagainst a stale on-chain verifier used to dump a rawUnreachableCodeReachedVM trap. It now reportsCAATINGA_ZK_EMBED_VK_UNSUPPORTED("most likely", since any contract panic looks the same on chain). The hint reads the localvk.rs: missing or still the placeholder → runctg zk build <circuit> --embed-vkfirst; real key → justctg build verifier+ctg deploy verifier --upgrade.ctg statuscalled an imported ceremony "MPC (audited)", which Caatinga cannot know. It now showsMPC (imported, verified <date>)afterverify-ceremony, ornot verified.--jsongainsceremonyVerifiedAt(additive).Tests
Live on testnet (2026-10-16), fresh projects:
p1-starter(fullzk init): deploy → prove → dynamic invoke ✔.--embed-vk→ re-prove → build →ctg upgradereproduced bug 1. With the fix, the new WASM uploads and its hash matches, then the call hits the missingupgradeentrypoint (bug 2).deploy verifier --upgradegives a newcontractId;invoke --embed-vk✔ and dynamicverify_proofon the new instance ✔. Generated bindings includeverify_proof_embedded.p2-existing(ctg init --minimal+ctg zk init): both contracts deployed,app.versionstill answers, dynamic invoke ✔.invoke --embed-vkagainst the placeholder verifier now gives the new error and hint; following the hint ✔.p3-mpc: an external snarkjs ceremony (2 contributions + beacon) is imported with provenance, thenverify-ceremony✔, deploy/invoke ✔.--embed-vkreuses the MPC keys (proof untouched) andinvoke --embed-vk✔. A tampered VK is refused byverify-ceremonyand by mainnet invoke before any tx.estimate verifyshows 44.06M / 400M.p4-freshandp1:npm run build(tsc && vite build) passes with placeholder and with generated bindings;npm audit --audit-level=highreports 0 vulnerabilities.Unit: new tests for the transaction-hash-first upload output (fails without the fix), the placeholder-trap mapping (with the real diagnostic text), and the status label. Lint, typecheck, docs:check, template imports, build, test and format:check all pass locally (core 658, cli 299, zk 98 + 6 opt-in, client 149).
Release Impact
Patch for
@caatinga/core,@caatinga/zk,@caatinga/cli(changeset included). It rides with 3.13.0. No error codes added or removed;ctg zk invoke --embed-vkreports an existing code (CAATINGA_ZK_EMBED_VK_UNSUPPORTED) where it used to reportCAATINGA_INVOKE_FAILED. Rollback: revert.Follow-up worth considering separately: an admin-gated
upgradeentrypoint in the verifier scaffold would make embedded VK an in-place change again, but it needs an admin at deploy time.Checklist
CAATINGA_*errors added or updated when public failures change.--sourceexamples use a local Stellar CLI identity, not a publicG...address.