Skip to content

Commit 85f01b6

Browse files
committed
fix: changed mapping to a boolean, reset dispute.jumped
1 parent 5ac93ef commit 85f01b6

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
6262
mapping(uint256 => uint256) public coreDisputeIDToLocal; // Maps the dispute ID in Kleros Core to the local dispute ID.
6363
bool public singleDrawPerJuror; // Whether each juror can only draw once per dispute, false by default.
6464
mapping(uint256 localDisputeID => mapping(uint256 localRoundID => mapping(address drawnAddress => bool)))
65-
public alreadyDrawn; // 'true' if the address has already been drawn, false by default. To be added to the Round struct when fully redeploying rather than upgrading.
66-
67-
mapping(uint256 => uint256) public coreDisputeIDToDisputeLength; // Maps core dispute ID with the current length of disputes array to avoid falling back to 0 index and make sure core dispute is indeed connected to this DK.
65+
public alreadyDrawn; // True if the address has already been drawn, false by default. To be added to the Round struct when fully redeploying rather than upgrading.
66+
mapping(uint256 coreDisputeID => bool) public coreDisputeIDToActive; // True if this dispute kit is active for this core dispute ID.
6867

6968
// ************************************* //
7069
// * Events * //
@@ -197,6 +196,7 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
197196
Dispute storage dispute = disputes.push();
198197
dispute.numberOfChoices = _numberOfChoices;
199198
dispute.extraData = _extraData;
199+
dispute.jumped = false; // Possibly true if this DK has jumped in a previous round.
200200

201201
// New round in the Core should be created before the dispute creation in DK.
202202
dispute.coreRoundIDToLocal[core.getNumberOfRounds(_coreDisputeID) - 1] = dispute.rounds.length;
@@ -206,7 +206,7 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
206206
round.tied = true;
207207

208208
coreDisputeIDToLocal[_coreDisputeID] = localDisputeID;
209-
coreDisputeIDToDisputeLength[_coreDisputeID] = localDisputeID + 1;
209+
coreDisputeIDToActive[_coreDisputeID] = true;
210210
emit DisputeCreation(_coreDisputeID, _numberOfChoices, _extraData);
211211
}
212212

@@ -253,7 +253,7 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
253253
(, , KlerosCore.Period period, , ) = core.disputes(_coreDisputeID);
254254
require(period == KlerosCoreBase.Period.commit, "The dispute should be in Commit period.");
255255
require(_commit != bytes32(0), "Empty commit.");
256-
require(coreDisputeIDToDisputeLength[_coreDisputeID] != 0, "No local dispute for core ID");
256+
require(coreDisputeIDToActive[_coreDisputeID], "Not active for core dispute ID");
257257

258258
Dispute storage dispute = disputes[coreDisputeIDToLocal[_coreDisputeID]];
259259
Round storage round = dispute.rounds[dispute.rounds.length - 1];
@@ -283,7 +283,7 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
283283
(, , KlerosCore.Period period, , ) = core.disputes(_coreDisputeID);
284284
require(period == KlerosCoreBase.Period.vote, "The dispute should be in Vote period.");
285285
require(_voteIDs.length > 0, "No voteID provided");
286-
require(coreDisputeIDToDisputeLength[_coreDisputeID] != 0, "No local dispute for core ID");
286+
require(coreDisputeIDToActive[_coreDisputeID], "Not active for core dispute ID");
287287

288288
Dispute storage dispute = disputes[coreDisputeIDToLocal[_coreDisputeID]];
289289
require(_choice <= dispute.numberOfChoices, "Choice out of bounds");
@@ -330,7 +330,7 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
330330
function fundAppeal(uint256 _coreDisputeID, uint256 _choice) external payable notJumped(_coreDisputeID) {
331331
Dispute storage dispute = disputes[coreDisputeIDToLocal[_coreDisputeID]];
332332
require(_choice <= dispute.numberOfChoices, "There is no such ruling to fund.");
333-
require(coreDisputeIDToDisputeLength[_coreDisputeID] != 0, "No local dispute for core ID");
333+
require(coreDisputeIDToActive[_coreDisputeID], "Not active for core dispute ID");
334334

335335
(uint256 appealPeriodStart, uint256 appealPeriodEnd) = core.appealPeriod(_coreDisputeID);
336336
require(block.timestamp >= appealPeriodStart && block.timestamp < appealPeriodEnd, "Appeal period is over.");
@@ -410,7 +410,7 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
410410
(, , , bool isRuled, ) = core.disputes(_coreDisputeID);
411411
require(isRuled, "Dispute should be resolved.");
412412
require(!core.paused(), "Core is paused");
413-
require(coreDisputeIDToDisputeLength[_coreDisputeID] != 0, "No local dispute for core ID");
413+
require(coreDisputeIDToActive[_coreDisputeID], "Not active for core dispute ID");
414414

415415
Dispute storage dispute = disputes[coreDisputeIDToLocal[_coreDisputeID]];
416416
Round storage round = dispute.rounds[dispute.coreRoundIDToLocal[_coreRoundID]];

contracts/test/foundry/KlerosCore.t.sol

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,7 +1393,7 @@ contract KlerosCoreTest is Test {
13931393
assertEq(jumped, false, "jumped should be false");
13941394
assertEq(extraData, newExtraData, "Wrong extra data");
13951395
assertEq(disputeKit.coreDisputeIDToLocal(0), disputeID, "Wrong local disputeID");
1396-
assertEq(disputeKit.coreDisputeIDToDisputeLength(0), 1, "Wrong disputes length");
1396+
assertEq(disputeKit.coreDisputeIDToActive(0), true, "Wrong disputes length");
13971397

13981398
(
13991399
uint256 winningChoice,
@@ -2885,11 +2885,11 @@ contract KlerosCoreTest is Test {
28852885

28862886
// Check that the new DK has the info but not the old one.
28872887

2888-
assertEq(disputeKit.coreDisputeIDToDisputeLength(disputeID), 0, "Should be 0 for old DK");
2888+
assertEq(disputeKit.coreDisputeIDToActive(disputeID), false, "Should be false for old DK");
28892889

28902890
// This is the DK where dispute was created. Core dispute points to index 1 because new DK has two disputes.
28912891
assertEq(newDisputeKit.coreDisputeIDToLocal(disputeID), 1, "Wrong local dispute ID for new DK");
2892-
assertEq(newDisputeKit.coreDisputeIDToDisputeLength(disputeID), 2, "Wrong disputes length for new DK");
2892+
assertEq(newDisputeKit.coreDisputeIDToActive(disputeID), true, "Should be active for new DK");
28932893
(uint256 numberOfChoices, , bytes memory extraData) = newDisputeKit.disputes(1);
28942894
assertEq(numberOfChoices, 2, "Wrong numberOfChoices in new DK");
28952895
assertEq(extraData, newExtraData, "Wrong extra data");
@@ -2901,7 +2901,7 @@ contract KlerosCoreTest is Test {
29012901

29022902
// Deliberately cast votes using the old DK to see if the exception will be caught.
29032903
vm.prank(staker1);
2904-
vm.expectRevert(bytes("No local dispute for core ID"));
2904+
vm.expectRevert(bytes("Not active for core dispute ID"));
29052905
disputeKit.castVote(disputeID, voteIDs, 2, 0, "XYZ");
29062906

29072907
// And check the new DK.

0 commit comments

Comments
 (0)