Skip to content

Commit 1ee8762

Browse files
alcercujaybuidl
authored andcommitted
fix(contracts): remove court and subcourt naming inconsistencies
1 parent 1a8974e commit 1ee8762

File tree

9 files changed

+255
-271
lines changed

9 files changed

+255
-271
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: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ contract ForeignGateway is IForeignGateway {
4343
address arbitrable
4444
);
4545

46-
event ArbitrationCostModified(uint96 indexed _subcourtID, uint256 _feeForJuror);
46+
event ArbitrationCostModified(uint96 indexed _courtID, uint256 _feeForJuror);
4747

4848
// ************************************* //
4949
// * Storage * //
@@ -53,7 +53,7 @@ contract ForeignGateway is IForeignGateway {
5353
uint256 public immutable override senderChainID;
5454
address public immutable override senderGateway;
5555
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.
56-
mapping(uint96 => uint256) public feeForJuror; // feeForJuror[subcourtID], it mirrors the value on KlerosCore.
56+
mapping(uint96 => uint256) public feeForJuror; // feeForJuror[courtID], it mirrors the value on KlerosCore.
5757
address public governor;
5858
IFastBridgeReceiver public fastBridgeReceiver;
5959
IFastBridgeReceiver public depreciatedFastbridge;
@@ -107,13 +107,13 @@ 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;
116-
emit ArbitrationCostModified(_subcourtID, _feeForJuror);
114+
function changeSubcourtJurorFee(uint96 _courtID, uint256 _feeForJuror) external onlyByGovernor {
115+
feeForJuror[_courtID] = _feeForJuror;
116+
emit ArbitrationCostModified(_courtID, _feeForJuror);
117117
}
118118

119119
// ************************************* //
@@ -156,8 +156,8 @@ contract ForeignGateway is IForeignGateway {
156156
}
157157

158158
function arbitrationCost(bytes calldata _extraData) public view override returns (uint256 cost) {
159-
(uint96 subcourtID, uint256 minJurors) = extraDataToSubcourtIDMinJurors(_extraData);
160-
cost = feeForJuror[subcourtID] * minJurors;
159+
(uint96 courtID, uint256 minJurors) = extraDataToSubcourtIDMinJurors(_extraData);
160+
cost = feeForJuror[courtID] * minJurors;
161161
}
162162

163163
/**
@@ -206,18 +206,18 @@ contract ForeignGateway is IForeignGateway {
206206

207207
function extraDataToSubcourtIDMinJurors(
208208
bytes memory _extraData
209-
) internal view returns (uint96 subcourtID, uint256 minJurors) {
209+
) internal view returns (uint96 courtID, uint256 minJurors) {
210210
// Note that here we ignore DisputeKitID
211211
if (_extraData.length >= 64) {
212212
assembly {
213213
// solium-disable-line security/no-inline-assembly
214-
subcourtID := mload(add(_extraData, 0x20))
214+
courtID := mload(add(_extraData, 0x20))
215215
minJurors := mload(add(_extraData, 0x40))
216216
}
217-
if (feeForJuror[subcourtID] == 0) subcourtID = 0;
217+
if (feeForJuror[courtID] == 0) courtID = 0;
218218
if (minJurors == 0) minJurors = MIN_JURORS;
219219
} else {
220-
subcourtID = 0;
220+
courtID = 0;
221221
minJurors = MIN_JURORS;
222222
}
223223
}

contracts/src/gateway/single-message/ForeignGatewayOnEthereum.sol

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ contract ForeignGatewayOnEthereum is IForeignGatewaySingleMessage {
2929
// at any point.
3030
uint256 internal localDisputeID = 1;
3131

32-
// feeForJuror by subcourtID
32+
// feeForJuror by courtID
3333
uint256[] internal feeForJuror;
3434
uint256 public chainID;
3535
uint256 public homeChainID;
@@ -84,12 +84,12 @@ contract ForeignGatewayOnEthereum is IForeignGatewaySingleMessage {
8484
}
8585
}
8686

87-
/** @dev Changes the `feeForJuror` property value of a specified subcourt.
88-
* @param _subcourtID The ID of the subcourt.
87+
/** @dev Changes the `feeForJuror` property value of a specified court.
88+
* @param _courtID The ID of the court.
8989
* @param _feeForJuror The new value for the `feeForJuror` property value.
9090
*/
91-
function changeSubcourtJurorFee(uint96 _subcourtID, uint256 _feeForJuror) external onlyByGovernor {
92-
feeForJuror[_subcourtID] = _feeForJuror;
91+
function changeCourtJurorFee(uint96 _courtID, uint256 _feeForJuror) external onlyByGovernor {
92+
feeForJuror[_courtID] = _feeForJuror;
9393
}
9494

9595
function createDispute(uint256 _choices, bytes calldata _extraData) external payable returns (uint256 disputeID) {
@@ -121,19 +121,15 @@ contract ForeignGatewayOnEthereum is IForeignGatewaySingleMessage {
121121
}
122122

123123
function arbitrationCost(bytes calldata _extraData) public view returns (uint256 cost) {
124-
(uint96 subcourtID, uint256 minJurors) = extraDataToSubcourtIDMinJurors(_extraData);
124+
(uint96 courtID, uint256 minJurors) = extraDataToCourtIDMinJurors(_extraData);
125125

126-
cost = feeForJuror[subcourtID] * minJurors;
126+
cost = feeForJuror[courtID] * minJurors;
127127
}
128128

129129
/**
130130
* Relay the rule call from the home gateway to the arbitrable.
131131
*/
132-
function relayRule(
133-
bytes32 _disputeHash,
134-
uint256 _ruling,
135-
address _relayer
136-
) external onlyFromFastBridge {
132+
function relayRule(bytes32 _disputeHash, uint256 _ruling, address _relayer) external onlyFromFastBridge {
137133
DisputeData storage dispute = disputeHashtoDisputeData[_disputeHash];
138134

139135
require(dispute.id != 0, "Dispute does not exist");
@@ -160,22 +156,20 @@ contract ForeignGatewayOnEthereum is IForeignGatewaySingleMessage {
160156
return disputeHashtoDisputeData[_disputeHash].id;
161157
}
162158

163-
function extraDataToSubcourtIDMinJurors(bytes memory _extraData)
164-
internal
165-
view
166-
returns (uint96 subcourtID, uint256 minJurors)
167-
{
159+
function extraDataToCourtIDMinJurors(
160+
bytes memory _extraData
161+
) internal view returns (uint96 courtID, uint256 minJurors) {
168162
// Note that here we ignore DisputeKitID
169163
if (_extraData.length >= 64) {
170164
assembly {
171165
// solium-disable-line security/no-inline-assembly
172-
subcourtID := mload(add(_extraData, 0x20))
166+
courtID := mload(add(_extraData, 0x20))
173167
minJurors := mload(add(_extraData, 0x40))
174168
}
175-
if (subcourtID >= feeForJuror.length) subcourtID = 0;
169+
if (courtID >= feeForJuror.length) courtID = 0;
176170
if (minJurors == 0) minJurors = MIN_JURORS;
177171
} else {
178-
subcourtID = 0;
172+
courtID = 0;
179173
minJurors = MIN_JURORS;
180174
}
181175
}

0 commit comments

Comments
 (0)