-
Notifications
You must be signed in to change notification settings - Fork 51
KlerosCore: do not pass the period to voting if all the commits are cast #2085
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-testnet ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
WalkthroughRemoves the areCommitsAllCast(_disputeID) check in passPeriod of KlerosCoreBase.sol so Commit→Vote transitions depend only on elapsed time since lastPeriodChange; reverts if the commit window hasn't passed. No public APIs changed. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as Caller
participant Core as KlerosCoreBase
participant Dispute as Dispute
Caller->>Core: passPeriod(disputeID)
Core->>Dispute: read period, lastPeriodChange
alt Period == Commit
alt time window not elapsed
Core-->>Caller: revert CommitPeriodNotPassed
else time window elapsed
Core->>Dispute: set period = Vote
Core-->>Caller: success
end
else other periods
Core->>Dispute: handle per existing logic (unchanged)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15–20 minutes Possibly related PRs
Suggested reviewers
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the "Integrations" page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
⏰ 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). (3)
✨ Finishing Touches🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for kleros-v2-testnet-devtools ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
❌ Deploy Preview for kleros-v2-university failed. Why did it fail? →
|
✅ Deploy Preview for kleros-v2-neo ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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
🔭 Outside diff range comments (1)
contracts/src/arbitration/KlerosCoreBase.sol (1)
569-574
: Add explicit commit→vote gating tests for hidden-votes courtsTo prevent regressions after removing the early-all-commits shortcut in passPeriod, add tests that:
- Verify that in a hidden-votes court, calling
passPeriod(disputeID)
duringPeriod.commit
always reverts withCommitPeriodNotPassed()
until the full commit duration has elapsed—even if all commits have been cast.- After advancing
block.timestamp
bytimesPerPeriod[uint256(Period.commit)]
,passPeriod(disputeID)
succeeds and moves the dispute toPeriod.vote
.- Cover edge cases where
timesPerPeriod[commit] == timesPerPeriod[vote]
andtimesPerPeriod[commit] > timesPerPeriod[vote]
.Update the existing suite in
contracts/test/foundry/KlerosCore.t.sol
:
- Around lines 1599–1617: replace early-all-commits assertions with time-warp + revert/assert sequences.
- Around lines 1890–1894: do likewise for the second test scenario.
Optionally, clean up any leftover production code paths that relied on
areCommitsAllCast
for gating (the script confirms its only remaining references are in the test files).
🧹 Nitpick comments (1)
contracts/src/arbitration/KlerosCoreBase.sol (1)
569-571
: Tighten and future-proof the inline commentStrengthen the rationale and mark it as a temporary workaround. This improves maintainability for future contributors.
Apply this diff to reword the comment:
- // Note that we do not want to pass to Voting period if all the commits are cast because it breaks the Shutter auto-reveal currently. + // Do not fast-forward to Period.vote when all commits are in. + // Shutter currently schedules decryption relative to the commit window; early transition shortens the reveal window + // and may break auto-reveal. This is a temporary workaround until event-based decryption is deployed.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
contracts/src/arbitration/KlerosCoreBase.sol
(1 hunks)
⏰ 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-university
- GitHub Check: Header rules - kleros-v2-university
- GitHub Check: Pages changed - kleros-v2-university
- GitHub Check: Redirect rules - kleros-v2-testnet-devtools
- GitHub Check: Header rules - kleros-v2-testnet-devtools
- GitHub Check: Pages changed - kleros-v2-testnet-devtools
- 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: Pages changed - kleros-v2-testnet
- GitHub Check: Pages changed - kleros-v2-testnet
- GitHub Check: Analyze (javascript)
- GitHub Check: contracts-testing
🔇 Additional comments (1)
contracts/src/arbitration/KlerosCoreBase.sol (1)
569-574
: Explicitly time-gating Commit->Vote transition to preserve Shutter auto-reveal — LGTMRemoving the early fast-forward (based on “all commits cast”) and relying solely on the commit period timeout is aligned with the PR’s objective and prevents the Shutter auto-reveal from being broken. No ABI changes; gas slightly improves by avoiding a DK call here.
d875d8c
to
257870c
Compare
|
It turns out that the Commit period optimization is really close to breaking the Shutter auto-reveal automation. In the Beta dispute 88, decryption time was scheduled barely 30 minutes before the end of the reveal period, leaving about ~3 runs of the bot.
For a court with an equal duration for the commit and reveal period, if all the commits are cast in the first 5 minutes in the period, the decryption time falls ~5 minutes before the end of the reveal period (depending on when the bot passed the period from commit to reveal exactly).
If the same thing happens in a court where the commit period is longer than the reveal period, then it cannot be auto-reveal at all, the decryption time falls after the end of the reveal period.
So in the short term and until Shutter releases event-based decryption, we should revert the optimisation of the commit period. We can keep voting and appeal period optimisations. The impact is only slowing down non-Shutter commit-reveal disputes.
PR-Codex overview
This PR focuses on fixing the transition between periods in the
KlerosCore
smart contract to prevent issues with the auto-reveal process when all commits are cast. It updates the logic to ensure that the voting period is only entered when appropriate.Detailed summary
KlerosCore.t.sol
.KlerosCoreBase.sol
logic to ensure theCommitPeriodNotPassed
revert is triggered appropriately.CHANGELOG.md
to reflect the fix and version bump for@kleros/vea-contracts
.Summary by CodeRabbit
Bug Fixes
Documentation