Skip to content

feat: make script for compilation to take --all flag [skip-line-limit]#1578

Merged
0xjei merged 17 commits into
mainfrom
compile/all
Jun 5, 2026
Merged

feat: make script for compilation to take --all flag [skip-line-limit]#1578
0xjei merged 17 commits into
mainfrom
compile/all

Conversation

@0xjei

@0xjei 0xjei commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features

    • CLI/build tooling accepts "large" and an "all" committee option; multi-committee circuit builds supported.
  • Improvements

    • Circuit artifacts, build stamps, caches and verification are organized per-committee.
    • Many components now include committee-size metadata and resolve committee-scoped artifact directories.
    • CI and dev templates/scripts prepare and sync committee-scoped circuit artifacts.
  • Tests

    • Test helpers, fixtures and integration tests updated for committee-scoped artifacts.
  • Bug Fixes

    • Preflight artifact checks and extraction scripts now honor the selected committee option.

@0xjei 0xjei self-assigned this Jun 4, 2026
@vercel

vercel Bot commented Jun 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
crisp Ready Ready Preview, Comment Jun 5, 2026 9:21am
enclave-docs Ready Ready Preview, Comment Jun 5, 2026 9:21am
enclave-enclave-dashboard Ready Ready Preview, Comment Jun 5, 2026 9:21am

Request Review

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • ✅ Review completed - (🔄 Check again to review again)
📝 Walkthrough

Walkthrough

Threads committee size from threshold parameters through aggregators, ZK request structs, proof builders, multithread handlers, and test/build artifact paths; adds per-committee artifact directories and extends the Noir build script and benchmark CLI for committee variants.

Changes

Committee-size threading through aggregation and proof generation

Layer / File(s) Summary
Committee size derivation and artifact path utilities
crates/zk-helpers/src/ciphernodes_committee.rs, crates/fhe-params/src/presets.rs
CiphernodesCommitteeSize::from_n_h maps (n,h) to committee variants; BfvPreset::artifacts_dir_for_committee builds per-committee artifact paths.
ZK request and metadata contracts
crates/events/src/enclave_event/compute_request/zk.rs
Adds committee_size: CiphernodesCommitteeSize to multiple public ZK request structs and updates PkBfvProofRequest::new to accept committee size.
PublicKeyAggregator committee threading
crates/aggregator/src/actors/publickey_aggregator.rs
PublicKeyAggregatorParams and PublicKeyAggregator store committee_size and forward it in ShareVerificationDispatched and DkgAggregationRequest; tests updated.
ThresholdPlaintextAggregator committee threading
crates/aggregator/src/actors/threshold_plaintext_aggregator.rs
ThresholdPlaintextAggregatorParams and ThresholdPlaintextAggregator store committee_size and include it in ShareVerificationDispatched, DecryptedSharesAggregationProofRequest, and DecryptionAggregationRequest; tests updated.
Aggregator extension wiring
crates/aggregator/src/ext.rs
Derive committee_size from (threshold_m, threshold_n) and inject it into aggregator params in startup and hydrate flows.
ZK prover domain and metadata
crates/zk-prover/src/domain/node_dkg_fold.rs, crates/zk-prover/src/actors/node_proof_aggregator.rs
NodeDkgFoldMeta gains committee_size and it is populated from incoming proof requests; fold requests include committee size; tests adjusted.
Proof verification actor committee tracking
crates/zk-prover/src/actors/proof_verification.rs
Store (BfvPreset, CiphernodesCommitteeSize) per e3_id; compute committee from thresholds and use artifacts_dir_for_committee for artifact loading.
Proof builder function signatures
crates/zk-prover/src/circuits/aggregation/node_dkg_fold.rs
prove_dkg_aggregation and prove_decryption_aggregation_jobs accept committee: CiphernodesCommitteeSize and use committee-specific artifact dirs.
Multithread job handlers with committee-specific routing
crates/multithread/src/multithread.rs
Handlers use artifacts_dir_for_committee(committee) and pass committee_size into proof builders.
Test circuit fixture helpers
crates/zk-prover/tests/common/helpers.rs
Add setup_compiled_circuit_for_committee and stage fixtures under insecure-512/{committee}/.
Integration test fixture discovery
crates/tests/tests/integration.rs
Resolve and stage dist/local artifacts using dist/circuits/<preset>/<committee>/... and circuits/bin/.../<preset>/<committee> layouts.
Noir circuit build system
scripts/build-circuits.ts
BuildOptions.committee accepts 'all'; builds iterate presets×committees; dist/stamp/hydration paths and cache checks scoped to dist/circuits/<preset>/<committee>/; CLI/help updated.
Local E2E tests updates
crates/zk-prover/tests/local_e2e_tests.rs
Switch E2E/local tests to use artifacts_dir_for_committee(...Micro...) for proof generation paths.
Benchmark CLI & helper scripts
circuits/benchmarks/scripts/run_benchmarks.sh, circuits/benchmarks/scripts/check_circuit_preset_artifacts.sh, circuits/benchmarks/scripts/extract_crisp_verify_gas.sh
--committee CLI validation and Usage updated (allow large/all where appropriate); artifact checks now accept --committee and verify committee-specific dist paths.
Verifier generator & build scripts
scripts/generate-verifiers.ts, scripts/build-circuits.ts
Verifier assertions and build stamps are checked/written per preset/committee; build-circuits supports committee: 'all' and iterates committees.
Slashing / accusation flow
crates/slashing/src/domain/accusation_voting.rs, crates/slashing/Cargo.toml
Derive committee_size for forwarded accusation verification and add e3-zk-helpers dependency.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Possibly related PRs

  • gnosisguild/enclave#1366: Related ZK verification request flow changes that this PR extends with committee_size propagation.
  • gnosisguild/enclave#1513: Overlapping changes to ZK request contracts and artifact preset handling; both touch ShareVerification and compute-request wiring.
  • gnosisguild/enclave#1576: Related additions around supporting a larger committee size in build/bench tooling and committee option handling.

Poem

A rabbit hops through circuits wide,
It threads committee sizes with pride,
Per-committee paths it tends,
Builds and proofs find matching friends,
Happy hops — the artifacts align! 🐰

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title mentions making a script accept an '--all flag', but the actual changes show comprehensive committee-size threading across 30+ files touching aggregators, event types, proof handlers, and test infrastructure—far beyond a simple script flag addition. Update the PR title to accurately reflect the full scope, such as: 'feat: add committee-size parameter throughout aggregation and proof pipelines' or similar.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 98.77% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch compile/all

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (5)
crates/zk-prover/src/actors/proof_verification.rs (1)

107-123: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Insert into pending only after the preset/committee lookup succeeds.

If self.presets misses this e3_id, this branch returns after inserting into self.pending, and that entry is never removed because no ZK request was dispatched. After a restart or missed CiphernodeSelected, each rejected key leaks stale pending state for (e3_id, party_id).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/zk-prover/src/actors/proof_verification.rs` around lines 107 - 123,
Currently the code inserts into self.pending (via self.pending.insert(...)
creating a PendingVerification for (msg.e3_id.clone(), msg.key.party_id)) before
checking self.presets.get(&msg.e3_id), which can cause leaked pending entries
when the preset is missing; move the self.pending.insert call so it occurs only
after the lookup succeeds (after let Some((preset, committee)) =
self.presets.get(&msg.e3_id).copied() else { ... }), remove the pre-check
insertion, and only construct PendingVerification and call
preset.artifacts_dir_for_committee(committee.as_str()) once the preset/committee
is present so rejected keys do not leave stale entries for (msg.e3_id,
msg.key.party_id).
scripts/build-circuits.ts (3)

109-115: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

--preset all / --committee all bypasses the unsupported-pair guard.

The constructor only calls isPresetCommitteeSupported(...) when both options are concrete. In the new nested build loop, unsupported combinations can still slip through, even though this file already documents that such pairs emit stub parity matrices and invalid proofs. Re-check each (preset, committee) inside buildAll() or buildForPreset().

Also applies to: 139-146

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/build-circuits.ts` around lines 109 - 115, The guard for unsupported
(preset, committee) pairs only runs for concrete options at construction, so
when buildAll() or buildForPreset() iterates nested presets/committees it can
still emit invalid combinations; call isPresetCommitteeSupported(preset,
committee) inside the nested loop in buildAll() and/or at the start of
buildForPreset() and skip (or throw) for unsupported pairs instead of proceeding
to build, ensuring you reference the same options.preset/options.committee
values when deciding to continue; update both places mentioned (the new nested
build loop and the buildForPreset() entry) so every generated (preset,
committee) is validated.

122-150: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Checksum manifests no longer identify which committee each artifact belongs to.

