Skip to content

Re-vendor circuits: constraint set 11 (Grain constants, declared poseidon2 height, rate-¼ quotient layout, versioned rVM keys, cell-count gas) - #194

Merged
dendisuhubdy merged 5 commits into
mainfrom
feat/cs11-revendor
Nov 19, 2026
Merged

dendisuhubdy merged 5 commits into
mainfrom
feat/cs11-revendor

Conversation

@dendisuhubdy

Copy link
Copy Markdown
Member

Issue #166 step 7: re-vendor the zkVM circuits from constraint set 9 (circuits b3e21d9) to constraint set 11 (circuits org/main 76a48dca), for the chain-22 cut and v0.8.7. This is a chain cut. Never roll it onto chain 21. Squash-merge only. Do not merge before the cut gates are met.

Pins, old → new

What Set 9 (chain 21) Set 11 (this PR, chain 22) Where
CIRCUITS_PIN b3e21d9 76a48dca92a2d0382370f383d6680971db0cc574 .github/workflows/ci.yml, both PROVENANCE.md
BUILD_CONSTRAINT_SET 9 11 crates/randprotocol-node/src/node.rs
bundle guest v1 hc 83d3a370…0ef8 71eedbfb…ee70 tests/guest_provenance.rs
bundle guest v2 hc 651043e2…839b 3aff6361…6046 same
bundle guest v3 hc (hc_bundle) 60af094a…3fce 00782b22…141e same; cut script EXPECT_HC_BUNDLE
auth guest hc (hc_auth) 1e4e347f…39c1 8373994c…6078 same; EXPECT_HC_AUTH
msauth guest hc (hc_auth_multisig) 9705f8e2…8247 41db73c5…9cd1 MSAUTH_HC; HC_AUTH_MULTISIG_DECIDED
legacy 2-in-2-out guest hc 4a27356f…4afb 6e968302…dc1d guest_provenance.rs
msauth VK blob, production 23 754 B 68facb06…cd30 23 851 B 168d79a8…71b3 keys/msauth-vk-production.bin, MSAUTH_VK_SHA256_PRODUCTION
msauth VK blob, test c82250e7…43f5 d30472df…db3d keys/msauth-vk-test.bin
gas_max(14,0,0) / bundle_gas_limit 20 479 22 527 core/src/gas.rs; cut BUNDLE_GAS_LIMIT
gas_max(10,0,0) (auth) 1 279 1 407 auth_gas_limit_pin
msauth gas word 436 159 355 775 (p2 height 16) msauth_gas_limit_pin
executor FRI mirror blowup 3 (stale) machine::LOG_BLOWUP = 2, 92 q / 24 pow executor.rs
inner vk digest 1b0c4b00…ddc7 b9046f5d…32da agg_executor.rs
interface digest (Test-0..2) 3753f2fd…86b4 517d13e4…a8c0 agg_executor.rs, scripts/recursion-fixtures.sh
production aggregate program digest 792a66d4…a982 43e02700…aa5b agg_executor.rs (= the vendored rVM test's pin)
recursion fixtures sha256 1f837913…, 3f19d551…, 08fddfc0… 2cd78847…, 641544f4…, c21895dd… scripts/recursion-fixtures.sh
test genesis hash 69010a43…ffb5 24ad1bc2…fef8 main.rs the_genesis_hash_is_pinned
admitted rVM tiers {18,19,20,21} / test {18,19,20} unchanged agg_executor::admitted_tiers

Chain 22 vs chain 21

Moved for chain 22:

  • poseidon2_log_height is now part of the proof header and is carried through ProofShape, MsauthShape, CallDryRun, the 8-component VerifierKeyShape and InnerShape.
  • These must declare their tier's full height (t+2), and the node refuses anything else:
    • bundle and auth proofs;
    • inner proofs covered by an aggregate (new INNER_POSEIDON2_REFUSAL);
    • the canonical perp state proof.
  • msauth is pinned at 16.
  • DeclaredShape (consensus-visible) is unchanged.
  • The call warm covers all admitted p2 heights.
  • Gas is the gas_max_declared mirror.
  • deploy/cut-chain22-genesis.sh changed only in its hc and gas values:
    • EXPECT_HC_BUNDLE, EXPECT_HC_AUTH and HC_AUTH_MULTISIG_DECIDED take the set-11 values;
    • BUNDLE_GAS_LIMIT is 22527;
    • the "g == g21" hc and gas comparisons now assert chain 22 at set 11 and chain 21 at set 9;
    • the three hc keys are excused from the chain-21-shape diff;
    • the expected refusal messages say "constraint set 11's … guest".
    • PR deploy: chain-22 treasury 5 of 6 with its balance carried; perps carried empty #193's treasury, carry and BONDED parts are untouched.

Stayed for chain 21:

  • deploy/genesis-chain21.json and every chain-14–21 file are byte-identical.
  • Chain 21's row stays (21, ca76c276…, 9).
  • invoke_wire_pin and beacon_gate_off_pin pass.
  • Set 11 changes every note commitment and state root, so no chain-14–21 genesis file builds on this build any more. As a result:
    • constraint_set::build_genesis refuses those files by chain id. The refusal names the chain's set, says nothing was written, and points to the release for that set (v0.8.6 for chain 21).
    • The "builds chain N to hash X" tests are now refusal tests. Their hashes stay pinned in CHAIN_CONSTRAINT_SETS.
    • node::tests::chain_21_is_byte_for_byte_what_it_was_before_the_beacon and chain_21_restarts_from_its_checkpoint… are #[ignore]d with that reason. The v0.8.6 line runs them.

Not done (cannot be): chain 22's CHAIN_CONSTRAINT_SETS row. There is no genesis-chain22.json until the cut. The cut prints the row (check-constraint-set.sh --print-row), and check-limits refuses until it is committed.

Tests (build droplet, Rust 1.98.1; the Mac built nothing)

Run Result
cargo test --workspace --lib --bins --release -- $(scripts/ci-fixture-skips.sh) 2200 passed, 0 failed, 7 ignored
prover::tests::the_trusted_provers ok
The integration list from ci.yml: submit, ws, public_rpc_check; prover http/service/pairing/wire/retired_flag/cli; client cli_*, rpc_methods; node prover_hosted, keygen_cli, prover_flag, network, cli_multisig, cli_staking, cli_vesting, cli_datadir, cli_bridge_gov; genesis_cli (15/15 after its msauth pin); dandelion; burst_memory; rpc_contract all ok
guest_provenance (19), verifier_key (zkvm, rvm), invoke_wire_pin, beacon_gate_off_pin, no_pre_phase4_recursion_pins ok
cluster subset (the 12 named in ci.yml) ok
clippy (lint job's command, -D warnings) clean
scripts/recursion-fixtures.sh --check pinned bytes
check-constraint-set.sh (with and without --upstream at the pin) and its tests in constraint_set ok
SELFTEST=1 bash deploy/cut-chain22-genesis.sh (after the rebase onto #193) 444 passed, 0 failed
deploy selftests in ci.yml ok (unit-limits and roll-fleet refuse to run as root, so they ran on the Mac: 66/66 each)
keygen-msauth-vk --profile production reproduces 168d79a8…71b3 byte for byte

Owed downstream

  • durian.market:
    • rebuild against set 11 and re-pin the perp engine;
    • measured on this build: rand perp image-hc gives 482215a8df02dff341265c38212c47e23fc8bfb3c3297afe9c385d6a63e65073 for artifacts/perp-engine.image.bin, with engine_program_log_height still 14 (was f286a611…);
    • the AMM image is be19a49a668d80a8e72b941e2ec0b0ca18d09da6794f02103c547cd7e4bb8fb1 (height 11);
    • perp-prover genesis-state must re-derive genesis_root, since chain 21's da0e3a53… is a set-9 Poseidon2 root;
    • until then the cut script's ENGINE_HC_DECIDED / PERPS_DECIDED / genesis_root checks stay at chain 21's values and are left for that re-pin. They are not guessed here.
  • Wallet WASM (clients) and randscan WASM: rebuild on set 11. Note commitments, nullifiers, scan keys and the guest hcs all moved. The msig signer-check fixtures in crates/randprotocol-msig/tests/fixtures were regenerated, so any copy of them in clients must follow.
  • Bridge: commitments and note openings are Poseidon2. The relayer and guardians must mint against set-11 commitments on chain 22.
  • circuits PR ZKH-3: POSEIDON2 syscall is a padding-free sponge: [a] and [a, 0] collide #27 (EVM block context / PREVRANDAO) is still open. When it lands it moves the evm guest's hc again, and that is one more CIRCUITS_PIN step. This PR stops at 76a48dca.
  • Minor: rand's non-CPU fee estimate still prices at the full-height gas_max. This over-charges and never under-charges.

🤖 Generated with Claude Code

https://claude.ai/code/session_01YGaYNLS2uLR7w6m2JtejVo

…idon2 height, rate-1/4 quotient layout, versioned rVM keys, cell-count gas)

Issue #166 step 7, for the chain-22 cut and v0.8.7. CIRCUITS_PIN b3e21d9 -> 76a48dca
(circuits org/main), synced with deploy/sync-zkvm.sh; seven guests (evm-v1 added).

- BUILD_CONSTRAINT_SET 11; chain 21 joins CHAINS_THIS_BUILD_CANNOT_RUN. Set 11 moves every
  Poseidon2 output, so no chain 14-21 genesis file builds any more:
  constraint_set::build_genesis refuses them by chain id at init/run/verify, before any
  datadir is touched. Chain 22's CHAIN_CONSTRAINT_SETS row is owed at its cut.
- Guest digests: bundle v1 71eedbfb, v2 3aff6361, v3 00782b22, auth 8373994c, msauth
  41db73c5 (guest_provenance pins both these and the set-10 values chains 14-21's files carry).
- Gas mirror gas_max_declared(t,k,s,m,p2): bundle 22527, auth 1407, msauth 355775
  (MSAUTH_POSEIDON2_LOG_HEIGHT 16). poseidon2_log_height carried through ProofShape,
  MsauthShape, CallDryRun and the aggregate path; bundle/auth inner proofs and the canonical
  perp state proof declare the tier's full height.
- msauth key blobs: production 23851 B 168d79a8 (reproduced by keygen), test d30472df.
- Executor FRI mirror follows machine::LOG_BLOWUP (2): 92 queries / 24 pow bits.
- Recursion fixtures Test-0..2 re-proved and re-pinned; inner vk b9046f5d, interface digest
  517d13e4, production aggregate program digest 43e02700. msig signer-check fixtures
  regenerated.
- deploy/cut-chain22-genesis.sh: EXPECT_HC_BUNDLE, EXPECT_HC_AUTH, HC_AUTH_MULTISIG_DECIDED,
  BUNDLE_GAS_LIMIT to set 11's; chain 21's file asserted at its set-9 values. Perps engine
  pins left as chain 21's (durian must rebuild).
- Docs, CHANGELOG (Unreleased) and AGENTS.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YGaYNLS2uLR7w6m2JtejVo
@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

The optional git dependency's rev moved with the re-vendor but the lock still named 71e1a04,
so every `--locked` job (clean-clone, wallet-e2e, release) refused to update it. `cargo update
-p rand-zkvm-cuda` under the pinned 1.98.1 toolchain: the cuda crate's new p3 deps, one
itertools dropped, range-compatible picks below it. Checked with --locked on the build
droplet in all three CI layouts: fullnode alone (metadata + check --workspace --tests),
beside circuits at the pin, and nested as wallet-e2e checks it out (release build of
rand-node and rand-prover).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YGaYNLS2uLR7w6m2JtejVo
dendisuhubdy and others added 2 commits November 20, 2026 02:58
…N-601)

A block carrying a tier-18 perps state proof made every validator build that
shape's verifier key (~1.7 GB with `parallel`, ~3.3-4 GB without), so a 2 GB
validator could OOM on a valid block. Chain 22 pins the keys instead.

- core: gated genesis field `perps.state_proof_keys` (serde default + skip,
  bound into the genesis hash only when set, `rand-perps-ext-3` persisted);
  check() admits only canonical shapes of the chain (<= 8, ordered, needs
  engine_program_log_height). When set, an unpinned declared shape is refused
  before any key is touched, at validate and at apply.
- zkvm (node-local executor.rs): `perp_vk` module (chain-22 shapes, compiled-in
  SHA-256 pins, file names, blob/check); pinned mode refuses unpinned shapes in
  perp_pre_key, verifies only against loaded keys and never builds one.
- node: `perps_key` loads every pinned file at startup (--perps-key-dir,
  RAND_PERPS_KEY_DIR, beside the binary), refuses to start on a missing or
  mismatched file, reports rand_status.perps_keys; rand_getPerps serves the
  list; `rand-node keygen-perp-vk` (--print-pinned, --check, --genesis-json,
  --profile --out-dir); `verify` loads them too.
- client: `rand perp prove` refuses non-canonical shapes on a pinned chain.
- keys: the four chain-22 Production files (tier 18, program 14, input 16,
  poseidon2 20, public 7/8/9/10), 13 685 bytes each, in
  crates/randprotocol-zkvm/keys/.
- deploy: the chain-22 cut sets the field from the shipped files held to the
  cutting rand-node's pins, asserts it, probes it in the hash and reads it
  back in check-limits (selftest 467 passed, 0 failed); release.yml ships,
  sums, attests and checks the files; roll-all.sh installs them (PERPS_VK_DIR).
- docs: deploy.md, perps.md, CHANGELOG.

Chain 21's genesis and pins are unchanged (the field is absent there).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YGaYNLS2uLR7w6m2JtejVo
…is root a45d8fda…

Set 11's Grain Poseidon2 constants move the engine's hc and the perps genesis root;
neither the image nor the genesis words change (durian.market #2, measured on a5e08a9):

- ENGINE_HC_DECIDED = 482215a8df02dff341265c38212c47e23fc8bfb3c3297afe9c385d6a63e65073
  (chain 21's image, sha256 77dfc228...); chain 21's f286a611... is kept as
  ENGINE_HC_CHAIN21 for the check on chain 21's genesis. The finished file's engine_hc must
  be the set-11 hc and not chain 21's; check-limits wants it from rand_getPerps.
- PERP_GENESIS_ROOT_DECIDED = a45d8fdab8cf7dab972e76dd6a7a18d9e82fc8210afab672a161ee60021698b4
  (perp-prover genesis-state over BTC-PERP -> rand perp genesis-root; the 26 words are
  chain 21's, sha256 bb32f0c4...). The genesis_root check is now "equals the recorded
  set-11 root" (was "equals chain 21's da0e3a53..."); chain 21's root is refused. The
  derivation moves into perp_genesis_root_step, which refuses the set-9 root and any other
  before the section is written.
- Selftest: perp_genesis_root_step against a fake prover and rand (5 cases), and refusals
  of chain 21's root and engine hc in the finished file: 474 passed, 0 failed.
- crates/randprotocol-core/tests/vectors/perps-v1.json: the three perp_digest vectors
  regenerated under set 11 (PERPS_WRITE_VECTORS=1); randprotocol-zkvm's perps_vectors
  failed on the set-9 values on #194/#195. core's golden test still passes.
- docs/deploy.md, CHANGELOG.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YGaYNLS2uLR7w6m2JtejVo
… issue #168)

CIRCUITS_PIN 76a48dca -> 41d64acd, and both rand-zkvm-cuda revs with it (Cargo.lock
updated with cargo update -p rand-zkvm-cuda). deploy/sync-zkvm.sh from circuits 41d64acd;
the recursion VM did not move (crates/randprotocol-rvm unchanged).

- evm.bin hc 3869b014...8920720d (program id 0eff0627...), evm-v1.bin 040c01c8...3454; the
  guests-compiled and vendor/circuits manifests and PROVENANCE.md re-synced. No hand-held
  evm hc pin existed elsewhere in fullnode (guest_provenance checks the manifests).
- evm_core::Host gained read_public: the vendored HostRef answers 0 (no context version,
  so the block opcodes trap as under a version-1 context), the new HostPublic reads a
  segment and panics past its end (no proof in the guest), and HostBox (ffi) forwards to
  READ_PUBLIC. No fullnode-owned Host impl exists.
- New crates/randprotocol-zkvm/tests/invoke_at_context.rs (excluded from the sync): the
  guest's CTX_* offsets equal the ledger's; the vendored interpreter over the segment the
  ledger builds (Transition::context_at over BlockFacts::context_words) pushes NUMBER,
  TIMESTAMP, CHAINID, BASEFEE, GASPRICE and PREVRANDAO from words 11-27, traps PREVRANDAO
  without a beacon and every block opcode under version 1; and a Test-profile InvokeAt
  proof of an RV32 program reading words 8+{0,11,12,13,16,17,19,27} verifies on its own
  block's segment and is refused on another time, another beacon value and a version-1
  context.
- docs/evm-block-context.md, CHANGELOG.md, AGENTS.md: the guest side is vendored.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YGaYNLS2uLR7w6m2JtejVo
@dendisuhubdy
dendisuhubdy merged commit 94b2c15 into main Nov 19, 2026
23 checks passed
@dendisuhubdy
dendisuhubdy deleted the feat/cs11-revendor branch November 19, 2026 21:34
dendisuhubdy added a commit that referenced this pull request Nov 20, 2026
…t 11)

- Workspace version 0.8.7: Cargo.toml, the seven workspace crates in
  Cargo.lock (cargo update -w on the build droplet; offline failed on the
  rand-zkvm-cuda git dependency), the rand_getVersion test.
- CHANGELOG: Unreleased becomes v0.8.7 (tag date a PLACEHOLDER), with a row
  for #197's cutover-fleet-chain22.sh and the asset list.
- docs/releases/v0.8.7.md: the set-11 gas change as a governance record
  (bundle 20 479 -> 22 527, auth 1 279 -> 1 407, msauth 436 159 -> 355 775;
  the per-row weights), the chain-22 cut, the operator upgrade steps and the
  rollback. The chain-22 genesis hash and the CHAIN_CONSTRAINT_SETS row are
  PLACEHOLDER-... until the cut.
- README release table: v0.8.7. AGENTS.md: #194 is merged.

Not tagged, not signed, not published.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YGaYNLS2uLR7w6m2JtejVo
dendisuhubdy added a commit that referenced this pull request Nov 20, 2026
…t 11) (#198)

* v0.8.7: version, changelog and release notes (chain 22, constraint set 11)

- Workspace version 0.8.7: Cargo.toml, the seven workspace crates in
  Cargo.lock (cargo update -w on the build droplet; offline failed on the
  rand-zkvm-cuda git dependency), the rand_getVersion test.
- CHANGELOG: Unreleased becomes v0.8.7 (tag date a PLACEHOLDER), with a row
  for #197's cutover-fleet-chain22.sh and the asset list.
- docs/releases/v0.8.7.md: the set-11 gas change as a governance record
  (bundle 20 479 -> 22 527, auth 1 279 -> 1 407, msauth 436 159 -> 355 775;
  the per-row weights), the chain-22 cut, the operator upgrade steps and the
  rollback. The chain-22 genesis hash and the CHAIN_CONSTRAINT_SETS row are
  PLACEHOLDER-... until the cut.
- README release table: v0.8.7. AGENTS.md: #194 is merged.

Not tagged, not signed, not published.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YGaYNLS2uLR7w6m2JtejVo

* v0.8.7 notes: the set-11 address re-derivation (#199) and WALLET22

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YGaYNLS2uLR7w6m2JtejVo

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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