refactor(stm): refactor error handling from Midnight library#3416
Merged
Conversation
hjeljeli32
requested review from
Alenar,
curiecrypt,
damrobi,
jpraynaud and
turmelclem
as code owners
July 17, 2026 06:29
hjeljeli32
force-pushed
the
hjeljeli32/3382-typed-circuit-errors
branch
from
July 17, 2026 08:12
11eb64d to
5ba6b14
Compare
There was a problem hiding this comment.
Pull request overview
This PR upgrades the midnight-* dependencies and refactors STM Halo2 circuit/proof plumbing to preserve typed circuit errors (StmCircuitError) across the Relation::circuit boundary (removing prior string-based synthesis error flattening). It also updates IVC fixed-base handling and regenerates/updates golden assets accordingly.
Changes:
- Upgrade
midnight-circuits/curves/proofs/zk-stdliband adapt call sites to new APIs (MidnightCircuit::from_relation(..., None), SRS downsizing, verifier params usage). - Preserve typed
StmCircuitErrorend-to-end in the non-recursive certificate circuit and update negative tests to assert on typed variants. - Update IVC accumulator/fixed-base handling (prefix renames, removal of
com_instancedummy entry, pre-flight MSM/fixed-base consistency check) and refresh related golden assets/tests.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| mithril-stm/src/protocol/aggregate_signature/clerk.rs | Adjust test setup to new MidnightCircuit/SRS downsizing API. |
| mithril-stm/src/protocol/aggregate_signature/ancillary_data.rs | Update expected digest constant to match regenerated assets/behavior. |
| mithril-stm/src/proof_system/ivc_halo2_snark/verifier_setup.rs | Remove tau_g2 storage/extraction; rely on verifier params and updated fixed-base prefixes. |
| mithril-stm/src/proof_system/ivc_halo2_snark/prover_setup.rs | Add MSM/fixed-base pre-flight checks; construct accumulators via from_dual_msm; update prefixes. |
| mithril-stm/src/proof_system/ivc_halo2_snark/prover_input_helpers.rs | Propagate new StmResult return from certificate_collapsed_accumulator. |
| mithril-stm/src/proof_system/ivc_halo2_snark/proof.rs | Update accumulator verification to use verifier params; adjust tests accordingly. |
| mithril-stm/src/proof_system/halo2_snark/setup.rs | Switch to MidnightCircuit::from_relation(..., None).k() and new SRS downsizing flow. |
| mithril-stm/src/proof_system/halo2_snark/proof.rs | Refresh golden proof/verifier-data fixtures; add ignored generator test helper. |
| mithril-stm/src/circuits/halo2/witness_assignments.rs | Return StmCircuitError from witness assignment helpers and propagate backend errors via From. |
| mithril-stm/src/circuits/halo2/tests/test_helpers.rs | Parameterize test harness over relation error type; update circuit degree derivation. |
| mithril-stm/src/circuits/halo2/tests/golden/helpers.rs | Remove backend string-matching helper; update proving error propagation and cost model calls. |
| mithril-stm/src/circuits/halo2/tests/golden/cases/negative.rs | Convert negative tests from string matching to typed StmCircuitError assertions. |
| mithril-stm/src/circuits/halo2/mod.rs | Update module docs to reflect backend error conversion (not synthesis flattening). |
| mithril-stm/src/circuits/halo2/keys.rs | Update circuit degree discovery and expose degree as u32; adapt keygen sizing. |
| mithril-stm/src/circuits/halo2/key_serialization.rs | Update test keygen path to new circuit degree/SRS handling. |
| mithril-stm/src/circuits/halo2/gadgets/unique_schnorr_signature.rs | Update focused test relation macro usage with explicit error type. |
| mithril-stm/src/circuits/halo2/gadgets/merkle_path.rs | Return StmCircuitError directly for guard failures; map backend assertion errors upward. |
| mithril-stm/src/circuits/halo2/gadgets/lottery.rs | Return StmCircuitError for lottery gadget assertions; adjust focused tests. |
| mithril-stm/src/circuits/halo2/gadgets/comparison.rs | Propagate StmCircuitError from comparison helpers and assertions. |
| mithril-stm/src/circuits/halo2/gadgets/comparison_helpers.rs | Convert helper APIs to StmCircuitError for typed propagation. |
| mithril-stm/src/circuits/halo2/errors.rs | Add backend catch-all + From<plonk::Error> to satisfy new Relation::Error bound; add unit test. |
| mithril-stm/src/circuits/halo2/circuit.rs | Set Relation::Error = StmCircuitError; remove synthesis flattening; update cost model calls and chips. |
| mithril-stm/src/circuits/halo2/bench_helpers.rs | Update cost model and MockProver API usage; update circuit degree calculation. |
| mithril-stm/src/circuits/halo2_ivc/witness_assignments.rs | Rename VK name constants to fixed-base prefixes throughout witness assignment. |
| mithril-stm/src/circuits/halo2_ivc/tests/off_circuit/proof_verification.rs | Use verifier params (not tau_g2) in accumulator checks. |
| mithril-stm/src/circuits/halo2_ivc/tests/off_circuit/mod.rs | Rename extraction-focused module references to resolution-focused ones. |
| mithril-stm/src/circuits/halo2_ivc/tests/off_circuit/fixed_base_resolution.rs | New tests for resolve_fixed_bases behavior/idempotency. |
| mithril-stm/src/circuits/halo2_ivc/tests/off_circuit/fixed_base_extraction.rs | Removed extraction tests (superseded by resolution approach). |
| mithril-stm/src/circuits/halo2_ivc/tests/off_circuit/accumulator_verification.rs | Use verifier params for accumulator checks. |
| mithril-stm/src/circuits/halo2_ivc/tests/off_circuit/accumulator_update.rs | Update pipeline to from_dual_msm/verifier params; remove extract step assumptions. |
| mithril-stm/src/circuits/halo2_ivc/tests/off_circuit/accumulator_construction.rs | Add negative test for fixed-base prefix mismatch detection. |
| mithril-stm/src/circuits/halo2_ivc/tests/off_circuit/accumulator_collapse.rs | Align collapse tests with from_dual_msm + verifier params flow. |
| mithril-stm/src/circuits/halo2_ivc/tests/golden/positive.rs | Update golden checks to pass verifier params into accumulator checks. |
| mithril-stm/src/circuits/halo2_ivc/tests/encoding/positive.rs | Add golden serialization test for recursive proof accumulator bytes. |
| mithril-stm/src/circuits/halo2_ivc/tests/common/helpers.rs | Update MockProver usage and accumulator construction via from_dual_msm; remove stored tau_g2. |
| mithril-stm/src/circuits/halo2_ivc/tests/common/generators/verification_key.rs | Update circuit degree computation for new MidnightCircuit API. |
| mithril-stm/src/circuits/halo2_ivc/tests/common/generators/transitions.rs | Update fixed-base prefix usage and accumulator construction via from_dual_msm. |
| mithril-stm/src/circuits/halo2_ivc/tests/common/generators/setup.rs | Rename constants and fixed-base prefix usage in setup generators. |
| mithril-stm/src/circuits/halo2_ivc/tests/common/generators/proofs.rs | Adjust proof generation call signature ordering. |
| mithril-stm/src/circuits/halo2_ivc/tests/common/generators/asset_generation.rs | Update accumulator construction/checks to verifier params + from_dual_msm; add ignored asset generator. |
| mithril-stm/src/circuits/halo2_ivc/tests/common/asset_readers.rs | Stop extracting/storing tau_g2 from embedded verifier params bytes. |
| mithril-stm/src/circuits/halo2_ivc/tests/assets/README.md | Document new ignored asset-generation command. |
| mithril-stm/src/circuits/halo2_ivc/mod.rs | Rename VK-name constants to fixed-base prefix constants; update foreign ECC chip imports. |
| mithril-stm/src/circuits/halo2_ivc/errors.rs | Add error variant for MSM/fixed-base mismatch detection. |
| mithril-stm/src/circuits/halo2_ivc/constraint_builder.rs | Update to ForeignWeierstrassEccChip API and verifier gadget prepare signature changes. |
| mithril-stm/src/circuits/halo2_ivc/config.rs | Adapt IVC circuit configuration to new weierstrass foreign-ECC chip configuration API. |
| mithril-stm/src/circuits/halo2_ivc/accumulator.rs | Remove com_instance dummy fixed base; add MSM/fixed-base consistency check helper. |
| mithril-stm/CHANGELOG.md | Add 0.11.0 entry describing dependency upgrades and key/fixed-base changes. |
| mithril-stm/Cargo.toml | Bump crate version and pin upgraded midnight-* crate versions. |
| mithril-common/Cargo.toml | Update mithril-stm dependency version to 0.11.0. |
| docs/runbook/update-circuit-keys/README.md | Update runbook checklist with nr_pow2range_cols guidance. |
| Cargo.lock | Lockfile updates for upgraded dependencies and new transitive crates. |
hjeljeli32
temporarily deployed
to
testing-preview
July 17, 2026 11:15 — with
GitHub Actions
Inactive
hjeljeli32
temporarily deployed
to
testing-2-preview
July 17, 2026 11:15 — with
GitHub Actions
Inactive
jpraynaud
approved these changes
Jul 17, 2026
hjeljeli32
force-pushed
the
hjeljeli32/3382-typed-circuit-errors
branch
from
July 20, 2026 22:59
5ba6b14 to
976d808
Compare
hjeljeli32
temporarily deployed
to
testing-2-preview
July 20, 2026 23:34 — with
GitHub Actions
Inactive
hjeljeli32
temporarily deployed
to
testing-preview
July 20, 2026 23:34 — with
GitHub Actions
Inactive
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.
Content
Typed
StmCircuitErrorguard failures raised in the non-recursive (certificate) circuit'sRelation::circuitimplementation were flattened intoplonk::Error::Synthesis(String)at the relation boundary (viato_synthesis_error), losing the error type and forcing callers and tests to rely on fragile string matching. Midnight zk 2.3.3 lets a relation surface its own error type end-to-end through theRelation::Errorassociated type (midnightntwrk/midnight-zk#248).This types the certificate circuit's error boundary: the circuit returns
StmCircuitErrordirectly, the flattening adapter is removed, and the negative tests assert typed variants. The change is confined to the non-recursive circuit (circuits/halo2/).Changes
StmCertificateCircuit::Erroris nowStmCircuitError(wasplonk::Error). ABackend(String)catch-all variant and aFrom<plonk::Error>conversion satisfy Midnight's newRelation::Error: From<plonk::Error>bound; backend/library errors convert into it while the circuit's own domain guards stay fully typed.to_synthesis_erroris deleted for the non-recursive circuit. The relation (circuit.rs), witness assignment (witness_assignments.rs), and the gadget layer it feeds (merkle_path,comparison_helpers,comparison,lottery) now returnStmCircuitErrordirectly; standard-libraryplonk::Errorvalues convert upward throughFrom.StmCircuitErrordowncastable through theanyhowsource chain, so callers and tests match on typed variants instead of parsing synthesis message text.assert_proving_backend_message_containsstring-matching helper; the six negative cases now assert exactStmCircuitErrorvariants; the focused test-relation macro is parameterized by error type; and aFrom<plonk::Error>conversion unit test guards the trait contract.Pre-submit checklist
Issue(s)
Closes #3382