Skip to content

refactor: add prettier plugin for solidity#1054

Merged
cedoor merged 2 commits into
mainfrom
refactor/prettier-sol
Dec 1, 2025
Merged

refactor: add prettier plugin for solidity#1054
cedoor merged 2 commits into
mainfrom
refactor/prettier-sol

Conversation

@cedoor

@cedoor cedoor commented Nov 28, 2025

Copy link
Copy Markdown
Contributor

Adds the Prettier Solidity plugin and formats Solidity files across the codebase. Updates .prettierrc.json and formats contract files in crates/, examples/CRISP, and templates/ for consistent formatting.

Summary by CodeRabbit

  • Chores

    • Added Solidity support to the project's formatting configuration and updated formatting scripts to include .sol files.
  • Style

    • Applied widespread formatting and consistency updates across contracts and docs (indentation, quoting, line breaks).
  • New Features

    • Introduced complete mock and example contract implementations that add new public-facing constants, state, events, and validation/verification APIs for testing and examples.

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

@vercel

vercel Bot commented Nov 28, 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 Dec 1, 2025 3:54pm
enclave-docs Ready Ready Preview Comment Dec 1, 2025 3:54pm

@coderabbitai

coderabbitai Bot commented Nov 28, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Adds Prettier Solidity plugin and includes .sol in formatting scripts; applies widespread formatting to Solidity fixtures/docs/templates; and introduces full implementations for MockCRISPProgram and MyProgram with new public state, errors, events, and validate/validateInput/verify flows.

Changes

Cohort / File(s) Summary
Prettier config & scripts
/.prettierrc.json, /package.json
Add prettier-plugin-solidity to Prettier plugins and include *.sol in format and format:check scripts.
Formatting: test fixtures & support
crates/evm-helpers/tests/fixtures/emit_logs.sol, crates/evm-helpers/tests/fixtures/fake_enclave.sol, crates/evm/tests/fixtures/emit_logs.sol, crates/indexer/tests/fixtures/emit_logs.sol, crates/indexer/tests/fixtures/fake_enclave.sol, crates/support/contracts/ImageID.sol, crates/support/tests/Elf.sol
Whitespace and layout normalization (events, structs, functions) with no semantic changes.
Formatting: docs & templates
docs/pages/building-with-enclave.mdx, docs/pages/computation-flow.mdx, docs/pages/write-e3-contract.mdx, templates/.../contracts/Mocks/MockRISC0Verifier.sol
Reformatted code examples and contract snippets (single-line vs multi-line signatures); no API changes.
Formatting: mock contracts
examples/CRISP/.../contracts/Mocks/MockEnclave.sol, examples/CRISP/.../contracts/Mocks/MockRISC0Verifier.sol, examples/CRISP/.../contracts/Mocks/RiscZeroGroth16Verifier.sol
Import spacing/quote normalization and indentation changes only; behavior unchanged.
MockCRISPProgram implementation
examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockCRISPProgram.sol
New comprehensive implementation: public constants, state, mappings, RoundData struct, custom errors, InputPublished event, constructor, setters, getParamsHash, validate, validateInput, decodeTally, verify, and internal encodeLengthPrefixAndHash.
MyProgram implementation
templates/default/contracts/MyProgram.sol
Replaces skeletal contract with full implementation mirroring MockCRISPProgram: adds constants, state, mappings, errors, events, constructor, validate/validateInput/verify, and helper serialization logic.
Minor string quoting
examples/CRISP/packages/crisp-contracts/contracts/CRISPProgram.sol
Normalized string quote style (single → double) in keccak256 and imports; no functional change.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Caller as Client
    participant Program as ProgramContract
    participant Enclave as Enclave (IEnclave)
    participant Verifier as RiscZeroVerifier

    Caller->>Program: validate(e3Id, seed, e3ProgramParams, computeProviderParams)
    Program-->>Program: check authorization/initialization, store paramsHash
    Program->>Enclave: call validate (initiate enclave run)
    Enclave-->>Program: returns ciphertextOutputHash
    Program->>Verifier: verify(ciphertextOutputHash, proof) [journal = ciphertextHash|paramsHash|inputRoot]
    Verifier-->>Program: verification result (bool)
    Program-->>Caller: returns encryptionSchemeId / verification outcome

    Note right of Program: validateInput invoked separately to extract/persist input
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

  • Files needing careful review:
    • examples/CRISP/.../MockCRISPProgram.sol — authorization checks, params hashing, journal layout, tally decoding and index/weighting math.
    • templates/default/contracts/MyProgram.sol — ensure interface compatibility and correctness of implementation details.
    • Prettier config and package.json — confirm script globs and plugin loading behave as expected in CI.

Possibly related PRs

Suggested labels

crisp

Suggested reviewers

  • ctrlc03

Poem

I hop through diff and tidy code tonight,
Prettier trims my fur and makes it bright,
New programs hum, verify and count each vote,
I munch on semicolons and happily emote,
🐰✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding the Prettier Solidity plugin and applying formatting to Solidity files across the repository.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/prettier-sol

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.

@cedoor cedoor changed the title refactor: add prettier plugin for solidity refactor: add prettier plugin for solidity [skip-line-limit] Nov 28, 2025
@cedoor cedoor changed the title refactor: add prettier plugin for solidity [skip-line-limit] refactor: add prettier plugin for solidity Nov 28, 2025

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

Caution

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

⚠️ Outside diff range comments (1)
package.json (1)

72-72: Update prettier-plugin-solidity to v2.x for Prettier 3.x compatibility.

Version 1.2.0 is incompatible with Prettier 3.1.1. Prettier 3.x introduced breaking plugin API changes; the v1 series was built for Prettier 2.x. Update to the latest v2.1.0 (or minimum v2.0.0) which supports Prettier 3.x:

"prettier-plugin-solidity": "^2.1.0",
🧹 Nitpick comments (1)
examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockCRISPProgram.sol (1)

112-114: Consider validating _imageId is non-zero.

Unlike setVerifier, this setter doesn't validate the input. If a zero imageId would cause verification failures, consider adding a validation check for consistency.

 function setImageId(bytes32 _imageId) external onlyOwner {
+    require(_imageId != bytes32(0), "Invalid image ID");
     imageId = _imageId;
 }
📜 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 9ac6408 and 85db766.

📒 Files selected for processing (18)
  • .prettierrc.json (1 hunks)
  • crates/evm-helpers/tests/fixtures/emit_logs.sol (1 hunks)
  • crates/evm-helpers/tests/fixtures/fake_enclave.sol (1 hunks)
  • crates/evm/tests/fixtures/emit_logs.sol (1 hunks)
  • crates/indexer/tests/fixtures/emit_logs.sol (1 hunks)
  • crates/indexer/tests/fixtures/fake_enclave.sol (1 hunks)
  • crates/support/contracts/ImageID.sol (1 hunks)
  • crates/support/tests/Elf.sol (1 hunks)
  • docs/pages/building-with-enclave.mdx (3 hunks)
  • docs/pages/computation-flow.mdx (2 hunks)
  • docs/pages/write-e3-contract.mdx (3 hunks)
  • examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockCRISPProgram.sol (1 hunks)
  • examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockEnclave.sol (1 hunks)
  • examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockRISC0Verifier.sol (1 hunks)
  • examples/CRISP/packages/crisp-contracts/contracts/Mocks/RiscZeroGroth16Verifier.sol (1 hunks)
  • package.json (1 hunks)
  • templates/default/contracts/Mocks/MockRISC0Verifier.sol (1 hunks)
  • templates/default/contracts/MyProgram.sol (1 hunks)
