Skip to content
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

Dispute template registry #1110

Merged
merged 3 commits into from
Aug 6, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: dispute template registry, wip
  • Loading branch information
jaybuidl committed Aug 6, 2023
commit 94a5f9a8f811772a7b22b074abcfd81ad1ccd510
18 changes: 14 additions & 4 deletions contracts/src/arbitration/KlerosGovernor.sol
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
pragma solidity 0.8.18;

import {IArbitrableV2, IArbitratorV2} from "./interfaces/IArbitrableV2.sol";
import "./interfaces/IDisputeTemplateRegistry.sol";
import "../libraries/CappedMath.sol";

/// @title KlerosGovernor for V2. Note that appeal functionality and evidence submission will be handled by the court.
@@ -53,7 +54,8 @@ contract KlerosGovernor is IArbitrableV2 {

IArbitratorV2 public arbitrator; // Arbitrator contract.
bytes public arbitratorExtraData; // Extra data for arbitrator.
uint256 public disputeTemplates; // The number of dispute templates created.
IDisputeTemplateRegistry public templateRegistry; // The dispute template registry.
uint256 public templateId; // The current dispute template identifier.

uint256 public submissionBaseDeposit; // The base deposit in wei that needs to be paid in order to submit the list.
uint256 public submissionTimeout; // Time in seconds allowed for submitting the lists. Once it's passed the contract enters the approval period.
@@ -138,9 +140,13 @@ contract KlerosGovernor is IArbitrableV2 {
withdrawTimeout = _withdrawTimeout;
sessions.push();

emit DisputeTemplate(disputeTemplates++, "", _templateData);
templateId = templateRegistry.setDisputeTemplate("", _templateData);
}

// ************************************* //
// * Governance * //
// ************************************* //

/// @dev Changes the value of the base deposit required for submitting a list.
/// @param _submissionBaseDeposit The new value of the base deposit, in wei.
function changeSubmissionDeposit(uint256 _submissionBaseDeposit) external onlyByGovernor {
@@ -180,9 +186,13 @@ contract KlerosGovernor is IArbitrableV2 {
/// @dev Update the dispute template data.
/// @param _templateData The new dispute template data.
function changeDisputeTemplate(string memory _templateData) external onlyByGovernor {
emit DisputeTemplate(disputeTemplates++, "", _templateData);
templateId = templateRegistry.setDisputeTemplate("", _templateData);
}

// ************************************* //
// * State Modifiers * //
// ************************************* //

/// @dev Creates transaction list based on input parameters and submits it for potential approval and execution.
/// Transactions must be ordered by their hash.
/// @param _target List of addresses to call.
@@ -294,7 +304,7 @@ contract KlerosGovernor is IArbitrableV2 {
session.sumDeposit = session.sumDeposit.subCap(arbitrationCost);

reservedETH = reservedETH.subCap(arbitrationCost);
emit DisputeRequest(arbitrator, session.disputeID, sessions.length - 1, disputeTemplates, "");
emit DisputeRequest(arbitrator, session.disputeID, sessions.length - 1, templateId, "");
}
}

21 changes: 13 additions & 8 deletions contracts/src/arbitration/arbitrables/ArbitrableExample.sol
Original file line number Diff line number Diff line change
@@ -32,6 +32,15 @@ contract ArbitrableExample is IArbitrableV2 {
mapping(uint256 => uint256) public externalIDtoLocalID; // Maps external (arbitrator side) dispute IDs to local dispute IDs.
DisputeStruct[] public disputes; // Stores the disputes' info. disputes[disputeID].

// ************************************* //
// * Function Modifiers * //
// ************************************* //

modifier onlyByGovernor() {
require(address(this) == msg.sender, "Only the governor allowed.");
_;
}

// ************************************* //
// * Constructor * //
// ************************************* //
@@ -60,23 +69,19 @@ contract ArbitrableExample is IArbitrableV2 {
// * Governance * //
// ************************************* //

function changeArbitrator(IArbitratorV2 _arbitrator) external {
require(msg.sender == governor, "Not authorized: governor only.");
function changeArbitrator(IArbitratorV2 _arbitrator) external onlyByGovernor {
arbitrator = _arbitrator;
}

function changeArbitratorExtraData(bytes calldata _arbitratorExtraData) external {
require(msg.sender == governor, "Not authorized: governor only.");
function changeArbitratorExtraData(bytes calldata _arbitratorExtraData) external onlyByGovernor {
arbitratorExtraData = _arbitratorExtraData;
}

function changeTemplateRegistry(IDisputeTemplateRegistry _templateRegistry) external {
require(governor == msg.sender, "Access not allowed: Governor only.");
function changeTemplateRegistry(IDisputeTemplateRegistry _templateRegistry) external onlyByGovernor {
templateRegistry = _templateRegistry;
}

function changeDisputeTemplate(string memory _templateData) external {
require(msg.sender == governor, "Not authorized: governor only.");
function changeDisputeTemplate(string memory _templateData) external onlyByGovernor {
templateId = templateRegistry.setDisputeTemplate("", _templateData);
}

Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ pragma solidity 0.8.18;

// TODO: standard interfaces should be placed in a separated repo (?)
import {IArbitrableV2, IArbitratorV2} from "../interfaces/IArbitrableV2.sol";
import "../interfaces/IDisputeTemplateRegistry.sol";
import "../../libraries/CappedMath.sol";

/// @title Implementation of the Evidence Standard with Moderated Submissions
@@ -61,6 +62,7 @@ contract ModeratedEvidenceModule is IArbitrableV2 {
ArbitratorData[] public arbitratorDataList; // Stores the arbitrator data of the contract. Updated each time the data is changed.
IArbitratorV2 public immutable arbitrator; // The trusted arbitrator to resolve potential disputes. If it needs to be changed, a new contract can be deployed.
address public governor; // The address that can make governance changes to the parameters of the contract.
IDisputeTemplateRegistry public templateRegistry; // The dispute template registry.
uint256 public bondTimeout; // The time in seconds during which the last moderation status can be challenged.
uint256 public totalCostMultiplier; // Multiplier of arbitration fees that must be ultimately paid as fee stake. In basis points.
uint256 public initialDepositMultiplier; // Multiplier of arbitration fees that must be paid as initial stake for submitting evidence. In basis points.
@@ -110,6 +112,7 @@ contract ModeratedEvidenceModule is IArbitrableV2 {
constructor(
IArbitratorV2 _arbitrator,
address _governor,
IDisputeTemplateRegistry _templateRegistry,
uint256 _totalCostMultiplier,
uint256 _initialDepositMultiplier,
uint256 _bondTimeout,
@@ -118,14 +121,15 @@ contract ModeratedEvidenceModule is IArbitrableV2 {
) {
arbitrator = _arbitrator;
governor = _governor;
templateRegistry = _templateRegistry;

totalCostMultiplier = _totalCostMultiplier; // For example 15000, which would provide a 100% reward to the dispute winner.
initialDepositMultiplier = _initialDepositMultiplier; // For example 63, which equals 1/16.
bondTimeout = _bondTimeout; // For example 24 hs.

ArbitratorData storage arbitratorData = arbitratorDataList.push();
arbitratorData.arbitratorExtraData = _arbitratorExtraData;
emit DisputeTemplate(arbitratorData.disputeTemplateId, "", _templateData);
arbitratorData.disputeTemplateId = templateRegistry.setDisputeTemplate("", _templateData);
}

// ************************************* //
@@ -161,14 +165,13 @@ contract ModeratedEvidenceModule is IArbitrableV2 {
/// @param _templateData The new dispute template data.
function changeDisputeTemplate(string calldata _templateData) external onlyGovernor {
ArbitratorData storage arbitratorData = arbitratorDataList[arbitratorDataList.length - 1];
uint256 newDisputeTemplateId = arbitratorData.disputeTemplateId + 1;
uint256 newDisputeTemplateId = templateRegistry.setDisputeTemplate("", _templateData);
arbitratorDataList.push(
ArbitratorData({
disputeTemplateId: newDisputeTemplateId,
arbitratorExtraData: arbitratorData.arbitratorExtraData
})
);
emit DisputeTemplate(newDisputeTemplateId, "", _templateData);
}

/// @dev Change the arbitrator to be used for disputes that may be raised in the next requests. The arbitrator is trusted to support appeal period and not reenter.