Skip to content

test(stm): consolidate the recursive circuit MockProver tests - #3486

Open
hjeljeli32 wants to merge 7 commits into
mainfrom
hjeljeli32/3464-consolidate-recursive-circuit-mockprover-tests
Open

test(stm): consolidate the recursive circuit MockProver tests#3486
hjeljeli32 wants to merge 7 commits into
mainfrom
hjeljeli32/3464-consolidate-recursive-circuit-mockprover-tests

Conversation

@hjeljeli32

@hjeljeli32 hjeljeli32 commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Content

This PR consolidates the MockProver tests in circuits::halo2_ivc and replaces every negative case's verify().is_err() with an exact failure signature. Consolidating test functions saves nothing, since MockProver::run re-synthesizes on every call, so only removing invocations helps. The tests were also weaker than their names: six were found to reject even with their tampering removed, because the cheap stimulus pairs empty proof slots with a trivial accumulator, which balances only at genesis where the gating scales both accumulator contributions to the group identity.

Measured locally at -j 4 on the ci-tests-snark profile: the slow tier goes from 403.2 s to 277.9 s aggregated and 107.0 s to 76.5 s wall, 22 tests becoming 15 and 20 MockProver invocations becoming 14. Net of −6.5 s drift on untouched tests, −118.7 s is attributable; about 65 s of the saving went on four deliberately added invocations. Fast tier unchanged at 541 passing. Per-item numbers are in #3464.

Changes

  • Failure-signature helper (tests/common/failure_signature.rs): a runner generic over Circuit<NativeField> asserting that the failing rows on the public-statement instance column are exactly the expected set and that every failure is a permutation failure. Unit-tested on a minimal two-instance-column circuit.
  • Public-input layout (tests/common/public_input_layout.rs): named row accessors for the global, state and accumulator sections, so no test carries a row literal, guarded by section-length and serialization-order tests.
  • Satisfiable non-genesis fixtures (tests/common/helpers.rs, tests/transitions/positive.rs): same-epoch and next-epoch stimuli built from the committed step assets, so nothing is proved at test time, plus two untampered acceptance cases; the first in-circuit positive coverage of non-genesis steps.
  • Consolidated binding cases (tests/transitions/negative/): thirteen single-field cases become three, one per transition context. Coverage widens at no cost, the step counter and the two genesis verification-key rows having been untested.
  • Preimage encoding cases (tests/encoding/negative.rs): the three byte-range cases now assert the message row plus the decoded field their window feeds, flipping one byte rather than filling a range. A new case isolates the message equality.
  • Accumulator case (tests/in_circuit/accumulator.rs): an untampered canary on a clone, then the whole accumulator section asserted rather than one element. Keeps its freshly proved certificate, the only unseen proof the circuit verifies.
  • Row-dependent mutation delta: mutations add row + 1, since two tampered cells in one permutation class stay equal under a shared delta and left one accumulator row unreported.
  • Deletions: in_circuit/state_transition.rs in full and public_inputs.rs's slow module: six cases, three vacuous and three duplicating the genesis case. Both weak rejection helpers are gone.
  • Genesis-only stimulus made explicit: the trivial-accumulator builders are renamed to say genesis and assert the step counter is zero, their generic names having invited the non-genesis use.
  • Not covered, unchanged from main: the chain-link constraints have no negative coverage, which the deleted cases did not provide either, and an exact row set does not prove each row carries the field named for it. Both are recorded for follow-up.

Pre-submit checklist

  • Branch
    • Tests are provided (if possible)
    • Crates versions are updated (if relevant)
    • CHANGELOG file is updated (if relevant)
    • Commit sequence broadly makes sense
    • Key commits have useful messages
  • PR
    • All check jobs of the CI have succeeded
    • Self-reviewed the diff
    • Useful pull request description
    • Reviewer requested
  • Documentation
    • No new TODOs introduced

Issue(s)

Closes #3464

@hjeljeli32 hjeljeli32 self-assigned this Aug 24, 2026
@hjeljeli32 hjeljeli32 added the run-slow-tests Technical label to run slow tests tiers in the CI. label Aug 24, 2026
@hjeljeli32
hjeljeli32 removed the request for review from curiecrypt August 24, 2026 03:10
@github-actions

Copy link
Copy Markdown

Test Results

     5 files  ±0     209 suites  ±0   2h 10m 53s ⏱️ - 2m 55s
 3 463 tests +1   3 463 ✅ +1  0 💤 ±0  0 ❌ ±0 
11 326 runs  +1  11 326 ✅ +1  0 💤 ±0  0 ❌ ±0 

Results for commit fe8639f. ± Comparison against base commit c8ff793.

