parameters for chain exercises - #122
Conversation
so this can also be run on testnet
The wormhole round-trips its amount back to the funding wallet and draws
it from the root account, which is funded independently of --total-amount,
so scaling it down saves nothing. Worse, each round re-partitions the
amount across num_proofs and deducts fees, so a scaled-down amount rounds
an output below the on-chain minimum in a later round and emits no
transfer event ("No transfer event found"). Restore the proven 50.0.
Verified on a local --dev node: full `quantus exercise` suite now passes
62/62 with --root-account crystal_alice --total-amount 40.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…nt flags The exercise command was undocumented in the README. Add a Command Reference section covering the phases, usage (dev node vs. public testnet), and a flag table for the new --root-account / --total-amount options and the existing --phases/--skip/--seed/--json flags. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Resolves the conflicts between the budget/root-account work and the scenarios main added (utility, vesting, recovery, dual-scheme wormhole): - ExerciseCtx keeps both `unit` and `test_unit`. Amounts spent by the budgeted ephemeral accounts use `test_unit`; amounts funded straight from the root account (recovery, vesting, wormhole) stay on `unit`. - Scales the new ephemeral-account amounts in balances, utility, multisig and reversible. - Adopts main's per-scheme wormhole wallet (dev wallets have no mnemonic), dropping the now-unneeded root_name/root_password ctx fields; keeps the unscaled 50-token multiround amount. - Picks up main's try_to_account_id_ss58check/account_id_of fallibility.
The phases main added fund their own accounts straight from the root account, so the budget only covered the initial ephemeral funding while the run actually spent ~1600 tokens. - ExerciseCtx measures spend as the root account's balance drop and refuses any root-funded transfer that would exceed --total-amount, failing with the numbers instead of a mid-run fee rejection. - recovery and wormhole sweep their dedicated accounts back into the root account, so their funding is borrowed rather than spent; wormhole is funded with the multiround amount plus headroom instead of 500. - recovery and vesting size their amounts from the chain's own deposit constants; the ephemeral accounts are funded from what the chain charges them rather than a share of the cap, so the cap is a ceiling the run never has to reach. - Setup checks each selected phase against the remaining headroom, separating what stays locked (governance deposits, vesting treasury) from what is returned (recovery, wormhole). - The report ends with the run's actual root-account spend. --total-amount 100 --skip governance covers a full run, peaking around 89 tokens. governance alone locks two 100-token referendum submission deposits, hence the 500 default.
n13
left a comment
There was a problem hiding this comment.
Verdict: REQUEST_CHANGES (opinion; GitHub does not permit a formal request-changes review on my own PR).
Two blocking correctness issues remain:
-
The documented custom-root testnet command still runs a dev-only vesting phase.
src/cli/exercise/mod.rs:59-62says only governance must be skipped, but setup replacesctx.alicewith the custom root.src/cli/exercise/scenarios/vesting.rs:294-310then derives the well-known dev treasury from[ctx.alice, bob, charlie]; with any custom root, that prediction cannot match the configured dev treasury and the default vesting phase fails. Keep the scenario's dev Alice identity separate from the funding account, make vesting support a custom signer set, or fail/skip vesting up front and update the documented command and caveat. -
--total-amountis not actually a hard cap on root-account spend.src/cli/exercise/runner.rs:52-90reserves only transfer values before submission, excluding the root signer's transaction fees, and several root-signed calls bypass these helpers entirely. In particular,src/cli/exercise/mod.rs:355-360budgets only two referendum submission deposits, whilegovernance::referendum_flowalso places and leaves locked the track's decision deposit (currently 1,000 tokens), plus root-paid preimage deposits and fees. A well-funded root can therefore spend far beyond the requested cap; a root funded only to the preflight amount can pass setup and fail mid-run. Route every root-paid fee/deposit/transfer through cap enforcement, include the runtime track's decision deposit, and verify that final spend cannot exceed the cap.
Validation on head 6ebb415c490ab250f3a497a7f2d35b87bbf3e652:
git diff --check bdc9c4d...6ebb415— passedSKIP_CIRCUIT_BUILD=1 cargo test --locked --lib cli::exercise::— 2 passed (only existing fuzz-classification tests; the new budget/custom-root paths have no focused unit coverage)SKIP_CIRCUIT_BUILD=1 cargo clippy --locked --all-targets -- -D warnings— passed- All six GitHub CI checks are green
n13
left a comment
There was a problem hiding this comment.
Verdict: REQUEST_CHANGES remains (opinion; GitHub does not permit a formal request-changes review on my own PR).
The live PR head is still 6ebb415c490ab250f3a497a7f2d35b87bbf3e652; no commits have been pushed since the previous review, so both blockers remain in the remote diff:
-
The documented custom-root testnet command still runs a dev-only vesting phase.
src/cli/exercise/mod.rs:59-62says only governance must be skipped, butsetupreplacesctx.alicewith the custom root.src/cli/exercise/scenarios/vesting.rs:294-310then derives the well-known dev treasury from[ctx.alice, bob, charlie]; with a custom root this cannot match the configured dev treasury, so the default vesting phase fails. Separate the dev scenario signer from the funding account, support a custom vesting signer set, or reject/skip vesting up front and update the docs. -
--total-amountstill is not a hard cap on root-account spend.src/cli/exercise/runner.rs:52-90guards transfer values only, excluding the root signer's fees, while direct root-signed calls bypass these helpers.src/cli/exercise/mod.rs:355-360budgets only two submission deposits even thoughgovernance::referendum_flowalso leaves the track's 1,000-token decision deposit locked, plus root-paid preimage deposits and fees. A sufficiently funded root can exceed the requested cap; a root funded only to the preflight amount can pass setup and fail mid-run. Account for every root-paid fee/deposit/transfer, include the runtime track decision deposit, and enforce the cap after each root-signed operation and at completion.
Fresh validation on the unchanged head:
git diff --check bdc9c4d...6ebb415— passedSKIP_CIRCUIT_BUILD=1 cargo test --locked --lib cli::exercise::— 2 passed (only fuzz-classification tests; no focused coverage for these new paths)SKIP_CIRCUIT_BUILD=1 cargo clippy --locked --all-targets -- -D warnings— passed- All six GitHub CI checks remain green
… dev Alice - Reserve the estimated fee plus values/deposits for every root-signed call, and fail the run if final root spend exceeds --total-amount. - Drop the governance phase when --total-amount is given (--phases governance overrides); when governance/upgrade do run, their dev-account spend is measured and exempted from the cap. - Keep the dev Alice/Bob/Charlie identities separate from the funding account: the vesting treasury multisig predicts from the dev identities and its admin steps skip when the chain's treasury is not the dev multisig; the reversible guardian, recovery/reads checks and sweeps use the root account; the vesting BadOrigin probe signs with an ephemeral account. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
n13
left a comment
There was a problem hiding this comment.
Verdict: REQUEST_CHANGES remains (opinion; GitHub does not permit a formal request-changes review on my own PR).
The custom-root/vesting blocker from the earlier review is fixed: funding and dev identities are separated, and non-dev treasuries skip only the admin steps. Two blockers remain on head 67b20137ddd08f049a0c68fd435494c2070e56ba:
-
Root-paid multisig costs still bypass the hard cap.
src/cli/exercise/scenarios/vesting.rs:350submitscreate_multisigwithreserved = 0, and line 427 does the same for each treasury proposal.submit_budgetedtherefore checks only the extrinsic partial fee, but these calls also draw pallet-level funds from Alice:create_multisigburnsMultisigFee(currently 0.6 token), whileproposeburns the dynamicProposalFee(about 1.03 tokens for three signers) and reservesProposalDeposit(1 token until execution). When the default root is dev Alice, a tightly capped vesting run can cross--total-amount; the final check reports the violation only after those funds have already been drawn. Pass the chain constants/dynamic proposal charge throughreserved(including the temporary deposit headroom), and include them in setup's phase-needs calculation as appropriate. -
The required format check is red.
cargo +nightly fmt --all -- --checkfails insrc/cli/exercise/mod.rs,runner.rs, andscenarios/vesting.rs. GitHub's Fast Checks job fails for the same reason and skips the build/test, Clippy/doc, audit, and examples jobs. Run the pinned formatter and commit its output.
Validation:
git diff --check bdc9c4d...67b2013— passedSKIP_CIRCUIT_BUILD=1 cargo test --locked --lib cli::exercise::— 2 passedSKIP_CIRCUIT_BUILD=1 cargo test --locked --lib cli::send::tests::— 10 passedSKIP_CIRCUIT_BUILD=1 cargo clippy --locked --all-targets -- -D warnings— passed locallycargo +nightly fmt --all -- --check— failed as described above; CI Fast Checks failed and downstream jobs were skipped
Keep budget/governance capping from this branch and --self-upgrade support from main. Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
Adds two parameters to
quantus exerciseso the suite can run against any funded account — e.g. a public testnet — instead of requiring the genesis-fundedcrystal_alicedev account and ~4000 tokens.What's new
--root-account <NAME>(+--root-password/--root-password-file) — the wallet that funds the run. Defaults to the built-incrystal_alicedev account, so existing--devusage is unchanged. Threaded through the funding step and the wormhole scenario.--total-amount <TOKENS>(default40) — total budget drawn from the root account, split evenly across the ephemeral test accounts.How it works
DISCRETIONARY_SCALE = 100via a newctx.test_unit = unit / 100, so the suite needs ~tens of tokens instead of ~4000.Inability to pay some fees) with fast, actionable errors:test_unit/2must stay above ED).50.0): it round-trips back to the wallet and draws from the separately-funded root account, so shrinking it saves nothing — and small per-proof amounts round below the on-chain minimum in later rounds (No transfer event found).Caveat
The
governancephase still relies on the dev genesis accounts (tech-collective membership), so pass--skip governancewhen using a custom root account on a public testnet. This is documented in--help.Testing
--devnode (spec 135 / tx 3): full suite 62/62 passing with--root-account crystal_alice --total-amount 40— funds 4 ephemeral accounts at 10 DEV each; multisig, governance, preimage (all deposit-bearing) and wormhole all green.Docs
quantus exercisewas previously undocumented — added a Chain Exercise Suite section to the README (phases, dev-node vs. testnet usage, and a flag table). All new flags are also self-documented in--help.