Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ env:
CXXFLAGS: -include cstdint
# The circuits commit this tree's vendored crates were synced from (deploy/sync-zkvm.sh). Bump it
# in the same commit as a re-vendor, or CI builds this workspace against a tree it did not vendor.
# 56b7061 is circuits branch feat/scan-compact: main c83b1c7 (tree aggregation, 4a244b6) plus
# viewing.rs's ScanKey and EnvelopeHead; recursion/ is 4a244b6's. The rand-zkvm-cuda revs stay
# at the pushed 71e1a04, where rand-zkvm-cuda/ is identical to this commit's.
CIRCUITS_PIN: b3e21d9ea16225452bcd03a94317cb61e1705979
# 41d64acd is circuits main at constraint set 11 (chain 22: Grain constants, the declared
# poseidon2 height, the rate-1/4 per-instance quotient layout, versioned rVM keys, cell-count
# gas; set 11 itself landed at 76a48dc) plus circuits #27, the EVM guest's block context v2
# (fullnode #168: NUMBER/TIMESTAMP/CHAINID/BASEFEE/PREVRANDAO from an InvokeAt's public
# context words; evm.bin hc 3869b014...). Both rand-zkvm-cuda revs name this commit too.
CIRCUITS_PIN: 41d64acd0fec1c6b15be18a8c7707ddce61ff790

jobs:
check-and-test:
Expand Down Expand Up @@ -255,10 +257,11 @@ jobs:
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
with:
workspaces: circuits/rand-guest
# Builds fib, keccak256, evm, sbpf, dilithium-verify and msauth from source with `rand-guest
# build` and compares: the four image containers byte for byte, the two legacy flat pins by
# program (base_pc, words, hc). circuits' gate lists all six at the pin (private multisig).
- name: circuits rebuilds the six guests from source
# Builds fib, keccak256, evm, evm-v1, sbpf, dilithium-verify and msauth from source with
# `rand-guest build` and compares: the image containers byte for byte, the legacy flat pins by
# program (base_pc, words, hc). circuits' gate lists all seven at the pin (constraint set 11
# added evm-v1, the EVM guest at output layout 1).
- name: circuits rebuilds the seven guests from source
working-directory: circuits/rand-guest
run: cargo test --release --test build -- --exact build_reproduces_every_committed_image_and_reports_hc
# Inline rather than circuits' `contracts/build.sh`: that script's `mktemp -t erc20.runtime.hex`
Expand Down
21 changes: 19 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ jobs:
# The precomputed msauth verifier key (private multisig): the committed blob, shipped
# beside the binaries and installed at /usr/local/bin/msauth-vk-production.bin.
cp crates/randprotocol-zkvm/keys/msauth-vk-production.bin dist/
( cd dist && sha256sum rand-node rand rand-prover msauth-vk-production.bin > SHA256SUMS && cat SHA256SUMS )
# CON-601: the four pinned perps state-proof verifier keys (chain 22's
# perps.state_proof_keys), shipped beside the binaries and installed in /usr/local/bin.
cp crates/randprotocol-zkvm/keys/perp-vk-production-*.bin dist/
( cd dist && sha256sum rand-node rand rand-prover msauth-vk-production.bin perp-vk-production-*.bin > SHA256SUMS && cat SHA256SUMS )
dist/rand-node --version
- name: The msauth key blob is the one this rand-node pins
working-directory: fullnode
Expand All @@ -198,6 +201,19 @@ jobs:
want=$(dist/rand-node keygen-msauth-vk --print-pinned production)
echo "msauth-vk-production.bin sha256 $got, pinned $want"
[ "$got" = "$want" ] || { echo "::error::dist/msauth-vk-production.bin ($got) is not the pin compiled into dist/rand-node ($want)"; exit 1; }
- name: The perps state-proof key files are the ones this rand-node pins (CON-601)
working-directory: fullnode
run: |
set -euo pipefail
n=0
while read -r name want; do
got=$(dist/rand-node keygen-perp-vk --check "dist/$name")
echo "$name sha256 $got, pinned $want"
[ "$got" = "$want" ] || { echo "::error::dist/$name ($got) is not the pin compiled into dist/rand-node ($want)"; exit 1; }
n=$((n + 1))
done < <(dist/rand-node keygen-perp-vk --print-pinned production)
shipped=$(ls dist/perp-vk-production-*.bin | wc -l)
[ "$n" -eq 4 ] && [ "$shipped" -eq "$n" ] || { echo "::error::rand-node pins $n perp-vk files, dist holds $shipped (want 4)"; exit 1; }
- name: Build provenance
uses: actions/attest-build-provenance@96278af6caaf10aea03fd8d33a09a777ca52d62f # v3.2.0
with:
Expand All @@ -206,6 +222,7 @@ jobs:
fullnode/dist/rand
fullnode/dist/rand-prover
fullnode/dist/msauth-vk-production.bin
fullnode/dist/perp-vk-production-*.bin
- name: The release
working-directory: fullnode
env:
Expand Down Expand Up @@ -248,4 +265,4 @@ jobs:
prerelease=""
case "$TAG" in *-rc*|*-alpha*|*-beta*) prerelease="--prerelease" ;; esac
gh release create "$TAG" --repo "$REPO" --verify-tag --title "$TAG" --notes-file notes.md $prerelease \
dist/rand-node dist/rand dist/rand-prover dist/msauth-vk-production.bin dist/SHA256SUMS
dist/rand-node dist/rand dist/rand-prover dist/msauth-vk-production.bin dist/perp-vk-production-*.bin dist/SHA256SUMS
38 changes: 38 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,44 @@ invariants, and known traps.

