-
Notifications
You must be signed in to change notification settings - Fork 51
Sortition module: externalize delayed stakes to a library #2111
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
base: fix/penalties-reduce-drawing-odds
Are you sure you want to change the base?
Sortition module: externalize delayed stakes to a library #2111
Conversation
❌ Deploy Preview for kleros-v2-university failed. Why did it fail? →
|
✅ 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-neo ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Caution Review failedFailed to post review comments. Configuration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (13)
⏰ 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). (9)
WalkthroughAdjusts Hardhat optimizer runs. Introduces DelayedStakes queue library and integrates it into Sortition modules. Changes draw to return (address, subcourtID) across interfaces and implementations. Adds per-subcourt juror tracking and penalty application in cores. Replaces penalizeStake with setStakePenalty. Updates tests to new queue/struct APIs. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Core as KlerosCore(Base/University)
participant DK as DisputeKitClassicBase
participant Sort as SortitionModule(Base/University)
Core->>DK: draw(coreDisputeID, nonce)
DK->>Sort: draw(courtKey, coreDisputeID, nonce)
Sort-->>DK: (drawnAddress, fromSubcourtID)
DK-->>Core: (drawnAddress, fromSubcourtID)
alt drawnAddress != 0
Core->>Core: record Round.drawnJurorFromCourtIDs[idx] = fromSubcourtID!=0?fromSubcourtID:courtID
else drawnAddress == 0
Core->>Core: no-op (propagate zeros)
end
sequenceDiagram
autonumber
actor Core as KlerosCore(Base/University)
participant Sort as SortitionModule(Base/University)
participant Courts as Courts Registry
Core->>Core: determine penalizedInCourtID from Round.drawnJurorFromCourtIDs[idx]
Core->>Sort: setStakePenalty(account, penalizedInCourtID, penalty)
Sort-->>Core: (pnkBalance, newCourtStake, availablePenalty)
alt pnkBalance == 0 or vote not active
Core->>Sort: setJurorInactive(account)
else newCourtStake < Courts.minStake(penalizedInCourtID)
Core->>Sort: setStake(account, penalizedInCourtID, 0, 0, 0) %% unstake in subcourt
else
Core->>Core: continue
end
sequenceDiagram
autonumber
actor Ext as External Caller
participant Sort as SortitionModuleBase
participant Lib as DelayedStakes.Queue
participant Core as KlerosCore
Ext->>Sort: setStake(account, courtID, deposit/withdraw)
alt drawing phase
Sort->>Lib: add(account, courtID, stake)
else not drawing
Sort->>Core: setStakeBySortitionModule(account, courtID, stake)
end
Ext->>Sort: executeDelayedStakes(iterations)
Sort->>Lib: execute(Core, iterations)
Lib->>Core: setStakeBySortitionModule(...) per item
Lib-->>Sort: executed? (bool)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
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. ✨ 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 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
PR-Codex overview
This PR primarily focuses on enhancing the staking functionality within the Kleros arbitration system. It introduces a new
DelayedStakes
library for managing delayed stakes, updates function signatures for clarity, and improves gas efficiency.Detailed summary
runs
inhardhat.config.ts
optimizer from 10,000 to 2,000.gasLimit
insetStake
from 300,000 to 500,000.draw
function inIDisputeKit
to returnfromSubcourtID
.setStakePenalty
function inISortitionModule
.penalizeStake
function.draw
function inISortitionModule
to returnfromSubcourtID
.getJurorBalance
to includefromSubcourtID
.DelayedStakes
library for handling delayed stakes.DelayedStakes
library methods.Summary by CodeRabbit