Skip to content

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

Merged
merged 3 commits into from
Aug 15, 2025

Conversation

jaybuidl
Copy link
Member

@jaybuidl jaybuidl commented Aug 13, 2025

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

  • Added a check to prevent passing to the Voting period if all commits are cast in KlerosCore.t.sol.
  • Updated the KlerosCoreBase.sol logic to ensure the CommitPeriodNotPassed revert is triggered appropriately.
  • Updated the CHANGELOG.md to reflect the fix and version bump for @kleros/vea-contracts.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • Bug Fixes

    • Voting now begins only after the commit period’s time window elapses, no longer transitioning early when all commits are submitted. This ensures consistent period progression and avoids premature transitions.
  • Documentation

    • Updated the changelog to note the fix regarding commit-to-vote period transition timing.

Copy link

netlify bot commented Aug 13, 2025

Deploy Preview for kleros-v2-testnet ready!

Name Link
🔨 Latest commit 257870c
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-testnet/deploys/689e86bfc2a1da0008dbbb36
😎 Deploy Preview https://deploy-preview-2085--kleros-v2-testnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

coderabbitai bot commented Aug 13, 2025

Walkthrough

Removes 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

Cohort / File(s) Summary of Changes
Arbitration Core Logic
contracts/src/arbitration/KlerosCoreBase.sol
In passPeriod, removed the areCommitsAllCast(_disputeID) gating for Commit→Vote. Now reverts with CommitPeriodNotPassed if the commit window time hasn't elapsed; otherwise advances to Period.vote. Added explanatory comment. No other control-flow or public-signature changes.
Changelog
contracts/CHANGELOG.md
Added Unreleased 0.13.0 Fixed entry documenting the change: do not pass to Voting when all commits are cast to preserve Shutter auto-reveal behavior. Documentation-only change.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15–20 minutes

Possibly related PRs

Suggested reviewers

  • kemuru
  • alcercu

Poem

A hop, a skip, a tick of time,
No need to count each hidden rhyme—
Commit to Vote when clocks align,
Shutter keeps its secret shine.
Thump-thump! says bunny, right on cue. 🐇⏳

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 details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8877044 and 6574140.

📒 Files selected for processing (1)
  • contracts/CHANGELOG.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • contracts/CHANGELOG.md
⏰ 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)
  • GitHub Check: Redirect rules - kleros-v2-testnet
  • GitHub Check: Header rules - kleros-v2-testnet
  • GitHub Check: Pages changed - kleros-v2-testnet
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/no-commit-period-speedup

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Aug 13, 2025

Deploy Preview for kleros-v2-testnet-devtools ready!

Name Link
🔨 Latest commit 257870c
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-testnet-devtools/deploys/689e86bf710571000894da3c
😎 Deploy Preview https://deploy-preview-2085--kleros-v2-testnet-devtools.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

netlify bot commented Aug 13, 2025

Deploy Preview for kleros-v2-university failed. Why did it fail? →

Name Link
🔨 Latest commit 257870c
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-university/deploys/689e86bf2383ea0009d4cc83

Copy link

netlify bot commented Aug 13, 2025

Deploy Preview for kleros-v2-neo ready!

Name Link
🔨 Latest commit 257870c
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-neo/deploys/689e86bf8c7b60000869f9af
😎 Deploy Preview https://deploy-preview-2085--kleros-v2-neo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 courts

To prevent regressions after removing the early-all-commits shortcut in passPeriod, add tests that:

  • Verify that in a hidden-votes court, calling passPeriod(disputeID) during Period.commit always reverts with CommitPeriodNotPassed() until the full commit duration has elapsed—even if all commits have been cast.
  • After advancing block.timestamp by timesPerPeriod[uint256(Period.commit)], passPeriod(disputeID) succeeds and moves the dispute to Period.vote.
  • Cover edge cases where timesPerPeriod[commit] == timesPerPeriod[vote] and timesPerPeriod[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 comment

Strengthen 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

📥 Commits

Reviewing files that changed from the base of the PR and between 5353ccf and 8877044.

📒 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 — LGTM

Removing 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.

coderabbitai[bot]
coderabbitai bot previously approved these changes Aug 13, 2025
@jaybuidl jaybuidl force-pushed the fix/no-commit-period-speedup branch from d875d8c to 257870c Compare August 15, 2025 01:00
@jaybuidl jaybuidl merged commit 257870c into dev Aug 15, 2025
5 checks passed
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant