Skip to content

Conversation

@jaybuidl
Copy link
Member

@jaybuidl jaybuidl commented Oct 17, 2025

PR-Codex overview

This PR focuses on optimizing the stake setting functionality in the KlerosCore and KlerosCoreUniversity contracts, while adding error handling for stake delays in the SortitionModule. It adjusts the optimizer settings and enhances function return types and event emissions.

Detailed summary

  • Changed optimizer.runs from 1000 to 800 in hardhat.config.ts.
  • Updated setStakeBySortitionModule functions in KlerosCore and KlerosCoreUniversity to return a bool indicating success.
  • Added StakeDelayedExecutionFailed event in SortitionModule for failed stake executions.
  • Modified the handling of delayed stakes to emit the new event on failure.

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

Summary by CodeRabbit

  • New Features

    • Added event notification for failed delayed stake executions, improving transparency on operation failures.
  • Bug Fixes

    • Stake operations now return success/failure status indicators to callers, enabling better error detection.
  • Chores

    • Tuned compiler optimization settings for improved build efficiency.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 17, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This change modifies stake-setting operations in the Kleros arbitration system to return success/failure status. The setStakeBySortitionModule function now returns a boolean across KlerosCore and its university variant, and delayed stake execution checks this return value, emitting an event on failure instead of silently proceeding. Compiler optimizer settings are also adjusted.

Changes

Cohort / File(s) Change Summary
Compiler Configuration
contracts/hardhat.config.ts
Reduced Solidity optimizer runs from 1000 to 800 under viaIR-enabled settings.
Core Stake-Setting API
contracts/src/arbitration/KlerosCore.sol, contracts/src/arbitration/university/KlerosCoreUniversity.sol
Updated setStakeBySortitionModule function signature to return bool, propagating the result from the internal _setStake call to callers instead of discarding it. Added return documentation.
Delayed Stake Execution
contracts/src/arbitration/SortitionModule.sol
Added new event StakeDelayedExecutionFailed(address indexed \_address, uint96 indexed \_courtID, uint256 \_amount). Modified executeDelayedStakes loop to check the boolean return value of core.setStakeBySortitionModule(...) and emit the failure event if false, while still removing the processed delayed stake entry.

Sequence Diagram

sequenceDiagram
    actor Caller
    participant SortitionModule
    participant KlerosCore
    
    Caller->>SortitionModule: executeDelayedStakes()
    loop for each delayed stake
        SortitionModule->>KlerosCore: setStakeBySortitionModule(account, courtID, stake)
        alt Success
            KlerosCore-->>SortitionModule: true
            SortitionModule->>SortitionModule: delete delayed stake entry
        else Failure
            KlerosCore-->>SortitionModule: false
            SortitionModule->>SortitionModule: emit StakeDelayedExecutionFailed
            SortitionModule->>SortitionModule: delete delayed stake entry
        end
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

The changes follow a consistent pattern across related files—updating function signatures to return a boolean and adding corresponding error-handling logic. While three files are affected, the modifications are straightforward and homogeneous. The compiler configuration change is cosmetic. No complex logic or architectural changes are introduced.

Possibly related PRs

  • #2127 — Directly overlaps with this PR's changes to KlerosCore.setStakeBySortitionModule return type and SortitionModule.executeDelayedStakes error handling logic.

Suggested reviewers

  • unknownunknown1

Poem

🐰 A rabbit hops through the stake-setting spree,
Where booleans now tell the tale true or not be,
Failed executions emit their cry,
While optimizers tune, oh so sly!
Success flows clear from dawn to dusk.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/extra-event-delayed-stakes-failure

📜 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 ca59e71 and 780e00a.

📒 Files selected for processing (4)
  • contracts/hardhat.config.ts (1 hunks)
  • contracts/src/arbitration/KlerosCore.sol (1 hunks)
  • contracts/src/arbitration/SortitionModule.sol (2 hunks)
  • contracts/src/arbitration/university/KlerosCoreUniversity.sol (1 hunks)

Comment @coderabbitai help to get the list of available commands and usage tips.

@jaybuidl jaybuidl merged commit c279eff into dev Oct 17, 2025
5 of 6 checks passed
@jaybuidl jaybuidl deleted the feat/extra-event-delayed-stakes-failure branch October 17, 2025 12:45
@sonarqubecloud
Copy link

@netlify
Copy link

netlify bot commented Oct 17, 2025

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

Name Link
🔨 Latest commit 780e00a
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-testnet-devtools/deploys/68f23a065fe9c800088e2ae1

@netlify
Copy link

netlify bot commented Oct 17, 2025

Deploy Preview for kleros-v2-neo ready!

Name Link
🔨 Latest commit 780e00a
🔍 Latest deploy log https://app.netlify.com/projects/kleros-v2-neo/deploys/68f23a06d3106e0008ff9bb6
😎 Deploy Preview https://deploy-preview-2182--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 17, 2025

Deploy Preview for kleros-v2-testnet ready!

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SortitionModule: do we need to emit an event to track failed delayed stakes execution?

2 participants