Skip to content

Commit 682a857

Browse files
unknownunknown1jaybuidl
authored andcommitted
feat(KC): add disabled to DK and leftover event
1 parent a41294a commit 682a857

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

contracts/hardhat.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const config: HardhatUserConfig = {
2525
enabled: true,
2626
runs: 100,
2727
},
28+
viaIR: true,
2829
},
2930
},
3031
paths: {

contracts/src/arbitration/KlerosCore.sol

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ contract KlerosCore is IArbitrator {
7474
uint256[] children; // List of child dispute kits.
7575
IDisputeKit disputeKit; // The dispute kit implementation.
7676
uint256 depthLevel; // How far this DK is from the root. 0 for root DK.
77+
bool disabled; // True if the dispute kit is disabled and can't be used. This parameter is added preemptively to avoid storage changes in the future.
7778
}
7879

7980
// ************************************* //
@@ -148,6 +149,12 @@ contract KlerosCore is IArbitrator {
148149
int256 _tokenAmount,
149150
int256 _ethAmount
150151
);
152+
event LeftoverRewardSent(
153+
uint256 indexed _disputeID,
154+
uint256 indexed _roundID,
155+
uint256 _tokenAmount,
156+
uint256 _ethAmount
157+
);
151158

152159
// ************************************* //
153160
// * Function Modifiers * //
@@ -193,7 +200,8 @@ contract KlerosCore is IArbitrator {
193200
parent: NULL_DISPUTE_KIT,
194201
children: new uint256[](0),
195202
disputeKit: _disputeKit,
196-
depthLevel: 0
203+
depthLevel: 0,
204+
disabled: false
197205
})
198206
);
199207
emit DisputeKitCreated(DISPUTE_KIT_CLASSIC, _disputeKit, NULL_DISPUTE_KIT);
@@ -290,7 +298,8 @@ contract KlerosCore is IArbitrator {
290298
parent: _parent,
291299
children: new uint256[](0),
292300
disputeKit: _disputeKitAddress,
293-
depthLevel: depthLevel
301+
depthLevel: depthLevel,
302+
disabled: false
294303
})
295304
);
296305

@@ -695,6 +704,7 @@ contract KlerosCore is IArbitrator {
695704
// No one was coherent. Send the rewards to governor.
696705
payable(governor).send(round.totalFeesForJurors);
697706
_safeTransfer(governor, penaltiesInRoundCache);
707+
emit LeftoverRewardSent(_disputeID, _round, penaltiesInRoundCache, round.totalFeesForJurors);
698708
}
699709
}
700710
} else {
@@ -736,11 +746,18 @@ contract KlerosCore is IArbitrator {
736746

737747
if (i == numberOfVotesInRound * 2 - 1) {
738748
// Due to partial coherence of the jurors there might still be a leftover reward. Send it to governor.
749+
uint256 leftoverReward;
750+
uint256 leftoverTokenReward;
739751
if (round.totalFeesForJurors > round.sumRewardPaid) {
740-
payable(governor).send(round.totalFeesForJurors - round.sumRewardPaid);
752+
leftoverReward = round.totalFeesForJurors - round.sumRewardPaid;
753+
payable(governor).send(leftoverReward);
741754
}
742755
if (penaltiesInRoundCache > round.sumTokenRewardPaid) {
743-
_safeTransfer(governor, penaltiesInRoundCache - round.sumTokenRewardPaid);
756+
leftoverTokenReward = penaltiesInRoundCache - round.sumTokenRewardPaid;
757+
_safeTransfer(governor, leftoverTokenReward);
758+
}
759+
if (leftoverReward != 0 || leftoverTokenReward != 0) {
760+
emit LeftoverRewardSent(_disputeID, _round, leftoverTokenReward, leftoverReward);
744761
}
745762
}
746763
}

0 commit comments

Comments
 (0)