Skip to content

Extend the on-disk test cache to the recursive circuit test fixtures #3462

Description

@jpraynaud

Why

The circuits/halo2_ivc test tree has no caching: every slow file rebuilds the 3000-signer fixture, and the two full-prover tests each regenerate the k=19 SRS and a real certificate proof independently.

What

Extend the content-keyed FileMutex cache to the circuit test fixtures so the SRS, the recursive context, and the heavy signer fixture are computed once and shared across tests and runs.

How

Paths are relative to mithril-stm/src/.

  • Replace the build_deterministic_params call inside build_shared_recursive_context (circuits/halo2_ivc/tests/common/generators/setup.rs) with the SRS persisted under the shared content-keyed cache (FileMutex::for_shared_cache, circuits/test_utils/file_mutex.rs), reusing the file Reuse the cached unsafe SRS in the SNARK test setups #3433 writes
  • Serialize the derived SharedRecursiveContext (certificate and recursive verifying keys, commitment parameters) into the same cache directory, fingerprinted like IvcSnarkProverSetup::build_for_test (production VK bytes, parameters, depth, degree, seed), so recursive keygen is paid once per fingerprint
  • Make the full-prover slow tests load through that one fingerprint:
    • golden/positive.rs: genesis_base_case_circuit_is_accepted
    • golden/positive.rs: replay_integrity_matches_stored_next_step_output
    • in_circuit/accumulator.rs: circuit_rejects_with_wrong_next_accumulator_in_same_epoch_step
  • Cache the 3000-signer fixture built by build_asset_generation_setup (generators/setup.rs, SIGNER_COUNT = 3000): serialize the signing keys and Merkle tree into the cache directory, or consolidate its consumers if serialization does not pay
  • Remove the STM_CIRCUIT_KEYS_CACHE LazyLock inside get_or_build_circuit_keys (circuits/halo2/tests/golden/helpers.rs), inert under the nextest process-per-test model, and route its consumers through the on-disk KeyProvider cache (circuits/key_provider.rs)
  • Assess the gain (expected: minutes off every slow circuit file) and report it in the issue

Depends on #3433.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions