Skip to content

Commit bbcc819

Browse files
committed
fix: feedback from reviews
sanity check in Core._getCompatibleNextRoundSettings(), bug fix in appealCost(), naming of the NextRoundSettingsChanged parameters, better comments describing the NextRoundSettings parameters.
1 parent e2daec5 commit bbcc819

File tree

2 files changed

+34
-29
lines changed

2 files changed

+34
-29
lines changed

contracts/src/arbitration/KlerosCore.sol

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,31 +1080,26 @@ contract KlerosCore is IArbitratorV2, Initializable, UUPSProxiable {
10801080

10811081
/// @notice Gets the cost of appealing a specified dispute.
10821082
/// @param _disputeID The ID of the dispute.
1083-
/// @return cost The appeal cost.
1084-
function appealCost(uint256 _disputeID) public view returns (uint256 cost) {
1083+
/// @return The appeal cost.
1084+
function appealCost(uint256 _disputeID) public view returns (uint256) {
10851085
Dispute storage dispute = disputes[_disputeID];
10861086
Round storage round = dispute.rounds[dispute.rounds.length - 1];
10871087
Court storage court = courts[dispute.courtID];
1088-
10891088
(uint96 newCourtID, , uint256 nbVotesAfterAppeal) = _getCompatibleNextRoundSettings(
10901089
dispute,
10911090
round,
10921091
court,
10931092
_disputeID
10941093
);
1095-
1096-
if (newCourtID != dispute.courtID) {
1097-
// Jump to parent court.
1098-
if (dispute.courtID == GENERAL_COURT) {
1099-
// TODO: Handle the forking when appealed in General court.
1100-
cost = NON_PAYABLE_AMOUNT; // Get the cost of the parent court.
1101-
} else {
1102-
cost = courts[court.parent].feeForJuror * nbVotesAfterAppeal;
1103-
}
1104-
} else {
1105-
// Stay in current court.
1106-
cost = court.feeForJuror * nbVotesAfterAppeal;
1094+
if (newCourtID == dispute.courtID) {
1095+
// No court jump
1096+
return court.feeForJuror * nbVotesAfterAppeal;
1097+
}
1098+
if (dispute.courtID != GENERAL_COURT && newCourtID != FORKING_COURT) {
1099+
// Court jump but not to the Forking court
1100+
return courts[newCourtID].feeForJuror * nbVotesAfterAppeal;
11071101
}
1102+
return NON_PAYABLE_AMOUNT; // Jumping to the Forking Court is not supported yet.
11081103
}
11091104

11101105
/// @notice Gets the start and the end of a specified dispute's current appeal period.
@@ -1256,12 +1251,22 @@ contract KlerosCore is IArbitratorV2, Initializable, UUPSProxiable {
12561251
disputeKitID,
12571252
_round.nbVotes
12581253
);
1259-
1254+
if (
1255+
newCourtID == FORKING_COURT ||
1256+
newCourtID >= courts.length ||
1257+
newDisputeKitID == NULL_DISPUTE_KIT ||
1258+
newDisputeKitID >= disputeKits.length
1259+
) {
1260+
// Falling back to the current court and dispute kit with default nbVotes.
1261+
newCourtID = _dispute.courtID;
1262+
newDisputeKitID = disputeKitID;
1263+
newRoundNbVotes = (_round.nbVotes * 2) + 1;
1264+
}
12601265
// Ensure compatibility between the next round's court and dispute kit.
1261-
if (!courts[newCourtID].supportedDisputeKits[newDisputeKitID] || newDisputeKitID == NULL_DISPUTE_KIT) {
1262-
// Fall back to `DisputeKitClassic` which is always supported.
1266+
if (!courts[newCourtID].supportedDisputeKits[newDisputeKitID]) {
1267+
// Falling back to `DisputeKitClassic` which is always supported and with default nbVotes.
12631268
newDisputeKitID = DISPUTE_KIT_CLASSIC;
1264-
newRoundNbVotes = (_round.nbVotes * 2) + 1; // Reset nbVotes to the default logic.
1269+
newRoundNbVotes = (_round.nbVotes * 2) + 1;
12651270
}
12661271
}
12671272

contracts/src/arbitration/dispute-kits/DisputeKitClassicBase.sol

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
6060

6161
struct NextRoundSettings {
6262
bool enabled; // True if the settings are enabled, false otherwise.
63-
uint96 jumpCourtID; // The ID of the court for the next round. Zero is considered as undefined.
64-
uint256 jumpDisputeKitID; // The ID of the dispute kit for the next round. Zero is considered as undefined.
65-
uint256 jumpDisputeKitIDOnCourtJump; // The ID of the dispute kit if the court jumps and `jumpDisputeKitID` is undefined. Zero is considered as undefined.
66-
uint256 nbVotes; // The number of votes for the next round. Zero is considered as undefined.
63+
uint96 jumpCourtID; // A non-zero value makes the next round use this court ID. Zero is considered as undefined.
64+
uint256 jumpDisputeKitID; // A non-zero value makes the next round use this dispute kit ID. Zero is considered as undefined.
65+
uint256 jumpDisputeKitIDOnCourtJump; // A non-zero value makes the next round use this dispute kit ID ONLY IF the court jumps and `jumpDisputeKitID` is undefined. Zero is considered as undefined.
66+
uint256 nbVotes; // A non-zero value makes the next round use this number of votes. Zero is considered as undefined.
6767
}
6868

6969
// ************************************* //
@@ -130,9 +130,9 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
130130
event ChoiceFunded(uint256 indexed _coreDisputeID, uint256 indexed _coreRoundID, uint256 indexed _choice);
131131

132132
/// @notice To be emitted when the next round settings are changed.
133-
/// @param _currentCourtID The ID of the current court.
133+
/// @param _courtID The ID of the court that the settings are changed for.
134134
/// @param _nextRoundSettings The settings for the next round.
135-
event NextRoundSettingsChanged(uint96 indexed _currentCourtID, NextRoundSettings _nextRoundSettings);
135+
event NextRoundSettingsChanged(uint96 indexed _courtID, NextRoundSettings _nextRoundSettings);
136136

137137
// ************************************* //
138138
// * Modifiers * //
@@ -198,14 +198,14 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
198198
}
199199

200200
/// @notice Changes the settings for the next round.
201-
/// @param _currentCourtID The ID of the current court.
201+
/// @param _courtID The ID of the court that the settings are changed for.
202202
/// @param _nextRoundSettings The settings for the next round.
203203
function changeNextRoundSettings(
204-
uint96 _currentCourtID,
204+
uint96 _courtID,
205205
NextRoundSettings memory _nextRoundSettings
206206
) external onlyByOwner {
207-
courtIDToNextRoundSettings[_currentCourtID] = _nextRoundSettings;
208-
emit NextRoundSettingsChanged(_currentCourtID, _nextRoundSettings);
207+
courtIDToNextRoundSettings[_courtID] = _nextRoundSettings;
208+
emit NextRoundSettingsChanged(_courtID, _nextRoundSettings);
209209
}
210210

211211
// ************************************* //

0 commit comments

Comments
 (0)