Skip to content

Commit ba60d8f

Browse files
committed
chore: prettify and removal of CHANGELOG.md (cause of too many conflicts)
1 parent df9b414 commit ba60d8f

File tree

8 files changed

+260
-306
lines changed

8 files changed

+260
-306
lines changed

.husky/pre-commit

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22
. "$(dirname "$0")/_/husky.sh"
33

44
yarn lint-staged \
5-
&& yarn depcheck \
6-
&& yarn changelog \
7-
&& git add CHANGELOG.md
5+
&& yarn depcheck

CHANGELOG.md

Lines changed: 0 additions & 39 deletions
This file was deleted.

contracts/src/arbitration/AbstractDisputeKit.sol

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ pragma solidity ^0.8;
55
import "./IArbitrator.sol";
66

77
abstract contract AbstractDisputeKit {
8-
98
/**
109
* Note: disputeID is maintained by Kleros Core, not the dispute kit
1110
* Note: the dispute kit does not receive any payment, Kleros Core does
@@ -27,5 +26,4 @@ abstract contract AbstractDisputeKit {
2726
* @param _iterations The number of iterations to run.
2827
*/
2928
function drawJurors(uint256 _disputeID, uint256 _iterations) external virtual;
30-
3129
}

contracts/src/arbitration/DisputeKitPlurality.sol

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,30 @@ contract DisputeKitPlurality is AbstractDisputeKit {
3434
struct Vote {
3535
address account; // The address of the juror.
3636
bytes32 commit; // The commit of the juror. For courts with hidden votes.
37-
uint choice; // The choice of the juror.
37+
uint256 choice; // The choice of the juror.
3838
bool voted; // True if the vote has been cast or revealed, false otherwise.
3939
}
4040
struct VoteCounter {
4141
// The choice with the most votes. Note that in the case of a tie, it is the choice that reached the tied number of votes first.
42-
uint winningChoice;
43-
mapping(uint => uint) counts; // The sum of votes for each choice in the form `counts[choice]`.
42+
uint256 winningChoice;
43+
mapping(uint256 => uint256) counts; // The sum of votes for each choice in the form `counts[choice]`.
4444
bool tied; // True if there is a tie, false otherwise.
4545
}
4646
struct Dispute {
4747
//NOTE: arbitrated needed?? But it needs the chainId too, not just an address.
4848
//IArbitrable arbitrated; // The address of the arbitrable contract.
4949
bytes arbitratorExtraData; // Extra data for the arbitrator.
5050
uint256 choices; // The number of choices the arbitrator can choose from.
51-
uint256 appealPeriodStart; // Time when the appeal funding becomes possible.
51+
uint256 appealPeriodStart; // Time when the appeal funding becomes possible.
5252
Vote[][] votes; // The votes in the form `votes[appeal][voteID]`. On each round, a new list is pushed and packed with as many empty votes as there are draws. We use `dispute.votes.length` to get the number of appeals plus 1 for the first round.
5353
VoteCounter[] voteCounters; // The vote counters in the form `voteCounters[appeal]`.
54-
uint[] tokensAtStakePerJurorForRound; // The amount of tokens at stake for each juror in the form `tokensAtStakePerJuror[appeal]`.
55-
uint[] arbitrationFeeForRound; // Fee paid by the arbitrable for the arbitration for each round. Must be equal or higher than arbitration cost.
56-
uint drawsInCurrentRound; // A counter of draws made in the current round.
57-
uint commitsInCurrentRound; // A counter of commits made in the current round.
58-
uint[] votesForRound; // A counter of votes made in each round in the form `votesInEachRound[appeal]`.
59-
uint[] repartitionsForRound; // A counter of vote reward repartitions made in each round in the form `repartitionsInEachRound[appeal]`.
60-
uint[] penaltiesForRound; // The amount of tokens collected from penalties in each round in the form `penaltiesInEachRound[appeal]`.
54+
uint256[] tokensAtStakePerJurorForRound; // The amount of tokens at stake for each juror in the form `tokensAtStakePerJuror[appeal]`.
55+
uint256[] arbitrationFeeForRound; // Fee paid by the arbitrable for the arbitration for each round. Must be equal or higher than arbitration cost.
56+
uint256 drawsInCurrentRound; // A counter of draws made in the current round.
57+
uint256 commitsInCurrentRound; // A counter of commits made in the current round.
58+
uint256[] votesForRound; // A counter of votes made in each round in the form `votesInEachRound[appeal]`.
59+
uint256[] repartitionsForRound; // A counter of vote reward repartitions made in each round in the form `repartitionsInEachRound[appeal]`.
60+
uint256[] penaltiesForRound; // The amount of tokens collected from penalties in each round in the form `penaltiesInEachRound[appeal]`.
6161
bool ruled; // True if the ruling has been executed, false otherwise.
6262
uint256 ruling; // Ruling given by the arbitrator.
6363
}
@@ -74,7 +74,7 @@ contract DisputeKitPlurality is AbstractDisputeKit {
7474
// * STORAGE * //
7575
// ************************ //
7676

77-
uint public constant ALPHA_DIVISOR = 1e4; // The number to divide `Court.alpha` by.
77+
uint256 public constant ALPHA_DIVISOR = 1e4; // The number to divide `Court.alpha` by.
7878

7979
// TODO: extract the necessary interfaces
8080
MockKlerosCore public immutable core;
@@ -124,10 +124,9 @@ contract DisputeKitPlurality is AbstractDisputeKit {
124124
dispute.choices = _choices;
125125
dispute.appealPeriodStart = 0;
126126

127-
uint numberOfVotes = _arbitrationFee / _subcourtFeeForJuror;
127+
uint256 numberOfVotes = _arbitrationFee / _subcourtFeeForJuror;
128128
Vote[] storage votes = dispute.votes.push(); // TODO: the array dimensions may be reversed, check!
129-
while (votes.length < numberOfVotes)
130-
votes.push();
129+
while (votes.length < numberOfVotes) votes.push();
131130

132131
dispute.voteCounters.push().tied = true;
133132
dispute.tokensAtStakePerJurorForRound.push((_subcourtMinStake * _subcourtAlpha) / ALPHA_DIVISOR);
@@ -137,18 +136,18 @@ contract DisputeKitPlurality is AbstractDisputeKit {
137136
dispute.penaltiesForRound.push(0);
138137
dispute.ruling = 0;
139138

140-
disputeIDtoRounds[_disputeID].push();
141-
}
139+
disputeIDtoRounds[_disputeID].push();
140+
}
142141

143-
function getVotes(uint _disputeID) public view returns(Vote[][] memory) {
142+
function getVotes(uint256 _disputeID) public view returns (Vote[][] memory) {
144143
return disputes[_disputeID].votes;
145144
}
146145

147-
function getVotesLength(uint _disputeID) public view returns(uint, uint) {
146+
function getVotesLength(uint256 _disputeID) public view returns (uint256, uint256) {
148147
return (disputes[_disputeID].votes.length, disputes[_disputeID].votes[0].length);
149148
}
150149

151-
function getVoteCounter(uint _disputeID) public view returns(bool) {
150+
function getVoteCounter(uint256 _disputeID) public view returns (bool) {
152151
return disputes[_disputeID].voteCounters[disputes[_disputeID].voteCounters.length - 1].tied;
153152
}
154153

@@ -161,8 +160,9 @@ contract DisputeKitPlurality is AbstractDisputeKit {
161160
uint96 subcourtID = core.getDispute(_disputeID).subcourtID;
162161
bytes32 key = bytes32(bytes12(subcourtID)); // due to new conversion restrictions in v0.8
163162
(
164-
uint256 k,
165-
/* stack */ ,
163+
uint256 k,
164+
,
165+
/* stack */
166166
uint256[] memory nodes
167167
) = core.getSortitionSumTree(key);
168168

@@ -173,7 +173,10 @@ contract DisputeKitPlurality is AbstractDisputeKit {
173173
for (uint256 i = 0; i < _iterations; i++) {
174174
uint256 treeIndex = draw(uint256(keccak256(abi.encodePacked(randomNumber, _disputeID, i))), k, nodes);
175175
bytes32 id = core.getSortitionSumTreeID(key, treeIndex);
176-
(address drawnAddress, /* subcourtID */) = stakePathIDToAccountAndSubcourtID(id);
176+
(
177+
address drawnAddress, /* subcourtID */
178+
179+
) = stakePathIDToAccountAndSubcourtID(id);
177180

178181
// TODO: Save the vote.
179182
// dispute.votes[dispute.votes.length - 1][i].account = drawnAddress;

contracts/src/arbitration/mock/MockKlerosCore.sol

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,19 @@ contract MockKlerosCore {
3333

3434
struct Court {
3535
uint96 parent; // The parent court.
36-
uint[] children; // List of child courts.
36+
uint256[] children; // List of child courts.
3737
bool hiddenVotes; // Whether to use commit and reveal or not.
38-
uint minStake; // Minimum tokens needed to stake in the court.
39-
uint alpha; // Basis point of tokens that are lost when incoherent.
40-
uint feeForJuror; // Arbitration fee paid per juror.
38+
uint256 minStake; // Minimum tokens needed to stake in the court.
39+
uint256 alpha; // Basis point of tokens that are lost when incoherent.
40+
uint256 feeForJuror; // Arbitration fee paid per juror.
4141
// The appeal after the one that reaches this number of jurors will go to the parent court if any, otherwise, no more appeals are possible.
42-
uint jurorsForCourtJump;
43-
uint[4] timesPerPeriod; // The time allotted to each dispute period in the form `timesPerPeriod[period]`.
42+
uint256 jurorsForCourtJump;
43+
uint256[4] timesPerPeriod; // The time allotted to each dispute period in the form `timesPerPeriod[period]`.
4444
}
4545

46-
event DisputeCreation(uint indexed _disputeID, IArbitrable indexed _arbitrable);
46+
event DisputeCreation(uint256 indexed _disputeID, IArbitrable indexed _arbitrable);
4747

48-
uint public constant MIN_JURORS = 3; // The global default minimum number of jurors in a dispute.
48+
uint256 public constant MIN_JURORS = 3; // The global default minimum number of jurors in a dispute.
4949

5050
Dispute[] public disputes;
5151
Court[] public courts;
@@ -65,19 +65,20 @@ contract MockKlerosCore {
6565
}
6666

6767
function createDispute(uint256 _choices, bytes calldata _extraData) external payable returns (uint256 disputeID) {
68-
(uint96 subcourtID, uint minJurors) = extraDataToSubcourtIDAndMinJurors(_extraData);
68+
(uint96 subcourtID, uint256 minJurors) = extraDataToSubcourtIDAndMinJurors(_extraData);
6969
disputeID = disputes.length;
7070

7171
Court storage court = courts[0];
7272

7373
disputeKit.createDispute(
74-
disputeID,
74+
disputeID,
7575
msg.value,
7676
court.feeForJuror,
7777
court.minStake,
7878
court.alpha,
79-
_choices,
80-
_extraData);
79+
_choices,
80+
_extraData
81+
);
8182

8283
emit DisputeCreation(disputeID, IArbitrable(msg.sender));
8384
}
@@ -110,9 +111,14 @@ contract MockKlerosCore {
110111
* @return subcourtID The subcourt ID.
111112
* @return minJurors The minimum number of jurors required.
112113
*/
113-
function extraDataToSubcourtIDAndMinJurors(bytes memory _extraData) internal view returns (uint96 subcourtID, uint minJurors) {
114+
function extraDataToSubcourtIDAndMinJurors(bytes memory _extraData)
115+
internal
116+
view
117+
returns (uint96 subcourtID, uint256 minJurors)
118+
{
114119
if (_extraData.length >= 64) {
115-
assembly { // solium-disable-line security/no-inline-assembly
120+
assembly {
121+
// solium-disable-line security/no-inline-assembly
116122
subcourtID := mload(add(_extraData, 0x20))
117123
minJurors := mload(add(_extraData, 0x40))
118124
}
@@ -124,7 +130,6 @@ contract MockKlerosCore {
124130
}
125131
}
126132

127-
128133
// SORTITION TREE FACTORY
129134

130135
struct SortitionSumTree {

contracts/test/arbitration/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,21 @@ function sleep(ms) {
1313

1414
describe("DisputeKitPlurality", function () {
1515
// eslint-disable-next-line no-unused-vars
16-
let deployer, claimant, supporter, challenger, innocentBystander;
16+
let deployer, claimant, supporter, challenger, innocentBystander;
1717
let core, disputeKit, arbitrable;
1818

1919
before("Deploying", async () => {
2020
[deployer, claimant, supporter, challenger, innocentBystander] = await ethers.getSigners();
2121
[core, disputeKit, arbitrable] = await deployContracts(deployer);
2222

2323
// To wait for eth gas reporter to fetch data. Remove this line when the issue is fixed. https://github.com/cgewecke/hardhat-gas-reporter/issues/72
24-
// await sleep(9000);
24+
// await sleep(9000);
2525
});
2626

2727
it("Should create a dispute", async function () {
28-
await expect(disputeKit.connect(deployer).createDispute(0, 0, 0, 0, 0, 0, "0x00"))
29-
.to.be.revertedWith("Not allowed: sender is not core");
28+
await expect(disputeKit.connect(deployer).createDispute(0, 0, 0, 0, 0, 0, "0x00")).to.be.revertedWith(
29+
"Not allowed: sender is not core"
30+
);
3031

3132
await expect(core.connect(deployer).createDispute(2, "0x00", { value: 1000 }))
3233
.to.emit(core, "DisputeCreation")
@@ -39,7 +40,6 @@ describe("DisputeKitPlurality", function () {
3940
});
4041
});
4142

42-
4343
async function deployContracts(deployer) {
4444
const MockKlerosCoreFactory = await ethers.getContractFactory("MockKlerosCore", deployer);
4545
const core = await MockKlerosCoreFactory.deploy();

0 commit comments

Comments
 (0)