🧰 Additional context used
🧠 Learnings (10)
📚 Learning: 2024-10-01T02:51:17.718Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 119
File: packages/evm/contracts/test/MockE3Program.sol:15-17
Timestamp: 2024-10-01T02:51:17.718Z
Learning: In mock contracts used for testing, it's acceptable for functions to lack access control since they do not pose security risks.

Applied to files:

  • examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockEnclave.sol
  • templates/default/contracts/Mocks/MockRISC0Verifier.sol
  • examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockRISC0Verifier.sol
📚 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:

  • examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockEnclave.sol
  • docs/pages/building-with-enclave.mdx
📚 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/contracts/Mocks/MockEnclave.sol
  • crates/indexer/tests/fixtures/fake_enclave.sol
  • crates/evm-helpers/tests/fixtures/fake_enclave.sol
📚 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/contracts/Mocks/MockEnclave.sol
  • docs/pages/building-with-enclave.mdx
  • templates/default/contracts/MyProgram.sol
  • examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockCRISPProgram.sol
📚 Learning: 2024-11-03T10:47:35.993Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 170
File: packages/ciphernode/evm/tests/fixtures/emit_logs.sol:7-11
Timestamp: 2024-11-03T10:47:35.993Z
Learning: In the `emit_logs.sol` Solidity contract, explicit visibility modifiers for state variables are not required.

Applied to files:

  • crates/indexer/tests/fixtures/emit_logs.sol
  • crates/evm-helpers/tests/fixtures/emit_logs.sol
  • crates/evm/tests/fixtures/emit_logs.sol
📚 Learning: 2024-11-03T11:00:21.089Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 170
File: packages/ciphernode/evm/tests/evm_reader.rs:14-18
Timestamp: 2024-11-03T11:00:21.089Z
Learning: The `emit_logs.json` fixture file in `packages/ciphernode/evm/tests/fixtures/` is generated during the build process and is not committed to the repository.

Applied to files:

  • crates/indexer/tests/fixtures/emit_logs.sol
  • crates/evm-helpers/tests/fixtures/emit_logs.sol
📚 Learning: 2024-11-05T06:49:46.285Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 173
File: packages/ciphernode/enclave_node/src/datastore.rs:14-16
Timestamp: 2024-11-05T06:49:46.285Z
Learning: In `packages/ciphernode/enclave_node/src/datastore.rs`, for internal functions like `get_in_mem_store`, adding extensive documentation and error handling may not be necessary if they are not client-facing.

Applied to files:

  • docs/pages/building-with-enclave.mdx
📚 Learning: 2024-11-05T06:48:58.177Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 173
File: packages/ciphernode/config/src/app_config.rs:13-21
Timestamp: 2024-11-05T06:48:58.177Z
Learning: In the `packages/ciphernode/config/src/app_config.rs` file, for the `Contract` enum, the team prefers to use `String` type for `address` fields, relying on parsing to handle validation, instead of using the `Address` type.

Applied to files:

  • docs/pages/building-with-enclave.mdx
📚 Learning: 2024-11-05T06:56:49.157Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 173
File: packages/ciphernode/enclave_node/src/aggregator.rs:0-0
Timestamp: 2024-11-05T06:56:49.157Z
Learning: `RegistryFilterSol` does not have a reader and does not require a repository reader or deploy block when calling `RegistryFilterSol::attach` in `packages/ciphernode/enclave_node/src/aggregator.rs`.

Applied to files:

  • docs/pages/building-with-enclave.mdx
📚 Learning: 2024-10-22T03:39:29.448Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 145
File: packages/ciphernode/evm/src/enclave_sol_reader.rs:87-89
Timestamp: 2024-10-22T03:39:29.448Z
Learning: In the `ciphernode` project, specifically in `packages/ciphernode/evm/src/enclave_sol_reader.rs`, the method `EnclaveSolReader::attach` should be retained even if it directly calls `EvmEventReader::attach` without additional processing. Avoid suggesting its removal in future reviews.

