Skip to content

Activate snark feature by default #3573

Closed

Description

@jpraynaud

Why

Once the pre-aggregation SNARK primitives are implemented (see #2792), we can activate the snark feature by default. The impact should only exist in the signer and aggregator which will start creating/registering "extended" key registration including Schnorr verification key. We want to be sure that the activation of the feature has no other impact on the Mithril network and that backward compatibility is fully maintained.

What

Activate the snark feature by default and provide full backward compatibility for Mithril networks.

How

  • Remove unnecessary/unused code before activation. Example:
    • params and merkle_tree_depth in SnarkProof
    • Some allow(dead_code)
    • Unnecessary feature flags
    • Update golden values
    • Removing the cfg_num_integer! macro from the SNARK lottery computation
    • Removing some dependencies from the snark feature (rand, rand-chacha)
  • Activate the snark feature by default in the STM library
  • Update the CI:
    • Do not run tests twice with snark
    • Include the .asset and .vkey files in the Hydra CI (flake.nix)
  • Run a green minimal e2e test with IVC Prover locallly
  • Run backward compatibility tests for concatenation locally:
    • Stable signer with new aggregator
    • Stable aggregator with new signer
    • Mix stable/new signer/aggregator
  • Bump the versions of the modified crates to the next minor/major
  • Re-deploy IVC SNARK test network (@jpraynaud)

Activity

  1. self-assigned this
    on Oct 22, 2026
  2. damrobi commented on Oct 30, 2026

    @damrobi
    Collaborator

    Backward compatibility checks

    I ran the end-to-end tests with the nodes of the branch (4a97e3b22f1, built with the default features) and swapped some nodes for a released distribution built without the snark feature:

    • 2642.0: aggregator 0.10.21, signer 1.2.5, client 0.13.29
    • 2630.1-hotfix: aggregator 0.9.22, signer 1.1.9, client 0.13.20

    Concatenation runs use --cardano-node-version 11.1.3 --cardano-slot-length 0.25 --cardano-epoch-length 45.0 full --signed-entity-types CardanoTransactions,CardanoStakeDistribution,CardanoDatabase.
    The SNARK run uses the settings of the nightly minimal-snark job.
    To mix signer versions in one run, the mithril-signer binary was a wrapper script picking the release or the branch binary from the DB_DIRECTORY of each pool.

    Test number Era Aggregator version Signer version Client version Aggregate signature Outcome Expected result
    1 Pythagoras 2642.0 unstable unstable Concatenation ✅ Success
    2 Pythagoras unstable 2642.0 unstable Concatenation ✅ Success
    3 Pythagoras unstable unstable 2642.0 Concatenation ✅ Success
    4 Pythagoras 2630.1-hotfix unstable unstable Concatenation ✅ Success
    5 Pythagoras unstable 2630.1-hotfix unstable Concatenation ✅ Success
    6 Pythagoras unstable unstable 2630.1-hotfix Concatenation ✅ Success
    7 Pythagoras → Lagrange unstable all signers 2642.0 unstable Concatenation ❌ Failure: No certificate after the switch: "Lagrange era requires a SNARK aggregate verification key"
    8 Pythagoras → Lagrange unstable all signers 2642.0, with re-genesis unstable Concatenation ❌ Failure: The re-genesis fails: "Rigid next_aggregate_verification_key_snark value is required"
    9 Pythagoras → Lagrange unstable all signers 2630.1-hotfix unstable Concatenation ❌ Failure: Same as 2642.0, with and without re-genesis
    10 Pythagoras → Lagrange unstable 1 signer 2642.0 out of 2 unstable Concatenation ❌ Failure: Quorum not reached after the switch: 226 lotteries out of 283, the old signer's signatures are dropped
    11 Pythagoras → Lagrange unstable 1 signer 2642.0 out of 5 unstable Concatenation ✅ Certificates signed by the 4 upgraded signers Success
    12 Lagrange unstable 1 signer 2642.0 out of 2 unstable Snark ✅ SNARK certificates signed by the upgraded signer Success
    13 Lagrange unstable unstable client 2642.0 Concatenation ❌ Failure: The client cannot decode the dual genesis verification key
    14 Lagrange aggregator 2642.0 unstable unstable Concatenation ❌ Failure: The aggregator does not start, it cannot decode the dual genesis verification key
    15 Lagrange unstable unstable unstable Concatenation ✅ Success

    The runner checks that every signer signs each certificate, so it reports the two ✅ mixed signer runs as failures.
    The certificates were checked in the aggregator database.

  3. added
    do-not-merge 🔒
    and removed
    do-not-merge 🔒
    on Nov 2, 2026
  4. jpraynaud commented on Nov 3, 2026

    @jpraynaud
    MemberAuthor

    Test-rust CI timings with SNARK activated by default

    Measured on the 2 linux amd64 test-rust jobs, main vs damrobi/msnark/3573-activate-snark-by-default, each job run alone from a clean build on 4 CPUs (2 physical cores, like a GitHub runner).

    TLDR

    • Activating SNARK by default does not make the CI pipeline slower: the pipeline time (the slower of the 2 jobs) is lower than on main, with and without slow tests.
    • The workspace job becomes the bottleneck without slow tests: it is about 2x slower than on main, because the certificate chain fixtures rebuild the aggregate verification key (AVK), which costs more with SNARK registrations at opt-level 0.
    • Caching the AVK in MithrilFixture can remove about 15% of the workspace job time.
    Pipeline time main SNARK branch with fixture cache Reduction
    Without slow tests 921 s 700 s 24%
    With slow tests 3540 s 2920 s 18%

    Without slow tests

    Filter not test(#*slow::*), cargo profile ci-tests.

    Version Job Build Tests Total
    main Workspace 357 s 205 s 562 s
    main SNARK (7 crates) 330 s 591 s 921 s
    SNARK branch Workspace (--exclude mithril-stm) 377 s 448 s 825 s
    SNARK branch mithril-stm 69 s 223 s 292 s
    SNARK branch with fixture cache Workspace (--exclude mithril-stm) 359 s 341 s 700 s

    With slow tests

    Filter all(), cargo profile ci-tests-snark for the job with SNARK slow tests, ci-tests for the workspace job.

    Version Job Cargo profile Build Tests Total
    main Workspace ci-tests 326 s 203 s 529 s
    main SNARK (7 crates) ci-tests-snark 959 s 2581 s 3540 s
    SNARK branch with fixture cache Workspace (--exclude mithril-stm) ci-tests 370 s 373 s 743 s
    SNARK branch with fixture cache mithril-stm ci-tests-snark 389 s 2531 s 2920 s

    The job with SNARK slow tests stays the bottleneck on both branches, and it is faster on the SNARK branch because it builds and tests only mithril-stm instead of 7 crates.

    Workspace job bottleneck

    Profile of verify_certificate_chain_verifies_all_chained_certificates with ci-tests:

    Measure main SNARK branch
    Test time 6.2 s 19.8 s
    Share in build_base_certificate 34% 52%
    KES verification 3.7 s 8.9 s
    SNARK lottery target computation 5.1 s

    Each registration runs 2 KES verifications (concatenation and SNARK) and computes the SNARK lottery target, and the fixtures did it again for every certificate of a chain.

    ci-tests-snark for the workspace job

    Cargo profile Build Tests Total
    ci-tests 359 s 341 s 700 s
    ci-tests-snark 762 s 86 s 848 s

    From a clean build it is slower, but the Rust cache on CI should keep the optimized dependencies, so it is worth a CI run before deciding.

    Next steps

    • Cache the AVK in MithrilFixture to remove about 15% of the workspace job time, and confirm the gain on CI.
    • Reduce the number of certificates of the slowest certificate chain tests to the minimum they need (about 6% of the workspace job time).
    • Build the era transition chain fixture once and share it between its tests (about 2% of the workspace job time).
    • Try ci-tests-snark for the workspace job (--exclude mithril-stm) in a CI run and keep it if the job is faster with the Rust cache.
  5. jpraynaud commented on Nov 3, 2026

    @jpraynaud
    MemberAuthor

    Proposed certificate chain reductions

    Chain size is (total certificates, certificates per epoch), the genesis certificate is alone in epoch 1 and [0] is the latest certificate.

    Test Crate Current chain Current time What the test needs Proposed chain Estimated time Saved Reduction
    test_convert_certificates aggregator (20, 3) 25.6 s Genesis and standard certificates for the round trip (3, 1) 5.0 s 20.6 s 80%
    test_get_certificate_records_by_epoch aggregator (20, 7) 22.4 s Epochs 1 and 3 with certificates, epoch 5 empty (5, 2) 7.0 s 15.4 s 69%
    verify_certificate_chain_verifies_all_chained_certificates common (10, 1) 17.0 s A chain over several epochs (5, 1) 8.4 s 8.6 s 51%
    24 verify_genesis_certificate_*, verify_standard_certificate_*, verify_certificate_integrity_*, verify_certificate_success_* tests common (5, 1) 24 × 8.4 s [0], [1] in different epochs, and the genesis (3, 1) 24 × 5.0 s 81.6 s 40%
    6 snark_avk_chaining_* and avk_chaining_dispatches_* tests with different epochs common (5, 1) 6 × 8.4 s Same as above, [3] becomes [1] in ..._when_previous_is_genesis_certificate (3, 1) 6 × 5.0 s 20.4 s 40%
    5 same-epoch tests (verify_standard_certificate_success_with_same_epoch_as_previous, 4 snark_avk_chaining_*_same_epoch_*) common (5, 2) 5 × 6.8 s [0], [1] in the same epoch, [1] not genesis (3, 2) 5 × 4.5 s 11.5 s 34%
    verify_certificate_chain_success_when_chain_is_valid, ..._fails_when_chain_is_tampered common (7, 2) 2 × 9.5 s A chain with sibling certificates (5, 2) 2 × 7.0 s 5.0 s 26%
    store_partial aggregator (8, 1) 13.9 s Stored certificates then newer ones to sync, [5] becomes [2] (4, 1) 6.7 s 7.2 s 52%
    store_all, check_and_raise_epoch_gap_error aggregator (8, 3) 2 × 10.7 s A chain with sibling certificates (5, 2) 2 × 7.0 s 7.4 s 35%
    succeed_with_a_valid_certificate_chain_and_only_get_first_certificate_of_each_epoch_plus_genesis aggregator (9, 2) 12.4 s Odd total, last epoch with 2 certificates (5, 2) 7.0 s 5.4 s 44%
    Total about 418 s about 243 s about 175 s 42%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

cryptography 🔐

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions