Skip to content

chore: prod switch [skip-line-limit]#1513

Merged
ctrlc03 merged 5 commits into
mainfrom
chore/preset-aware-circuit-artifacts
Apr 8, 2026
Merged

chore: prod switch [skip-line-limit]#1513
ctrlc03 merged 5 commits into
mainfrom
chore/preset-aware-circuit-artifacts

Conversation

@ctrlc03

@ctrlc03 ctrlc03 commented Apr 8, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Configurable BFV parameter presets threaded into proof generation/verification, messaging, and artifact-directory resolution.
    • Circuit tooling now supports per-preset compilation and CLI preset selection.
  • Bug Fixes / Behavior Changes

    • Proof-aggregation is disabled by default when per-E3 aggregation metadata is absent; several tests and fixtures updated to reflect proofAggregationEnabled = false.
  • Chores

    • Tests, build scripts, and fixtures updated to use preset-scoped artifact paths.

@vercel

vercel Bot commented Apr 8, 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 Apr 8, 2026 1:54pm
enclave-docs Ready Ready Preview, Comment Apr 8, 2026 1:54pm

Request Review

@coderabbitai

coderabbitai Bot commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@ctrlc03 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 7 minutes and 6 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 7 minutes and 6 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b2978906-33ec-453e-a0e4-d719c3affc20

📥 Commits

Reviewing files that changed from the base of the PR and between 0567d3d and 20989a4.

📒 Files selected for processing (3)
  • crates/aggregator/src/proof_fold.rs
  • crates/aggregator/src/publickey_aggregator.rs
  • crates/aggregator/src/threshold_plaintext_aggregator.rs
📝 Walkthrough

Walkthrough

Threads a BFV parameter preset (BfvPreset) through events, actor/state structs, prover APIs, circuit build scripts, tests, and smart-contract gates so proof generation/verification resolve circuit artifacts via a preset-derived artifacts_dir.

Changes

