Skip to content

Consolidate the halo2_snark slow proof tests around shared and golden proofs #3463

Closed

Description

@jpraynaud

Why

Each of the 16 halo2_snark::proof::slow tests generates its own full proof (100s to 620s each, 3458s aggregated) even when the assertion only needs proof bytes to tamper with.

What

Prove once per configuration and run each negative verify assertion as its own unit test against a committed golden proof or a cached proof, keeping 4 or 5 genuine proving tests.

How

All tests live in mithril-stm/src/proof_system/halo2_snark/proof.rs.

  • Route the verify-only tests to the committed golden proof (GOLDEN_PROOF_JSON and golden_proof(), parameters m=200, k=3, phi_f=0.8, depth 4):
    • valid_proof_verifies, then merge it into golden_conversion if routing makes them identical
    • verify_fails_with_random_bytes_or_wrong_number_bytes
    • verify_fails_with_wrong_message
    • verify_fails_with_wrong_circuit_verification_key
    • valid_proof_prepares_and_checks
    • prepare_and_check_fails_with_wrong_message
    • prepare_and_check_fails_with_random_bytes
    • snark_proof_to_from_bytes
  • Prove once into the content-keyed cache directory for different_parameters_prove_and_verify_fails, which needs two parameter sets the single golden proof cannot serve (a proof is a few KB; fingerprint by parameters, depth, message, and prover seed)
  • Keep as genuine proving tests:
    • produces_valid_snark_proof
    • valid_snark_proof_with_different_path_length
    • non_deterministic_proofs_verify
  • Leave unchanged, they fail during aggregation before any proving and their setup cost is absorbed by the cache of Reuse the cached unsafe SRS in the SNARK test setups #3433:
    • fails_with_empty_signatures
    • fails_with_insufficient_signatures
  • Leave unchanged, they already run against the golden proof:
    • golden_conversion
    • golden_aggregate_signature_verifies_with_ancillary
  • Assess the gain (expected: about 35 minutes aggregated) and report it in the issue

Depends on #3433.

Activity

  1. self-assigned this
    on Aug 17, 2026
  2. hjeljeli32 commented on Aug 18, 2026

    @hjeljeli32
    Collaborator

    Dear @jpraynaud @damrobi

    The cached proof for different_parameters_prove_and_verify_fails does not pay

    Measured locally, ci-tests-snark, --test-threads 1:

    that test tier
    Before 4.624 s 15.310 s
    Cached, cold 5.273 s (+0.65) 16.085 s
    Cached, warm 4.150 s (−0.47) 14.962 s

    Proving is only ~0.74 s of that test. The other ~3.6 s is the two build_for_test calls, which the cache cannot avoid: the verifying keys still have to be derived from the current circuit to check the cached proof against. So it removes the cheapest part of the test and adds the derivations to the rest.

    On CI the cache directory is empty on every run, so this is a pure +0.65 s regression until the test caches are persisted.

    I left the test unchanged and the item unticked; the patch is ready if you disagree. Are you fine with this conclusion?

  3. hjeljeli32 commented on Aug 19, 2026

    @hjeljeli32
    Collaborator

    Dear @jpraynaud and @damrobi, here is the gain

    Change Scope Before After Gain
    Verify negatives routed to the golden proof 4 tests, 1 deleted as a duplicate 9.8 s 0.2 s -9.7 s (-98 %)
    Prepare-and-check and codec tests routed 4 tests 9.1 s 0.2 s -9.0 s (-98 %)
    Wrong key read from the embedded production key instead of a second prover 1 test 3.5 s 0.05 s included above
    Fresh-proof prepare_and_check coverage added back 1 test 2.82 s 2.84 s +0.03 s
    Forged proof read from the content-keyed cache 1 test 4.6 s 5.3 s not shipped, regression
    Suite Before After Gain
    halo2_snark::proof slow, local warm 33.9 s 15.3 s -18.5 s (-55 %)
    halo2_snark::proof slow, local cold 65.8 s 47.1 s -18.7 s (-28 %)
    halo2_snark::proof slow, CI 1358 s 1140 s -218 s (-16 %)

    Local figures are serial (--test-threads 1); the CI row compares PR #3483 against the nightly on 58b575afb, the branch's base commit.

    Remarks

    • The CI baseline for these 16 tests is 1358 s, not the 3458 s in the issue: that figure predates Reuse the cached unsafe SRS in the SNARK test setups #3433's key cache. The tier was already about 2.5x cheaper than the estimate assumed, so the saving is proportionally smaller than the ~35 minutes stated.
    • On CI the change removed 324 s outright: the seven routed tests fall from 302.7 s to 4.3 s, and the deleted one was 25.8 s. The aggregate improves by 218 s rather than 324 s because the eight untouched tests billed +106 s more than in the nightly. They are byte-identical to main, the differences are spread across them and one is negative, so this is CI wall-clock variance rather than added work.
    • The cold floor does not move: 31.8 s before and after, locally. It is the five distinct parameter sets, each paying one unsafe SRS generation plus keygen on first touch, and all five are still required by tests this ticket keeps. We removed proving, not keygen. Retiring parameter sets rather than proofs is where the remaining time sits, and that would change what the surviving proving tests prove.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions