Skip to content

Commit 5276f64

Browse files
committed
refactor: function renames, removed unnecessary booleans courtJump and disputeKitJump
1 parent 6cbd494 commit 5276f64

File tree

3 files changed

+26
-61
lines changed

3 files changed

+26
-61
lines changed

contracts/src/arbitration/KlerosCore.sol

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -785,13 +785,13 @@ contract KlerosCore is IArbitratorV2, Initializable, UUPSProxiable {
785785
Round storage extraRound = dispute.rounds.push();
786786
uint256 extraRoundID = dispute.rounds.length - 1;
787787

788-
(uint96 newCourtID, uint256 newDisputeKitID, , bool courtJump, ) = _getCourtAndDisputeKitJumps(
788+
(uint96 newCourtID, uint256 newDisputeKitID, ) = _getCompatibleNextRoundSettings(
789789
dispute,
790790
round,
791791
courts[dispute.courtID],
792792
_disputeID
793793
);
794-
if (courtJump) {
794+
if (newCourtID != dispute.courtID) {
795795
emit CourtJump(_disputeID, extraRoundID, dispute.courtID, newCourtID);
796796
}
797797

@@ -1086,14 +1086,14 @@ contract KlerosCore is IArbitratorV2, Initializable, UUPSProxiable {
10861086
Round storage round = dispute.rounds[dispute.rounds.length - 1];
10871087
Court storage court = courts[dispute.courtID];
10881088

1089-
(, , uint256 nbVotesAfterAppeal, bool courtJump, ) = _getCourtAndDisputeKitJumps(
1089+
(uint96 newCourtID, , uint256 nbVotesAfterAppeal) = _getCompatibleNextRoundSettings(
10901090
dispute,
10911091
round,
10921092
court,
10931093
_disputeID
10941094
);
10951095

1096-
if (courtJump) {
1096+
if (newCourtID != dispute.courtID) {
10971097
// Jump to parent court.
10981098
if (dispute.courtID == GENERAL_COURT) {
10991099
// TODO: Handle the forking when appealed in General court.
@@ -1204,12 +1204,14 @@ contract KlerosCore is IArbitratorV2, Initializable, UUPSProxiable {
12041204
Round storage round = dispute.rounds[dispute.rounds.length - 1];
12051205
Court storage court = courts[dispute.courtID];
12061206

1207-
(newCourtID, newDisputeKitID, newRoundNbVotes, courtJump, disputeKitJump) = _getCourtAndDisputeKitJumps(
1207+
(newCourtID, newDisputeKitID, newRoundNbVotes) = _getCompatibleNextRoundSettings(
12081208
dispute,
12091209
round,
12101210
court,
12111211
_disputeID
12121212
);
1213+
courtJump = (newCourtID != dispute.courtID);
1214+
disputeKitJump = (newDisputeKitID != round.disputeKitID);
12131215
}
12141216

12151217
/// @notice Returns the length of disputeKits array.
@@ -1230,48 +1232,35 @@ contract KlerosCore is IArbitratorV2, Initializable, UUPSProxiable {
12301232
// * Internal * //
12311233
// ************************************* //
12321234

1233-
/// @notice Checks whether a dispute will jump to new court/DK and enforces a compatibility check.
1235+
/// @notice Get the next round settings for a given dispute
1236+
/// @dev Enforces a compatibility check between the next round's court and dispute kit.
12341237
/// @param _dispute Dispute data.
12351238
/// @param _round Round ID.
12361239
/// @param _court Current court ID.
12371240
/// @param _disputeID Dispute ID.
12381241
/// @return newCourtID Court ID after jump.
12391242
/// @return newDisputeKitID Dispute kit ID after jump.
12401243
/// @return newRoundNbVotes The number of votes in the new round.
1241-
/// @return courtJump Whether the dispute jumps to a new court or not.
1242-
/// @return disputeKitJump Whether the dispute jumps to a new dispute kit or not.
1243-
function _getCourtAndDisputeKitJumps(
1244+
function _getCompatibleNextRoundSettings(
12441245
Dispute storage _dispute,
12451246
Round storage _round,
12461247
Court storage _court,
12471248
uint256 _disputeID
1248-
)
1249-
internal
1250-
view
1251-
returns (
1252-
uint96 newCourtID,
1253-
uint256 newDisputeKitID,
1254-
uint256 newRoundNbVotes,
1255-
bool courtJump,
1256-
bool disputeKitJump
1257-
)
1258-
{
1249+
) internal view returns (uint96 newCourtID, uint256 newDisputeKitID, uint256 newRoundNbVotes) {
12591250
uint256 disputeKitID = _round.disputeKitID;
1260-
(newCourtID, newDisputeKitID, newRoundNbVotes, courtJump, disputeKitJump) = disputeKits[disputeKitID]
1261-
.getCourtAndDisputeKitJumps(
1262-
_disputeID,
1263-
_dispute.courtID,
1264-
_court.parent,
1265-
_court.jurorsForCourtJump,
1266-
disputeKitID,
1267-
_round.nbVotes
1268-
);
1251+
(newCourtID, newDisputeKitID, newRoundNbVotes) = disputeKits[disputeKitID].getNextRoundSettings(
1252+
_disputeID,
1253+
_dispute.courtID,
1254+
_court.parent,
1255+
_court.jurorsForCourtJump,
1256+
disputeKitID,
1257+
_round.nbVotes
1258+
);
12691259

12701260
// Ensure compatibility between the next round's court and dispute kit.
12711261
if (!courts[newCourtID].supportedDisputeKits[newDisputeKitID] || newDisputeKitID == NULL_DISPUTE_KIT) {
12721262
// Fall back to `DisputeKitClassic` which is always supported.
12731263
newDisputeKitID = DISPUTE_KIT_CLASSIC;
1274-
disputeKitJump = (newDisputeKitID != disputeKitID);
12751264
newRoundNbVotes = (newRoundNbVotes * 2) + 1; // Reset nbVotes to the default logic.
12761265
}
12771266
}

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

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -628,27 +628,17 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
628628
}
629629

630630
/// @inheritdoc IDisputeKit
631-
function getCourtAndDisputeKitJumps(
631+
function getNextRoundSettings(
632632
uint256 /* _coreDisputeID */,
633633
uint96 _currentCourtID,
634634
uint96 _parentCourtID,
635635
uint256 _currentCourtJurorsForJump,
636636
uint256 _currentDisputeKitID,
637637
uint256 _currentRoundNbVotes
638-
)
639-
public
640-
view
641-
virtual
642-
override
643-
returns (
644-
uint96 newCourtID,
645-
uint256 newDisputeKitID,
646-
uint256 newRoundNbVotes,
647-
bool courtJump,
648-
bool disputeKitJump
649-
)
650-
{
638+
) public view virtual override returns (uint96 newCourtID, uint256 newDisputeKitID, uint256 newRoundNbVotes) {
651639
NextRoundSettings storage nextRoundSettings = courtIDToNextRoundSettings[_currentCourtID];
640+
bool courtJump;
641+
bool disputeKitJump;
652642
if (nextRoundSettings.enabled) {
653643
newRoundNbVotes = nextRoundSettings.nbVotes;
654644
newCourtID = nextRoundSettings.jumpCourtID;
@@ -668,9 +658,6 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
668658
if (newDisputeKitID == 0) {
669659
newDisputeKitID = _currentDisputeKitID;
670660
}
671-
if (!disputeKitJump) {
672-
disputeKitJump = (newDisputeKitID != _currentDisputeKitID);
673-
}
674661
}
675662

676663
/// @inheritdoc IDisputeKit

contracts/src/arbitration/interfaces/IDisputeKit.sol

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ interface IDisputeKit {
124124
/// @return Whether the appeal funding is finished.
125125
function isAppealFunded(uint256 _coreDisputeID) external view returns (bool);
126126

127-
/// @notice Returns the court and dispute kit jumps for a given dispute.
127+
/// @notice Returns the next round settings for a given dispute.
128128
/// @dev This function does not check for compatibility between `newDisputeKitID` and `newCourtID`, this is the Core's responsibility.
129129
/// @param _coreDisputeID The ID of the dispute in Kleros Core, not in the Dispute Kit.
130130
/// @param _currentCourtID The ID of the current court.
@@ -135,25 +135,14 @@ interface IDisputeKit {
135135
/// @return newCourtID Court ID after jump.
136136
/// @return newDisputeKitID Dispute kit ID after jump.
137137
/// @return newRoundNbVotes The number of votes in the new round.
138-
/// @return courtJump Whether the dispute jumps to a new court or not.
139-
/// @return disputeKitJump Whether the dispute jumps to a new dispute kit or not.
140-
function getCourtAndDisputeKitJumps(
138+
function getNextRoundSettings(
141139
uint256 _coreDisputeID,
142140
uint96 _currentCourtID,
143141
uint96 _parentCourtID,
144142
uint256 _currentCourtJurorsForJump,
145143
uint256 _currentDisputeKitID,
146144
uint256 _currentRoundNbVotes
147-
)
148-
external
149-
view
150-
returns (
151-
uint96 newCourtID,
152-
uint256 newDisputeKitID,
153-
uint256 newRoundNbVotes,
154-
bool courtJump,
155-
bool disputeKitJump
156-
);
145+
) external view returns (uint96 newCourtID, uint256 newDisputeKitID, uint256 newRoundNbVotes);
157146

158147
/// @notice Returns true if the specified voter was active in this round.
159148
/// @param _coreDisputeID The ID of the dispute in Kleros Core, not in the Dispute Kit.

0 commit comments

Comments
 (0)