buildAll() now merges compiled outputs from multiple committees into one result.compiled, but the checksum manifest still emits paths shaped like <preset>/<variant>/... without the committee segment. Under --committee all, entries for different committees collide in checksums.json / SHA256SUMS, and the recorded paths no longer match the actual files written under <preset>/<committee>/....

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/build-circuits.ts` around lines 122 - 150, The checksum manifest
ignores the committee segment because buildAll merges outputs from multiple
committees into result.compiled; update either buildForPreset to embed the
committee into each compiled artifact's output path or modify
generateChecksumFile to read a committee property from each compiled entry and
include it in the emitted path (so manifest entries become
<preset>/<committee>/<variant>/...). Locate buildForPreset, result.compiled, and
generateChecksumFile in scripts/build-circuits.ts and ensure the produced path
used by generateChecksumFile includes the committee segment (when
this.options.committee === 'all' or committees contains multiple entries) so
checksums reference the actual file locations.

457-539: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

The active-bin stamp can record "all" instead of the concrete committee in circuits/bin/.

writeActiveBinPresetStamp() serializes this.options.committee, so a --committee all run writes { committee: "all" } on every iteration even though circuits/bin only contains the last committee built. That breaks consumers that use .active-preset.json to determine the staged ABI. Pass the current loop's committee into the stamp writer.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/build-circuits.ts` around lines 457 - 539, The active-bin stamp is
being written using this.options.committee causing "--committee all" runs to
record "all" instead of the specific committee just built; update the
writeActiveBinPresetStamp call in buildForPreset (inside the block after
copyArtifacts where currently this.writeActiveBinPresetStamp(preset, sourceHash)
is invoked) to pass the current loop's committee
(this.writeActiveBinPresetStamp(preset, sourceHash, committee)) and update the
writeActiveBinPresetStamp function signature/implementation to accept and
serialize that committee parameter instead of reading this.options.committee.
crates/zk-prover/src/circuits/aggregation/node_dkg_fold.rs (1)

364-372: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Validate the new committee argument against the request payload before selecting artifacts.

These builders now trust committee to choose preset/committee/..., but they never check it against the other committee-shaped inputs they already have. A mismatched caller can therefore load the wrong circuit ABI/VKs and fail later with opaque witness/proof errors. At minimum, reject when the selected committee's registered-party count does not match committee_addresses.len().