Cohort / File(s) Summary
Aggregator & keyshare
crates/aggregator/src/proof_fold.rs, crates/aggregator/src/publickey_aggregator.rs, crates/aggregator/src/threshold_plaintext_aggregator.rs, crates/keyshare/src/threshold_keyshare.rs
Added params_preset: BfvPreset to fold state and propagated preset into ShareVerificationDispatched and ZkRequest::FoldProofs; constructors/reset now preserve the preset.
Events / requests
crates/events/src/enclave_event/compute_request/zk.rs, crates/events/src/enclave_event/share_verification.rs
Extended ZkRequest::FoldProofs, VerifyShareProofsRequest, VerifyShareDecryptionProofsRequest, and ShareVerificationDispatched to carry params_preset: BfvPreset.
FHE params utils
crates/fhe-params/src/presets.rs
Added security_tier() and artifacts_dir() on BfvPreset and unit test for artifacts dir formatting.
ZK prover core & traits
crates/zk-prover/src/prover.rs, crates/zk-prover/src/traits.rs
Threaded artifacts_dir: &str through prover APIs/traits; circuits_dir now resolves via base.join(artifacts_dir).join(variant).
Recursive circuits & utils
crates/zk-prover/src/circuits/recursive_aggregation/mod.rs, crates/zk-prover/src/circuits/utils.rs
Added artifacts_dir param to wrapper/fold/recursive proof generation and adjusted artifact/VK lookup and tests.
Actors & verification flow
crates/zk-prover/src/actors/...
crates/zk-prover/src/actors/accusation_manager.rs, .../accusation_manager_ext.rs, node_proof_aggregator.rs, proof_verification.rs, share_verification.rs, zk_actor.rs
Actors capture/store/pass params_preset; ZkVerificationRequest gains artifacts_dir; handlers compute/forward artifacts_dir to prover verify/generate calls; some actor constructors accept params_preset.
Multithread execution
crates/multithread/src/multithread.rs
Extracts artifacts_dir from requests and passes it into all proof generation and verification call sites.
Tests & fixtures
crates/tests/tests/integration.rs, crates/zk-prover/tests/*, crates/zk-prover/tests/local_e2e_tests.rs, packages/enclave-contracts/test/*, crates/zk-prover/tests/integration_tests.rs, crates/zk-prover/tests/backend_tests.rs
Updated tests/fixtures to use preset-scoped artifact dirs and thread artifacts_dir into prove/verify calls; default proofAggregationEnabled flipped to false in multiple tests.
Circuit build & scripts
scripts/build-circuits.ts, scripts/circuit-constants.ts
Added CircuitPreset support, per-preset builds (including all), Noir config swapping per preset, and preset-aware artifact/checksum layout and CLI option.
Smart contracts
packages/enclave-contracts/contracts/Enclave.sol, packages/enclave-contracts/contracts/registry/CiphernodeRegistryOwnable.sol
Guarded decryption/C5 proof verification behind e3.proofAggregationEnabled (skip verification when disabled).
Misc client/tests/templates & scripts
templates/default/..., packages/enclave-contracts/tasks/enclave.ts, tests/integration/persist.sh, templates/default/client/src/pages/steps/RequestComputation.tsx
Minor cleanup and test/script toggles: removed unused imports, renamed destructured param to _e3Params, and toggled proof-aggregation flags.
Other internal proof call sites
crates/zk-prover/src/circuits/..., crates/zk-prover/src/prover.rs, crates/zk-prover/src/traits.rs
Many internal APIs updated to accept artifacts_dir and thread it into prover/generator/verification implementations and tests.

Sequence Diagram(s)

sequenceDiagram
    participant ShareActor as ShareVerificationActor
    participant ZkActor as ZkActor
    participant Prover as ZkProver

    ShareActor->>ShareActor: capture params_preset from event
    ShareActor->>ZkActor: Send VerifyShareProofsRequest(proofs..., params_preset)
    ZkActor->>ZkActor: artifacts_dir = params_preset.artifacts_dir()
    ZkActor->>Prover: verify_proof(proof, e3_id, party_id, artifacts_dir)
    Prover-->>ZkActor: verification result
    ZkActor-->>ShareActor: publish verification outcome
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

Suggested reviewers

  • cedoor
  • 0xjei
  • hmzakhalid

Poem

🐇
I hopped through presets, near and far,
Placed artifacts beneath each star,
From actor, fold, to prover's jar,
Circuits find their slated bar,
Hooray—proofs follow where I spar! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title "chore: prod switch" is vague and does not clearly convey the main objective of this extensive changeset, which involves adding preset-aware circuit artifacts and parameter propagation throughout the codebase. Consider using a more descriptive title that captures the primary change, such as "chore: add BfvPreset-aware circuit artifact resolution" or "chore: propagate circuit parameter presets through proof generation pipeline".
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 87.23% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/preset-aware-circuit-artifacts

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: 6

Caution

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

⚠️ Outside diff range comments (2)
crates/keyshare/src/threshold_keyshare.rs (1)

1417-1425: ⚠️ Potential issue | 🟠 Major

Dispatch the threshold preset here, not share_enc_preset.

Both verification publishes send the actor’s DKG preset, but the corresponding proof requests in this file are built with threshold_counterpart(). That makes proof generation and verification disagree on the preset, and C4 can break as soon as downstream code uses the actual preset value instead of the shared artifacts_dir() name. Based on learnings, the share-decryption circuit codegen only accepts threshold BFV presets, not DKG presets.

Also applies to: 2045-2053

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/keyshare/src/threshold_keyshare.rs` around lines 1417 - 1425, The
publish is using the wrong preset: replace share_enc_preset with the actor’s
threshold preset so verification uses the same preset used to build proofs (use
threshold_counterpart()’s preset/field rather than share_enc_preset) in the
ShareVerificationDispatched for VerificationKind::ShareProofs (the block that
constructs share_proofs/decryption_proofs with e3_id and
party_proofs_to_verify); make the same change in the corresponding publish at
the other location (around the 2045-2053 block) so proof generation and
verification agree on the threshold BFV preset.
crates/aggregator/src/proof_fold.rs (1)

22-46: ⚠️ Potential issue | 🟠 Major

Add a serde default for the new persisted preset.

Line 33 makes params_preset mandatory on a state object that's explicitly persisted for restart recovery. Any ProofFoldState serialized before this change will fail to deserialize after deploy/restart, which breaks the recovery path this type exists for.

🛠️ Suggested fix
+fn default_params_preset() -> BfvPreset {
+    BfvPreset::default()
+}
+
-#[derive(Clone, Debug, Default, serde::Serialize, serde::Deserialize)]
+#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
 pub struct ProofFoldState {
@@
-    params_preset: BfvPreset,
+    #[serde(default = "default_params_preset")]
+    params_preset: BfvPreset,
 }
+
+impl Default for ProofFoldState {
+    fn default() -> Self {
+        Self::new()
+    }
+}
@@
-            params_preset: BfvPreset::default(),
+            params_preset: default_params_preset(),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/aggregator/src/proof_fold.rs` around lines 22 - 46, ProofFoldState's
new non-optional field params_preset breaks deserialization of older persisted
state; mark params_preset with serde default so missing field deserializes to
BfvPreset::default(). Concretely, add a serde default for the params_preset
field (or apply #[serde(default)] at the struct level) so
ProofFoldState::deserialize will populate params_preset using
BfvPreset::default() when the field is absent; keep the existing Default
implementation for ProofFoldState unchanged.
🧹 Nitpick comments (2)
crates/tests/tests/integration.rs (1)

881-893: Keep an aggregation-enabled end-to-end case around.

Hardcoding proof_aggregation_enabled = false makes every if proof_aggregation_enabled { ... } assertion below dead in this test, so the wrapper/fold path added in this PR stops being exercised here. I’d split this into two cases, or parameterize the flag, so both branches keep coverage.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/tests/tests/integration.rs` around lines 881 - 893, The test currently
hardcodes proof_aggregation_enabled = false causing all branches that run when
aggregation is enabled to be untested; update the test around the E3Requested
construction to exercise both branches by either adding a second test case with
proof_aggregation_enabled = true (keeping the existing false case) or
parameterizing the test to run twice with proof_aggregation_enabled true/false,
ensuring the E3Requested instance (and subsequent assertions that check if
proof_aggregation_enabled lead to wrapper/fold behavior) are executed for the
true case so the aggregation-enabled paths are covered.
crates/zk-prover/src/traits.rs (1)

55-85: Consider replacing the free-form artifacts_dir with a typed proof context.

Every caller now has to keep params/proof context and artifacts_dir in sync manually. Wrapping those together—or deriving the directory inside this trait for param types that know it—would remove a runtime-only mismatch class and cut down a lot of repetitive plumbing across the call sites.

Also applies to: 106-145

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/zk-prover/src/traits.rs` around lines 55 - 85, The trait's methods
prove and prove_with_variant currently accept a free-form artifacts_dir: &str
which forces callers to keep params/inputs and artifact paths in sync; introduce
a typed context (e.g., an associated type ProofContext or a struct ProofContext
{ params: Self::Params, artifacts_dir: PathBuf, /* maybe input or id */ }) and
replace the artifacts_dir parameter with that context in both fn signatures (or
add a helper method on Params to derive the artifacts dir, e.g.,
Params::artifact_dir(&self) -> PathBuf), update trait bounds accordingly, and
adjust implementations to use the typed ProofContext (or Params::artifact_dir)
so callers pass a single coherent object instead of separate params and
artifacts_dir strings; refer to the trait methods prove and prove_with_variant
to locate where to change signatures and usages.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@crates/fhe-params/src/presets.rs`:
- Around line 385-390: The fixtures loader was not updated for the new
artifacts_dir() layout: update setup_test_zk_backend() in
crates/tests/tests/integration.rs so it places/looks up fixtures under
circuits/{preset.artifacts_dir()}/{variant}/... (or compute
metadata().as_config_str()/degree via Preset::artifacts_dir()) instead of the
old circuits/{recursive,default,evm}/... paths; ensure the same prefix logic
used by crates/zk-prover/src/prover.rs (which expects
circuits/<artifacts_dir>/<variant>/...) is applied when copying test fixtures so
local bb fixtures are mirrored under insecure-512/ or secure-8192/ as produced
by artifacts_dir().

In `@crates/zk-prover/src/actors/proof_verification.rs`:
- Around line 148-153: The code must not call unwrap_or_default() on
self.presets when computing artifacts_dir for msg.e3_id because that can return
a wrong VK path after actor restart; instead check for the preset explicitly
(e.g. if let Some(preset) = self.presets.get(&msg.e3_id)) and use
preset.copied().artifacts_dir(), otherwise handle the missing entry by either
using a directory provided by the incoming message or deferring/aborting
verification (do not guess); update the logic around
self.presets.get(&msg.e3_id), .copied(), and artifacts_dir() accordingly so C0
verification uses only a confirmed artifact set (and ensure this ties into
replaying CiphernodeSelected where appropriate).

In `@packages/enclave-contracts/contracts/Enclave.sol`:
- Around line 415-423: The current branch sets success = true when
e3.proofAggregationEnabled is false, which skips plaintext verification; change
it to always call e3.decryptionVerifier.verify(...) for the plaintext proof and
only treat foldProof as optional. Specifically, replace the unconditional
success=true with a call to
e3.decryptionVerifier.verify(keccak256(plaintextOutput), proof, foldProof) (or a
variant/overload that accepts an empty/optional foldProof) and keep
require(success, InvalidOutput(plaintextOutput)); referenced symbols:
e3.proofAggregationEnabled, e3.decryptionVerifier.verify, plaintextOutput,
proof, foldProof, InvalidOutput.

In `@packages/enclave-contracts/contracts/registry/CiphernodeRegistryOwnable.sol`:
- Around line 222-225: publishCommittee currently skips verification when
e3.proofAggregationEnabled is false, allowing unverified publicKeyHash to be
published; change the logic so verification always occurs before committing
publicKeyHash and advancing lifecycle: in publishCommittee, after fetching E3
via enclave.getE3(e3Id) ensure either (A) require(e3.proofAggregationEnabled,
"aggregation disabled") to forbid publishing when aggregation is off, or (B)
call e3.pkVerifier.verify(proof, foldProof) unconditionally (and only write
e3.publicKeyHash and advance lifecycle after that call). Make sure to reference
E3 e3, e3.proofAggregationEnabled, e3.pkVerifier.verify, publishCommittee,
publicKeyHash, proof and foldProof so the verification decision and state
mutation are co-located and atomic.

In `@scripts/build-circuits.ts`:
- Around line 101-103: buildAll currently mutates the tracked file at modNrPath
(circuits/lib/src/configs/.../mod.nr) and restores originalModNr, which is
process-global and races between parallel runs; change the implementation to
perform each preset build in an isolated workspace: for each preset in
buildAll(), create a temporary working copy (e.g., copy the entire circuits tree
or at minimum the configs/default folder) and write the preset-specific mod.nr
into that temp copy, then invoke the compiler/tooling pointing at that temp
workspace (rather than rewriting modNrPath) and delete the temp when done;
update uses around modNrPath/originalModNr (and the similar blocks at the other
noted ranges) to operate on the temp copy so builds are local and non-mutating.
- Line 38: The preset field is currently treated as a plain string and can be
overridden to undefined/invalid when merging options, which later produces
invalid generated code; change the preset variable/type to CircuitPreset,
validate the CLI/parse boundary (where --preset is read in buildCircuits/main or
the options parser) and reject unknown values (exit/error) before any codegen or
before calling rewriteModNr, and when merging defaults with options ensure you
do not let undefined override defaults (use explicit preset = providedPreset ??
defaultPreset or spread defaults last). Ensure all uses (rewriteModNr, options
merging, and constructor call sites) expect CircuitPreset so invalid strings
never flow into codegen.

---

Outside diff comments:
In `@crates/aggregator/src/proof_fold.rs`:
- Around line 22-46: ProofFoldState's new non-optional field params_preset
breaks deserialization of older persisted state; mark params_preset with serde
default so missing field deserializes to BfvPreset::default(). Concretely, add a
serde default for the params_preset field (or apply #[serde(default)] at the
struct level) so ProofFoldState::deserialize will populate params_preset using
BfvPreset::default() when the field is absent; keep the existing Default
implementation for ProofFoldState unchanged.

In `@crates/keyshare/src/threshold_keyshare.rs`:
- Around line 1417-1425: The publish is using the wrong preset: replace
share_enc_preset with the actor’s threshold preset so verification uses the same
preset used to build proofs (use threshold_counterpart()’s preset/field rather
than share_enc_preset) in the ShareVerificationDispatched for
VerificationKind::ShareProofs (the block that constructs
share_proofs/decryption_proofs with e3_id and party_proofs_to_verify); make the
same change in the corresponding publish at the other location (around the
2045-2053 block) so proof generation and verification agree on the threshold BFV
preset.

---

Nitpick comments:
In `@crates/tests/tests/integration.rs`:
- Around line 881-893: The test currently hardcodes proof_aggregation_enabled =
false causing all branches that run when aggregation is enabled to be untested;
update the test around the E3Requested construction to exercise both branches by
either adding a second test case with proof_aggregation_enabled = true (keeping
the existing false case) or parameterizing the test to run twice with
proof_aggregation_enabled true/false, ensuring the E3Requested instance (and
subsequent assertions that check if proof_aggregation_enabled lead to
wrapper/fold behavior) are executed for the true case so the aggregation-enabled
paths are covered.

In `@crates/zk-prover/src/traits.rs`:
- Around line 55-85: The trait's methods prove and prove_with_variant currently
accept a free-form artifacts_dir: &str which forces callers to keep
params/inputs and artifact paths in sync; introduce a typed context (e.g., an
associated type ProofContext or a struct ProofContext { params: Self::Params,
artifacts_dir: PathBuf, /* maybe input or id */ }) and replace the artifacts_dir
parameter with that context in both fn signatures (or add a helper method on
Params to derive the artifacts dir, e.g., Params::artifact_dir(&self) ->
PathBuf), update trait bounds accordingly, and adjust implementations to use the
typed ProofContext (or Params::artifact_dir) so callers pass a single coherent
object instead of separate params and artifacts_dir strings; refer to the trait
methods prove and prove_with_variant to locate where to change signatures and
usages.
🪄 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: 8620de8d-794a-4eae-aabe-252db9ac20e1

📥 Commits

Reviewing files that changed from the base of the PR and between 8821e2d and 807dea7.

📒 Files selected for processing (32)
  • crates/aggregator/src/proof_fold.rs
  • crates/aggregator/src/publickey_aggregator.rs
  • crates/aggregator/src/threshold_plaintext_aggregator.rs
  • crates/events/src/enclave_event/compute_request/zk.rs
  • crates/events/src/enclave_event/share_verification.rs
  • crates/fhe-params/src/presets.rs
  • crates/keyshare/src/threshold_keyshare.rs
  • crates/multithread/src/multithread.rs
  • crates/tests/tests/integration.rs
  • crates/zk-prover/src/actors/accusation_manager.rs
  • crates/zk-prover/src/actors/accusation_manager_ext.rs
  • crates/zk-prover/src/actors/node_proof_aggregator.rs
  • crates/zk-prover/src/actors/proof_verification.rs
  • crates/zk-prover/src/actors/share_verification.rs
  • crates/zk-prover/src/actors/zk_actor.rs
  • crates/zk-prover/src/circuits/recursive_aggregation/mod.rs
  • crates/zk-prover/src/circuits/utils.rs
  • crates/zk-prover/src/prover.rs
  • crates/zk-prover/src/traits.rs
  • crates/zk-prover/tests/backend_tests.rs
  • crates/zk-prover/tests/local_e2e_tests.rs
  • packages/enclave-contracts/artifacts/contracts/Enclave.sol/Enclave.json
  • packages/enclave-contracts/artifacts/contracts/registry/CiphernodeRegistryOwnable.sol/CiphernodeRegistryOwnable.json
  • packages/enclave-contracts/contracts/Enclave.sol
  • packages/enclave-contracts/contracts/registry/CiphernodeRegistryOwnable.sol
  • packages/enclave-contracts/test/E3Lifecycle/E3Integration.spec.ts
  • packages/enclave-contracts/test/Enclave.spec.ts
  • packages/enclave-contracts/test/Registry/CiphernodeRegistryOwnable.spec.ts
  • packages/enclave-contracts/test/Slashing/CommitteeExpulsion.spec.ts
  • scripts/build-circuits.ts
  • scripts/circuit-constants.ts
  • tests/integration/persist.sh

Comment thread crates/fhe-params/src/presets.rs
Comment thread crates/zk-prover/src/actors/proof_verification.rs Outdated
Comment thread packages/enclave-contracts/contracts/Enclave.sol
Comment thread scripts/build-circuits.ts
Comment thread scripts/build-circuits.ts
cedoor
cedoor previously approved these changes Apr 8, 2026

@cedoor cedoor 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.

Besides CodeRabbit's comments, 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.

Caution

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

⚠️ Outside diff range comments (2)
packages/enclave-contracts/test/Registry/CiphernodeRegistryOwnable.spec.ts (1)

247-271: ⚠️ Potential issue | 🟠 Major

Keep proof aggregation configurable in this fixture.

packages/enclave-contracts/contracts/registry/CiphernodeRegistryOwnable.sol:196-232 only calls e3.pkVerifier.verify(...) when e3.proofAggregationEnabled is true. Hard-coding false here means every publishCommittee() case in this spec now runs through the no-verification branch, so a broken C5 verifier integration would still pass. Make this flag explicit per test instead of changing the shared default.

Suggested change
async function makeRequest(
  enclave: any,
  usdcToken: any,
  mockE3Program: any,
  mockDecryptionVerifier: any,
-  signer?: Signer,
+  {
+    signer,
+    proofAggregationEnabled = true,
+  }: { signer?: Signer; proofAggregationEnabled?: boolean } = {},
) {
  const abiCoder = ethers.AbiCoder.defaultAbiCoder();

  const currentTime = await networkHelpers.time.latest();
  const requestParams = {
    committeeSize: 0,
    inputWindow: [currentTime + 100, currentTime + 300] as [number, number],
    e3Program: await mockE3Program.getAddress(),
    paramSet: 0,
    computeProviderParams: abiCoder.encode(
      ["address"],
      [await mockDecryptionVerifier.getAddress()],
    ),
    customParams: abiCoder.encode(
      ["address"],
      ["0x1234567890123456789012345678901234567890"],
    ),
-    proofAggregationEnabled: false,
+    proofAggregationEnabled,
  };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/enclave-contracts/test/Registry/CiphernodeRegistryOwnable.spec.ts`