## Project memory (state as of 2026-11-08)

### Constraint set 11 re-vendored (issue #166 step 7; 2026-11-20, branch `feat/cs11-revendor`, PR open, NOT merged)

`CIRCUITS_PIN` **`41d64acd`** (circuits main: set 11 landed at `76a48dca`, "Constraint set 11:
Grain constants, declared poseidon2 height, quotient layout, versioned rVM key"; then #27, the EVM
guest's block context v2 for #168 — `evm.bin` hc `3869b014…`, `evm_core::Host::read_public`,
proved end to end by `tests/invoke_at_context.rs`; was `b3e21d9`, set 9), synced with
`deploy/sync-zkvm.sh`; seven guests (evm-v1 added). **A chain cut: chain 22 on, never a roll onto
chain 21.** What moved, and where it lives:

- **Guest digests** (`crates/randprotocol-zkvm/tests/guest_provenance.rs`, both columns pinned —
`SET_10_*` for the committed chains 14–21 files, the set-11 ones for this source): bundle v1
`71eedbfb…ee70`, v2 `3aff6361…6046`, v3 `00782b22…141e`, auth `8373994c…6078`, msauth
(`MSAUTH_HC`) `41db73c5…9cd1`; the retired legacy guest `6e968302…dc1d` (files carry `4a27356f…`).
`deploy/cut-chain22-genesis.sh`'s `EXPECT_HC_BUNDLE`, `EXPECT_HC_AUTH`,
`HC_AUTH_MULTISIG_DECIDED` and `BUNDLE_GAS_LIMIT` (22527) moved with them; chain 21's file is
asserted at its set-9 values.
- **Gas** (`randprotocol-core/src/gas.rs`, mirrored against the vendored zkVM in the executor's
gas test): `gas_max_declared(t, k, s, m, p2)`; bundle 22 527, auth 1 407, msauth 355 775
(`MSAUTH_POSEIDON2_LOG_HEIGHT` 16). Fee pricing of a call still uses the full-height ceiling (an
over-charge, never an under-charge).
- **Proof header**: `poseidon2_log_height` in `ProofShape`, `MsauthShape`, `CallDryRun` and the
aggregate path; bundle/auth inner proofs, the canonical perp state proof and the inner proofs
an aggregate covers must declare the full height (`Tier::max_poseidon2_log_height()`), msauth 16.
- **msauth key blobs**: production 23 851 B `168d79a8…71b3` (reproduced by `keygen-msauth-vk` on
the build droplet), test `d30472df…db3d`.
- **Recursion fixtures** Test-0..2 re-proved (`scripts/recursion-fixtures.sh` against circuits
`76a48dc`, 135 s each on the 16-vCPU droplet) and re-pinned; the msig signer-check fixtures
regenerated (the policy id is a Poseidon2 digest).
- **The guard**: `BUILD_CONSTRAINT_SET` 11; chain 21 in `CHAINS_THIS_BUILD_CANNOT_RUN`. No chain
14–21 genesis file builds under set 11 (`NoteCommitmentMismatch` / the bundle-limit check), so
`constraint_set::build_genesis` refuses them by chain id; the chain-14..21 "builds to its hash"
tests are refusal tests now, and `node::tests::chain_21_*` are `#[ignore]`d (the v0.8.6 line
runs them). **Chain 22's `CHAIN_CONSTRAINT_SETS` row is owed at the cut** (no genesis yet).
- **Owed downstream**: durian must rebuild against set 11 and re-pin the perp engine (its image's
hc moves; `perps.engine_hc`, `genesis_root` and `ENGINE_HC_DECIDED` in the cut script are still
chain 21's); wallet and randscan WASM; bridge commitments. A later circuits PR (EVM block
context / PREVRANDAO) moves the evm guest's hc again: one more `CIRCUITS_PIN` step.