Applied to files:

  • docs/pages/building-with-enclave.mdx
  • crates/indexer/tests/fixtures/fake_enclave.sol
  • crates/evm-helpers/tests/fixtures/fake_enclave.sol
⏰ 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_net
  • GitHub Check: integration_prebuild
  • GitHub Check: build_sdk
  • GitHub Check: build_e3_support_dev
  • GitHub Check: test_contracts
  • GitHub Check: rust_integration
  • GitHub Check: build_e3_support_risc0
  • GitHub Check: rust_unit
  • GitHub Check: crisp_rust_unit
  • GitHub Check: Build & Push Image
🔇 Additional comments (27)
package.json (1)

16-17: LGTM! Solidity file support added to formatting scripts.

The addition of .sol to the format and format:check scripts correctly enables Prettier formatting for Solidity files across the repository.

crates/support/tests/Elf.sol (1)

22-23: LGTM! Formatting adjustment applied.

The indentation and line wrapping have been adjusted according to the Prettier Solidity plugin rules. The file is auto-generated (as noted in line 17), so the machine-specific path is expected.

crates/evm-helpers/tests/fixtures/emit_logs.sol (1)

10-33: LGTM! Formatting applied consistently.

All changes are formatting-only: event and function declarations have been collapsed to single lines where appropriate, and the empty string literal has been normalized from "" to '' per the Prettier configuration's singleQuote: true setting. No functional changes detected.

.prettierrc.json (1)

12-12: LGTM! Prettier Solidity plugin configured.

The addition of the prettier-plugin-solidity plugin correctly enables Solidity-aware formatting across the repository, which is the core objective of this PR.

crates/support/contracts/ImageID.sol (1)

22-22: LGTM! Indentation normalized.

The indentation has been adjusted from 4 spaces to 2 spaces, aligning with the tabWidth: 2 setting in .prettierrc.json. No functional changes.

examples/CRISP/packages/crisp-contracts/contracts/Mocks/RiscZeroGroth16Verifier.sol (1)

8-12: LGTM! Import and constructor formatting applied.

The import statements have been normalized to use single quotes and adjusted spacing, and the constructor has been collapsed to a single line. All changes are formatting-only with no functional impact.

docs/pages/computation-flow.mdx (2)

65-65: LGTM! Function signature formatting improved.

The function signature has been collapsed to a single line for improved readability in the documentation.


79-83: LGTM! Function signature formatting improved.

The function signature line breaks have been adjusted for better readability in the documentation.

templates/default/contracts/Mocks/MockRISC0Verifier.sol (1)

8-13: LGTM! Import and function formatting applied.

The import statement has been normalized to use single quotes with adjusted spacing, and function declarations have been collapsed to single lines. All changes are formatting-only with no functional impact.

docs/pages/building-with-enclave.mdx (1)

22-37: LGTM - documentation formatting update.

The formatting changes to the Solidity code examples are consistent and improve readability.

examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockRISC0Verifier.sol (1)

8-13: LGTM - formatting changes only.

The import statement and function declarations have been reformatted consistently. No functional changes detected.

templates/default/contracts/MyProgram.sol (1)

8-12: Formatting looks good overall.

The import statements and contract structure formatting are consistent, aside from the string literal issue noted separately.

Also applies to: 15-16, 19-112

examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockEnclave.sol (1)

8-10: LGTM on formatting changes.

The import statements and function formatting are consistent, aside from the string literal syntax issues noted separately.

Also applies to: 13-13, 15-17, 19-29, 32-37

crates/indexer/tests/fixtures/fake_enclave.sol (2)

10-14: Approve formatting changes pending syntax fix.

The event declarations, function formatting, and struct layout changes are consistent with Prettier configuration, once the string literal syntax is corrected.

Also applies to: 17-40, 42-48, 62-76


49-56: Critical: Multiple invalid string literal syntax errors.