around lines 247 - 271, The fixture hard-codes
requestParams.proofAggregationEnabled = false inside makeRequest, which forces
the no-verification branch; change makeRequest to accept an optional
proofAggregationEnabled parameter (or include it in a passed-in
requestOverrides) and set requestParams.proofAggregationEnabled from that
parameter instead of the literal false so individual tests can opt into
true/false; update call sites in the spec to pass the desired boolean where
tests need verification enabled.
packages/enclave-contracts/tasks/enclave.ts (1)

107-111: ⚠️ Potential issue | 🟡 Minor

Don't keep --e3Params as a silent no-op.

packages/enclave-contracts/contracts/interfaces/IEnclave.sol:418-431 no longer has an e3Params field, and the requestParams object here never uses this value. Renaming it to _e3Params hides the mismatch but still accepts committee:new --e3Params ... without changing the request. Either remove the option or fail fast when callers pass it.

Suggested change
      {
        committeeSize,
        inputWindowStart,
        inputWindowEnd,
        e3Address,
-        e3Params: _e3Params,
+        e3Params,
        computeParams,
        customParams,
        proofAggregationEnabled,
      },
      hre,
    ) => {
+      if (e3Params !== ZeroAddress) {
+        throw new Error(
+          "--e3Params is no longer consumed by committee:new; remove it from the invocation.",
+        );
+      }
+
       if (![0, 1, 2, 3].includes(committeeSize)) {

Also applies to: 131-148

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/enclave-contracts/tasks/enclave.ts` around lines 107 - 111, The CLI
option "e3Params" in packages/enclave-contracts/tasks/enclave.ts is a silent
no-op (never used when building requestParams) and must either be removed or
cause a hard failure when supplied; update the task that defines the "e3Params"
argument (and the duplicate at the other block around lines 131-148) to either
delete the addOptionalParam/addParam declaration for "e3Params" or add
validation in the task action that checks the taskArgs.e3Params value and throws
a clear error (e.g., "e3Params is no longer supported") if it differs from the
default (ZeroAddress), and ensure requestParams remains unchanged.
🧹 Nitpick comments (1)
crates/zk-prover/src/actors/proof_verification.rs (1)

198-210: Consider cleanup of stale presets.

The presets map grows unboundedly as new E3s are processed. For long-running nodes, consider adding cleanup logic when an E3 completes or fails (e.g., listen for E3Completed/E3Failed events).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/zk-prover/src/actors/proof_verification.rs` around lines 198 - 210,
The presets HashMap is never trimmed which causes unbounded growth; update the
EnclaveEvent handler (handle method in proof_verification.rs) to also match
EnclaveEventData::E3Completed and EnclaveEventData::E3Failed (or whatever
completion/failure enum names exist) and call self.presets.remove(&data.e3_id)
(or appropriate field) to drop the preset for that E3; ensure the removal branch
is added alongside the existing CiphernodeSelected and EncryptionKeyReceived
arms so presets are cleaned when an E3 finishes or fails.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@packages/enclave-contracts/tasks/enclave.ts`:
- Around line 107-111: The CLI option "e3Params" in
packages/enclave-contracts/tasks/enclave.ts is a silent no-op (never used when
building requestParams) and must either be removed or cause a hard failure when
supplied; update the task that defines the "e3Params" argument (and the
duplicate at the other block around lines 131-148) to either delete the
addOptionalParam/addParam declaration for "e3Params" or add validation in the
task action that checks the taskArgs.e3Params value and throws a clear error
(e.g., "e3Params is no longer supported") if it differs from the default
(ZeroAddress), and ensure requestParams remains unchanged.

In `@packages/enclave-contracts/test/Registry/CiphernodeRegistryOwnable.spec.ts`:
- Around line 247-271: The fixture hard-codes
requestParams.proofAggregationEnabled = false inside makeRequest, which forces
the no-verification branch; change makeRequest to accept an optional
proofAggregationEnabled parameter (or include it in a passed-in
requestOverrides) and set requestParams.proofAggregationEnabled from that
parameter instead of the literal false so individual tests can opt into
true/false; update call sites in the spec to pass the desired boolean where
tests need verification enabled.

---

Nitpick comments:
In `@crates/zk-prover/src/actors/proof_verification.rs`:
- Around line 198-210: The presets HashMap is never trimmed which causes
unbounded growth; update the EnclaveEvent handler (handle method in
proof_verification.rs) to also match EnclaveEventData::E3Completed and
EnclaveEventData::E3Failed (or whatever completion/failure enum names exist) and
call self.presets.remove(&data.e3_id) (or appropriate field) to drop the preset
for that E3; ensure the removal branch is added alongside the existing
CiphernodeSelected and EncryptionKeyReceived arms so presets are cleaned when an
E3 finishes or fails.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 06e25f6f-e212-4ad8-a382-5020be10c3c1

📥 Commits

Reviewing files that changed from the base of the PR and between 807dea7 and 6ab6ded.

📒 Files selected for processing (8)
  • circuits/lib/src/configs/default/mod.nr
  • crates/tests/tests/integration.rs
  • crates/zk-prover/src/actors/proof_verification.rs
  • packages/enclave-contracts/tasks/enclave.ts
  • packages/enclave-contracts/test/Registry/CiphernodeRegistryOwnable.spec.ts
  • scripts/build-circuits.ts
  • templates/default/client/src/pages/steps/RequestComputation.tsx
  • templates/default/tests/integration.spec.ts
💤 Files with no reviewable changes (2)
  • templates/default/client/src/pages/steps/RequestComputation.tsx
  • templates/default/tests/integration.spec.ts
✅ Files skipped from review due to trivial changes (1)
  • circuits/lib/src/configs/default/mod.nr
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/build-circuits.ts

0xjei
0xjei previously approved these changes Apr 8, 2026

@0xjei 0xjei 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.

utAck

Comment thread crates/aggregator/src/proof_fold.rs Outdated

@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 (1)
crates/zk-prover/tests/common/helpers.rs (1)

44-45: Parameterize the preset directory instead of hardcoding "insecure-512".

Behavior is correct today, but hardcoding makes the later secure-params batch switch noisier and easier to miss in helpers.

♻️ Proposed refactor
-pub async fn setup_compiled_circuit(backend: &ZkBackend, group: &str, circuit_name: &str) {
+pub async fn setup_compiled_circuit(
+    backend: &ZkBackend,
+    artifacts_dir: &str,
+    group: &str,
+    circuit_name: &str,
+) {
@@
-    let preset_dir = backend.circuits_dir.join("insecure-512");
+    let preset_dir = backend.circuits_dir.join(artifacts_dir);

Based on learnings: tests intentionally use insecure BFV parameter presets consistently across the suite during the transition period.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@crates/zk-prover/tests/common/helpers.rs` around lines 44 - 45, The line that
hardcodes "insecure-512" when computing preset_dir should be parameterized:
replace the literal in helpers.rs (where preset_dir is computed from
backend.circuits_dir.join("insecure-512")) with a variable or constant passed
into the helper; e.g., add a new parameter (preset_name or preset_dir_name) to
the helper function that constructs/uses preset_dir (or introduce a crate-level
const like DEFAULT_PRESET that tests can override), update all call sites to
pass "insecure-512" for now, and use backend.circuits_dir.join(preset_name)
instead of the literal so the preset can be switched centrally without editing
helpers.rs.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@crates/zk-prover/tests/common/helpers.rs`:
- Around line 44-45: The line that hardcodes "insecure-512" when computing
preset_dir should be parameterized: replace the literal in helpers.rs (where
preset_dir is computed from backend.circuits_dir.join("insecure-512")) with a
variable or constant passed into the helper; e.g., add a new parameter
(preset_name or preset_dir_name) to the helper function that constructs/uses
preset_dir (or introduce a crate-level const like DEFAULT_PRESET that tests can
override), update all call sites to pass "insecure-512" for now, and use
backend.circuits_dir.join(preset_name) instead of the literal so the preset can
be switched centrally without editing helpers.rs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 503393a4-746e-45ee-b601-f48b78858755

📥 Commits

Reviewing files that changed from the base of the PR and between 8c68afd and 0567d3d.

📒 Files selected for processing (3)
  • crates/zk-prover/src/actors/proof_request.rs
  • crates/zk-prover/tests/common/helpers.rs
  • crates/zk-prover/tests/integration_tests.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/zk-prover/tests/integration_tests.rs

@ctrlc03 ctrlc03 changed the title chore: prod switch chore: prod switch [skip-line-limit] Apr 8, 2026
@ctrlc03 ctrlc03 merged commit f8afdd8 into main Apr 8, 2026
32 checks passed
@ctrlc03 ctrlc03 deleted the chore/preset-aware-circuit-artifacts branch April 8, 2026 14:30
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.

3 participants