Skip to content

Commit 7fd5997

Browse files
committed
chore: reverted changes to the PoC
1 parent cd016b3 commit 7fd5997

File tree

4 files changed

+7
-24
lines changed

4 files changed

+7
-24
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {DisputeKitClassicBase, KlerosCore} from "./DisputeKitClassicBase.sol";
1111
/// - an incentive system: equal split between coherent votes,
1212
/// - an appeal system: fund 2 choices only, vote on any choice.
1313
contract DisputeKitClassic is DisputeKitClassicBase {
14-
string public constant override version = "0.9.0";
14+
string public constant override version = "0.8.0";
1515

1616
// ************************************* //
1717
// * Constructor * //

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

+3-20
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
238238
/// `n` is the number of votes.
239239
/// @param _coreDisputeID The ID of the dispute in Kleros Core.
240240
/// @param _voteIDs The IDs of the votes.
241-
/// @param _commit The commitment hash.
241+
/// @param _commit The commit. Note that justification string is a part of the commit.
242242
function castCommit(
243243
uint256 _coreDisputeID,
244244
uint256[] calldata _voteIDs,
@@ -283,14 +283,13 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
283283
Round storage round = dispute.rounds[dispute.rounds.length - 1];
284284
(uint96 courtID, , , , ) = core.disputes(_coreDisputeID);
285285
(, bool hiddenVotes, , , , , ) = core.courts(courtID);
286-
bytes32 voteHash = hashVote(_choice, _salt, _justification);
287286

288287
// Save the votes.
289288
for (uint256 i = 0; i < _voteIDs.length; i++) {
290289
require(round.votes[_voteIDs[i]].account == msg.sender, "The caller has to own the vote.");
291290
require(
292-
!hiddenVotes || round.votes[_voteIDs[i]].commit == voteHash,
293-
"The vote hash must match the commitment in courts with hidden votes."
291+
!hiddenVotes || round.votes[_voteIDs[i]].commit == keccak256(abi.encodePacked(_choice, _salt)),
292+
"The commit must match the choice in courts with hidden votes."
294293
);
295294
require(!round.votes[_voteIDs[i]].voted, "Vote already cast.");
296295
round.votes[_voteIDs[i]].choice = _choice;
@@ -436,22 +435,6 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi
436435
// * Public Views * //
437436
// ************************************* //
438437

439-
/**
440-
* @dev Computes the hash of a vote using ABI encoding
441-
* @dev The unused parameters may be used by overriding contracts.
442-
* @param _choice The choice being voted for
443-
* @param _justification The justification for the vote
444-
* @param _salt A random salt for commitment
445-
* @return bytes32 The hash of the encoded vote parameters
446-
*/
447-
function hashVote(
448-
uint256 _choice,
449-
uint256 _salt,
450-
string memory _justification
451-
) public pure virtual returns (bytes32) {
452-
return keccak256(abi.encodePacked(_choice, _salt));
453-
}
454-
455438
function getFundedChoices(uint256 _coreDisputeID) public view returns (uint256[] memory fundedChoices) {
456439
Dispute storage dispute = disputes[coreDisputeIDToLocal[_coreDisputeID]];
457440
Round storage lastRound = dispute.rounds[dispute.rounds.length - 1];

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ interface IBalanceHolderERC1155 {
2727
/// - an incentive system: equal split between coherent votes,
2828
/// - an appeal system: fund 2 choices only, vote on any choice.
2929
contract DisputeKitGated is DisputeKitClassicBase {
30-
string public constant override version = "0.9.0";
30+
string public constant override version = "0.8.0";
3131

3232
// ************************************* //
3333
// * Storage * //

contracts/test/foundry/KlerosCore.t.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -1654,11 +1654,11 @@ contract KlerosCoreTest is Test {
16541654

16551655
// Check the require with the wrong choice and then with the wrong salt
16561656
vm.prank(staker1);
1657-
vm.expectRevert(bytes("The vote hash must match the commitment in courts with hidden votes."));
1657+
vm.expectRevert(bytes("The commit must match the choice in courts with hidden votes."));
16581658
disputeKit.castVote(disputeID, voteIDs, 2, salt, "XYZ");
16591659

16601660
vm.prank(staker1);
1661-
vm.expectRevert(bytes("The vote hash must match the commitment in courts with hidden votes."));
1661+
vm.expectRevert(bytes("The commit must match the choice in courts with hidden votes."));
16621662
disputeKit.castVote(disputeID, voteIDs, YES, salt - 1, "XYZ");
16631663

16641664
vm.prank(staker1);

0 commit comments

Comments
 (0)