-
Notifications
You must be signed in to change notification settings - Fork 50
fix(ShutterDK): tie recovery commit #2175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for kleros-v2-neo ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
❌ Deploy Preview for kleros-v2-testnet-devtools failed. Why did it fail? →
|
✅ Deploy Preview for kleros-v2-testnet ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
WalkthroughDerive commit on-chain from Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Caller
participant DK as DisputeKit(Shutter|Gated)
participant Core as Core/_castCommit
Note over Caller,DK: castCommitShutter(coreDisputeID, voteIDs, recoveryCommit, justification, identity, encryptedVote)
Caller->>DK: castCommitShutter(...)
DK->>DK: justificationHash = keccak256(bytes(justification))
DK->>DK: commit = keccak256(abi.encode(recoveryCommit, justificationHash))
DK->>Core: _castCommit(coreDisputeID, voteIDs, commit, identity, encryptedVote)
Core-->>DK: result
DK-->>Caller: emit CommitCastShutter(commit, recoveryCommit, ...)
alt non-juror reveal/hash path
Note over DK: voteHash = keccak256(abi.encode( keccak256(abi.encodePacked(choice, salt)), justificationHash ))
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (1)📚 Learning: 2025-09-30T17:18:12.895Z
Applied to files:
⏰ 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). (15)
🔇 Additional comments (3)
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.
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)
contracts/src/arbitration/dispute-kits/DisputeKitGatedShutter.sol (1)
114-136
: LGTM! On-chain commit derivation improves security.The change to derive the commit on-chain from
_recoveryCommit
and_justification
ensures that the commitment structure is always correctly formed. This prevents potential issues where an incorrectly constructed commit could be submitted.Consider using
string calldata _justification
instead ofstring memory
for better gas efficiency:function castCommitShutter( uint256 _coreDisputeID, uint256[] calldata _voteIDs, bytes32 _recoveryCommit, - string memory _justification, + string calldata _justification, bytes32 _identity, bytes calldata _encryptedVote ) external notJumped(_coreDisputeID) {While the conversion to
bytes(_justification)
for hashing will copy to memory anyway, usingcalldata
signals intent and may provide minor gas savings in some scenarios.contracts/src/arbitration/dispute-kits/DisputeKitShutter.sol (1)
98-120
: LGTM! On-chain commit derivation improves security.The change to derive the commit on-chain from
_recoveryCommit
and_justification
ensures that the commitment structure is always correctly formed. This prevents potential issues where an incorrectly constructed commit could be submitted.Consider using
string calldata _justification
instead ofstring memory
for better gas efficiency:function castCommitShutter( uint256 _coreDisputeID, uint256[] calldata _voteIDs, bytes32 _recoveryCommit, - string memory _justification, + string calldata _justification, bytes32 _identity, bytes calldata _encryptedVote ) external notJumped(_coreDisputeID) {While the conversion to
bytes(_justification)
for hashing will copy to memory anyway, usingcalldata
signals intent and may provide minor gas savings in some scenarios.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
contracts/src/arbitration/dispute-kits/DisputeKitGatedShutter.sol
(3 hunks)contracts/src/arbitration/dispute-kits/DisputeKitShutter.sol
(3 hunks)contracts/test/arbitration/dispute-kit-shutter.ts
(22 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: jaybuidl
PR: kleros/kleros-v2#2145
File: contracts/src/arbitration/dispute-kits/DisputeKitClassicBase.sol:277-286
Timestamp: 2025-09-30T17:18:12.895Z
Learning: In DisputeKitClassicBase.sol's castCommit function, jurors are allowed to re-submit commits during the commit period. The implementation uses a commitCount variable to track only first-time commits (where commit == bytes32(0)) so that totalCommitted is not incremented when a juror updates their existing commit.
📚 Learning: 2025-09-30T17:18:12.895Z
Learnt from: jaybuidl
PR: kleros/kleros-v2#2145
File: contracts/src/arbitration/dispute-kits/DisputeKitClassicBase.sol:277-286
Timestamp: 2025-09-30T17:18:12.895Z
Learning: In DisputeKitClassicBase.sol's castCommit function, jurors are allowed to re-submit commits during the commit period. The implementation uses a commitCount variable to track only first-time commits (where commit == bytes32(0)) so that totalCommitted is not incremented when a juror updates their existing commit.
Applied to files:
contracts/src/arbitration/dispute-kits/DisputeKitShutter.sol
contracts/test/arbitration/dispute-kit-shutter.ts
contracts/src/arbitration/dispute-kits/DisputeKitGatedShutter.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). (14)
- GitHub Check: Redirect rules - kleros-v2-testnet
- GitHub Check: Redirect rules - kleros-v2-testnet
- GitHub Check: Header rules - kleros-v2-testnet
- GitHub Check: Header rules - kleros-v2-testnet
- GitHub Check: Redirect rules - kleros-v2-testnet-devtools
- GitHub Check: Pages changed - kleros-v2-testnet
- GitHub Check: Pages changed - kleros-v2-testnet
- GitHub Check: Header rules - kleros-v2-testnet-devtools
- GitHub Check: Redirect rules - kleros-v2-neo
- GitHub Check: Pages changed - kleros-v2-testnet-devtools
- GitHub Check: Header rules - kleros-v2-neo
- GitHub Check: Pages changed - kleros-v2-neo
- GitHub Check: Analyze (javascript)
- GitHub Check: hardhat-tests
🔇 Additional comments (4)
contracts/src/arbitration/dispute-kits/DisputeKitGatedShutter.sol (1)
172-185
: LGTM! Hash logic aligns with on-chain commit construction.The updated hash logic for non-jurors now correctly mirrors the commit structure by first hashing
(choice, salt)
to produce the recovery commit, then encoding it with the justification hash. This ensures consistency between commit construction incastCommitShutter
and vote validation incastVoteShutter
.contracts/test/arbitration/dispute-kit-shutter.ts (2)
95-108
: LGTM! Test helper correctly reflects on-chain commit structure.The
generateCommitments
helper now properly constructs the full commit by encoding the recovery commit and justification hash as two separatebytes32
values. This aligns with the contract's on-chain commit derivation logic.
623-637
: LGTM! Hash computation test validates the new structure.The test correctly verifies that
hashVote
for non-jurors produces a hash matching the commit structure:keccak256(abi.encode(recoveryCommit, justificationHash))
whererecoveryCommit = keccak256(abi.encode([choice, salt]))
.contracts/src/arbitration/dispute-kits/DisputeKitShutter.sol (1)
156-169
: LGTM! Hash logic aligns with on-chain commit construction.The updated hash logic for non-jurors now correctly mirrors the commit structure by first hashing
(choice, salt)
to produce the recovery commit, then encoding it with the justification hash. This ensures consistency between commit construction incastCommitShutter
and vote validation incastVoteShutter
.
|
PR-Codex overview
This PR focuses on updating the
castCommitShutter
function in theDisputeKitGatedShutter
andDisputeKitShutter
contracts to improve handling of justification and commitment hashes. It streamlines the parameters and updates the hash computation logic.Detailed summary
castCommitShutter
parameters to includejustificationHash
andidentity
._commit
and changed_recoveryCommit
to be used with the new justification approach.recoveryCommit
andjustificationHash
.Summary by CodeRabbit
New Features
Tests