Skip to content

feat: connect crisp to blockchain time [skip-line-limit]#1052

Merged
ryardley merged 33 commits into
mainfrom
ry/1020-blockchain-time-draft-2
Nov 27, 2025
Merged

feat: connect crisp to blockchain time [skip-line-limit]#1052
ryardley merged 33 commits into
mainfrom
ry/1020-blockchain-time-draft-2

Conversation

@ryardley

@ryardley ryardley commented Nov 25, 2025

Copy link
Copy Markdown
Contributor

This is part of #1020

  • Create a BlockListener to listen for blocks with tests.
  • Use a ThresholdQueue as an abstraction to hold ordered events or callbacks to dispatch in order (can use this in ciphernodes too later)
  • Created a concrete CallbackQueue to use the ThresholdQueue for holding callbacks.
  • Add do_later method on the indexer ctx to register a future task using blocktime.
  • Use block time to trigger intervals in crisp to avoid waits in the "server".
  • Renamed variables

Next steps:

  • Add this to ciphernodes to fix the architectural issues with CommitteeFinalizer around this
  • Add this logic to the TS sdk (probably with refactoring)
  • Setup long expiry for waits and use fast forward to jump ahead in time in tests.

Summary by CodeRabbit

  • New Features

    • Real-time block listener with pluggable handlers
    • Threshold-based queue and callback scheduler for timed async tasks
  • Improvements

    • Indexer split into separate event and block monitoring with scheduling support and clearer logging
    • RPC parameter naming standardized; server startup now uses non-blocking, scheduled timing handlers
  • Chores

    • Removed local test deployment entries
  • Tests

    • Added integration tests for block listener and callback scheduling

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel

vercel Bot commented Nov 25, 2025

Copy link
Copy Markdown

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

Project Deployment Preview Comments Updated (UTC)
crisp Ready Ready Preview Comment Nov 27, 2025 3:26am
enclave-docs Ready Ready Preview Comment Nov 27, 2025 3:26am

@coderabbitai

coderabbitai Bot commented Nov 25, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Adds a BlockListener and EventListener accessor, introduces ThresholdQueue and CallbackQueue for time-based scheduling, refactors the Indexer to use separate event and block listeners with do_later scheduling, renames RPC parameters (ws/http_rpc -> rpc_url/url), and updates CRISP example, tests, and Hardhat config accordingly.

Changes

Cohort / File(s) Summary
Block listener & event accessor
crates/evm-helpers/src/block_listener.rs, crates/evm-helpers/src/event_listener.rs
New BlockListener with constructor, handler registration and listen() loop; EventListener::provider() accessor added; create_contract_listener param renamed ws_urlrpc_url; removed tracing::info import.
Threshold queue & callback system
crates/evm-helpers/src/threshold_queue.rs, crates/indexer/src/callback_queue.rs
New generic ThresholdQueue<T> and ThresholdItem trait; CallbackQueue/TimedCallback built atop ThresholdQueue to schedule and execute async callbacks by timestamp, with ordering, execution, and tests.
Contracts RPC param rename
crates/evm-helpers/src/contracts.rs
Renamed http_rpc_urlrpc_url in EnclaveContractFactory::create_write and create_read; updated .connect(rpc_url) calls.
Indexer refactor & scheduling
crates/indexer/src/indexer.rs
Replaced single listener with event_listener and block_listener; added CallbackQueue field and do_later() scheduling API; constructors changed to use rpc_url; listen loop now monitors both listeners (tokio::select!), registers blocktime callback handler, and converts prints to info!/warn!.
Module exports
crates/evm-helpers/src/lib.rs, crates/indexer/src/lib.rs
Added block_listener and event_listener modules; replaced listener export with threshold_queue; added private callback_queue module to indexer crate.
Integration tests
crates/evm-helpers/tests/integration.rs, crates/indexer/tests/integration.rs
Added test_block_listener (Anvil + BlockListener) and test_do_later_memory_leak; adjusted EventListener import paths and moved sol! declaration scope.
CRISP example: indexer & handlers
examples/CRISP/server/src/server/indexer.rs
start_indexer signature changed (ws_urlurl, added store and private_key); replaced blocking sleeps in handlers with do_later scheduling; added handle_e3_input_deadline_expiration and handle_committee_time_expired helper functions.
Hardhat & tests & deployments
examples/CRISP/packages/crisp-contracts/hardhat.config.ts, examples/CRISP/test/crisp.spec.ts, examples/CRISP/packages/crisp-contracts/deployed_contracts.json
Added networks.default with mining config; adjusted localhost entry; smoke test waits for full page load; removed localhost deployment block from deployed_contracts.json.