This pull request removes 14 and adds 15 tests. Note that renamed tests count towards both.
mithril-stm ‑ circuits::halo2_ivc::tests::in_circuit::accumulator::slow::circuit_rejects_with_wrong_next_accumulator_in_same_epoch_step
mithril-stm ‑ circuits::halo2_ivc::tests::in_circuit::public_inputs::slow::circuit_rejects_wrong_certificate_circuit_verification_key_representation_global_field
mithril-stm ‑ circuits::halo2_ivc::tests::in_circuit::public_inputs::slow::circuit_rejects_wrong_genesis_message_global_field
mithril-stm ‑ circuits::halo2_ivc::tests::in_circuit::public_inputs::slow::circuit_rejects_wrong_ivc_circuit_verification_key_representation_global_field
mithril-stm ‑ circuits::halo2_ivc::tests::in_circuit::state_transition::slow::circuit_rejects_wrong_same_epoch_msg_blake2b_constraint
mithril-stm ‑ circuits::halo2_ivc::tests::in_circuit::state_transition::slow::circuit_rejects_wrong_same_epoch_next_merkle_tree_commitment
mithril-stm ‑ circuits::halo2_ivc::tests::in_circuit::state_transition::slow::circuit_rejects_wrong_same_epoch_next_protocol_parameters
mithril-stm ‑ circuits::halo2_ivc::tests::transitions::negative::genesis::slow::circuit_rejects_msg_inconsistent_with_preimage
mithril-stm ‑ circuits::halo2_ivc::tests::transitions::negative::next_epoch::slow::circuit_rejects_epoch_non_increment_in_next_epoch_step
mithril-stm ‑ circuits::halo2_ivc::tests::transitions::negative::next_epoch::slow::circuit_rejects_merkle_tree_commitment_non_advance_in_next_epoch_step
…
mithril-stm ‑ circuits::halo2_ivc::tests::common::failure_signature::tests::helper_accepts_rejection_with_an_empty_expected_signature
mithril-stm ‑ circuits::halo2_ivc::tests::common::failure_signature::tests::helper_rejects_an_empty_signature_when_a_row_did_fail
mithril-stm ‑ circuits::halo2_ivc::tests::common::failure_signature::tests::helper_rejects_an_incomplete_expected_signature
mithril-stm ‑ circuits::halo2_ivc::tests::common::failure_signature::tests::helper_reports_bound_public_statement_rows_only
mithril-stm ‑ circuits::halo2_ivc::tests::common::failure_signature::tests::minimal_circuit_accepts_honest_instances
mithril-stm ‑ circuits::halo2_ivc::tests::common::failure_signature::tests::mutation_gives_equal_valued_rows_distinct_nonzero_deltas
mithril-stm ‑ circuits::halo2_ivc::tests::common::public_input_layout::tests::layout_matches_the_circuit_statement_contract
mithril-stm ‑ circuits::halo2_ivc::tests::common::public_input_layout::tests::state_public_input_order_matches_the_layout
mithril-stm ‑ circuits::halo2_ivc::tests::encoding::negative::slow::circuit_rejects_preimage_inconsistent_with_the_message
mithril-stm ‑ circuits::halo2_ivc::tests::in_circuit::accumulator::slow::circuit_rejects_tampered_same_epoch_accumulator_public_inputs
…

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Consolidates recursive-circuit MockProver tests while strengthening rejection assertions with exact failure signatures.

Changes:

  • Adds public-input layout and failure-signature helpers.
  • Introduces satisfiable non-genesis fixtures and positive checks.
  • Consolidates negative transition, encoding, and accumulator cases.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
transitions/positive.rs Adds non-genesis acceptance tests.
transitions/negative/same_epoch.rs Consolidates same-epoch binding checks.
transitions/negative/next_epoch.rs Consolidates next-epoch binding checks.
transitions/negative/genesis.rs Consolidates genesis public-input checks.
transitions/mod.rs Clarifies transition-test scope.
in_circuit/state_transition.rs Removes redundant negative tests.
in_circuit/public_inputs.rs Removes migrated MockProver checks.
in_circuit/mod.rs Updates test organization documentation.
in_circuit/accumulator.rs Checks the complete accumulator signature.
golden/positive.rs Uses explicit genesis fixtures.
encoding/negative.rs Adds exact preimage failure signatures.
common/public_input_layout.rs Defines named public-input rows.
common/mod.rs Exposes new test helpers.
common/helpers.rs Adds asset-backed step fixtures.
common/generators/mod.rs Removes unused generator exports.
common/failure_signature.rs Adds exact MockProver failure classification.
Suppressed comments (1)

mithril-stm/src/circuits/halo2_ivc/tests/common/public_input_layout.rs:58

  • These crate-visible enum variants are missing doc comments. Document each variant so the public row-layout API remains self-describing.
pub(crate) enum StateField {

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +17 to +23
pub(crate) enum GlobalField {
GenesisMessage,
GenesisVerificationKeyX,
GenesisVerificationKeyY,
CertificateCircuitVerificationKeyRepresentation,
IvcCircuitVerificationKeyRepresentation,
}
Comment on lines +122 to +130
use super::*;
use crate::circuits::halo2_ivc::{
NativeField,
state::State,
tests::common::asset_readers::load_embedded_verification_context_asset,
types::{
EpochNumber, MerkleTreeCommitment, MessageHash, ProtocolParametersHash, StepCounter,
},
};
Comment on lines +146 to +150
for (offset, field) in GlobalField::ALL.iter().enumerate() {
assert_eq!(
field.row(),
offset,
"{} is not at global row {offset}",
Comment on lines +73 to +75
let unexpected_classes: Vec<String> = failures
.iter()
.filter(|failure| !matches!(failure, VerifyFailure::Permutation { .. }))

@damrobi damrobi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍
Just one small nitpick and the Copilot comments that seem relevant

}

#[test]
#[should_panic(expected = "public-input failure signature mismatch")]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick but can we try to avoid those should_panic?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-slow-tests Technical label to run slow tests tiers in the CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consolidate the recursive circuit MockProver tests

3 participants