Skip to content

Conversation

@unknownunknown1
Copy link
Contributor

@unknownunknown1 unknownunknown1 commented Oct 27, 2025

PR-Codex overview

This PR focuses on enhancing the period transition logic in the KlerosCore contract to prevent switching to the voting period until all commits are cast. It also updates the test cases to reflect this new logic.

Detailed summary

  • Modified the condition for transitioning from Period.commit to Period.vote to include a check for all commits being cast.
  • Added a revert statement CommitPeriodNotPassed() if the transition conditions are not met.
  • Updated tests to expect a revert when trying to pass the period before all commits are cast.
  • Adjusted comments in the test to clarify the expected behavior regarding period transitions.

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

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Enhanced commit period validation to ensure all commits are cast before advancing to the voting period, preventing premature period transitions during the arbitration process.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 27, 2025

Walkthrough

The Commit period guard in passPeriod flow now enforces that not all commits are cast before allowing period advancement, in addition to existing time-based checks. This prevents early transition to the voting period if commits remain incomplete for the current dispute kit.

Changes

Cohort / File(s) Summary
Commit Period Validation Logic
contracts/src/arbitration/KlerosCore.sol
Modified the Commit period guard to require both time elapsed since last period change AND that not all commits have been cast; reverts with CommitPeriodNotPassed() if either condition fails
Voting Period Tests
contracts/test/foundry/KlerosCore_Voting.t.sol
Updated test expectations to verify passPeriod() reverts with CommitPeriodNotPassed before all commits are cast; restructured test flow to assert all commits are cast before allowing period transition

Sequence Diagram

sequenceDiagram participant Test participant KlerosCore rect rgb(200, 220, 255) Note over Test,KlerosCore: Before all commits cast Test->>KlerosCore: passPeriod(disputeID) KlerosCore->>KlerosCore: Check: time passed ✓ KlerosCore->>KlerosCore: Check: not all commits cast ✓ KlerosCore->>Test: revert CommitPeriodNotPassed() end rect rgb(200, 255, 200) Note over Test,KlerosCore: After all commits cast Test->>KlerosCore: passPeriod(disputeID) KlerosCore->>KlerosCore: Check: time passed ✓ KlerosCore->>KlerosCore: Check: not all commits cast ✗ KlerosCore->>Test: success (advance to voting) end 
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • The logic change is a single conditional addition to guard period advancement
  • Test modifications follow the same pattern change and are straightforward validations
  • Changes are focused and cohesive with minimal file spread

Possibly related PRs

Suggested labels

Type: Feature🗿, Package: Contracts

Suggested reviewers

  • jaybuidl
  • kemuru

Poem

🐰 A commit must finish before votes can flow,
The period guard now blocks the early show,
No rushing past when ballots remain,
All voices cast—then voting takes the reins! 🗳️

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 (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "feat(KC): allow to pass commit period quicker" accurately describes the main change in the changeset. The pull request modifies the commit period guard logic to require that all commits be cast before advancing to the next period, which enables passing the commit period more quickly when all participants have committed early, rather than waiting for the full timer to expire. The title is specific, clear, and directly related to the primary objective of the change. The KC reference (Kleros Core) appropriately identifies the affected component.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/quick-commits

📜 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 32fe70a and 8795f88.

📒 Files selected for processing (2)
  • contracts/src/arbitration/KlerosCore.sol (1 hunks)
  • contracts/test/foundry/KlerosCore_Voting.t.sol (2 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/test/foundry/KlerosCore_Voting.t.sol
  • contracts/src/arbitration/KlerosCore.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). (2)
  • GitHub Check: hardhat-tests
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (3)
contracts/src/arbitration/KlerosCore.sol (1)

711-714: LGTM! Logic enables early commit period passage.

The updated guard correctly allows the commit period to advance if either:

  1. The configured time period has fully elapsed (timeout), OR
  2. All commits have been cast (early passage)

This makes the commit period behavior consistent with the vote period (lines 719-723) and appeal period (lines 728-732), all of which follow the same pattern.

contracts/test/foundry/KlerosCore_Voting.t.sol (2)

97-99: Good test coverage for the early passage guard.

This assertion correctly verifies that the commit period cannot be passed early when only 1 out of 3 jurors has committed, ensuring the guard prevents premature period transitions.


116-118: Excellent demonstration of early passage feature.

By commenting out the time warp and successfully passing the period after all commits are cast, this test clearly demonstrates the new early passage capability. The test confirms that waiting for the full time period is no longer necessary once all jurors have committed.


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.

@netlify
Copy link

netlify bot commented Oct 27, 2025

Deploy Preview for kleros-v2-testnet ready!

Name Link
🔨 Latest commit 8795f88
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-testnet/deploys/68ff905800ca440008e264f3
😎 Deploy Preview https://deploy-preview-2196--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.

@netlify
Copy link

netlify bot commented Oct 27, 2025

Deploy Preview for kleros-v2-neo ready!

Name Link
🔨 Latest commit 8795f88
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-neo/deploys/68ff9058a2c54d00085fa450
😎 Deploy Preview https://deploy-preview-2196--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.

@netlify
Copy link

netlify bot commented Oct 27, 2025

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

Name Link
🔨 Latest commit 8795f88
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-testnet-devtools/deploys/68ff90581d76040008799e1f
@jaybuidl jaybuidl merged commit 2dd02dc into dev Oct 27, 2025
16 of 20 checks passed
@jaybuidl jaybuidl deleted the feat/quick-commits branch October 27, 2025 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants