Repository navigation
feat: activate snark by default - #3650
Conversation
9922568 to
69e851a
Compare
Test Results 5 files ± 0 211 suites - 25 2h 10m 16s ⏱️ + 1h 11m 6s Results for commit 311b2d5. ± Comparison against base commit 09a9e8b. This pull request removes 5 and adds 74 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
5ae648c to
4c65935
Compare
4c65935 to
573b7a5
Compare
d943f15 to
4a97e3b
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Four unresolved findings remain, the most significant being that the mithril-stm opt-out feature build (--no-default-features --features num-integer-backend) is no longer compiled or tested in CI, alongside missing crate version bumps and SNARK being enabled by default for the WASM client.
4 open issues
4 files not reviewed
examples/client-wasm-nodejs/package-lock.json: Generated fileexamples/client-wasm-web/package-lock.json: Generated filemithril-client-wasm/ci-test/package-lock.json: Generated filemithril-explorer/package-lock.json: Generated file
What changed in this PR
This PR turns on the snark feature by default across the Mithril crates, and cleans up mithril-stm so the SNARK code no longer carries stale allow(dead_code) attributes, repeated feature gates, or unused proof fields. The feature stays opt-out. It fits the work tracked in issue #3573, which asks for snark to be enabled by default while keeping backward compatibility for existing networks.
Changes:
mithril-stm0.14.0 drops the parameters and Merkle depth fromSnarkProof, stops serializing theIvcProofhash marker, and always computes the lottery target with num-integer arithmetic. Golden values are updated.snarkis a default feature inmithril-stm,mithril-common,mithril-client, the CLI and WASM clients, the aggregator, signer, relay, key registry, end-to-end runner and protocol demo. Crate versions are bumped to match.- CI runs
mithril-stmin its own job, skips slow tests on ARM and macOS, and no longer passes--features snark. Docs, examples and runbooks drop that flag too.
| File | Description |
|---|---|
| mithril-test-lab/mithril-end-to-end/Cargo.toml | Enables snark by default and bumps the crate version. |
| mithril-stm/src/signature_scheme/schnorr_signature/jubjub/field_elements.rs | Replaces feature gates with cfg(test) for test-only helpers. |
| mithril-stm/src/signature_scheme/schnorr_signature/error.rs | Removes redundant snark gates from the Schnorr error module. |
| mithril-stm/src/protocol/participant/initializer.rs | Updates an expect message that no longer mentions the old feature name. |
| mithril-stm/src/protocol/key_registration/register.rs | Limits number_of_leaves to test builds with snark. |
| mithril-stm/src/protocol/key_registration/closed_registration_entry.rs | Simplifies the SNARK field check in serialization. |
| mithril-stm/src/protocol/aggregate_signature/signature.rs | Updates tests for the new SnarkProof constructor and the new golden CBOR bytes. |
| mithril-stm/src/protocol/aggregate_signature/clerk.rs | Updates test helpers for the new SnarkProof constructor. |
| mithril-stm/src/proof_system/halo2_snark/signer.rs | Removes a cfg attribute from a test registration call. |
| mithril-stm/src/proof_system/halo2_snark/prover_input.rs | Removes stale allow(dead_code) attributes. |
| mithril-stm/src/proof_system/halo2_snark/proof.rs | Drops params and merkle_tree_depth from SnarkProof and updates the golden JSON. |
| mithril-stm/src/proof_system/halo2_snark/mod.rs | Removes a cfg attribute from a test registration call. |
| mithril-stm/src/proof_system/halo2_snark/eligibility.rs | Removes the cfg_num_integer! macro so the lottery target always uses num-integer arithmetic. |
| mithril-stm/src/proof_system/halo2_snark/clerk.rs | Removes a cfg attribute from a test registration call. |
| mithril-stm/src/proof_system/halo2_snark/aggregate_key.rs | Removes a cfg attribute from a test registration call. |
| mithril-stm/src/proof_system/halo2_ivc_snark/verifier_setup.rs | Narrows IVC setup helpers to test or benchmark builds. |
| mithril-stm/src/proof_system/halo2_ivc_snark/prover_input.rs | Updates test fixtures for the new SnarkProof constructor. |
| mithril-stm/src/proof_system/halo2_ivc_snark/proof.rs | Skips the hash marker in IvcProof serialization and updates test fixtures. |
| mithril-stm/src/proof_system/halo2_ivc_snark/mod.rs | Switches a test-only re-export to a plain cfg(test) gate. |
| mithril-stm/src/membership_commitment/merkle_tree/tree.rs | Removes repeated snark gates from tests. |
| mithril-stm/src/membership_commitment/merkle_tree/path.rs | Removes the allow(dead_code) markers and gates legacy serialization to tests. |
| mithril-stm/src/membership_commitment/merkle_tree/leaf.rs | Removes the allow(dead_code) markers on SNARK leaf types. |
| mithril-stm/src/membership_commitment/merkle_tree/error.rs | Limits the invalid-path error variant to SNARK test builds. |
| mithril-stm/src/membership_commitment/merkle_tree/commitment.rs | Gates test-only commitment helpers and removes stale attributes. |
| mithril-stm/src/lib.rs | Simplifies the Poseidon digest import and re-export gating. |
| mithril-stm/src/circuits/halo2/witness.rs | Gates the verification key accessor to tests. |
| mithril-stm/src/circuits/halo2/mod.rs | Removes module-level allow(dead_code) attributes. |
| mithril-stm/src/circuits/halo2/keys.rs | Gates the verifying key constructor to tests and benchmarks. |
| mithril-stm/src/circuits/halo2_ivc/tests/assets/README.md | Drops --features snark from the asset regeneration commands. |
| mithril-stm/src/circuits/halo2_ivc/state.rs | Removes stale allow(dead_code) attributes. |
| mithril-stm/src/circuits/halo2_ivc/mod.rs | Removes a stale allow(dead_code) attribute. |
| mithril-stm/src/circuits/halo2_ivc/keys.rs | Gates key constructors and accessors to tests or benchmarks. |
| mithril-stm/src/circuits/halo2_ivc/certificate_proof.rs | Removes a stale allow(dead_code) attribute. |
| mithril-stm/src/circuits/halo2_ivc/bench/helpers.rs | Updates benchmark setup for the new SnarkProof constructor and the feature command. |
| mithril-stm/SNARK.md | Updates the SNARK book to describe the feature as enabled by default. |
| mithril-stm/README.md | Updates build, example and benchmark commands for the default feature. |
| mithril-stm/examples/recursive_snark_aggregate_signature.rs | Updates the run command in the example header. |
| mithril-stm/examples/non_recursive_snark_aggregate_signature.rs | Updates the run command in the example header. |
| mithril-stm/CHANGELOG.md | Adds the 0.14.0 entry with the breaking changes. |
| mithril-stm/Cargo.toml | Makes snark a default feature, drops rand, and bumps the version to 0.14.0. |
| mithril-stm/benches/size_benches.rs | Reuses the crate's Poseidon digest type in the benchmark. |
| mithril-stm/benches/README.md | Drops --features snark from benchmark commands. |
| mithril-stm/benches/halo2_ivc_snark.rs | Drops --features snark from the run command in the doc header. |
| mithril-signer/Cargo.toml | Enables snark by default and bumps the version. |
| mithril-relay/Cargo.toml | Enables snark by default and bumps the version. |
| mithril-explorer/package-lock.json | Updates the lock entry for the WASM client version. |
| mithril-common/Cargo.toml | Enables snark by default and bumps the version to 0.9.0. |
| mithril-client/Cargo.toml | Enables snark by default and bumps the version to 0.15.0. |
| mithril-client-wasm/package.json | Bumps the package version. |
| mithril-client-wasm/ci-test/package-lock.json | Updates the lock entry for the WASM client version. |
| mithril-client-wasm/Cargo.toml | Enables snark by default and bumps the version. |
| mithril-client-cli/Cargo.toml | Enables snark by default and bumps the version. |
| mithril-aggregator/Cargo.toml | Enables snark by default and bumps the version. |
| internal/mithril-circuit-key-registry/Cargo.toml | Enables snark by default and points to the new mithril-common version. |
| internal/mithril-aggregator-discovery/Cargo.toml | Points the mithril-common dependency to 0.9.0. |
| internal/mithril-aggregator-client/Cargo.toml | Points the mithril-common dependency to 0.9.0. |
| internal/cardano-node/mithril-cardano-node-internal-database/Cargo.toml | Points the mithril-common dependency to 0.9.0. |
| flake.nix | Keeps the circuit .asset and .vkey files in the Nix source filter. |
| examples/client-wasm-web/package-lock.json | Updates the lock entry for the WASM client version. |
| examples/client-wasm-nodejs/package-lock.json | Updates the lock entry for the WASM client version. |
| docs/runbook/update-circuit-keys/README.md | Drops --features snark from key update commands. |
| docs/runbook/circuit-key-registry/README.md | Updates the registry note and the aggregator build command. |
| demo/protocol-demo/Cargo.toml | Enables snark by default and bumps the version. |
| CHANGELOG.md | Adds a changelog entry for the default SNARK feature. |
| Cargo.toml | Updates a comment on the CI test profile. |
| Cargo.lock | Records the new crate versions and dependency links. |
| .github/workflows/test-rust.yml | Runs mithril-stm in its own job and skips slow tests on ARM and macOS. |
| .github/workflows/test-e2e.yml | Removes the --features snark defaults from the end-to-end build inputs. |
| .github/workflows/scripts/clippy-check.sh | Runs clippy for mithril-stm with only benchmark-internals. |
Review effort: Lite
b0ec52a to
cb6e2de
Compare
cb6e2de to
4bdb8b0
Compare
|
Enabling Note All slow tests are currently contained in For example on my computer, on the
Twice as long, and in the CI the results are clear, if we compare the last main merge to the penultimate CI test runs in this branch: Notes:
This is, in my opinion, a deterioration of our working conditions as we are already loosing time by waiting for our CI to complete. So we should explore ways to speedup our tests suites. From what I see the impact is especially strong on the Looking into it I found an optimization which speed them up, here's a patch proposal: Patch
diff --git a/mithril-common/src/protocol/signer_builder.rs b/mithril-common/src/protocol/signer_builder.rs
index 6b2acfe7e..10c0e85b0 100644
--- a/mithril-common/src/protocol/signer_builder.rs
+++ b/mithril-common/src/protocol/signer_builder.rs
@@ -77,12 +77,30 @@ impl SignerBuilder {
let closed_registration = key_registration.close(&protocol_parameters.clone().into())?;
- Ok(Self {
+ Ok(Self::from_registration(
+ closed_registration,
+ protocol_parameters,
+ epoch,
+ ))
+ }
+
+ /// [SignerBuilder] constructor from an already closed key registration.
+ ///
+ /// Unlike [SignerBuilder::new], the signers registrations are not verified again, the given
+ /// closed key registration must have been made with the given protocol parameters and epoch.
+ pub(crate) fn from_registration(
+ closed_key_registration: ProtocolClosedKeyRegistration,
+ protocol_parameters: &ProtocolParameters,
+ epoch: Epoch,
+ ) -> Self {
+ #[cfg(not(feature = "snark"))]
+ let _epoch = epoch;
+ Self {
protocol_parameters: protocol_parameters.clone(),
- closed_key_registration: closed_registration,
+ closed_key_registration,
#[cfg(feature = "snark")]
epoch,
- })
+ }
}
/// Build a [MultiSigner] based on the registered parties
@@ -269,6 +287,28 @@ mod test {
.expect("We should be able to construct a signer builder with valid signers");
}
+ #[test]
+ fn signer_builder_from_registration_computes_same_avk_as_signer_builder_from_signers() {
+ let fixture = MithrilFixtureBuilder::default().with_signers(3).build();
+ let signer_builder = SignerBuilder::new(
+ &fixture.signers_with_stake(),
+ &fixture.protocol_parameters(),
+ Epoch::default(),
+ )
+ .unwrap();
+
+ let signer_builder_from_registration = SignerBuilder::from_registration(
+ fixture.signers_fixture()[0].protocol_closed_key_registration.clone(),
+ &fixture.protocol_parameters(),
+ Epoch::default(),
+ );
+
+ assert_eq!(
+ signer_builder.compute_aggregate_verification_key(),
+ signer_builder_from_registration.compute_aggregate_verification_key()
+ );
+ }
+
#[test]
fn cant_build_single_signer_for_unregistered_party() {
let fixture = MithrilFixtureBuilder::default().with_signers(3).build();
diff --git a/mithril-common/src/test/builder/mithril_fixture.rs b/mithril-common/src/test/builder/mithril_fixture.rs
index d8bb8c8a9..06b4cb195 100644
--- a/mithril-common/src/test/builder/mithril_fixture.rs
+++ b/mithril-common/src/test/builder/mithril_fixture.rs
@@ -228,13 +228,22 @@ impl MithrilFixture {
}
/// Compute the Aggregate Verification Key for this fixture.
+ ///
+ /// Reuses the closed key registration shared by the fixture signers instead of re-running
+ /// a full key registration, which is costly (especially with the `snark` feature).
pub fn compute_aggregate_verification_key(&self) -> ProtocolAggregateVerificationKey {
- SignerBuilder::new(
- &self.signers_with_stake(),
+ let closed_key_registration = self
+ .signers
+ .first()
+ .expect("a fixture must have at least one signer to compute its AVK")
+ .protocol_closed_key_registration
+ .clone();
+
+ SignerBuilder::from_registration(
+ closed_key_registration,
&self.protocol_parameters,
self.epoch,
)
- .unwrap()
.compute_aggregate_verification_key()
}
Taking up my
It's significantly better with Another optimization would be looking up for tests that doesn't need "true" certificates and use baked one instead , this would remove the |
1f889b2 to
d18f5b9
Compare
|
LGTM 👍 (and agree with Alenar & Jpraynaud comments) |
087df65 to
8ab62a8
Compare
…est for the IvcProof encoding `SnarkProof` no longer holds the parameters and the Merkle tree depth, which were written but never read, so `SnarkProof::new` only takes the circuit proof bytes. The golden values are updated accordingly. A golden test pins the CBOR encoding of `IvcProof` with a round trip on stored bytes, built from the next-epoch step output asset.
…gates Items that are used no longer carry `#[allow(dead_code)]`, and the ones only used by tests are gated with `cfg(test)` instead. Gates repeating the `snark` feature inside modules that already require it are removed. The Merkle batch commitment tests do not depend on SNARK code, so they now also run without the `snark` feature. An expect message still referring to the former `future_snark` feature name is fixed.
…metic backend The SNARK lottery target computation was only compiled with the num-integer backend, so a `rug-backend` + `snark` build failed on Unix. It now always uses num-integer arithmetic, which keeps the target value identical for every signer and aggregator whatever backend is selected, and the `snark` feature enables `num-integer` and `num-rational`. The `snark` feature no longer enables `rand` and `rand_chacha`. `rand` was only used by tests, which already get it as a dev-dependency. `rand_chacha` is only needed outside tests by the benchmark helpers, so it is now enabled by `benchmark-internals`.
The `snark` feature is enabled by default in mithril-stm, mithril-common, mithril-client, mithril-client-cli, mithril-client-wasm, the nodes, the circuit key registry, the end-to-end runner and the protocol demo. The CI follows: - the workspace test job now covers the SNARK code of every crate except mithril-stm, which runs in its own job - the slow tests are excluded on the ARM and macOS platforms - clippy and the end-to-end workflow no longer pass `--features snark` - the Hydra CI includes the circuit test assets and verification keys
The SNARK book, the mithril-stm READMEs, examples and benches, the circuit key runbooks and the IVC test assets README no longer ask for `--features snark` and describe the feature as enabled by default.
…on and aggregator
8ab62a8 to
311b2d5
Compare


Content
Warning
We want to clear the CI cache before merging this PR
This PR enables the
snarkfeature by default in all crates and cleans up some ofmithril-stmoutdated code.The feature stays an opt-out.
Changed
Cleanup of
mithril-stm:SnarkProofno longer holds the parameters and the Merkle tree depth andIvcProofgets a golden serialization test. The golden values are updated.#[allow(dead_code)]attributes andsnarkgates repeated inside modules that already require the feature are removed. Items only used by tests are gated withcfg(test).rug-backend+snarkbuild. Thesnarkfeature no longer enablesrandandrand_chacha.Switch to default:
snarkis a default feature ofmithril-stm,mithril-common,mithril-client,mithril-client-cli,mithril-client-wasm, the aggregator, the signer, the relay, the circuit key registry, the end-to-end runner and the protocol demo.mithril-stm, which runs in its own job in place of the formersnarkjob--features snarkmithril-stmREADMEs, examples and benches, and the circuit key runbooks no longer ask for--features snark.The breaking changes are in
mithril-stm 0.14.0andmithril-common 0.9.0. All the modified crates get a minor bump, exceptmithril-client, which goes to 0.15.1.Added
Test fixtures, to limit the slowdown of the tests with
snark:MithrilFixturecomputes its aggregate verification key once, from the closed key registration shared by its signers, instead of registering all the signers again.mithril-commonandmithril-aggregatorcreate fewer certificates.MithrilFixtureBuilderwithout creating the signers' keys.Pre-submit checklist
Comments
Issue(s)
Relates to #3573