Lines 49-56 contain multiple string literals using single quotes ('), which is invalid Solidity syntax. String literals must use double quotes ("). This will cause compilation failures.

Apply this diff to fix all string literals:

-      encryptionSchemeId: bytes32(keccak256('AES-256-GCM')),
+      encryptionSchemeId: bytes32(keccak256("AES-256-GCM")),
       e3Program: 0x7F3E4df648B8Cb96C1D343be976b91B97CaD5c21,
       decryptionVerifier: 0x4B0D8c2E5f7a6c832f8b16d3aB0e7F5d9E9B24b1,
-      e3ProgramParams: abi.encode(42, 'testParams'),
-      customParams: abi.encode('custom_params'),
-      committeePublicKey: bytes32(keccak256('committee_public_key')),
-      ciphertextOutput: bytes32(keccak256('encrypted_data')),
-      plaintextOutput: abi.encode('decrypted_result')
+      e3ProgramParams: abi.encode(42, "testParams"),
+      customParams: abi.encode("custom_params"),
+      committeePublicKey: bytes32(keccak256("committee_public_key")),
+      ciphertextOutput: bytes32(keccak256("encrypted_data")),
+      plaintextOutput: abi.encode("decrypted_result")

Likely an incorrect or invalid review comment.

docs/pages/write-e3-contract.mdx (1)

26-31: LGTM - documentation formatting improvements.

The Solidity code examples have been reformatted consistently and remain syntactically correct.

Also applies to: 52-56, 82-85

crates/evm/tests/fixtures/emit_logs.sol (1)

10-14: Approve formatting changes.

The event declaration and function formatting are consistent with the Prettier configuration.

Also applies to: 16-16, 20-28

crates/indexer/tests/fixtures/emit_logs.sol (1)

10-10: Based on my verification, I can now provide the rewritten review comment.


Formatting changes look good. Solidity compilation will be validated automatically by CI.

The Prettier indentation adjustments are consistent with the project's configuration. Since the CI workflow (ci.yml) installs solc and runs cargo test, the Solidity file compilation will be validated automatically during the test execution via the build_fixtures.sh script. No manual verification is needed—just ensure the PR passes CI checks.

crates/evm-helpers/tests/fixtures/fake_enclave.sol (2)

10-58: LGTM! Formatting changes only.

The events, emitter functions, and getE3 function have been reformatted for consistent styling. No functional changes detected.


61-76: Formatting looks good.

The E3 struct fields are reformatted without any semantic changes.

examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockCRISPProgram.sol (7)

17-96: PR claims formatting-only but this file contains substantial new logic.

The PR objective states this is a formatting change (Prettier Solidity plugin), but this file introduces significant new functionality: state variables, mappings, errors, events, constructor validation, and multiple new functions. This inconsistency should be clarified in the PR description.


86-96: Constructor validation looks good.

Proper zero-address checks for critical contract dependencies. The enclave is correctly added to authorizedContracts.


102-108: LGTM!

The single-use guard pattern is correctly implemented.


133-139: LGTM!

Authorization and re-initialization guards are properly implemented.


141-148: LGTM!

The empty data check and decoding logic are appropriate. Note that abi.decode will revert naturally if the data format doesn't match the expected tuple structure.


192-203: LGTM!

The existence check and journal construction appear correct. The function properly reverts via the verifier if proof verification fails.


209-215: LGTM!

The encoding correctly places length prefix and hash bytes at 4-byte intervals, matching the expected RISC Zero journal format. Each encoded segment uses exactly 132 bytes.

Comment thread crates/evm/tests/fixtures/emit_logs.sol Outdated
Comment thread crates/indexer/tests/fixtures/emit_logs.sol Outdated
Comment thread examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockEnclave.sol Outdated
Comment thread templates/default/contracts/MyProgram.sol Outdated
@cedoor cedoor requested a review from 0xjei December 1, 2025 15:40
@cedoor cedoor enabled auto-merge (squash) December 1, 2025 15:52
@cedoor cedoor force-pushed the refactor/prettier-sol branch from 14b8151 to 308253c Compare December 1, 2025 15:52

@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

@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

♻️ Duplicate comments (1)
examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockCRISPProgram.sol (1)

154-186: Potential underflow if tally.length < 56.

This issue was previously identified: if the decoded tally array has fewer than 56 elements (2 × HALF_LARGEST_MINIMUM_DEGREE), the subtractions at lines 164-165 will underflow in Solidity versions prior to 0.8.0, or revert due to automatic overflow checking in 0.8.0+.

Add a bounds check before computing the indices:

     uint256[] memory tally = abi.decode(e3.plaintextOutput, (uint256[]));
+    require(tally.length >= HALF_LARGEST_MINIMUM_DEGREE * 2, "Tally too short");

     uint256 halfD = tally.length / 2;
🧹 Nitpick comments (2)
templates/default/contracts/MyProgram.sol (2)

22-24: Consider making constructor-set variables immutable.

enclave, verifier, and imageId are only assigned in the constructor and never modified. Declaring them as immutable saves gas on reads and signals intent.

-  IEnclave public enclave;
-  IRiscZeroVerifier public verifier;
-  bytes32 public imageId;
+  IEnclave public immutable enclave;
+  IRiscZeroVerifier public immutable verifier;
+  bytes32 public immutable imageId;

106-111: Minor: Inline the offset for clarity.

The startIndex += 4 modifies a local copy, which works but is slightly confusing. Consider inlining the offset in the loop for clarity.

  function encodeLengthPrefixAndHash(bytes memory journal, uint256 startIndex, bytes32 hashVal) internal pure {
    journal[startIndex] = 0x20;
-   startIndex += 4;
    for (uint256 i = 0; i < 32; i++) {
-     journal[startIndex + i * 4] = hashVal[i];
+     journal[startIndex + 4 + i * 4] = hashVal[i];
    }
  }
📜 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 85db766 and 308253c.

📒 Files selected for processing (19)
  • .prettierrc.json (1 hunks)
  • crates/evm-helpers/tests/fixtures/emit_logs.sol (1 hunks)
  • crates/evm-helpers/tests/fixtures/fake_enclave.sol (1 hunks)
  • crates/evm/tests/fixtures/emit_logs.sol (1 hunks)
  • crates/indexer/tests/fixtures/emit_logs.sol (1 hunks)
  • crates/indexer/tests/fixtures/fake_enclave.sol (1 hunks)
  • crates/support/contracts/ImageID.sol (1 hunks)
  • crates/support/tests/Elf.sol (1 hunks)
  • docs/pages/building-with-enclave.mdx (3 hunks)
  • docs/pages/computation-flow.mdx (2 hunks)
  • docs/pages/write-e3-contract.mdx (3 hunks)
  • examples/CRISP/packages/crisp-contracts/contracts/CRISPProgram.sol (2 hunks)
  • examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockCRISPProgram.sol (1 hunks)
  • examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockEnclave.sol (1 hunks)
  • examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockRISC0Verifier.sol (1 hunks)
  • examples/CRISP/packages/crisp-contracts/contracts/Mocks/RiscZeroGroth16Verifier.sol (1 hunks)
  • package.json (1 hunks)
  • templates/default/contracts/Mocks/MockRISC0Verifier.sol (1 hunks)
  • templates/default/contracts/MyProgram.sol (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • examples/CRISP/packages/crisp-contracts/contracts/CRISPProgram.sol
  • crates/support/contracts/ImageID.sol
🚧 Files skipped from review as they are similar to previous changes (9)
  • docs/pages/computation-flow.mdx
  • templates/default/contracts/Mocks/MockRISC0Verifier.sol
  • crates/indexer/tests/fixtures/emit_logs.sol
  • crates/support/tests/Elf.sol
  • crates/evm-helpers/tests/fixtures/fake_enclave.sol
  • crates/evm-helpers/tests/fixtures/emit_logs.sol
  • package.json
  • crates/evm/tests/fixtures/emit_logs.sol
  • crates/indexer/tests/fixtures/fake_enclave.sol
🧰 Additional context used
🧠 Learnings (9)
📚 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/contracts/Mocks/MockEnclave.sol
  • examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockCRISPProgram.sol
  • docs/pages/building-with-enclave.mdx
  • templates/default/contracts/MyProgram.sol
📚 Learning: 2024-10-01T02:51:17.718Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 119
File: packages/evm/contracts/test/MockE3Program.sol:15-17
Timestamp: 2024-10-01T02:51:17.718Z
Learning: In mock contracts used for testing, it's acceptable for functions to lack access control since they do not pose security risks.

Applied to files:

  • examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockEnclave.sol
  • examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockRISC0Verifier.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/contracts/Mocks/MockEnclave.sol
  • templates/default/contracts/MyProgram.sol
📚 Learning: 2024-10-08T19:45:18.209Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 107
File: packages/ciphernode/sortition/src/distance.rs:1-1
Timestamp: 2024-10-08T19:45:18.209Z
Learning: In `packages/ciphernode/core/src/events.rs`, the import statements use the correct and updated `alloy::primitives` module.

Applied to files:

  • docs/pages/building-with-enclave.mdx
📚 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:

  • docs/pages/building-with-enclave.mdx
📚 Learning: 2024-11-05T06:49:46.285Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 173
File: packages/ciphernode/enclave_node/src/datastore.rs:14-16
Timestamp: 2024-11-05T06:49:46.285Z
Learning: In `packages/ciphernode/enclave_node/src/datastore.rs`, for internal functions like `get_in_mem_store`, adding extensive documentation and error handling may not be necessary if they are not client-facing.

Applied to files:

  • docs/pages/building-with-enclave.mdx
📚 Learning: 2024-11-05T06:48:58.177Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 173
File: packages/ciphernode/config/src/app_config.rs:13-21
Timestamp: 2024-11-05T06:48:58.177Z
Learning: In the `packages/ciphernode/config/src/app_config.rs` file, for the `Contract` enum, the team prefers to use `String` type for `address` fields, relying on parsing to handle validation, instead of using the `Address` type.

Applied to files:

  • docs/pages/building-with-enclave.mdx
📚 Learning: 2024-11-05T06:56:49.157Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 173
File: packages/ciphernode/enclave_node/src/aggregator.rs:0-0
Timestamp: 2024-11-05T06:56:49.157Z
Learning: `RegistryFilterSol` does not have a reader and does not require a repository reader or deploy block when calling `RegistryFilterSol::attach` in `packages/ciphernode/enclave_node/src/aggregator.rs`.

Applied to files:

  • docs/pages/building-with-enclave.mdx
📚 Learning: 2024-10-22T03:39:29.448Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 145
File: packages/ciphernode/evm/src/enclave_sol_reader.rs:87-89
Timestamp: 2024-10-22T03:39:29.448Z
Learning: In the `ciphernode` project, specifically in `packages/ciphernode/evm/src/enclave_sol_reader.rs`, the method `EnclaveSolReader::attach` should be retained even if it directly calls `EvmEventReader::attach` without additional processing. Avoid suggesting its removal in future reviews.

Applied to files:

  • docs/pages/building-with-enclave.mdx
⏰ 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). (9)
  • GitHub Check: build_enclave_cli
  • GitHub Check: test_net
  • GitHub Check: test_contracts
  • GitHub Check: build_sdk
  • GitHub Check: integration_prebuild
  • GitHub Check: crisp_rust_unit
  • GitHub Check: rust_integration
  • GitHub Check: rust_unit
  • GitHub Check: Build & Push Image
🔇 Additional comments (14)
.prettierrc.json (1)

12-25: LGTM! Prettier Solidity plugin configuration is correct.

The addition of the Prettier Solidity plugin and the override for .sol files to use double quotes aligns with Solidity's syntax requirements for string literals.

examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockRISC0Verifier.sol (1)

8-13: LGTM! Formatting changes applied consistently.

The formatting adjustments to import statements and function signatures align with the Prettier Solidity plugin configuration. No functional changes detected.

examples/CRISP/packages/crisp-contracts/contracts/Mocks/RiscZeroGroth16Verifier.sol (1)

8-12: LGTM! Formatting changes applied consistently.

Import statement spacing and constructor indentation have been adjusted to match the configured Prettier standards. No functional changes.

examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockEnclave.sol (1)

8-37: LGTM! Formatting changes applied correctly.

The formatting adjustments to import statements, indentation, and multi-line return statements align with the Prettier Solidity plugin configuration. The string literals correctly use double quotes as required by Solidity syntax.

docs/pages/building-with-enclave.mdx (3)

22-36: LGTM! Documentation code examples formatted consistently.

The state variable declarations have been reformatted for consistency with the Prettier Solidity plugin standards.


124-124: LGTM! Function signature formatted consistently.

The validateInput function signature has been reformatted to a single line, consistent with Prettier formatting.


140-146: LGTM! Event declarations formatted consistently.

The event declarations have been reformatted to single-line format, aligning with the Prettier Solidity plugin configuration.

docs/pages/write-e3-contract.mdx (3)

26-31: LGTM! Function signature formatted consistently.

The validate function signature has been reformatted to align with the Prettier Solidity plugin standards.


52-56: LGTM! Function signature formatted consistently.

The verify function signature has been reformatted to match Prettier formatting conventions.


82-85: LGTM! Code example formatted consistently.

The indentation and formatting of the validateInput example function body align with the configured Prettier standards.

templates/default/contracts/MyProgram.sol (3)

57-65: LGTM!

The validation logic correctly checks authorization, prevents re-initialization, stores the params hash, and initializes the input tree.


89-100: LGTM!

The verification logic correctly validates E3 existence, constructs the journal with the expected encoding, and delegates to the RISC Zero verifier.


71-83: Add access control to validateInput or clarify the security model.

The validateInput function lacks authorization checks while validate() strictly restricts access to authorizedContracts or owner(). Since validateInput modifies state (inserting into the input tree), it should either enforce similar access control or document why it's intentionally open. Additionally, the sender parameter is unused despite being passed and documented—consider whether it should be used for validation logic as the interface suggests.

examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockCRISPProgram.sol (1)

192-203: Invalid syntax: custom errors cannot be used with require().

Line 193 uses a custom error with require(), which is invalid Solidity syntax.

Apply this diff to fix the syntax:

   function verify(uint256 e3Id, bytes32 ciphertextOutputHash, bytes memory proof) external view override returns (bool) {
-    require(paramsHashes[e3Id] != bytes32(0), E3DoesNotExist());
+    if (paramsHashes[e3Id] == bytes32(0)) revert E3DoesNotExist();
     bytes32 inputRoot = bytes32(votes[e3Id]._root(TREE_DEPTH));
⛔ Skipped due to learnings
Learnt from: ctrlc03
Repo: gnosisguild/enclave PR: 766
File: packages/enclave-contracts/contracts/registry/BondingRegistry.sol:320-367
Timestamp: 2025-10-07T09:12:52.812Z
Learning: Solidity 0.8.26+ supports using custom errors with require statements in the format `require(condition, CustomError())`. This feature was introduced in 0.8.26 for the IR pipeline and expanded to the legacy pipeline in 0.8.27. Projects using pragma solidity >=0.8.26 (IR) or >=0.8.27 (legacy) can safely use this pattern.

Comment thread templates/default/contracts/MyProgram.sol
@cedoor cedoor merged commit 9bf3db5 into main Dec 1, 2025
26 checks passed
@github-actions github-actions Bot deleted the refactor/prettier-sol branch December 9, 2025 02:51
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