Also applies to: 493-503

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/zk-prover/src/circuits/aggregation/node_dkg_fold.rs` around lines 364
- 372, The code currently picks artifacts via
preset.artifacts_dir_for_committee(committee.as_str()) without checking that the
chosen CiphernodesCommitteeSize actually matches the payload; before calling
artifacts_dir_for_committee, fetch the expected registered-party count from the
CiphernodesCommitteeSize value (use its method that returns the registered party
count) and compare it to input.committee_addresses.len(); if they differ, return
an Err(ZkError::InvalidInput/validation error) instead of proceeding. Apply the
same validation in the other identical block mentioned (the second
prove_dkg_aggregation-like usage around the 493-503 region) so both locations
reject mismatched committee sizes before loading presets/VKs.
🧹 Nitpick comments (2)
crates/zk-helpers/src/ciphernodes_committee.rs (1)

55-64: ⚡ Quick win

Add direct regression tests for from_n_h mapping.

This new constructor is part of the committee-size contract surface, but there’s no direct test proving canonical pairs map correctly and unknown pairs error.

✅ Suggested test addition
 #[cfg(test)]
 mod tests {
     use super::*;
@@
+    #[test]
+    fn from_n_h_maps_canonical_rows_and_rejects_unknown() {
+        assert_eq!(CiphernodesCommitteeSize::from_n_h(3, 3).unwrap(), CiphernodesCommitteeSize::Micro);
+        assert_eq!(CiphernodesCommitteeSize::from_n_h(5, 5).unwrap(), CiphernodesCommitteeSize::Small);
+        assert_eq!(CiphernodesCommitteeSize::from_n_h(10, 8).unwrap(), CiphernodesCommitteeSize::Medium);
+        assert_eq!(CiphernodesCommitteeSize::from_n_h(20, 15).unwrap(), CiphernodesCommitteeSize::Large);
+        assert!(CiphernodesCommitteeSize::from_n_h(10, 7).is_err());
+    }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/zk-helpers/src/ciphernodes_committee.rs` around lines 55 - 64, Add
unit tests that cover CommitteeSize::from_n_h: assert that from_n_h(3,3) ->
Ok(CommitteeSize::Micro), (5,5) -> Ok(Small), (10,8) -> Ok(Medium), (20,15) ->
Ok(Large), and that an unknown pair (e.g. from_n_h(4,2)) returns Err. Place
tests in the module tests (or #[cfg(test)] mod tests) alongside
ciphernodes_committee.rs, using the same enum/constructor names (CommitteeSize
and from_n_h) so they fail if mappings change or error handling regresses.
crates/fhe-params/src/presets.rs (1)

396-402: ⚡ Quick win

Add a unit test for committee-scoped artifact path formatting.

artifacts_dir_for_committee is now part of the runtime routing contract but isn’t covered by tests in this file.

✅ Suggested test addition
 #[cfg(test)]
 mod tests {
     use super::*;
@@
+    #[test]
+    fn test_artifacts_dir_for_committee() {
+        assert_eq!(
+            BfvPreset::InsecureThreshold512.artifacts_dir_for_committee("micro"),
+            "insecure-512/micro"
+        );
+        assert_eq!(
+            BfvPreset::SecureThreshold8192.artifacts_dir_for_committee("large"),
+            "secure-8192/large"
+        );
+    }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/fhe-params/src/presets.rs` around lines 396 - 402, Add a unit test in
this module that constructs a Preset instance and asserts
artifacts_dir_for_committee returns the expected string by comparing it to
format!("{}/{}", preset.artifacts_dir(), committee). In the test call
preset.artifacts_dir_for_committee with a couple of representative committee
names (e.g. "medium", "micro") and assert equality to the explicit format; use
the existing Preset constructor present in this file to create the preset and
place the test in the #[cfg(test)] tests module in this file.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/aggregator/src/ext.rs`:
- Around line 87-88: The code currently calls
CiphernodesCommitteeSize::from_threshold(...).unwrap_or(CiphernodesCommitteeSize::Micro),
which silently masks invalid/unknown threshold configs; change these sites to
fail fast instead: replace unwrap_or(Micro) with explicit error handling that
returns a Result or panics with a clear message (e.g., using expect or mapping
the Err into a startup error) so misconfiguration surfaces during
hydrate/startup of both publickey and plaintext aggregator wiring; update the
occurrences where committee_size is assigned (the
CiphernodesCommitteeSize::from_threshold calls) to propagate an error upward or
terminate with a descriptive message rather than defaulting to Micro.

In `@crates/multithread/src/multithread.rs`:
- Around line 699-701: Several earlier ZK handler code paths still call
params_preset.artifacts_dir(), causing them to look in the legacy directory;
update those to use the committee-specific path. Replace uses of
req.params_preset.artifacts_dir() with
req.params_preset.artifacts_dir_for_committee(req.committee_size.as_str())
(e.g., where artifacts_dir is assigned in the C0–C7 handlers and the ranges
around the noted spots such as the blocks referenced around artifacts_dir
assignment, and the ranges 753-759 and 788-796). Ensure each handler (the
functions/blocks that currently call params_preset.artifacts_dir()) assigns
artifacts_dir using artifacts_dir_for_committee and that any downstream logic
still references that local artifacts_dir variable unchanged.

In `@crates/zk-prover/src/actors/proof_verification.rs`:
- Around line 169-173: The code currently defaults unknown (m,n) pairs to
CiphernodesCommitteeSize::Micro via unwrap_or, which masks invalid thresholds;
change the logic around
CiphernodesCommitteeSize::from_threshold(data.threshold_m, data.threshold_n) so
that unknown pairs are rejected instead of mapped to Micro: match the
Result/Option returned by from_threshold (or remove unwrap_or) and on None/Err
return or propagate an error (or skip insertion and log) rather than inserting a
Micro committee; update the call site where
self.presets.insert(data.e3_id.clone(), (data.params_preset, committee)) is
performed to only insert when a valid committee is returned.

In `@scripts/build-circuits.ts`:
- Around line 408-422: The check in isDistPresetUpToDate keys stamps by
"preset/committee" but requiredDistMarkers and hydrateBinFromDist still use the
old preset-only dist path; update those functions to construct and check dist
paths under dist/circuits/<preset>/<committee>/... (not
dist/circuits/<preset>/...) so requiredDistMarkers(), hydrateBinFromDist(), and
any other dist-readers look in the committee subdirectory consistent with
readPresetStamp/readActiveBinPreset; ensure path construction uses the same
preset+committee combination used by isDistPresetUpToDate and isPresetUpToDate.

---

Outside diff comments:
In `@crates/zk-prover/src/actors/proof_verification.rs`:
- Around line 107-123: Currently the code inserts into self.pending (via
self.pending.insert(...) creating a PendingVerification for (msg.e3_id.clone(),
msg.key.party_id)) before checking self.presets.get(&msg.e3_id), which can cause
leaked pending entries when the preset is missing; move the self.pending.insert
call so it occurs only after the lookup succeeds (after let Some((preset,
committee)) = self.presets.get(&msg.e3_id).copied() else { ... }), remove the
pre-check insertion, and only construct PendingVerification and call
preset.artifacts_dir_for_committee(committee.as_str()) once the preset/committee
is present so rejected keys do not leave stale entries for (msg.e3_id,
msg.key.party_id).

In `@crates/zk-prover/src/circuits/aggregation/node_dkg_fold.rs`:
- Around line 364-372: The code currently picks artifacts via
preset.artifacts_dir_for_committee(committee.as_str()) without checking that the
chosen CiphernodesCommitteeSize actually matches the payload; before calling
artifacts_dir_for_committee, fetch the expected registered-party count from the
CiphernodesCommitteeSize value (use its method that returns the registered party
count) and compare it to input.committee_addresses.len(); if they differ, return
an Err(ZkError::InvalidInput/validation error) instead of proceeding. Apply the
same validation in the other identical block mentioned (the second
prove_dkg_aggregation-like usage around the 493-503 region) so both locations
reject mismatched committee sizes before loading presets/VKs.

In `@scripts/build-circuits.ts`:
- Around line 109-115: The guard for unsupported (preset, committee) pairs only
runs for concrete options at construction, so when buildAll() or
buildForPreset() iterates nested presets/committees it can still emit invalid
combinations; call isPresetCommitteeSupported(preset, committee) inside the
nested loop in buildAll() and/or at the start of buildForPreset() and skip (or
throw) for unsupported pairs instead of proceeding to build, ensuring you
reference the same options.preset/options.committee values when deciding to
continue; update both places mentioned (the new nested build loop and the
buildForPreset() entry) so every generated (preset, committee) is validated.
- Around line 122-150: The checksum manifest ignores the committee segment
because buildAll merges outputs from multiple committees into result.compiled;
update either buildForPreset to embed the committee into each compiled
artifact's output path or modify generateChecksumFile to read a committee
property from each compiled entry and include it in the emitted path (so
manifest entries become <preset>/<committee>/<variant>/...). Locate
buildForPreset, result.compiled, and generateChecksumFile in
scripts/build-circuits.ts and ensure the produced path used by
generateChecksumFile includes the committee segment (when this.options.committee
=== 'all' or committees contains multiple entries) so checksums reference the
actual file locations.
- Around line 457-539: The active-bin stamp is being written using
this.options.committee causing "--committee all" runs to record "all" instead of
the specific committee just built; update the writeActiveBinPresetStamp call in
buildForPreset (inside the block after copyArtifacts where currently
this.writeActiveBinPresetStamp(preset, sourceHash) is invoked) to pass the
current loop's committee (this.writeActiveBinPresetStamp(preset, sourceHash,
committee)) and update the writeActiveBinPresetStamp function
signature/implementation to accept and serialize that committee parameter
instead of reading this.options.committee.