### The chain-22 treasury is 5 of 6 with its RAND carried; perps carried empty (2026-11-19, branch `feat/chain22-treasury-carry`; deploy only)

Owner's decisions of 2026-11-19 in `deploy/cut-chain22-genesis.sh` (OPEN 1–4 of its header;
Expand Down
50 changes: 50 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,56 @@ stopped at v0.4 until 2026-09-30, when the entries v0.5 to v0.6.7 were written f

## Unreleased

Perps (**a chain cut, chain 22**; chain 21 unchanged):

- **Chain 22's perps on constraint set 11.** The cut pins the engine at `482215a8…5073` (chain
21's image, the same bytes, under the Grain Poseidon2 constants; durian.market #2) and the perps
`genesis_root` at the recorded set-11 root `a45d8fda…98b4` (`perp-prover genesis-state` →
`rand perp genesis-root`; the genesis words are chain 21's). It no longer asserts chain 21's
`f286a611…` / `da0e3a53…`; `perp_genesis_root_step` refuses the set-9 root and any other
(selftest 474 passed, 0 failed). `tests/vectors/perps-v1.json`'s three digests are regenerated
under set 11: `perps_vectors` failed on the set-9 values.
- **Pinned state-proof verifier keys (CON-601, monorepo#23).** A new gated genesis field,
`perps.state_proof_keys`, lists the state-proof shapes a chain admits, each with the SHA-256 of
its precomputed key file. It is omitted when empty and bound into the genesis hash only when
set (`rand-perps-ext-3` in the persisted section). On such a chain an unpinned shape is refused
before any key build, at validate and apply. Pinned keys come only from hash-matched files,
loaded at startup (`--perps-key-dir`, `RAND_PERPS_KEY_DIR`, default beside the binary). The node
refuses to start if one is missing or mismatched, and never builds a pinned key.
`rand_status.perps_keys` and `rand_getPerps.state_proof_keys` report them. New
`rand-node keygen-perp-vk` (`--print-pinned`, `--check`, `--genesis-json`, `--profile
--out-dir`). Chain 22's four keys are the canonical tier-18 shapes (program 14, input 16,
poseidon2 20, public 7–10), 13 685 bytes each, committed in `crates/randprotocol-zkvm/keys/`,
shipped by the release workflow and installed by `deploy/roll-all.sh` (`PERPS_VK_DIR`). The
chain-22 cut script sets, asserts, hash-probes and reads back the field. `rand perp prove`
refuses a non-canonical shape on a pinned chain.

zkVM (**a chain cut: constraint set 11, for chain 22 and v0.8.7**; chain 21 stays on the set-9
v0.8.6 line):

- **EVM block context in the guest** (circuits `41d64acd`, #27; issue #168): under an `InvokeAt`'s
version-2 context the vendored EVM interpreter's `NUMBER`, `TIMESTAMP`, `CHAINID`, `BASEFEE`,
`GASPRICE`, `PREVRANDAO` (beacon; traps without one), `COINBASE` (0) and `GASLIMIT` (`u32::MAX`)
read public words 11–27 instead of trapping. `evm_core::Host` gained `read_public`; `evm.bin` hc
`3869b014…8920720d`, `evm-v1.bin` `040c01c8…3454`. `CIRCUITS_PIN` and both rand-zkvm-cuda revs
at `41d64acd`. New `crates/randprotocol-zkvm/tests/invoke_at_context.rs`.
- **Circuits re-vendored at constraint set 11** (circuits `76a48dc`, from `b3e21d9` at set 9):
the Grain-derived Poseidon2 round constants (every guest `hc`, note commitment, nullifier,
Merkle and state root and verifier key moves), a declared poseidon2 table height in the proof
header (`Proof::poseidon2_log_height`, an 8-component verifier-key shape), the rate-¼ quotient
layout (FRI blowup 2, 92 queries / 24 pow bits at Production), versioned rVM keys, and gas by
table cells (`KECCAK` 134, `SHA256` 49, the per-op MODQ weights, 4 per Poseidon2 absorb): the
tier-14 bundle ceiling `gas_max(14, 0, 0)` is **22 527** (was 20 479), the auth guest's 1 407
(was 1 279), msauth's 355 775 (was 436 159). New guest digests: bundle v3 `00782b22…141e`,
auth `8373994c…6078`, msauth `41db73c5…9cd1`; production msauth key blob 23 851 B,
`168d79a8…71b3`. Bundle and auth proofs declare their tier's full poseidon2 height, msauth 16.
- **`BUILD_CONSTRAINT_SET` is 11, and chain 21 is refused.** Chain 21 joins
`CHAINS_THIS_BUILD_CANNOT_RUN`; because set 11 moves every Poseidon2 output, no genesis file of
chains 14–21 builds under it any more, so `init`, `run` and `verify` refuse them by chain id
(`constraint_set::build_genesis`) before touching a datadir. Chain 22's
`CHAIN_CONSTRAINT_SETS` row is added at its cut. The chain-22 cut script expects the set-11
digests and bundle limit.

Core and node (**genesis-gated, on no chain** — chain 21's genesis hash, header and block bytes,
state root, wire tags 0–45 and store rows are unchanged, pinned at values taken before the
change):
Expand Down
29 changes: 11 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,14 @@ opt-level = 2
# chunk of rows, filled in parallel (vendor/p3-merkle-tree/src/counter_rng.rs; the proof format and
# the verifier are unchanged). Everything else is the crates.io source.
# `vendor/p3-batch-stark` is a third: p3-batch-stark 0.7.0 with a quotient-layout switch
# (`QuotientLayout`), the circuits fork copied verbatim from circuits 5ff7676; circuits'
# `vendor/PROVENANCE.md` and `recursion/docs/05-quotient-layout.md` are its record.
# (`QuotientLayout`) and its self-check switch, the circuits fork copied verbatim from circuits
# 76a48dc (constraint set 11); circuits' `vendor/PROVENANCE.md` and
# `recursion/docs/05-quotient-layout.md` are its record.
[patch.crates-io]
p3-fri = { path = "vendor/p3-fri" }
p3-merkle-tree = { path = "vendor/p3-merkle-tree" }
# The quotient-layout fork (circuits `vendor/PROVENANCE.md`, `recursion/docs/05-quotient-layout.md`):
# `QuotientLayout::PerChunk` is crates.io's behaviour byte for byte and is what `randprotocol-zkvm`
# (the RV32 machine, every wallet proof) gets; `randprotocol-rvm` pins `PerInstance`.
# `QuotientLayout::PerChunk` is crates.io's behaviour byte for byte; since constraint set 11 both
# `randprotocol-zkvm` (the RV32 machine, every wallet proof, ZKVM-111) and `randprotocol-rvm` pin
# `PerInstance`.
p3-batch-stark = { path = "vendor/p3-batch-stark" }
4 changes: 2 additions & 2 deletions crates/randprotocol-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2446,12 +2446,12 @@ mod tests {
});
let mut circuit = base();
circuit["gas_metering"] = json!("circuit");
circuit["bundle_gas_limit"] = json!(20479);
circuit["bundle_gas_limit"] = json!(22527);
circuit["adjust_bps"] = json!(1250);
let rpc = RpcClient::new(scripted_rpc(vec![("rand_getLimits", Reply::Ok(circuit))]).await);
let l = rpc.limits().await.unwrap().unwrap();
assert!(l.gas_circuit);
assert_eq!((l.bundle_gas_limit, l.adjust_bps), (Some(20_479), Some(1_250)));
assert_eq!((l.bundle_gas_limit, l.adjust_bps), (Some(22_527), Some(1_250)));
for metering in [json!("header"), json!(null), json!("quantum")] {
let mut other = base();
other["gas_metering"] = metering.clone();
Expand Down
4 changes: 2 additions & 2 deletions crates/randprotocol-client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3952,7 +3952,7 @@ mod tests {
#[test]
fn fee_call_without_gas_defaults_to_the_headers_ceiling_under_a_section() {
assert_eq!(fee_call_default_gas(true, 12, None, None), Some(gas::gas_max(12, 0, 0)));
assert_eq!(fee_call_default_gas(true, 14, None, None), Some(20_479));
assert_eq!(fee_call_default_gas(true, 14, None, None), Some(22_527));
// Heights given describe a hashing header: its ceiling, not the hash-free one.
assert_eq!(fee_call_default_gas(true, 14, Some(12), Some(13)), Some(gas::gas_max(14, 12, 13)));
// A tier past u8 clamps like the header rule does (gas_max clamps to 20).
Expand All @@ -3965,7 +3965,7 @@ mod tests {
/// explicit limit is refused naming `--gas-limit max`.
#[test]
fn a_non_cpu_backend_declares_the_ceiling_and_refuses_an_explicit_limit() {
let run = executor::CallDryRun { gas: 700, tier: 10, keccak_log_height: 0, sha256_log_height: 0 };
let run = executor::CallDryRun { gas: 700, tier: 10, keccak_log_height: 0, sha256_log_height: 0, poseidon2_log_height: 12 };
let l = section_limits();
let ceiling = gas::gas_max(10, 0, 0);
assert_eq!(resolve_gas_limit(GasArg::Default, &run, 10, Some(&l), true).unwrap(), (Some(768), 768), "CPU: the bucket");
Expand Down
Loading
Loading