Skip to content

Feat/kleros liquid proxy #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jan 17, 2022
Prev Previous commit
Next Next commit
fix: frozen tokens notification
  • Loading branch information
fnanni-0 committed Jan 12, 2022
commit 2ad8d7ab2d6dd6864318f7eab132cbaeaf36bb34
10 changes: 10 additions & 0 deletions contracts/src/kleros-v1/IKlerosLiquid.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ interface IKlerosLiquid is IArbitrator {
execution // Tokens are redistributed and the ruling is executed.
}

enum Phase {
staking, // Stake sum trees can be updated. Pass after `minStakingTime` passes and there is at least one dispute without jurors.
generating, // Waiting for a random number. Pass as soon as it is ready.
drawing // Jurors can be drawn. Pass after all disputes have jurors or `maxDrawingTime` passes.
}

struct Dispute {
// Note that appeal `0` is equivalent to the first round of the dispute.
uint96 subcourtID; // The ID of the subcourt the dispute is in.
Expand All @@ -29,8 +35,12 @@ interface IKlerosLiquid is IArbitrator {
uint256 lockedTokens; // The juror's total amount of tokens locked in disputes.
}

function phase() external view returns (Phase);

function lockInsolventTransfers() external view returns (bool);

function minStakingTime() external view returns (uint256);

function pinakion() external view returns (address);

function disputes(uint256 _index) external view returns (Dispute memory);
Expand Down
6 changes: 5 additions & 1 deletion contracts/src/kleros-v1/KlerosV1Governor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,16 @@ contract KlerosV1Governor is IArbitrable, ITokenController {
_disputeID
);

uint256 minStakingTime = klerosLiquid.minStakingTime();
IKlerosLiquid.Phase phase = klerosLiquid.phase();
bool isDrawingForbidden = phase == IKlerosLiquid.Phase.staking && minStakingTime == type(uint256).max;

for (uint256 round = 0; round < votesLengths.length; round++) {
if (isDisputeNotified[_disputeID][round]) continue;

for (uint256 voteID = 0; voteID < votesLengths[round]; voteID++) {
(address account, , , ) = klerosLiquid.getVote(_disputeID, round, voteID);
require(account != address(0x0), "Juror not drawn yet.");
require(account != address(0x0) || isDrawingForbidden, "Juror not drawn yet.");
frozenTokens[account] += tokensAtStakePerJuror[round];
}
isDisputeNotified[_disputeID][round] = true;
Expand Down