Skip to content

Commit cb2ae4a

Browse files
committed
fix(contracts): remove court and subcourt naming inconsistencies
1 parent cb59730 commit cb2ae4a

File tree

9 files changed

+261
-281
lines changed

9 files changed

+261
-281
lines changed

contracts/scripts/populateCourts.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -41,70 +41,70 @@ async function main() {
4141
const core = (await ethers.getContractAt("KlerosCore", klerosCoreDeployment.address)) as KlerosCore;
4242

4343
for (const court of courtsV2) {
44-
const subcourtPresent = await core.courts(court.id).catch(() => {});
45-
if (subcourtPresent) {
46-
console.log("Subcourt %d found: %O", court.id, subcourtPresent);
44+
const courtPresent = await core.courts(court.id).catch(() => {});
45+
if (courtPresent) {
46+
console.log("Court %d found: %O", court.id, courtPresent);
4747

48-
// Subcourt.parent and sortitionSumTreeK cannot be changed.
48+
// Court.parent and sortitionSumTreeK cannot be changed.
4949

50-
if (subcourtPresent.hiddenVotes !== court.hiddenVotes) {
50+
if (courtPresent.hiddenVotes !== court.hiddenVotes) {
5151
console.log(
52-
"Subcourt %d: changing hiddenVotes from %d to %d",
52+
"Court %d: changing hiddenVotes from %d to %d",
5353
court.id,
54-
subcourtPresent.hiddenVotes,
54+
courtPresent.hiddenVotes,
5555
court.hiddenVotes
5656
);
57-
await core.changeSubcourtHiddenVotes(court.id, court.hiddenVotes);
57+
await core.changeCourtHiddenVotes(court.id, court.hiddenVotes);
5858
}
5959

60-
if (!subcourtPresent.minStake.eq(court.minStake)) {
61-
console.log("Subcourt %d: changing minStake from %d to %d", court.id, subcourtPresent.minStake, court.minStake);
62-
await core.changeSubcourtMinStake(court.id, court.minStake);
60+
if (!courtPresent.minStake.eq(court.minStake)) {
61+
console.log("Court %d: changing minStake from %d to %d", court.id, courtPresent.minStake, court.minStake);
62+
await core.changeCourtMinStake(court.id, court.minStake);
6363
}
6464

65-
if (!subcourtPresent.alpha.eq(court.alpha)) {
66-
console.log("Subcourt %d: changing alpha from %d to %d", court.id, subcourtPresent.alpha, court.alpha);
67-
await core.changeSubcourtAlpha(court.id, court.alpha);
65+
if (!courtPresent.alpha.eq(court.alpha)) {
66+
console.log("Court %d: changing alpha from %d to %d", court.id, courtPresent.alpha, court.alpha);
67+
await core.changeCourtAlpha(court.id, court.alpha);
6868
}
6969

70-
if (!subcourtPresent.feeForJuror.eq(court.feeForJuror)) {
70+
if (!courtPresent.feeForJuror.eq(court.feeForJuror)) {
7171
console.log(
72-
"Subcourt %d: changing feeForJuror from %d to %d",
72+
"Court %d: changing feeForJuror from %d to %d",
7373
court.id,
74-
subcourtPresent.feeForJuror,
74+
courtPresent.feeForJuror,
7575
court.feeForJuror
7676
);
77-
await core.changeSubcourtJurorFee(court.id, court.feeForJuror);
77+
await core.changeCourtJurorFee(court.id, court.feeForJuror);
7878
}
7979

80-
if (!subcourtPresent.jurorsForCourtJump.eq(court.jurorsForCourtJump)) {
80+
if (!courtPresent.jurorsForCourtJump.eq(court.jurorsForCourtJump)) {
8181
console.log(
82-
"Subcourt %d: changing jurorsForCourtJump from %d to %d",
82+
"Court %d: changing jurorsForCourtJump from %d to %d",
8383
court.id,
84-
subcourtPresent.jurorsForCourtJump,
84+
courtPresent.jurorsForCourtJump,
8585
court.jurorsForCourtJump
8686
);
87-
await core.changeSubcourtJurorsForJump(court.id, court.jurorsForCourtJump);
87+
await core.changeCourtJurorsForJump(court.id, court.jurorsForCourtJump);
8888
}
8989

9090
const timesPerPeriodPresent = (await core.getTimesPerPeriod(court.id)).map((bn) => bn.toNumber());
9191
if (!timesPerPeriodPresent.every((val, index) => val === court.timesPerPeriod[index])) {
9292
console.log(
93-
"Subcourt %d: changing timesPerPeriod from %O to %O",
93+
"Court %d: changing timesPerPeriod from %O to %O",
9494
court.id,
9595
timesPerPeriodPresent,
9696
court.timesPerPeriod
9797
);
98-
await core.changeSubcourtTimesPerPeriod(court.id, [
98+
await core.changeCourtTimesPerPeriod(court.id, [
9999
court.timesPerPeriod[0],
100100
court.timesPerPeriod[1],
101101
court.timesPerPeriod[2],
102102
court.timesPerPeriod[3],
103103
]);
104104
}
105105
} else {
106-
console.log("Subcourt %d not found, creating it with", court.id, court);
107-
await core.createSubcourt(
106+
console.log("Court %d not found, creating it with", court.id, court);
107+
await core.createCourt(
108108
court.parent,
109109
court.hiddenVotes,
110110
court.minStake,

contracts/src/arbitration/KlerosCore.sol

Lines changed: 171 additions & 181 deletions
Large diffs are not rendered by default.

contracts/src/arbitration/PolicyRegistry.sol

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pragma solidity ^0.8;
44
/**
55
* @title PolicyRegistry
66
* @author Enrique Piqueras - <epiquerass@gmail.com>
7-
* @dev A contract to maintain a policy for each subcourt.
7+
* @dev A contract to maintain a policy for each court.
88
*/
99
contract PolicyRegistry {
1010
// ************************************* //
@@ -13,10 +13,10 @@ contract PolicyRegistry {
1313

1414
/**
1515
* @dev Emitted when a policy is updated.
16-
* @param _subcourtID The ID of the policy's subcourt.
16+
* @param _courtID The ID of the policy's court.
1717
* @param _policy The URI of the policy JSON.
1818
*/
19-
event PolicyUpdate(uint256 indexed _subcourtID, string _policy);
19+
event PolicyUpdate(uint256 indexed _courtID, string _policy);
2020

2121
// ************************************* //
2222
// * Storage * //
@@ -65,12 +65,12 @@ contract PolicyRegistry {
6565
// ************************************* //
6666

6767
/**
68-
* @dev Sets the policy for the specified subcourt.
69-
* @param _subcourtID The ID of the specified subcourt.
68+
* @dev Sets the policy for the specified court.
69+
* @param _courtID The ID of the specified court.
7070
* @param _policy The URI of the policy JSON.
7171
*/
72-
function setPolicy(uint256 _subcourtID, string calldata _policy) external onlyByGovernor {
73-
policies[_subcourtID] = _policy;
74-
emit PolicyUpdate(_subcourtID, policies[_subcourtID]);
72+
function setPolicy(uint256 _courtID, string calldata _policy) external onlyByGovernor {
73+
policies[_courtID] = _policy;
74+
emit PolicyUpdate(_courtID, policies[_courtID]);
7575
}
7676
}

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ contract DisputeKitClassic is BaseDisputeKit, IEvidence {
226226
Dispute storage dispute = disputes[coreDisputeIDToLocal[_coreDisputeID]];
227227
Round storage round = dispute.rounds[dispute.rounds.length - 1];
228228

229-
(uint96 subcourtID, , , , ) = core.disputes(_coreDisputeID);
230-
bytes32 key = bytes32(uint256(subcourtID)); // Get the ID of the tree.
229+
(uint96 courtID, , , , ) = core.disputes(_coreDisputeID);
230+
bytes32 key = bytes32(uint256(courtID)); // Get the ID of the tree.
231231

232232
(uint256 K, uint256 nodesLength, ) = core.getSortitionSumTree(key, 0);
233233
uint256 treeIndex = 0;
@@ -319,16 +319,16 @@ contract DisputeKitClassic is BaseDisputeKit, IEvidence {
319319
require(_choice <= dispute.numberOfChoices, "Choice out of bounds");
320320

321321
Round storage round = dispute.rounds[dispute.rounds.length - 1];
322-
(uint96 subcourtID, , , , ) = core.disputes(_coreDisputeID);
323-
(, bool hiddenVotes, , , , ) = core.courts(subcourtID);
322+
(uint96 courtID, , , , ) = core.disputes(_coreDisputeID);
323+
(, bool hiddenVotes, , , , ) = core.courts(courtID);
324324

325325
// Save the votes.
326326
for (uint256 i = 0; i < _voteIDs.length; i++) {
327327
require(round.votes[_voteIDs[i]].account == msg.sender, "The caller has to own the vote.");
328328
require(
329329
!hiddenVotes ||
330330
round.votes[_voteIDs[i]].commit == keccak256(abi.encodePacked(_choice, _justification, _salt)),
331-
"The commit must match the choice in subcourts with hidden votes."
331+
"The commit must match the choice in courts with hidden votes."
332332
);
333333
require(!round.votes[_voteIDs[i]].voted, "Vote already cast.");
334334
round.votes[_voteIDs[i]].choice = _choice;
@@ -645,13 +645,13 @@ contract DisputeKitClassic is BaseDisputeKit, IEvidence {
645645
* @return Whether the address can be drawn or not.
646646
*/
647647
function postDrawCheck(uint256 _coreDisputeID, address _juror) internal view override returns (bool) {
648-
(uint96 subcourtID, , , , ) = core.disputes(_coreDisputeID);
648+
(uint96 courtID, , , , ) = core.disputes(_coreDisputeID);
649649
(uint256 lockedAmountPerJuror, , , , , ) = core.getRoundInfo(
650650
_coreDisputeID,
651651
core.getNumberOfRounds(_coreDisputeID) - 1
652652
);
653-
(uint256 stakedTokens, uint256 lockedTokens) = core.getJurorBalance(_juror, subcourtID);
654-
(, , uint256 minStake, , , ) = core.courts(subcourtID);
653+
(uint256 stakedTokens, uint256 lockedTokens) = core.getJurorBalance(_juror, courtID);
654+
(, , uint256 minStake, , , ) = core.courts(courtID);
655655
return stakedTokens >= lockedTokens + lockedAmountPerJuror && stakedTokens >= minStake;
656656
}
657657

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,8 @@ contract DisputeKitSybilResistant is BaseDisputeKit, IEvidence {
251251
Dispute storage dispute = disputes[coreDisputeIDToLocal[_coreDisputeID]];
252252
Round storage round = dispute.rounds[dispute.rounds.length - 1];
253253

254-
(uint96 subcourtID, , , , ) = core.disputes(_coreDisputeID);
255-
bytes32 key = bytes32(uint256(subcourtID)); // Get the ID of the tree.
254+
(uint96 courtID, , , , ) = core.disputes(_coreDisputeID);
255+
bytes32 key = bytes32(uint256(courtID)); // Get the ID of the tree.
256256

257257
(uint256 K, uint256 nodesLength, ) = core.getSortitionSumTree(key, 0);
258258
uint256 treeIndex = 0;
@@ -345,16 +345,16 @@ contract DisputeKitSybilResistant is BaseDisputeKit, IEvidence {
345345
require(_choice <= dispute.numberOfChoices, "Choice out of bounds");
346346

347347
Round storage round = dispute.rounds[dispute.rounds.length - 1];
348-
(uint96 subcourtID, , , , ) = core.disputes(_coreDisputeID);
349-
(, bool hiddenVotes, , , , ) = core.courts(subcourtID);
348+
(uint96 courtID, , , , ) = core.disputes(_coreDisputeID);
349+
(, bool hiddenVotes, , , , ) = core.courts(courtID);
350350

351351
// Save the votes.
352352
for (uint256 i = 0; i < _voteIDs.length; i++) {
353353
require(round.votes[_voteIDs[i]].account == msg.sender, "The caller has to own the vote.");
354354
require(
355355
!hiddenVotes ||
356356
round.votes[_voteIDs[i]].commit == keccak256(abi.encodePacked(_choice, _justification, _salt)),
357-
"The commit must match the choice in subcourts with hidden votes."
357+
"The commit must match the choice in courts with hidden votes."
358358
);
359359
require(!round.votes[_voteIDs[i]].voted, "Vote already cast.");
360360
round.votes[_voteIDs[i]].choice = _choice;
@@ -671,13 +671,13 @@ contract DisputeKitSybilResistant is BaseDisputeKit, IEvidence {
671671
* @return Whether the address can be drawn or not.
672672
*/
673673
function postDrawCheck(uint256 _coreDisputeID, address _juror) internal view override returns (bool) {
674-
(uint96 subcourtID, , , , ) = core.disputes(_coreDisputeID);
674+
(uint96 courtID, , , , ) = core.disputes(_coreDisputeID);
675675
(uint256 lockedAmountPerJuror, , , , , ) = core.getRoundInfo(
676676
_coreDisputeID,
677677
core.getNumberOfRounds(_coreDisputeID) - 1
678678
);
679-
(uint256 stakedTokens, uint256 lockedTokens) = core.getJurorBalance(_juror, subcourtID);
680-
(, , uint256 minStake, , , ) = core.courts(subcourtID);
679+
(uint256 stakedTokens, uint256 lockedTokens) = core.getJurorBalance(_juror, courtID);
680+
(, , uint256 minStake, , , ) = core.courts(courtID);
681681
if (stakedTokens < lockedTokens + lockedAmountPerJuror || stakedTokens < minStake) {
682682
return false;
683683
} else {

contracts/src/gateway/ForeignGateway.sol

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ contract ForeignGateway is IForeignGateway {
5151
uint256 public immutable override senderChainID;
5252
address public immutable override senderGateway;
5353
uint256 internal localDisputeID = 1; // The disputeID must start from 1 as the KlerosV1 proxy governor depends on this implementation. We now also depend on localDisputeID not ever being zero.
54-
uint256[] internal feeForJuror; // feeForJuror[subcourtID]
54+
uint256[] internal feeForJuror; // feeForJuror[courtID]
5555
address public governor;
5656
IFastBridgeReceiver public fastBridgeReceiver;
5757
IFastBridgeReceiver public depreciatedFastbridge;
@@ -107,32 +107,30 @@ contract ForeignGateway is IForeignGateway {
107107
}
108108

109109
/**
110-
* @dev Changes the `feeForJuror` property value of a specified subcourt.
111-
* @param _subcourtID The ID of the subcourt.
110+
* @dev Changes the `feeForJuror` property value of a specified court.
111+
* @param _courtID The ID of the court.
112112
* @param _feeForJuror The new value for the `feeForJuror` property value.
113113
*/
114-
function changeSubcourtJurorFee(uint96 _subcourtID, uint256 _feeForJuror) external onlyByGovernor {
115-
feeForJuror[_subcourtID] = _feeForJuror;
114+
function changeCourtJurorFee(uint96 _courtID, uint256 _feeForJuror) external onlyByGovernor {
115+
feeForJuror[_courtID] = _feeForJuror;
116116
}
117117

118118
/**
119-
* @dev Creates the `feeForJuror` property value for a new subcourt.
119+
* @dev Creates the `feeForJuror` property value for a new court.
120120
* @param _feeForJuror The new value for the `feeForJuror` property value.
121121
*/
122-
function createSubcourtJurorFee(uint256 _feeForJuror) external onlyByGovernor {
122+
function createCourtJurorFee(uint256 _feeForJuror) external onlyByGovernor {
123123
feeForJuror.push(_feeForJuror);
124124
}
125125

126126
// ************************************* //
127127
// * State Modifiers * //
128128
// ************************************* //
129129

130-
function createDispute(uint256 _choices, bytes calldata _extraData)
131-
external
132-
payable
133-
override
134-
returns (uint256 disputeID)
135-
{
130+
function createDispute(
131+
uint256 _choices,
132+
bytes calldata _extraData
133+
) external payable override returns (uint256 disputeID) {
136134
require(msg.value >= arbitrationCost(_extraData), "Not paid enough for arbitration");
137135

138136
disputeID = localDisputeID++;
@@ -165,9 +163,9 @@ contract ForeignGateway is IForeignGateway {
165163
}
166164

167165
function arbitrationCost(bytes calldata _extraData) public view override returns (uint256 cost) {
168-
(uint96 subcourtID, uint256 minJurors) = extraDataToSubcourtIDMinJurors(_extraData);
166+
(uint96 courtID, uint256 minJurors) = extraDataToCourtIDMinJurors(_extraData);
169167

170-
cost = feeForJuror[subcourtID] * minJurors;
168+
cost = feeForJuror[courtID] * minJurors;
171169
}
172170

173171
/**
@@ -214,22 +212,20 @@ contract ForeignGateway is IForeignGateway {
214212
// * Internal * //
215213
// ************************ //
216214

217-
function extraDataToSubcourtIDMinJurors(bytes memory _extraData)
218-
internal
219-
view
220-
returns (uint96 subcourtID, uint256 minJurors)
221-
{
215+
function extraDataToCourtIDMinJurors(
216+
bytes memory _extraData
217+
) internal view returns (uint96 courtID, uint256 minJurors) {
222218
// Note that here we ignore DisputeKitID
223219
if (_extraData.length >= 64) {
224220
assembly {
225221
// solium-disable-line security/no-inline-assembly
226-
subcourtID := mload(add(_extraData, 0x20))
222+
courtID := mload(add(_extraData, 0x20))
227223
minJurors := mload(add(_extraData, 0x40))
228224
}
229-
if (subcourtID >= feeForJuror.length) subcourtID = 0;
225+
if (courtID >= feeForJuror.length) courtID = 0;
230226
if (minJurors == 0) minJurors = MIN_JURORS;
231227
} else {
232-
subcourtID = 0;
228+
courtID = 0;
233229
minJurors = MIN_JURORS;
234230
}
235231
}

0 commit comments

Comments
 (0)