Sequence Diagram(s)

sequenceDiagram
    rect rgba(70,130,180,0.06)
    participant BlockListener as BlockListener
    participant CallbackQueue as CallbackQueue
    participant Handlers as Handlers
    end
    BlockListener->>BlockListener: listen()
    loop for each new block
        BlockListener->>Handlers: spawn handler tasks (concurrent)
        Handlers->>Handlers: process Header
        BlockListener->>CallbackQueue: execute_until_including(block.timestamp)
        CallbackQueue->>CallbackQueue: run eligible callbacks (sequentially)
    end
Loading
sequenceDiagram
    participant Indexer as Indexer
    participant EventListener as EventListener
    participant BlockListener as BlockListener
    participant EventHandlers as EventHandlers
    participant BlockHandlers as BlockHandlers

    Indexer->>Indexer: listen() (tokio::select!)
    par monitor events
        EventListener-->>Indexer: contract event
        Indexer->>EventHandlers: invoke event handlers
    and monitor blocks
        BlockListener-->>Indexer: new block
        Indexer->>BlockHandlers: invoke block handlers
        Indexer->>CallbackQueue: check & execute scheduled callbacks
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45–70 minutes

  • Pay attention to concurrency and locking in ThresholdQueue / CallbackQueue.
  • Verify task spawning, cancellation, and error handling in BlockListener::listen.
  • Review tokio::select! restart/backoff logic and logging changes in indexer.rs.
  • Inspect CRISP deadline handlers for correctness after replacing sleeps with scheduled callbacks.

Possibly related PRs

Suggested labels

crisp

Suggested reviewers

  • hmzakhalid
  • ctrlc03
  • 0xjei

Poem

🐇 I hopped through blocks both near and far,
I queued small deadlines beneath the star.
Heaps sort the time, callbacks wake and run,
Listeners listen until the work is done. ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 52.38% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: connect crisp to blockchain time' accurately summarizes the main objective of the PR - connecting Crisp to blockchain time through new BlockListener, ThresholdQueue, and CallbackQueue infrastructure.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ry/1020-blockchain-time-draft-2

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.

@ryardley ryardley changed the base branch from main to ry/1020-prefactor-integrate-registry November 25, 2025 20:13
@ryardley ryardley changed the title Connect CRISP to blockchain time feat: connect crisp to blockchain time Nov 25, 2025
@ryardley ryardley changed the base branch from ry/1020-prefactor-integrate-registry to main November 25, 2025 22:06
@vercel vercel Bot temporarily deployed to Preview – enclave-docs November 26, 2025 02:13 Inactive
@vercel vercel Bot temporarily deployed to Preview – crisp November 26, 2025 02:13 Inactive
@vercel vercel Bot temporarily deployed to Preview – crisp November 26, 2025 02:33 Inactive
@vercel vercel Bot temporarily deployed to Preview – enclave-docs November 26, 2025 02:33 Inactive
@vercel vercel Bot temporarily deployed to Preview – crisp November 26, 2025 03:09 Inactive
@vercel vercel Bot temporarily deployed to Preview – enclave-docs November 26, 2025 03:09 Inactive
@vercel vercel Bot temporarily deployed to Preview – crisp November 26, 2025 03:51 Inactive
@vercel vercel Bot temporarily deployed to Preview – enclave-docs November 26, 2025 03:51 Inactive
@vercel vercel Bot temporarily deployed to Preview – crisp November 26, 2025 04:15 Inactive
@vercel vercel Bot temporarily deployed to Preview – enclave-docs November 26, 2025 04:15 Inactive
@vercel vercel Bot temporarily deployed to Preview – crisp November 26, 2025 19:13 Inactive
@vercel vercel Bot temporarily deployed to Preview – enclave-docs November 26, 2025 19:13 Inactive
@vercel vercel Bot temporarily deployed to Preview – enclave-docs November 26, 2025 19:15 Inactive
@vercel vercel Bot temporarily deployed to Preview – crisp November 26, 2025 19:15 Inactive

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

🧹 Nitpick comments (1)
examples/CRISP/packages/crisp-contracts/hardhat.config.ts (1)

75-78: Mining config fits blockchain‑time usage; confirm EDR support and consider configurability

This mining: { auto: false, interval: 1000 } setup makes sense for deterministic block‑time progression driving CRISP behavior and shouldn’t affect Hardhat’s default hardhat network. Two minor suggestions:

  1. Consider making the interval configurable (e.g., via env or a shared test constant), so you can easily speed up local/test runs or align it precisely with CRISP timeout/interval assumptions.
  2. Since this network uses type: 'edr-simulated', please confirm that the EDR/Anvil integration actually respects the mining field here (and doesn’t ignore or reject it), to avoid surprises where blocks don’t advance as expected.
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 35107ad and 1dac4a3.

📒 Files selected for processing (2)
  • examples/CRISP/packages/crisp-contracts/hardhat.config.ts (1 hunks)
  • examples/CRISP/scripts/dev.sh (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • examples/CRISP/scripts/dev.sh
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: test_net
  • GitHub Check: test_contracts
  • GitHub Check: build_e3_support_risc0
  • GitHub Check: crisp_rust_unit
  • GitHub Check: build_sdk
  • GitHub Check: rust_unit
  • GitHub Check: rust_integration
  • GitHub Check: integration_prebuild
  • GitHub Check: build_enclave_cli
  • GitHub Check: Build & Push Image
  • GitHub Check: Build & Push Image

@ryardley ryardley requested a review from cedoor November 26, 2025 19:24
cedoor
cedoor previously approved these changes Nov 26, 2025

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

Last commits look ok to me, there's an error in crisp e2e tests tho.

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

🧹 Nitpick comments (2)
deploy/local/start.sh (1)

132-132: Ensure file ends with a trailing newline.

Bash best practice is to include a trailing newline at the end of scripts. The final echo statement should be followed by a newline character.

Apply this diff to add the trailing newline:

-echo "🚨 CRISP development environment stopped" 
+echo "🚨 CRISP development environment stopped"

Note: Ensure the file ends with a newline after this line.

packages/enclave-contracts/hardhat.config.ts (1)

111-118: Confirm intent of local as an EDR‑simulated, URL‑less network

Switching local to type: "edr-simulated" without a url (and sharing chainId 31337 with hardhat) is a non‑trivial behavioral change from a classic HTTP localhost network. Please double‑check:

  • Any scripts/CI that use --network local aren’t relying on networks.local.url or RPC_URL.
  • The duplication with the hardhat network (same chainId, similar type) is intentional and documented somewhere (even a brief comment here) so future readers understand when to use hardhat vs local.

If everything already uses the new EDR flow, then this looks fine; otherwise, it might be worth either keeping a small url-based network around or adding a comment to make the new semantics explicit.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1dac4a3 and 05d073e.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (12)
  • deploy/local/contracts.sh (1 hunks)
  • deploy/local/start.sh (2 hunks)
  • docs/pages/CRISP/setup.mdx (1 hunks)
  • examples/CRISP/packages/crisp-contracts/hardhat.config.ts (1 hunks)
  • examples/CRISP/scripts/crisp_deploy.sh (1 hunks)
  • examples/CRISP/scripts/dev.sh (1 hunks)
  • packages/enclave-contracts/README.md (2 hunks)
  • packages/enclave-contracts/hardhat.config.ts (1 hunks)
  • templates/default/package.json (1 hunks)
  • templates/default/scripts/dev_ciphernodes.sh (1 hunks)
  • tests/integration/base.sh (4 hunks)
  • tests/integration/persist.sh (4 hunks)
✅ Files skipped from review due to trivial changes (1)
  • deploy/local/contracts.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • examples/CRISP/scripts/dev.sh
🧰 Additional context used
🧠 Learnings (12)
📚 Learning: 2025-09-19T11:16:53.825Z
Learnt from: cedoor
Repo: gnosisguild/enclave PR: 752
File: packages/enclave-contracts/contracts/Enclave.sol:15-17
Timestamp: 2025-09-19T11:16:53.825Z
Learning: The Enclave contract in the gnosisguild/enclave repository has not been deployed yet as of September 2025, so storage layout considerations for upgradeable contracts don't apply to current changes.

Applied to files:

  • packages/enclave-contracts/README.md
📚 Learning: 2025-09-11T13:09:03.800Z
Learnt from: ctrlc03
Repo: gnosisguild/enclave PR: 677
File: packages/enclave-contracts/scripts/deployAndSave/naiveRegistryFilter.ts:30-31
Timestamp: 2025-09-11T13:09:03.800Z
Learning: In Hardhat v3 deployment scripts, use `(await signer.provider?.getNetwork())?.name ?? "localhost"` instead of `hre.globalOptions.network` to reliably get the network name, as `hre.globalOptions.network` can be undefined in some contexts.

Applied to files:

  • packages/enclave-contracts/README.md
  • examples/CRISP/packages/crisp-contracts/hardhat.config.ts
  • templates/default/package.json
  • packages/enclave-contracts/hardhat.config.ts
📚 Learning: 2024-09-26T04:12:09.345Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 107
File: tests/basic_integration/test.sh:103-114
Timestamp: 2024-09-26T04:12:09.345Z
Learning: In `tests/basic_integration/test.sh`, the user prefers not to refactor the ciphernode addition section to reduce duplication.

Applied to files:

  • tests/integration/base.sh
  • tests/integration/persist.sh
  • templates/default/scripts/dev_ciphernodes.sh
📚 Learning: 2024-10-23T01:59:27.215Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 156
File: tests/basic_integration/test.sh:21-21
Timestamp: 2024-10-23T01:59:27.215Z
Learning: In `tests/basic_integration/test.sh`, the hardcoded `CIPHERNODE_SECRET` is acceptable for testing purposes and does not need to be changed.

Applied to files:

  • tests/integration/base.sh
  • tests/integration/persist.sh
  • templates/default/scripts/dev_ciphernodes.sh
📚 Learning: 2024-11-25T09:47:48.863Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 184
File: packages/ciphernode/net/tests/entrypoint.sh:4-8
Timestamp: 2024-11-25T09:47:48.863Z
Learning: When reviewing test scripts like `packages/ciphernode/net/tests/entrypoint.sh`, avoid suggesting additional error handling and cleanup for `iptables` commands, as it may not be necessary.

Applied to files:

  • tests/integration/base.sh
  • tests/integration/persist.sh
  • templates/default/scripts/dev_ciphernodes.sh
📚 Learning: 2025-10-10T12:56:40.538Z
Learnt from: 0xjei
Repo: gnosisguild/enclave PR: 830
File: templates/default/README.md:123-128
Timestamp: 2025-10-10T12:56:40.538Z
Learning: In the Enclave repository, the hard-coded Hardhat development private key `0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80` is acceptable in template README files and documentation for local testing/interaction purposes.

Applied to files:

  • tests/integration/base.sh
  • examples/CRISP/packages/crisp-contracts/hardhat.config.ts
  • tests/integration/persist.sh
  • packages/enclave-contracts/hardhat.config.ts
📚 Learning: 2025-11-05T14:12:57.814Z
Learnt from: ctrlc03
Repo: gnosisguild/enclave PR: 963
File: examples/CRISP/client/package.json:25-25
Timestamp: 2025-11-05T14:12:57.814Z
Learning: In the Enclave/CRISP codebase, `enclave-e3/sdk` and `crisp-e3/sdk` are different packages: `enclave-e3/sdk` is the general Enclave SDK, while `crisp-e3/sdk` is the CRISP-specific SDK. The CRISP client (`examples/CRISP/client`) intentionally depends on `enclave-e3/sdk`, not `crisp-e3/sdk`.

Applied to files:

  • deploy/local/start.sh
📚 Learning: 2025-08-25T10:28:56.174Z
Learnt from: ctrlc03
Repo: gnosisguild/enclave PR: 657
File: Cargo.toml:32-34
Timestamp: 2025-08-25T10:28:56.174Z
Learning: The examples/CRISP directory has its own Cargo.toml workspace configuration with members like "server", "wasm-crypto", "program/core", "program/client", etc. The root workspace intentionally excludes "examples/CRISP/server", "examples/CRISP/program", and "examples/CRISP/wasm-crypto" to prevent double workspace membership, which is the correct approach for self-contained example workspaces.

Applied to files:

  • deploy/local/start.sh
📚 Learning: 2025-09-11T13:09:03.800Z
Learnt from: ctrlc03
Repo: gnosisguild/enclave PR: 677
File: packages/enclave-contracts/scripts/deployAndSave/naiveRegistryFilter.ts:30-31
Timestamp: 2025-09-11T13:09:03.800Z
Learning: In Hardhat v3, hre.network.name is not available anymore. Use hre.globalOptions.network to get the network name instead.

Applied to files:

  • examples/CRISP/packages/crisp-contracts/hardhat.config.ts
  • packages/enclave-contracts/hardhat.config.ts
📚 Learning: 2024-10-08T19:45:18.209Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 107
File: tests/basic_integration/test.sh:92-102
Timestamp: 2024-10-08T19:45:18.209Z
Learning: In the `tests/basic_integration/test.sh` script, it's acceptable not to redirect output of background `ciphernode` processes to log files.

Applied to files:

  • tests/integration/persist.sh
📚 Learning: 2024-10-23T01:59:42.967Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 156
File: packages/ciphernode/tests/tests/test_aggregation_and_decryption.rs:274-274
Timestamp: 2024-10-23T01:59:42.967Z
Learning: In the `packages/ciphernode/tests/tests/test_aggregation_and_decryption.rs` file and other test files within this project, hardcoding `CIPHERNODE_SECRET` is acceptable for testing purposes.

Applied to files:

  • tests/integration/persist.sh
📚 Learning: 2025-09-11T12:56:39.601Z
Learnt from: ctrlc03
Repo: gnosisguild/enclave PR: 677
File: packages/enclave-contracts/test/Enclave.spec.ts:804-807
Timestamp: 2025-09-11T12:56:39.601Z
Learning: In Hardhat v3, the chai matchers syntax changed to support multiple network connections: `.to.not.be.revert(ethers)` is the correct new syntax, replacing the old `.to.not.be.reverted` (without parameters). The ethers object must be passed as a parameter to the revert/reverted matchers in Hardhat v3. Similarly, `.revertedWithoutReason(ethers)` replaces `.revertedWithoutReason`.

Applied to files:

  • packages/enclave-contracts/hardhat.config.ts
🧬 Code graph analysis (1)
tests/integration/base.sh (2)
tests/integration/fns.sh (2)
  • heading (53-60)
  • waiton (66-71)
packages/enclave-sdk/src/utils.ts (1)
  • sleep (38-40)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: test_contracts
  • GitHub Check: build_sdk
  • GitHub Check: build_enclave_cli
  • GitHub Check: integration_prebuild
  • GitHub Check: test_net
  • GitHub Check: rust_unit
  • GitHub Check: build_e3_support_risc0
  • GitHub Check: crisp_rust_unit
  • GitHub Check: rust_integration
  • GitHub Check: Build & Push Image
  • GitHub Check: Build & Push Image
🔇 Additional comments (10)
deploy/local/start.sh (2)

71-71: Standardization to local network alias.

This change aligns well with the PR objective to standardize deployment and testing workflows on the local network alias instead of localhost.


86-88: Verify network parameter consistency across deployment commands.

Lines 86–88 still reference --network "localhost" in the pnpm ciphernode:add calls, while line 71 was updated to use --network local. Given the PR's objective to standardize on the local network alias, confirm whether these references should also be updated to --network "local" for consistency.

templates/default/package.json (1)

10-10: Deploy script now targets local network consistently

Switching the deploy script to --network local matches the rest of the repo’s network naming and keeps template behavior aligned with the new default.

packages/enclave-contracts/README.md (1)

44-45: Docs updated to use --network local

Using --network local in these examples keeps the README consistent with the updated Hardhat network name and other scripts. No further changes needed here.

Also applies to: 99-100

templates/default/scripts/dev_ciphernodes.sh (1)

55-59: Ciphernode admin-add now points at local network

All ciphernode:admin-add calls use --network local, matching the rest of the tooling and avoiding the old localhost alias mismatch.

docs/pages/CRISP/setup.mdx (1)

234-235: CRISP setup docs correctly reference local network

Updating the deploy step to --network local keeps the guide in sync with the Hardhat config and other CRISP scripts.

examples/CRISP/scripts/crisp_deploy.sh (1)

11-12: CRISP deploy script aligned with networks.local

Using --network local for both clean and full deploy is consistent with the CRISP hardhat config and avoids relying on the deprecated localhost alias.

tests/integration/base.sh (1)

20-94: Integration test flow now targets local network consistently

All pnpm CLI calls in this script now use --network local, which keeps the integration tests aligned with the updated Hardhat network naming without altering control flow.

tests/integration/persist.sh (1)

20-99: Persist integration test switched to local network

The updated --network local flags keep this script consistent with the rest of the integration suite and the configured Hardhat network, without changing the underlying test behavior.

examples/CRISP/packages/crisp-contracts/hardhat.config.ts (1)

68-79: Based on my verification:

Hardhat v3 network configuration is valid and correctly implemented

The networks.local configuration uses the standard Hardhat v3 pattern established throughout the repository:

  • type: 'edr-simulated' is consistently used for local/hardhat networks across 4 config files
  • chainType: 'l1' is the standard pairing with edr-simulated networks
  • mining: { auto: false, interval: 1000 } is valid for Hardhat v3 and implements the documented behavior of disabling automatic mining with 1-second interval blocks (matching CRISP's predictable block-time requirement)

TypeScript strict mode (enabled in tsconfig.json) would catch any schema violations, and no compilation errors are reported. The mining configuration aligns with comments in the template scripts that describe this exact pattern.

@vercel vercel Bot temporarily deployed to Preview – enclave-docs November 26, 2025 20:46 Inactive
@vercel vercel Bot temporarily deployed to Preview – crisp November 26, 2025 20:46 Inactive
@vercel vercel Bot temporarily deployed to Preview – enclave-docs November 26, 2025 20:53 Inactive
@vercel vercel Bot temporarily deployed to Preview – crisp November 26, 2025 20:53 Inactive

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

🧹 Nitpick comments (1)
packages/enclave-contracts/scripts/deployEnclave.ts (1)

25-27: Ensure networkName reflects the actual Hardhat network when --network is omitted

Changing the fallback from "localhost" to "local" matches the repo-wide alias change, but this still depends on hre.globalOptions.network, which is undefined when the script runs without an explicit --network flag (Hardhat then uses its configured default, often "hardhat"). In that case, autoCleanForLocalhost will receive "local" even if the underlying provider is actually on "hardhat", which could target the wrong ignition state.

Consider deriving the network name from the provider (e.g., via signer.provider.getNetwork().name) and only falling back to a literal default if that’s unavailable, using hre.globalOptions.network as a secondary hint. Based on learnings, hre.globalOptions.network alone is not always reliable in Hardhat v3 deployment scripts.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4637c29 and ada2792.

📒 Files selected for processing (2)
  • packages/enclave-contracts/scripts/deployEnclave.ts (1 hunks)
  • packages/enclave-contracts/scripts/utils.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/enclave-contracts/scripts/utils.ts
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-09-11T13:09:03.800Z
Learnt from: ctrlc03
Repo: gnosisguild/enclave PR: 677
File: packages/enclave-contracts/scripts/deployAndSave/naiveRegistryFilter.ts:30-31
Timestamp: 2025-09-11T13:09:03.800Z
Learning: In Hardhat v3 deployment scripts, use `(await signer.provider?.getNetwork())?.name ?? "localhost"` instead of `hre.globalOptions.network` to reliably get the network name, as `hre.globalOptions.network` can be undefined in some contexts.

Applied to files:

  • packages/enclave-contracts/scripts/deployEnclave.ts
📚 Learning: 2025-09-11T13:09:03.800Z
Learnt from: ctrlc03
Repo: gnosisguild/enclave PR: 677
File: packages/enclave-contracts/scripts/deployAndSave/naiveRegistryFilter.ts:30-31
Timestamp: 2025-09-11T13:09:03.800Z
Learning: In Hardhat v3, hre.network.name is not available anymore. Use hre.globalOptions.network to get the network name instead.

Applied to files:

  • packages/enclave-contracts/scripts/deployEnclave.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: build_enclave_cli
  • GitHub Check: test_contracts
  • GitHub Check: test_net
  • GitHub Check: rust_unit
  • GitHub Check: build_sdk
  • GitHub Check: build_e3_support_dev
  • GitHub Check: integration_prebuild
  • GitHub Check: build_e3_support_risc0
  • GitHub Check: rust_integration
  • GitHub Check: crisp_rust_unit
  • GitHub Check: Build & Push Image

@vercel vercel Bot temporarily deployed to Preview – crisp November 26, 2025 21:20 Inactive
@vercel vercel Bot temporarily deployed to Preview – enclave-docs November 26, 2025 21:20 Inactive
@ryardley ryardley force-pushed the ry/1020-blockchain-time-draft-2 branch from 2de3907 to 4637c29 Compare November 26, 2025 21:53

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

🧹 Nitpick comments (1)
crates/evm-helpers/tests/integration.rs (1)

8-12: Clean up unused and redundant imports.

Line 8 imports BlockHeader but it's not used in the test. Line 11 imports the block_listener module, which appears redundant since BlockListener is already imported from it on line 12.

Apply this diff to remove the unused imports:

-use alloy::consensus::BlockHeader;
 use alloy::providers::ext::AnvilApi;
 use alloy::{node_bindings::Anvil, providers::ProviderBuilder, sol};
-use e3_evm_helpers::block_listener;
 use e3_evm_helpers::{block_listener::BlockListener, event_listener::EventListener};
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5ae8a14 and 08d8a60.

📒 Files selected for processing (1)
  • crates/evm-helpers/tests/integration.rs (2 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2024-09-26T03:11:29.311Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 107
File: packages/ciphernode/sortition/src/distance.rs:1-1
Timestamp: 2024-09-26T03:11:29.311Z
Learning: In `packages/ciphernode/core/src/events.rs`, the import statements use the correct and updated `alloy::primitives` module.

Applied to files:

  • crates/evm-helpers/tests/integration.rs
📚 Learning: 2024-10-22T02:10:34.864Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 145
File: packages/ciphernode/tests/tests/test_aggregation_and_decryption.rs:82-83
Timestamp: 2024-10-22T02:10:34.864Z
Learning: In the file `packages/ciphernode/tests/tests/test_aggregation_and_decryption.rs`, when reviewing test functions like `generate_pk_share`, minor performance optimizations (e.g., minimizing mutex locks) are not a priority.

Applied to files:

  • crates/evm-helpers/tests/integration.rs
📚 Learning: 2025-10-27T15:37:59.138Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 904
File: crates/net/src/bin/p2p_test.rs:22-45
Timestamp: 2025-10-27T15:37:59.138Z
Learning: In test files (especially integration test binaries like p2p_test.rs), suggesting correlation ID filtering for DHT events may be unnecessarily complex since test environments are typically more controlled and false positives are less of a concern.

Applied to files:

  • crates/evm-helpers/tests/integration.rs
🧬 Code graph analysis (1)
crates/evm-helpers/tests/integration.rs (1)
crates/evm-helpers/src/block_listener.rs (1)
  • new (24-29)
🔇 Additional comments (1)
crates/evm-helpers/tests/integration.rs (1)

210-252: Test relies on sleep-based synchronization, which may cause flakiness.

The test uses fixed sleep durations (100ms on line 237 and 1s on line 243) to coordinate listener startup and block processing. This approach could lead to intermittent test failures in CI environments or under system load, as there's no guarantee the listener is ready after 100ms or that all blocks are processed within 1 second.

Consider using synchronization primitives instead of arbitrary sleeps. For example:

  • Use a channel or condition variable to signal when the listener is ready
  • Use a channel to wait for the expected number of block events before asserting
  • Or implement a polling mechanism with a reasonable timeout

Example approach using a channel to signal readiness:

let (ready_tx, mut ready_rx) = tokio::sync::mpsc::channel::<()>(1);
let events_handler = events.clone();

block_listener
    .add_block_handler(move |block| {
        let events = events_handler.clone();
        let blockheight = block.number();
        let ready_tx = ready_tx.clone();
        async move {
            let mut events = events.lock().await;
            events.push(blockheight);
            // Signal when we've collected all expected blocks
            if events.len() == 5 {
                let _ = ready_tx.send(()).await;
            }
            Ok(())
        }
    })
    .await;

// ... start listener ...

provider.anvil_mine(Some(5), None).await?;

// Wait for all blocks with a timeout
tokio::time::timeout(Duration::from_secs(5), ready_rx.recv()).await??;

This would make the test more deterministic and reliable.

⛔ Skipped due to learnings
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 170
File: packages/ciphernode/evm/tests/evm_reader.rs:63-63
Timestamp: 2024-11-05T03:56:22.254Z
Learning: In the Rust test function `test_logs` in `packages/ciphernode/evm/tests/evm_reader.rs`, a sleep duration of 1 millisecond is sufficient for reliable event processing, even in CI environments.
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 904
File: crates/net/src/bin/p2p_test.rs:22-45
Timestamp: 2025-10-27T15:37:59.138Z
Learning: In test files (especially integration test binaries like p2p_test.rs), suggesting correlation ID filtering for DHT events may be unnecessarily complex since test environments are typically more controlled and false positives are less of a concern.
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 145
File: packages/ciphernode/tests/tests/test_aggregation_and_decryption.rs:82-83
Timestamp: 2024-10-22T02:10:34.864Z
Learning: In the file `packages/ciphernode/tests/tests/test_aggregation_and_decryption.rs`, when reviewing test functions like `generate_pk_share`, minor performance optimizations (e.g., minimizing mutex locks) are not a priority.

@ryardley

Copy link
Copy Markdown
Contributor Author

ok fixed!

Comment thread examples/CRISP/packages/crisp-contracts/hardhat.config.ts
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