Skip to content

chore: store e3 requester#1151

Merged
ctrlc03 merged 2 commits into
mainfrom
chore/add-requester
Jan 7, 2026
Merged

chore: store e3 requester#1151
ctrlc03 merged 2 commits into
mainfrom
chore/add-requester

Conversation

@ctrlc03

@ctrlc03 ctrlc03 commented Jan 6, 2026

Copy link
Copy Markdown
Collaborator

fix #1150

Summary by CodeRabbit

  • New Features
    • E3 requests now include requester address tracking. The requester address is captured during E3 creation and propagated through contract events, indexing, and state management layers, enabling complete visibility into the origin of each E3 request across the system.

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

@ctrlc03 ctrlc03 requested a review from hmzakhalid January 6, 2026 21:15
@vercel

vercel Bot commented Jan 6, 2026

Copy link
Copy Markdown

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

2 Skipped Deployments
Project Deployment Review Updated (UTC)
crisp Skipped Skipped Jan 6, 2026 9:17pm
enclave-docs Skipped Skipped Jan 6, 2026 9:17pm

@coderabbitai

coderabbitai Bot commented Jan 6, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR adds a new requester field to the E3 struct across the entire E3 ecosystem—from contract definitions and interfaces to indexers and repositories. The field captures the address of the entity requesting an E3 and propagates it through event handling, indexing, and application logic.

Changes

Cohort / File(s) Summary
Contract Definitions & Interfaces
packages/enclave-contracts/contracts/interfaces/IE3.sol, crates/evm-helpers/src/contracts.rs, crates/evm-helpers/src/events.rs
Added requester: address field to E3 struct definitions; expands data model to track requester identity
Enclave Contract Logic
packages/enclave-contracts/contracts/Enclave.sol
Sets e3.requester = msg.sender during E3 creation; captures requester at request time
Enclave ABI Artifacts
packages/enclave-contracts/artifacts/contracts/interfaces/IEnclave.sol/IEnclave.json
Updated ABI to include requester field in E3 struct (affects getE3 return and E3Requested event); buildInfoId updated
Mock Contracts
examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockEnclave.sol
Added requester: address(0) to E3 struct literal in getE3 return
Indexer Layer
crates/indexer/src/indexer.rs, crates/indexer/src/models.rs
E3Activated handler now assigns requester: e3.requester.to_string(); E3 model struct gains pub requester: String field
CRISP Server Models
examples/CRISP/server/src/server/models.rs
Added pub requester: String field to three structs: E3StateLite, E3, and E3Crisp
CRISP Server Integration
examples/CRISP/server/src/server/indexer.rs, examples/CRISP/server/src/server/repo.rs
E3Requested handler now fetches full E3 details asynchronously and passes requester to initialize_round; initialize_round signature updated to accept requester parameter and thread it through E3Crisp initialization

Sequence Diagram(s)

sequenceDiagram
    participant User as User/Requester
    participant Contract as Enclave Contract
    participant Event as E3Requested Event
    participant Indexer as Indexer
    participant Server as CRISP Server
    participant Repo as Repository

    User->>Contract: request_e3(...)
    activate Contract
    Note over Contract: e3.requester = msg.sender
    Contract->>Event: emit E3Requested(e3, ...)
    deactivate Contract

    Event->>Indexer: E3Requested event (includes e3.requester)
    activate Indexer
    Indexer->>Indexer: Parse and index E3 with requester
    deactivate Indexer

    Event->>Server: E3Requested event
    activate Server
    Server->>Contract: fetch full E3 details (contract.get_e3)
    activate Contract
    Contract-->>Server: return E3 {requester, ...}
    deactivate Contract
    
    Note over Server: Extract requester from E3
    Server->>Repo: initialize_round(..., requester)
    activate Repo
    Repo->>Repo: Create E3Crisp with requester field
    Repo-->>Server: E3Crisp initialized
    deactivate Repo
    deactivate Server
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

crisp

Suggested reviewers

  • hmzakhalid
  • ryardley
  • cedoor

Poem

🐰 Whiskers twitch as requester fields spring to life,
From contract down to server, through indexer's stride,
The E3 now remembers who came to ask,
No more mystery—just identity tracked,
Hopping forward, data flows complete!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore: store e3 requester' accurately and concisely summarizes the main objective of the pull request: adding storage and persistence of the E3 requester address.
Linked Issues check ✅ Passed The pull request successfully implements the requirement to store and persist the E3 requester address across all layers: contract definitions (IE3, IEnclave), implementations (Enclave, MockEnclave), indexing (models, indexer), and repository logic (CRISP server).
Out of Scope Changes check ✅ Passed All changes are directly related to storing the E3 requester as specified in issue #1150. Changes consistently add the requester field across contracts, indexers, and models without introducing unrelated modifications.
✨ Finishing touches
  • 📝 Generate docstrings

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.

@vercel vercel Bot temporarily deployed to Preview – crisp January 6, 2026 21:17 Inactive
@vercel vercel Bot temporarily deployed to Preview – enclave-docs January 6, 2026 21:17 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/server/src/server/indexer.rs (1)

49-78: Avoid redundant RPC call - use event.e3.requester directly.

The E3Requested event already includes the complete E3 struct with the requester field. The additional contract.get_e3() call introduces unnecessary RPC overhead. Other parts of this handler already use event.e3 directly (lines 61, 100).

🔎 Proposed fix to eliminate redundant contract call
-            let contract = ctx.contract();
-
             info!("[e3_id={}] E3Requested: {:?}", e3_id, event);

             async move {
-                let e3 = contract.get_e3(event.e3Id).await?;
-
                 // Convert custom params bytes back to token address and balance threshold.

                 // Use sol_data types instead of primitives
@@ -75,7 +71,7 @@
                     .with_context(|| "Invalid token address")?;

                 // save the e3 details
-                repo.initialize_round(custom_params.token_address, custom_params.balance_threshold, e3.requester.to_string())
+                repo.initialize_round(custom_params.token_address, custom_params.balance_threshold, event.e3.requester.to_string())
                     .await?;
📜 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 ed01af6 and d605566.

📒 Files selected for processing (11)
  • crates/evm-helpers/src/contracts.rs
  • crates/evm-helpers/src/events.rs
  • crates/indexer/src/indexer.rs
  • crates/indexer/src/models.rs
  • examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockEnclave.sol
  • examples/CRISP/server/src/server/indexer.rs
  • examples/CRISP/server/src/server/models.rs
  • examples/CRISP/server/src/server/repo.rs
  • packages/enclave-contracts/artifacts/contracts/interfaces/IEnclave.sol/IEnclave.json
  • packages/enclave-contracts/contracts/Enclave.sol
  • packages/enclave-contracts/contracts/interfaces/IE3.sol
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 139
File: packages/ciphernode/core/src/events.rs:323-323
Timestamp: 2024-10-08T01:50:45.185Z
Learning: When suggesting that instances of `E3Requested` should include `src_chain_id`, double-check to ensure that the field is actually missing before making the suggestion.
📚 Learning: 2024-10-22T03:47:04.014Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 145
File: packages/ciphernode/router/src/e3_request_router.rs:202-235
Timestamp: 2024-10-22T03:47:04.014Z
Learning: In `packages/ciphernode/router/src/e3_request_router.rs`, within the `E3RequestRouter::from_snapshot` method, errors during context restoration propagate upwards due to the `?` operator, and skipping contexts when `repositories.context(&e3_id).read().await?` returns `Ok(None)` is acceptable, as missing snapshots are expected.

Applied to files:

  • examples/CRISP/server/src/server/indexer.rs
📚 Learning: 2024-10-22T03:44:33.301Z
Learnt from: ryardley
Repo: gnosisguild/enclave PR: 145
File: packages/ciphernode/router/src/e3_request_router.rs:126-133
Timestamp: 2024-10-22T03:44:33.301Z
Learning: In `E3RequestRouter::handle` method in `e3_request_router.rs`, `self.repository()` cannot fail, so it's not necessary to handle errors when accessing repositories via `self.repository().repositories()`.

Applied to files:

  • examples/CRISP/server/src/server/indexer.rs
📚 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/contracts/Enclave.sol
📚 Learning: 2025-12-23T17:18:22.421Z
Learnt from: cedoor
Repo: gnosisguild/enclave PR: 1142
File: examples/CRISP/packages/crisp-contracts/contracts/CRISPProgram.sol:141-147
Timestamp: 2025-12-23T17:18:22.421Z
Learning: For Solidity contracts that verify Noir circuit proofs, the verifier's public inputs array must include both the circuit's public inputs and the public outputs. Ensure the verification input array length equals pub_inputs + pub_outputs. Example: a Noir circuit with 3 public inputs and 2064 public outputs should pass an array of length 2067 (3 + 2064). Apply this consistently across all contract verifier implementations and adjust tests accordingly.

Applied to files:

  • packages/enclave-contracts/contracts/Enclave.sol
  • packages/enclave-contracts/contracts/interfaces/IE3.sol
  • examples/CRISP/packages/crisp-contracts/contracts/Mocks/MockEnclave.sol
🧬 Code graph analysis (3)
crates/evm-helpers/src/contracts.rs (1)
crates/config/src/app_config.rs (1)
  • address (307-309)
examples/CRISP/server/src/server/indexer.rs (1)
crates/indexer/src/indexer.rs (1)
  • contract (185-187)
crates/evm-helpers/src/events.rs (2)
crates/evm-helpers/src/contracts.rs (1)
  • address (195-197)
examples/CRISP/crates/evm_helpers/src/lib.rs (1)
  • address (150-152)
⏰ 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_crisp_sdk
  • GitHub Check: build_sdk
  • GitHub Check: integration_prebuild
  • GitHub Check: build_enclave_cli
  • GitHub Check: test_net
  • GitHub Check: build_ciphernode_image
  • GitHub Check: rust_integration
  • GitHub Check: rust_unit
  • GitHub Check: Build & Push Image
🔇 Additional comments (13)
packages/enclave-contracts/contracts/Enclave.sol (1)

260-260: LGTM!

Correctly captures the requester address as msg.sender during E3 creation, consistent with the PR objective to enable refunds and requester-based queries.

packages/enclave-contracts/contracts/interfaces/IE3.sol (1)

30-47: LGTM!

The requester field is properly documented and correctly placed at the end of the struct. Based on learnings, storage layout compatibility isn't a concern since the contract hasn't been deployed yet.

crates/evm-helpers/src/contracts.rs (1)

40-58: LGTM!

The requester field is correctly added to the sol! macro E3 struct, maintaining field order consistency with the Solidity contract definition in IE3.sol.

crates/evm-helpers/src/events.rs (1)

28-45: LGTM!

The requester field is correctly added to the E3 struct for event parsing, maintaining consistency with the contract definition and enabling proper decoding of E3Requested events.

crates/indexer/src/models.rs (1)

29-29: LGTM!

The requester field is correctly added as a String type, consistent with how other address fields (e.g., enclave_address) are stored in this model.

crates/indexer/src/indexer.rs (1)

405-423: LGTM!

The requester field is correctly populated from the contract call result. Unlike E3Requested, the E3Activated event only contains e3Id, expiration, and committeePublicKey, so fetching the full E3 from the contract is necessary here.

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

40-41: LGTM!

The requester field is correctly added to the E3 struct literal, maintaining proper field ordering. Using address(0) as a default value is appropriate for this mock contract.

examples/CRISP/server/src/server/models.rs (3)

180-181: LGTM!

The requester field is correctly added to E3StateLite for exposing the requester in lightweight state representations.


217-219: LGTM!

Good addition of the requester field with a descriptive comment clarifying its purpose.


235-235: LGTM!

The requester field is consistently added to E3Crisp, completing the model updates for the CRISP application.

examples/CRISP/server/src/server/repo.rs (2)

225-243: LGTM!

The requester field is correctly propagated from e3_crisp to the E3StateLite response, ensuring the requester information is available in the lightweight state view.


133-154: No action needed—the existing call site at examples/CRISP/server/src/server/indexer.rs:78 already correctly passes the requester parameter when calling initialize_round.

Likely an incorrect or invalid review comment.

packages/enclave-contracts/artifacts/contracts/interfaces/IEnclave.sol/IEnclave.json (1)

195-200: LGTM!

The ABI artifact correctly reflects the addition of the requester field (type address) to the E3 struct. The field is consistently added as the last member across all struct occurrences: E3Requested event, getE3 output, and request output.

Also applies to: 533-538, 809-814

@ctrlc03 ctrlc03 enabled auto-merge (squash) January 6, 2026 21:23
@ctrlc03 ctrlc03 merged commit 2c68e60 into main Jan 7, 2026
27 checks passed
@ctrlc03 ctrlc03 deleted the chore/add-requester branch January 7, 2026 17:08
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.

Store E3 requester

2 participants