---

Nitpick comments:
In `@crates/fhe-params/src/presets.rs`:
- Around line 396-402: Add a unit test in this module that constructs a Preset
instance and asserts artifacts_dir_for_committee returns the expected string by
comparing it to format!("{}/{}", preset.artifacts_dir(), committee). In the test
call preset.artifacts_dir_for_committee with a couple of representative
committee names (e.g. "medium", "micro") and assert equality to the explicit
format; use the existing Preset constructor present in this file to create the
preset and place the test in the #[cfg(test)] tests module in this file.

In `@crates/zk-helpers/src/ciphernodes_committee.rs`:
- Around line 55-64: Add unit tests that cover CommitteeSize::from_n_h: assert
that from_n_h(3,3) -> Ok(CommitteeSize::Micro), (5,5) -> Ok(Small), (10,8) ->
Ok(Medium), (20,15) -> Ok(Large), and that an unknown pair (e.g. from_n_h(4,2))
returns Err. Place tests in the module tests (or #[cfg(test)] mod tests)
alongside ciphernodes_committee.rs, using the same enum/constructor names
(CommitteeSize and from_n_h) so they fail if mappings change or error handling
regresses.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b01b61a0-214b-4193-814d-02d70dac304f

📥 Commits

Reviewing files that changed from the base of the PR and between 2396f43 and ce128a2.

📒 Files selected for processing (14)
  • circuits/benchmarks/scripts/run_benchmarks.sh
  • crates/aggregator/src/actors/publickey_aggregator.rs
  • crates/aggregator/src/actors/threshold_plaintext_aggregator.rs
  • crates/aggregator/src/ext.rs
  • crates/events/src/enclave_event/compute_request/zk.rs
  • crates/fhe-params/src/presets.rs
  • crates/multithread/src/multithread.rs
  • crates/zk-helpers/src/ciphernodes_committee.rs
  • crates/zk-prover/src/actors/node_proof_aggregator.rs
  • crates/zk-prover/src/actors/proof_verification.rs
  • crates/zk-prover/src/circuits/aggregation/node_dkg_fold.rs
  • crates/zk-prover/src/domain/node_dkg_fold.rs
  • crates/zk-prover/tests/common/helpers.rs
  • scripts/build-circuits.ts

Comment thread crates/aggregator/src/ext.rs Outdated
Comment thread crates/multithread/src/multithread.rs Outdated
Comment thread crates/zk-prover/src/actors/proof_verification.rs Outdated
Comment thread scripts/build-circuits.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/zk-prover/src/actors/proof_verification.rs (1)

107-122: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Move pending-cache insertion after preset lookup.

At Line 107, pending state is inserted before the preset guard at Line 115. If preset is missing, the function returns without dispatching verification, leaving stale pending entries.

Suggested fix
-        // Store the signed payload so we can reference it in the verification response
-        self.pending.insert(
-            (msg.e3_id.clone(), msg.key.party_id),
-            PendingVerification {
-                signed_payload: validated.signed_payload,
-                recovered_signer: validated.recovered_signer,
-            },
-        );
-
         let Some((preset, committee)) = self.presets.get(&msg.e3_id).copied() else {
             error!(
                 "No BfvPreset known for e3_id={} — cannot determine circuit artifacts directory. \
                  This can happen if CiphernodeSelected was missed (e.g. after restart). Rejecting key from party {}.",
                 msg.e3_id, msg.key.party_id
             );
             return;
         };
+        // Store pending only when we are actually dispatching verification.
+        self.pending.insert(
+            (msg.e3_id.clone(), msg.key.party_id),
+            PendingVerification {
+                signed_payload: validated.signed_payload,
+                recovered_signer: validated.recovered_signer,
+            },
+        );
         let artifacts_dir = preset.artifacts_dir_for_committee(committee.as_str());
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/zk-prover/src/actors/proof_verification.rs` around lines 107 - 122,
The pending insertion currently happens before checking for a preset, which can
leave stale entries if the guard returns early; move the self.pending.insert
call and creation of PendingVerification (the tuple key using msg.e3_id and
msg.key.party_id and values validated.signed_payload /
validated.recovered_signer) to after the preset lookup that uses
self.presets.get(&msg.e3_id).copied() (the block that logs the "No BfvPreset
known for e3_id=..." error) so insertion only occurs once the preset and
committee are present and verification will be dispatched.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@crates/zk-prover/src/actors/proof_verification.rs`:
- Around line 107-122: The pending insertion currently happens before checking
for a preset, which can leave stale entries if the guard returns early; move the
self.pending.insert call and creation of PendingVerification (the tuple key
using msg.e3_id and msg.key.party_id and values validated.signed_payload /
validated.recovered_signer) to after the preset lookup that uses
self.presets.get(&msg.e3_id).copied() (the block that logs the "No BfvPreset
known for e3_id=..." error) so insertion only occurs once the preset and
committee are present and verification will be dispatched.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c77d62e6-2f5d-498e-ad67-bbc507bbb813

📥 Commits

Reviewing files that changed from the base of the PR and between ce128a2 and 1550537.

📒 Files selected for processing (4)
  • crates/aggregator/src/ext.rs
  • crates/multithread/src/multithread.rs
  • crates/zk-prover/src/actors/proof_verification.rs
  • scripts/build-circuits.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/build-circuits.ts

ctrlc03
ctrlc03 previously approved these changes Jun 4, 2026

@ctrlc03 ctrlc03 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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/tests/tests/integration.rs`:
- Around line 382-386: The current fallback reuses circuits/bin when
circuits_bin_marker exists but doesn't verify it matches the requested preset;
update the check around uses_dist_preset_artifacts/preset_build_stamp to
validate the active bin stamp contents against the requested preset (use
resolve_preset_stamp_path, preset_subdir and committee_str) before trusting
circuits_bin_marker. Concretely: read/parse the active preset stamp (the file
pointed to by circuits_bin_marker or the .active-preset.json in circuits/bin),
compare its stored preset identifier/committee to preset_subdir and
committee_str (or compare to preset_build_stamp identity), and only skip
rebuilding/copying if the stamp matches; otherwise treat it as missing and fall
through to copy/build as when !preset_build_stamp.exists().
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d6f65efc-c78e-4bcd-910c-570524d27f77

📥 Commits

Reviewing files that changed from the base of the PR and between 1550537 and 1e80066.

📒 Files selected for processing (2)
  • crates/tests/tests/integration.rs
  • crates/zk-prover/tests/local_e2e_tests.rs

Comment thread crates/tests/tests/integration.rs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
crates/zk-prover/src/actors/proof_verification.rs (1)

62-62: ⚡ Quick win

Remove or use circuits_base in ProofVerificationActor
crates/zk-prover/src/actors/proof_verification.rs stores circuits_base: PathBuf in the actor and threads it through new/setup, but self.circuits_base is never read anywhere in the actor file. If it isn’t intended for artifact-path derivation/other logic yet, drop the field + constructor parameter (and the backend.circuits_dir.clone() argument in crates/zk-prover/src/actors/mod.rs).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/zk-prover/src/actors/proof_verification.rs` at line 62, The
ProofVerificationActor struct contains an unused field circuits_base (and its
constructor parameter) that is only threaded through new/setup but never read;
remove the circuits_base field from ProofVerificationActor, delete the
corresponding parameter in ProofVerificationActor::new and any uses in setup,
and remove the argument backend.circuits_dir.clone() passed when constructing
the actor in actors::mod (or adjust the callsite to match the new constructor
signature) so there are no unused fields or parameters left.
examples/CRISP/scripts/lib/dev_config.sh (1)

83-97: ⚡ Quick win

Consider whether silent fallback is the desired behavior when circuit artifacts are missing.

The function returns 0 (success) when the expected circuit artifacts at ${src}/recursive/dkg/pk/pk.json don't exist, with a message directing users to run pnpm dev:setup first. This silent fallback means dependent operations won't fail, which could hide configuration issues if a developer expects the sync to ensure artifacts are present.

If the intent is to gracefully fall back to release artifacts downloaded by enclave noir setup, the current behavior is appropriate. Otherwise, consider returning a non-zero exit code to surface missing artifacts as an error.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@examples/CRISP/scripts/lib/dev_config.sh` around lines 83 - 97, The
sync_enclave_circuit_artifacts function currently returns success (0) when
circuit artifacts are missing which silently masks failures; change it to either
return a non-zero exit status to surface the missing-artifact error or make the
behavior configurable (e.g. check an env flag like CRISP_ALLOW_RELEASE_FALLBACK)
so that by default missing `${src}/recursive/dkg/pk/pk.json` causes the function
to exit non‑zero (and print the same guidance message), while when the flag
allows fallback it continues as today; update the existence-check branch inside
sync_enclave_circuit_artifacts to implement the chosen behavior and ensure
callers handle the non-zero return appropriately.
.github/workflows/ci.yml (1)

775-798: 💤 Low value

Reassess the SHA-pinning request for the new Nargo/Barretenberg steps

The concern isn’t consistent with the existing workflow: in .github/workflows/ci.yml, only akhilmhdh/contributors-readme-action@1ff4c56187458b34cd602aee93e897344ce34bfc is pinned to a commit SHA, while other actions (including actions/cache@v4 and actions/checkout@v6) use version tags. Keep these as-is unless the repo has an explicit documented policy requiring SHA pins.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/ci.yml around lines 775 - 798, Leave the new workflow
steps as version-tagged actions rather than converting them to commit-SHA pins:
keep the "Install Nargo" step using noir-lang/noirup@v0.1.4, keep the "Cache
Barretenberg binary" step using actions/cache@v4 (id: cache-bb), and leave the
"Install Barretenberg (bb)" and "Build enclave circuits" steps unchanged; only
change to SHA pins is acceptable if the repository has an explicit documented
policy requiring SHA-pinning—otherwise match existing convention where only
akhilmhdh/contributors-readme-action is SHA-pinned.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In @.github/workflows/ci.yml:
- Around line 775-798: Leave the new workflow steps as version-tagged actions
rather than converting them to commit-SHA pins: keep the "Install Nargo" step
using noir-lang/noirup@v0.1.4, keep the "Cache Barretenberg binary" step using
actions/cache@v4 (id: cache-bb), and leave the "Install Barretenberg (bb)" and
"Build enclave circuits" steps unchanged; only change to SHA pins is acceptable
if the repository has an explicit documented policy requiring
SHA-pinning—otherwise match existing convention where only
akhilmhdh/contributors-readme-action is SHA-pinned.

In `@crates/zk-prover/src/actors/proof_verification.rs`:
- Line 62: The ProofVerificationActor struct contains an unused field
circuits_base (and its constructor parameter) that is only threaded through
new/setup but never read; remove the circuits_base field from
ProofVerificationActor, delete the corresponding parameter in
ProofVerificationActor::new and any uses in setup, and remove the argument
backend.circuits_dir.clone() passed when constructing the actor in actors::mod
(or adjust the callsite to match the new constructor signature) so there are no
unused fields or parameters left.

In `@examples/CRISP/scripts/lib/dev_config.sh`:
- Around line 83-97: The sync_enclave_circuit_artifacts function currently
returns success (0) when circuit artifacts are missing which silently masks
failures; change it to either return a non-zero exit status to surface the
missing-artifact error or make the behavior configurable (e.g. check an env flag
like CRISP_ALLOW_RELEASE_FALLBACK) so that by default missing
`${src}/recursive/dkg/pk/pk.json` causes the function to exit non‑zero (and
print the same guidance message), while when the flag allows fallback it
continues as today; update the existence-check branch inside
sync_enclave_circuit_artifacts to implement the chosen behavior and ensure
callers handle the non-zero return appropriately.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: af197f06-40e2-44e0-b590-92df188ce6fd

📥 Commits

Reviewing files that changed from the base of the PR and between 5b66ae7 and 0bb07f7.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock
  • examples/CRISP/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (37)
  • .github/workflows/ci.yml
  • circuits/benchmarks/results_insecure_agg_micro/benchmark_run_meta.json
  • circuits/benchmarks/results_insecure_agg_micro/crisp_verify_gas.json
  • circuits/benchmarks/results_insecure_agg_micro/integration_summary.json
  • circuits/benchmarks/results_insecure_agg_micro/report.md
  • circuits/benchmarks/scripts/check_circuit_preset_artifacts.sh
  • circuits/benchmarks/scripts/extract_crisp_verify_gas.sh
  • circuits/benchmarks/scripts/run_benchmarks.sh
  • crates/aggregator/src/actors/publickey_aggregator.rs
  • crates/aggregator/src/actors/threshold_plaintext_aggregator.rs
  • crates/aggregator/src/ext.rs
  • crates/events/src/enclave_event/compute_request/zk.rs
  • crates/events/src/enclave_event/encryption_key_pending.rs
  • crates/events/src/enclave_event/share_verification.rs
  • crates/evm/src/contracts.rs
  • crates/fhe-params/src/presets.rs
  • crates/keyshare/src/actors/threshold_keyshare.rs
  • crates/keyshare/src/domain/decryption_key_calculation.rs
  • crates/multithread/src/multithread.rs
  • crates/slashing/Cargo.toml
  • crates/slashing/src/domain/accusation_voting.rs
  • crates/tests/tests/integration.rs
  • crates/zk-prover/src/actors/mod.rs
  • crates/zk-prover/src/actors/proof_request.rs
  • crates/zk-prover/src/actors/proof_verification.rs
  • crates/zk-prover/src/actors/share_verification.rs
  • crates/zk-prover/src/circuits/aggregation/node_dkg_fold.rs
  • crates/zk-prover/src/domain/proof_request.rs
  • crates/zk-prover/src/domain/share_verification.rs
  • crates/zk-prover/src/prover.rs
  • examples/CRISP/scripts/dev_cipher.sh
  • examples/CRISP/scripts/lib/dev_config.sh
  • examples/CRISP/scripts/setup.sh
  • templates/default/package.json
  • templates/default/scripts/dev_ciphernodes.sh
  • templates/default/scripts/lib/dev_config.sh
  • templates/default/scripts/setup.sh
✅ Files skipped from review due to trivial changes (4)
  • crates/slashing/Cargo.toml
  • circuits/benchmarks/results_insecure_agg_micro/benchmark_run_meta.json
  • crates/events/src/enclave_event/encryption_key_pending.rs
  • circuits/benchmarks/results_insecure_agg_micro/report.md
🚧 Files skipped from review as they are similar to previous changes (17)
  • crates/events/src/enclave_event/share_verification.rs
  • crates/zk-prover/src/domain/proof_request.rs
  • crates/zk-prover/src/actors/proof_request.rs
  • circuits/benchmarks/scripts/run_benchmarks.sh
  • crates/fhe-params/src/presets.rs
  • crates/zk-prover/src/domain/share_verification.rs
  • circuits/benchmarks/scripts/check_circuit_preset_artifacts.sh
  • crates/zk-prover/src/circuits/aggregation/node_dkg_fold.rs
  • circuits/benchmarks/scripts/extract_crisp_verify_gas.sh
  • crates/aggregator/src/ext.rs
  • crates/zk-prover/src/actors/share_verification.rs
  • crates/multithread/src/multithread.rs
  • crates/keyshare/src/actors/threshold_keyshare.rs
  • crates/events/src/enclave_event/compute_request/zk.rs
  • crates/aggregator/src/actors/publickey_aggregator.rs
  • crates/aggregator/src/actors/threshold_plaintext_aggregator.rs
  • crates/tests/tests/integration.rs

@0xjei 0xjei merged commit 556de54 into main Jun 5, 2026
31 of 34 checks passed
@ctrlc03 ctrlc03 deleted the compile/all branch June 5, 2026 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants