Skip to content

chore: update template#1604

Merged
hmzakhalid merged 6 commits into
mainfrom
chore/update-template
Jun 16, 2026
Merged

chore: update template#1604
hmzakhalid merged 6 commits into
mainfrom
chore/update-template

Conversation

@hmzakhalid

@hmzakhalid hmzakhalid commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Chores
    • Pinned Hardhat toolchain and updated Chai; added package manager overrides for consistent verifier/keystore versions
    • Added Rust toolchain pinning (rustfmt/rust-src)
    • Setup now installs and builds Rust/Cargo dependencies first, and resets the support folder while preserving generated artifacts
  • New Features
    • Added an SDK runtime check to ensure the active circuit preset matches the expected “minimum” configuration
  • Configuration
    • Updated localhost deployment metadata and integration/example configuration (addresses and deploy blocks), plus refreshed recorded deployment details in example artifacts
  • Refactor
    • Standardized how verifier/VK hash paths and repo-root/circuit artifact paths are derived using shared helpers

@vercel

vercel Bot commented Jun 16, 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 16, 2026 10:53am
enclave-docs Ready Ready Preview, Comment Jun 16, 2026 10:53am
interfold-dashboard Ready Ready Preview, Comment Jun 16, 2026 10:53am

Request Review

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@hmzakhalid, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 11 minutes and 54 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 62a94180-14fd-4788-b1b6-b62d31188dbf

📥 Commits

Reviewing files that changed from the base of the PR and between 3be30e2 and d3a995a.

📒 Files selected for processing (4)
  • crates/init/src/file_utils.rs
  • examples/CRISP/interfold.config.yaml
  • packages/interfold-contracts/test/BfvVkBindingIntegration.spec.ts
  • packages/interfold-sdk/src/circuits/assert-minimum-circuits.ts
📝 Walkthrough

Walkthrough

Adds a localhost deployment section to deployed_contracts.json with per-contract metadata, and updates integration test and example configs to match. Pins Rust toolchain 1.91.1 in the default template, adds a cargo build step to setup.sh, and locks Hardhat dependencies with pnpm.overrides. Introduces a remove_dir_except Rust utility to preserve the generated directory during installation. Refactors VK path resolution across verifier modules, deployment scripts, and benchmarking tools from eager constants to lazy-loaded functions. Splits SDK circuit validation into Node-specific and browser-safe paths using dynamic imports.

Changes

Localhost Deployment and Template Infrastructure Setup

Layer / File(s) Summary
Localhost contract deployment records
packages/interfold-contracts/deployed_contracts.json
Adds a new localhost network object with per-contract deployment metadata (blockNumber, address, constructorArgs, proxyRecords) for core contracts and mock components.
Integration and example config updates
tests/integration/interfold.config.yaml, examples/CRISP/interfold.config.yaml, examples/CRISP/packages/crisp-contracts/deployed_contracts.json
Updates localhost chain entries and example deployment configs to reference the new addresses and deploy_block values; adjusts InterfoldToken constructor timing fields in the CRISP example.
Rust toolchain pin, cargo build, and Hardhat dependency updates
templates/default/rust-toolchain.toml, templates/default/scripts/setup.sh, templates/default/package.json
Pins Rust 1.91.1 with rustfmt and rust-src; inserts cargo build after pnpm install; updates @nomicfoundation/hardhat-* versions, bumps chai to ^5.1.2, and adds pnpm.overrides for hardhat-mocha and hardhat-keystore.

Rust Directory Utility and VK Path Resolution Refactoring

Layer / File(s) Summary
Directory cleanup utility
crates/init/src/file_utils.rs, crates/init/src/lib.rs
Adds remove_dir_except(dir, keep) to remove all directory entries except those in a keep list; updates installation reset to preserve the generated subdirectory under .interfold instead of deleting the entire directory.
VK path resolution core refactoring
packages/interfold-contracts/scripts/utils.ts
Replaces eager REPO_ROOT constant with memoized getRepoRoot() function; replaces static VK-hash-path constants with dynamic getter functions (getBfvPkSubCircuitVkHashPaths, getBfvDecryptionSubCircuitVkHashPaths) that resolve paths at call time.
VK path consumer updates in ignition modules
packages/interfold-contracts/ignition/modules/bfvDecryptionVerifier.ts, packages/interfold-contracts/ignition/modules/bfvPkVerifier.ts
Updates modules to call the new VK path getter functions and derive hash inputs from their dynamic outputs instead of static constants.
VK path consumer updates in deployment scripts
packages/interfold-contracts/scripts/deployAndSave/bfvDecryptionVerifier.ts, packages/interfold-contracts/scripts/deployAndSave/bfvPkVerifier.ts
Updates deployment preconditions to compute expected hash values from the new dynamic path getters.
VK path consumer updates in benchmarking script
packages/interfold-contracts/scripts/benchmarkGasFromRaw.ts
Refactors all path construction (honk directory, preset JSON, Hardhat cwd, VK hash reading) to use lazy-loaded helper functions instead of removed constants.

SDK Circuit Validation Environment Split

Layer / File(s) Summary
SDK Node-specific minimum circuits validator
packages/interfold-sdk/src/circuits/assert-minimum-circuits-node.ts
New Node-only module that locates and caches the active preset JSON path, exporting checkSdkMinimumCircuits() to validate the preset's committee field matches "minimum", with specific error codes for missing artifacts, invalid JSON, or mismatches.
SDK universal validation refactoring
packages/interfold-sdk/src/circuits/assert-minimum-circuits.ts
Refactors to detect browser environments (no-op via isNode guard), avoid repeated validation (via checked flag), and delegate to the Node-specific module using dynamic import, propagating any thrown errors.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 Localhost deploys with addresses so bright,
Rust toolchains locked in the default setup's light.
Paths now resolve as they're needed, not before,
SDK validation split: Node-ways and more!
The rabbit refactors with meticulous care,
Building robust systems without despair! 🌟

Possibly related PRs

  • gnosisguild/interfold#1595: Both PRs update the SDK's minimum-circuits validation path—this PR refactors packages/interfold-sdk/src/circuits/assert-minimum-circuits.ts and adds a Node-specific module, while PR #1595 modifies the same assertion logic around the active committee preset.

Suggested reviewers

  • ctrlc03
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'chore: update template' is vague and generic, failing to convey the substantial scope of changes across contract deployments, dependency updates, Rust toolchain configuration, utility functions, and circuit validation logic. Use a more descriptive title that captures the main changes, such as 'chore: update template with localhost deployment config and refactor VK path resolution' or similar.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 88.24% 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.

✏️ 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/update-template

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

🧹 Nitpick comments (1)
templates/default/scripts/setup.sh (1)

15-16: ⚡ Quick win

Use --locked for deterministic Cargo resolution in setup.

This keeps template bootstrap reproducible and consistent with the later CLI build command.

Suggested patch
 echo "Installing Cargo dependencies..."
-cargo build
+cargo build --locked
🤖 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 `@templates/default/scripts/setup.sh` around lines 15 - 16, The cargo build
command in the setup script needs to include the --locked flag to ensure
deterministic dependency resolution and keep template bootstrap reproducible and
consistent with other build commands in the project. Modify the cargo build
command to add the --locked flag so that it uses the exact versions specified in
Cargo.lock.
🤖 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 `@templates/default/package.json`:
- Around line 48-55: The chai dependency version 5.1.2 creates a major version
mismatch with `@types/chai` version 4.2.0 and is ESM-only, making it incompatible
with Hardhat's plugin ecosystem including `@nomicfoundation/hardhat-chai-matchers`
which requires Chai v4. Either downgrade the chai dependency from ^5.1.2 to ^4.x
to align with the `@types/chai` version and Hardhat's testing setup, or if full
ESM support is explicitly configured for this template, upgrade `@types/chai` to
^5.x to match the Chai v5 version. The preferred solution is to downgrade chai
to v4 unless the template has dedicated ESM configuration.

---

Nitpick comments:
In `@templates/default/scripts/setup.sh`:
- Around line 15-16: The cargo build command in the setup script needs to
include the --locked flag to ensure deterministic dependency resolution and keep
template bootstrap reproducible and consistent with other build commands in the
project. Modify the cargo build command to add the --locked flag so that it uses
the exact versions specified in Cargo.lock.
🪄 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: f3ecb404-7a17-47e4-b113-270beaa0ef01

📥 Commits

Reviewing files that changed from the base of the PR and between 06299a5 and f10992b.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • packages/interfold-contracts/deployed_contracts.json
  • templates/default/package.json
  • templates/default/rust-toolchain.toml
  • templates/default/scripts/setup.sh
  • tests/integration/interfold.config.yaml

Comment thread templates/default/package.json

@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: 3

Caution

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

⚠️ Outside diff range comments (1)
packages/interfold-sdk/src/circuits/assert-minimum-circuits.ts (1)

37-60: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Dead code left over from previous implementation causes syntax errors.

Lines 37-60 contain orphaned code from the old implementation that should have been removed:

  • Lines 37-38 have unmatched closing delimiters () and })
  • Lines 40-60 reference variables (raw, committee, SDKError, ACTIVE_PRESET_PATH, SDK_CIRCUIT_COMMITTEE) that are no longer defined or imported in this file

This will cause compilation/syntax errors.

🐛 Proposed fix: Remove leftover dead code
   import('./assert-minimum-circuits-node').then(
     (m) => m.checkSdkMinimumCircuits(),
     (err) => {
       throw err
     },
   )
 }
-    )
-  }
-
-  let committee: string | undefined
-  try {
-    committee = JSON.parse(raw)?.committee as string | undefined
-  } catch {
-    throw new SDKError(
-      `Invalid JSON in ${ACTIVE_PRESET_PATH}. Rebuild with \`pnpm -C packages/interfold-sdk compile:circuits\`.`,
-      'SDK_CIRCUIT_STAMP_INVALID',
-    )
-  }
-
-  if (committee !== SDK_CIRCUIT_COMMITTEE) {
-    throw new SDKError(
-      `SDK requires circuits built for committee "${SDK_CIRCUIT_COMMITTEE}" ` +
-        `(active preset is "${committee ?? 'unknown'}"). ` +
-        `Run: pnpm -C packages/interfold-sdk compile:circuits`,
-      'SDK_CIRCUIT_COMMITTEE_MISMATCH',
-    )
-  }
-
-  checked = true
-}
🤖 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 `@packages/interfold-sdk/src/circuits/assert-minimum-circuits.ts` around lines
37 - 60, Remove the entire dead code block that contains orphaned implementation
from a previous version. This block includes the try-catch statement that
attempts to parse JSON and assign to the committee variable, the if statement
that checks committee against SDK_CIRCUIT_COMMITTEE, and the checked assignment
at the end. These lines reference undefined variables (raw, SDKError,
ACTIVE_PRESET_PATH, SDK_CIRCUIT_COMMITTEE) and contain unmatched closing
delimiters at the beginning, all of which cause syntax errors. Delete all of
this orphaned code entirely, ensuring the file is clean and only contains the
current active implementation.
🤖 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/init/src/file_utils.rs`:
- Around line 82-85: The remove_dir_except function returns Ok(()) when the path
exists but is not a directory, which masks an invalid state rather than failing
fast. Modify the guard clause to distinguish between these cases: when dir does
not exist, return Ok(()), but when dir exists and is not a directory, return an
error immediately so that invalid .interfold states are caught and reported at
the source rather than causing confusing failures downstream. This ensures
deterministic reset behavior.

In `@examples/CRISP/interfold.config.yaml`:
- Around line 16-21: Remove the duplicate bonding_registry key from the
configuration file. The YAML mapping contains two identical bonding_registry
entries with the same address and deploy_block values at lines 16-21. Delete one
of these duplicate key-value pairs to ensure the YAML structure is valid, as
YAML does not permit duplicate keys in mappings. Keep only a single
bonding_registry entry with its address and deploy_block configuration.

In `@packages/interfold-sdk/src/circuits/assert-minimum-circuits.ts`:
- Around line 29-35: The function assertSdkMinimumCircuits() is declared
synchronous but performs an async dynamic import via .then() callbacks, causing
errors in the promise callbacks to become unhandled rejections instead of
propagating to the caller. Fix this by either converting the async dynamic
import to a synchronous require() call (if CJS compatibility is acceptable) to
maintain the synchronous contract, or make the function async, update its return
type to return a Promise, and update all downstream callers in
user-data-encryption.ts and other locations to await the result.

---

Outside diff comments:
In `@packages/interfold-sdk/src/circuits/assert-minimum-circuits.ts`:
- Around line 37-60: Remove the entire dead code block that contains orphaned
implementation from a previous version. This block includes the try-catch
statement that attempts to parse JSON and assign to the committee variable, the
if statement that checks committee against SDK_CIRCUIT_COMMITTEE, and the
checked assignment at the end. These lines reference undefined variables (raw,
SDKError, ACTIVE_PRESET_PATH, SDK_CIRCUIT_COMMITTEE) and contain unmatched
closing delimiters at the beginning, all of which cause syntax errors. Delete
all of this orphaned code entirely, ensuring the file is clean and only contains
the current active implementation.
🪄 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: 9f3b6370-7e19-4416-9941-279ddfd34c31

📥 Commits

Reviewing files that changed from the base of the PR and between f10992b and 3be30e2.

📒 Files selected for processing (12)
  • crates/init/src/file_utils.rs
  • crates/init/src/lib.rs
  • examples/CRISP/interfold.config.yaml
  • examples/CRISP/packages/crisp-contracts/deployed_contracts.json
  • packages/interfold-contracts/ignition/modules/bfvDecryptionVerifier.ts
  • packages/interfold-contracts/ignition/modules/bfvPkVerifier.ts
  • packages/interfold-contracts/scripts/benchmarkGasFromRaw.ts
  • packages/interfold-contracts/scripts/deployAndSave/bfvDecryptionVerifier.ts
  • packages/interfold-contracts/scripts/deployAndSave/bfvPkVerifier.ts
  • packages/interfold-contracts/scripts/utils.ts
  • packages/interfold-sdk/src/circuits/assert-minimum-circuits-node.ts
  • packages/interfold-sdk/src/circuits/assert-minimum-circuits.ts

Comment thread crates/init/src/file_utils.rs
Comment thread examples/CRISP/interfold.config.yaml Outdated
Comment thread packages/interfold-sdk/src/circuits/assert-minimum-circuits.ts Outdated
@hmzakhalid hmzakhalid merged commit 1dcb5f1 into main Jun 16, 2026
33 checks passed
@ctrlc03 ctrlc03 deleted the chore/update-template branch June 16, 2026 11:26
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