refactor: clean up crisp contracts#1075
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
WalkthroughThe PR refactors the CRISP contract's Merkle root management by replacing the Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
examples/CRISP/packages/crisp-contracts/contracts/CRISPProgram.sol (1)
19-25: Well-structured data consolidation.The
RoundDatastruct effectively consolidates all per-E3 state into a single mapping, improving code organization and clarity.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
examples/CRISP/crates/evm_helpers/src/lib.rs(2 hunks)examples/CRISP/package.json(0 hunks)examples/CRISP/packages/crisp-contracts/contracts/CRISPProgram.sol(4 hunks)examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockCRISPProgram.sol(0 hunks)examples/CRISP/packages/crisp-contracts/deploy/crisp.ts(2 hunks)examples/CRISP/packages/crisp-contracts/package.json(0 hunks)examples/CRISP/packages/crisp-contracts/tests/crisp.contracts.test.ts(2 hunks)examples/CRISP/packages/crisp-sdk/README.md(1 hunks)examples/CRISP/server/src/server/indexer.rs(2 hunks)
💤 Files with no reviewable changes (3)
- examples/CRISP/packages/crisp-contracts/package.json
- examples/CRISP/package.json
- examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockCRISPProgram.sol
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: ctrlc03
Repo: gnosisguild/enclave PR: 996
File: examples/CRISP/packages/crisp-contracts/contracts/CRISPProgram.sol:144-169
Timestamp: 2025-11-12T10:08:30.720Z
Learning: In the CRISP program (examples/CRISP/packages/crisp-contracts/contracts/CRISPProgram.sol), there are plans to move the merkle tree from the Enclave contract to the program contract itself in the future, which would allow direct calls to validateInput to be stored in the merkle tree.
📚 Learning: 2025-11-12T10:08:30.720Z
Learnt from: ctrlc03
Repo: gnosisguild/enclave PR: 996
File: examples/CRISP/packages/crisp-contracts/contracts/CRISPProgram.sol:144-169
Timestamp: 2025-11-12T10:08:30.720Z
Learning: In the CRISP program (examples/CRISP/packages/crisp-contracts/contracts/CRISPProgram.sol), there are plans to move the merkle tree from the Enclave contract to the program contract itself in the future, which would allow direct calls to validateInput to be stored in the merkle tree.
Applied to files:
examples/CRISP/packages/crisp-contracts/tests/crisp.contracts.test.tsexamples/CRISP/packages/crisp-contracts/deploy/crisp.tsexamples/CRISP/server/src/server/indexer.rsexamples/CRISP/crates/evm_helpers/src/lib.rsexamples/CRISP/packages/crisp-contracts/contracts/CRISPProgram.sol
📚 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:
examples/CRISP/packages/crisp-contracts/deploy/crisp.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 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:
examples/CRISP/packages/crisp-contracts/deploy/crisp.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:
examples/CRISP/packages/crisp-contracts/deploy/crisp.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:
examples/CRISP/packages/crisp-sdk/README.md
⏰ 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). (4)
- GitHub Check: rust_integration
- GitHub Check: Build & Push Image
- GitHub Check: build_enclave_cli
- GitHub Check: rust_unit
🔇 Additional comments (8)
examples/CRISP/packages/crisp-sdk/README.md (1)
3-4: LGTM!Minor documentation wording improvement.
examples/CRISP/server/src/server/indexer.rs (1)
145-169: LGTM!The refactored call to
setMerkleRootcorrectly aligns with the simplified contract API. The removal ofbalance_thresholdfrom the contract call is appropriate since it's handled via E3 custom parameters.examples/CRISP/packages/crisp-contracts/deploy/crisp.ts (1)
66-72: LGTM!The deployment path is now simplified by consistently using
CRISPProgramFactory. The library linking syntax for PoseidonT3 is correct.examples/CRISP/packages/crisp-contracts/tests/crisp.contracts.test.ts (1)
111-111: LGTM!Test correctly updated to use the simplified
setMerkleRootAPI.examples/CRISP/crates/evm_helpers/src/lib.rs (1)
82-97: LGTM!The Rust wrapper correctly implements the simplified
setMerkleRootAPI, matching the updated Solidity contract interface.examples/CRISP/packages/crisp-contracts/contracts/CRISPProgram.sol (3)
65-75: LGTM!Constructor properly validates all address parameters against zero addresses and correctly initializes immutable state.
77-85: Verify the one-time merkle root design choice.The
setMerkleRootfunction can only be called once per E3 (Line 82 prevents re-setting). While this appears intentional for immutability, confirm this aligns with the expected workflow. If a merkle root needs correction after being set, there's currently no mechanism to update it.Verify that the one-time setting design meets the intended requirements and consider whether an emergency update mechanism might be needed for operational flexibility.
208-225: LGTM! Clever vote tracking implementation.The
_processVotefunction uses a well-designed pattern: storingindex + 1allows differentiating between "no vote" (0) and "vote at index 0" (stored as 1). This correctly handles both first votes and re-votes.
Closes #1074
Summary by CodeRabbit
Refactor
setRoundDatatosetMerkleRoot, streamlining parameter requirements and improving usabilityChores
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.