refactor: remove slot empty endpoint from crisp server#1386
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughThis PR removes the separate slot-empty API and changes slot lookup semantics: Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Client SDK
participant Server as CRISP Server
participant Contract as CRISPProgram Contract
rect rgba(100,150,200,0.5)
Note over Client,Contract: Previous Flow (with isSlotEmpty)
Client->>Server: isSlotEmpty(e3Id, address)
Server->>Contract: getSlotIndex(e3Id, address)
Contract-->>Server: uint40 (reverts if empty)
Server-->>Client: {is_empty: bool}
alt slot not empty
Client->>Server: getPreviousCiphertext(e3Id, address)
Server->>Contract: getSlotIndex(e3Id, address)
Contract-->>Server: uint40
Server-->>Client: Uint8Array
end
end
rect rgba(150,200,100,0.5)
Note over Client,Contract: New Flow (direct call)
Client->>Server: getPreviousCiphertext(e3Id, address)
Server->>Contract: getSlotIndex(e3Id, address)
Contract-->>Server: int40 (-1 if empty)
alt slot exists
Server-->>Client: Uint8Array
else slot empty
Server-->>Client: 404 / undefined
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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.
🧹 Nitpick comments (1)
examples/CRISP/crates/evm_helpers/src/lib.rs (1)
25-25: Align ABI return width: Solidity declaresint40, binding declaresint256.The contract's
getSlotIndexfunction returnsint40(line 244 in CRISPProgram.sol), but the Rust binding declaresint256(line 25). This works via ABI sign-extension, but explicitly matching the return type widths or documenting the intentional widening will reduce maintenance risk and improve code clarity.The negative sentinel handling (lines 143–147) correctly interprets negative values as empty slots, so the current implementation is functionally sound.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@examples/CRISP/crates/evm_helpers/src/lib.rs` at line 25, The generated binding for function getSlotIndex currently declares the return as int256 while the Solidity contract (CRISPProgram.sol) returns int40; update the ABI/binding declaration for getSlotIndex to match the contract's return width (int40) so the binding signature and generated types align, or if you intentionally widen to 256 bits, add a clear comment in the binding next to getSlotIndex explaining the deliberate sign-extension widening and why negative sentinel handling remains valid (refer to getSlotIndex and the sentinel logic in CRISPProgram.sol).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@examples/CRISP/crates/evm_helpers/src/lib.rs`:
- Line 25: The generated binding for function getSlotIndex currently declares
the return as int256 while the Solidity contract (CRISPProgram.sol) returns
int40; update the ABI/binding declaration for getSlotIndex to match the
contract's return width (int40) so the binding signature and generated types
align, or if you intentionally widen to 256 bits, add a clear comment in the
binding next to getSlotIndex explaining the deliberate sign-extension widening
and why negative sentinel handling remains valid (refer to getSlotIndex and the
sentinel logic in CRISPProgram.sol).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d7442819-5132-4dc3-b415-5a61de12a527
📒 Files selected for processing (9)
examples/CRISP/crates/evm_helpers/src/lib.rsexamples/CRISP/packages/crisp-contracts/contracts/CRISPProgram.solexamples/CRISP/packages/crisp-sdk/README.mdexamples/CRISP/packages/crisp-sdk/src/constants.tsexamples/CRISP/packages/crisp-sdk/src/sdk.tsexamples/CRISP/packages/crisp-sdk/src/state.tsexamples/CRISP/packages/crisp-sdk/tests/vote.test.tsexamples/CRISP/server/src/server/models.rsexamples/CRISP/server/src/server/routes/state.rs
💤 Files with no reviewable changes (2)
- examples/CRISP/packages/crisp-sdk/src/constants.ts
- examples/CRISP/server/src/server/models.rs
- cargo-chef v0.1.77 requires Rust 1.88 - Resolves Docker build failure at cargo install step Made-with: Cursor
Closes #1155
Summary by CodeRabbit
Breaking Changes
API Updates
Tests