KlerosGovernor

Git Source

Inherits: IArbitrable, IMetaEvidence

State Variables

arbitrator

IArbitrator public arbitrator;

arbitratorExtraData

bytes public arbitratorExtraData;

metaEvidenceUpdates

uint256 public metaEvidenceUpdates;

submissionBaseDeposit

uint256 public submissionBaseDeposit;

submissionTimeout

uint256 public submissionTimeout;

executionTimeout

uint256 public executionTimeout;

withdrawTimeout

uint256 public withdrawTimeout;

lastApprovalTime

uint256 public lastApprovalTime;

reservedETH

uint256 public reservedETH;

submissions

Submission[] public submissions;

sessions

Session[] public sessions;

Functions

duringSubmissionPeriod

modifier duringSubmissionPeriod();

duringApprovalPeriod

modifier duringApprovalPeriod();

onlyByGovernor

modifier onlyByGovernor();

constructor

Constructor.

constructor(
    IArbitrator _arbitrator,
    bytes memory _arbitratorExtraData,
    string memory _metaEvidence,
    uint256 _submissionBaseDeposit,
    uint256 _submissionTimeout,
    uint256 _executionTimeout,
    uint256 _withdrawTimeout
);

Parameters

NameTypeDescription
_arbitratorIArbitratorThe arbitrator of the contract.
_arbitratorExtraDatabytesExtra data for the arbitrator.
_metaEvidencestringThe URI of the meta evidence file.
_submissionBaseDeposituint256The base deposit required for submission.
_submissionTimeoutuint256Time in seconds allocated for submitting transaction list.
_executionTimeoutuint256Time in seconds after approval that allows to execute transactions of the approved list.
_withdrawTimeoutuint256Time in seconds after submission that allows to withdraw submitted list.

changeSubmissionDeposit

Changes the value of the base deposit required for submitting a list.

function changeSubmissionDeposit(uint256 _submissionBaseDeposit) external onlyByGovernor;

Parameters

NameTypeDescription
_submissionBaseDeposituint256The new value of the base deposit, in wei.

changeSubmissionTimeout

Changes the time allocated for submission. Note that it can't be changed during approval period because there can be an active dispute in the old arbitrator contract and prolonging submission timeout might switch it back to submission period.

function changeSubmissionTimeout(uint256 _submissionTimeout) external onlyByGovernor duringSubmissionPeriod;

Parameters

NameTypeDescription
_submissionTimeoutuint256The new duration of the submission period, in seconds.

changeExecutionTimeout

Changes the time allocated for list's execution.

function changeExecutionTimeout(uint256 _executionTimeout) external onlyByGovernor;

Parameters

NameTypeDescription
_executionTimeoutuint256The new duration of the execution timeout, in seconds.

changeWithdrawTimeout

Changes list withdrawal timeout. Note that withdrawals are only possible in the first half of the submission period.

function changeWithdrawTimeout(uint256 _withdrawTimeout) external onlyByGovernor;

Parameters

NameTypeDescription
_withdrawTimeoutuint256The new duration of withdraw period, in seconds.

changeArbitrator

Changes the arbitrator of the contract. Note that it can't be changed during approval period because there can be an active dispute in the old arbitrator contract.

function changeArbitrator(IArbitrator _arbitrator, bytes memory _arbitratorExtraData)
    external
    onlyByGovernor
    duringSubmissionPeriod;

Parameters

NameTypeDescription
_arbitratorIArbitratorThe new trusted arbitrator.
_arbitratorExtraDatabytesThe extra data used by the new arbitrator.

changeMetaEvidence

Update the meta evidence used for disputes.

function changeMetaEvidence(string memory _metaEvidence) external onlyByGovernor;

Parameters

NameTypeDescription
_metaEvidencestringURI to the new meta evidence file.

submitList

Creates transaction list based on input parameters and submits it for potential approval and execution. Transactions must be ordered by their hash.

function submitList(
    address[] memory _target,
    uint256[] memory _value,
    bytes memory _data,
    uint256[] memory _dataSize,
    string memory _description
) external payable duringSubmissionPeriod;

Parameters

NameTypeDescription
_targetaddress[]List of addresses to call.
_valueuint256[]List of values required for respective addresses.
_databytesConcatenated calldata of all transactions of this list.
_dataSizeuint256[]List of lengths in bytes required to split calldata for its respective targets.
_descriptionstringString in CSV format that describes list's transactions.

withdrawTransactionList

Withdraws submitted transaction list. Reimburses submission deposit. Withdrawal is only possible during the first half of the submission period and during withdrawTimeout after the submission is made.

function withdrawTransactionList(uint256 _submissionID, bytes32 _listHash) external;

Parameters

NameTypeDescription
_submissionIDuint256Submission's index in the array of submitted lists of the current sesssion.
_listHashbytes32Hash of a withdrawing list.

executeSubmissions

Approves a transaction list or creates a dispute if more than one list was submitted. TRUSTED. If nothing was submitted changes session.

function executeSubmissions() external duringApprovalPeriod;

rule

Gives a ruling for a dispute. Must be called by the arbitrator.

function rule(uint256 _disputeID, uint256 _ruling) external override;

Parameters

NameTypeDescription
_disputeIDuint256ID of the dispute in the Arbitrator contract.
_rulinguint256Ruling given by the arbitrator. Note that 0 is reserved for "Refuse to arbitrate". Note If the final ruling is "0" nothing is approved and deposits will stay locked in the contract.

executeTransactionList

Executes selected transactions of the list. UNTRUSTED.

function executeTransactionList(uint256 _listID, uint256 _cursor, uint256 _count) external;

Parameters

NameTypeDescription
_listIDuint256The index of the transaction list in the array of lists.
_cursoruint256Index of the transaction from which to start executing.
_countuint256Number of transactions to execute. Executes until the end if set to "0" or number higher than number of transactions in the list.

receive

Receive function to receive funds for the execution of transactions.

receive() external payable;

getExpendableFunds

Gets the sum of contract funds that are used for the execution of transactions.

function getExpendableFunds() public view returns (uint256);

Returns

NameTypeDescription
<none>uint256Contract balance without reserved ETH.

getTransactionInfo

Gets the info of the specific transaction in the specific list.

function getTransactionInfo(uint256 _listID, uint256 _transactionIndex)
    external
    view
    returns (address target, uint256 value, bytes memory data, bool executed);

Parameters

NameTypeDescription
_listIDuint256The index of the transaction list in the array of lists.
_transactionIndexuint256The index of the transaction.

Returns

NameTypeDescription
targetaddressThe target of the transaction.
valueuint256The value of the transaction.
databytesThe data of the transaction.
executedboolWhether the transaction was executed or not.

getSubmittedLists

Gets the array of submitted lists in the session. Note that this function is O(n), where n is the number of submissions in the session. This could exceed the gas limit, therefore this function should only be used for interface display and not by other contracts.

function getSubmittedLists(uint256 _session) external view returns (uint256[] memory submittedLists);

Parameters

NameTypeDescription
_sessionuint256The ID of the session.

Returns

NameTypeDescription
submittedListsuint256[]Indexes of lists that were submitted during the session.

getNumberOfTransactions

Gets the number of transactions in the list.

function getNumberOfTransactions(uint256 _listID) external view returns (uint256 txCount);

Parameters

NameTypeDescription
_listIDuint256The index of the transaction list in the array of lists.

Returns

NameTypeDescription
txCountuint256The number of transactions in the list.

getNumberOfCreatedLists

Gets the number of lists created in contract's lifetime.

function getNumberOfCreatedLists() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The number of created lists.

getCurrentSessionNumber

Gets the number of the ongoing session.

function getCurrentSessionNumber() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The number of the ongoing session.

Events

ListSubmitted

Emitted when a new list is submitted.

event ListSubmitted(uint256 indexed _listID, address indexed _submitter, uint256 indexed _session, string _description);

Structs

Session

struct Session {
    uint256 ruling;
    uint256 disputeID;
    uint256[] submittedLists;
    uint256 sumDeposit;
    Status status;
    mapping(bytes32 => bool) alreadySubmitted;
    uint256 durationOffset;
}

Transaction

struct Transaction {
    address target;
    uint256 value;
    bytes data;
    bool executed;
}

Submission

struct Submission {
    address payable submitter;
    uint256 deposit;
    Transaction[] txs;
    bytes32 listHash;
    uint256 submissionTime;
    bool approved;
    uint256 approvalTime;
}

Enums

Status

enum Status {
    NoDispute,
    DisputeCreated,
    Resolved
}