diff --git a/contracts/CHANGELOG.md b/contracts/CHANGELOG.md index 751bd5473..79845b880 100644 --- a/contracts/CHANGELOG.md +++ b/contracts/CHANGELOG.md @@ -12,6 +12,7 @@ The format is based on [Common Changelog](https://common-changelog.org/). - **Breaking:** Replace `require()` with `revert()` and custom errors outside KlerosCore for consistency and smaller bytecode ([#2084](https://github.com/kleros/kleros-v2/issues/2084)) - **Breaking:** Rename the interface from `RNG` to `IRNG` ([#2054](https://github.com/kleros/kleros-v2/issues/2054)) - **Breaking:** Remove the `_block` parameter from `IRNG.requestRandomness()` and `IRNG.receiveRandomness()`, not needed for the primary VRF-based RNG ([#2054](https://github.com/kleros/kleros-v2/issues/2054)) +- **Breaking:** Rename `governor` to `owner` in order to comply with the lightweight ownership standard [ERC-5313](https://eipsinsight.com/ercs/erc-5313) ([#2112](https://github.com/kleros/kleros-v2/issues/2112)) - Make the primary VRF-based RNG fall back to `BlockhashRNG` if the VRF request is not fulfilled within a timeout ([#2054](https://github.com/kleros/kleros-v2/issues/2054)) - Authenticate the calls to the RNGs to prevent 3rd parties from depleting the Chainlink VRF subscription funds ([#2054](https://github.com/kleros/kleros-v2/issues/2054)) - Use `block.timestamp` rather than `block.number` for `BlockhashRNG` for better reliability on Arbitrum as block production is sporadic depending on network conditions. ([#2054](https://github.com/kleros/kleros-v2/issues/2054)) diff --git a/contracts/deploy/00-home-chain-arbitration-ruler.ts b/contracts/deploy/00-home-chain-arbitration-ruler.ts index 5e6e5bdc7..a9077dbe6 100644 --- a/contracts/deploy/00-home-chain-arbitration-ruler.ts +++ b/contracts/deploy/00-home-chain-arbitration-ruler.ts @@ -29,7 +29,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) await deployUpgradable(deployments, "KlerosCoreRuler", { from: deployer, args: [ - deployer, // governor + deployer, // owner pnk.target, [minStake, alpha, feeForJuror, jurorsForCourtJump], ], diff --git a/contracts/deploy/00-home-chain-arbitration-university.ts b/contracts/deploy/00-home-chain-arbitration-university.ts index e3fce871e..2aa5f747b 100644 --- a/contracts/deploy/00-home-chain-arbitration-university.ts +++ b/contracts/deploy/00-home-chain-arbitration-university.ts @@ -50,7 +50,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) const klerosCore = await deployUpgradable(deployments, "KlerosCoreUniversity", { from: deployer, args: [ - deployer, // governor + deployer, // owner deployer, // instructor pnk.target, ZeroAddress, // KlerosCore is configured later diff --git a/contracts/hardhat.config.ts b/contracts/hardhat.config.ts index 3bb2787ca..d451ef05f 100644 --- a/contracts/hardhat.config.ts +++ b/contracts/hardhat.config.ts @@ -15,7 +15,7 @@ import "hardhat-contract-sizer"; import "hardhat-tracer"; require("./scripts/populatePolicyRegistry"); require("./scripts/populateCourts"); -require("./scripts/changeGovernor"); +require("./scripts/changeOwner"); require("./scripts/getDisputeTemplate"); require("./scripts/compareStorageLayout"); require("./scripts/storage-layout"); diff --git a/contracts/scripts/changeGovernor.ts b/contracts/scripts/changeGovernor.ts deleted file mode 100644 index e9a9cd01c..000000000 --- a/contracts/scripts/changeGovernor.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { task } from "hardhat/config"; -import { prompt, print } from "gluegun"; -import { Cores, getContracts } from "./utils/contracts"; -import { isAddress } from "viem"; - -const { bold } = print.colors; - -task("change-governor", "Changes the governor for all the contracts") - .addPositionalParam("newGovernor", "The address of the new governor") - .addOptionalParam("coreType", "The type of core to use between base, neo, university (default: base)", Cores.BASE) - .setAction(async (taskArgs, hre) => { - const newGovernor = taskArgs.newGovernor; - if (!isAddress(newGovernor)) { - throw new Error("Invalid governor address provided"); - } - print.highlight(`💣 Changing governor to ${bold(newGovernor)}`); - - const { confirm } = await prompt.ask({ - type: "confirm", - name: "confirm", - message: "Are you sure you want to proceed?", - }); - if (!confirm) { - console.log("Operation cancelled by user."); - return; - } - - const coreType = Cores[taskArgs.coreType.toUpperCase() as keyof typeof Cores]; - if (coreType === undefined) { - console.error("Invalid core type, must be one of base, neo, university"); - return; - } - console.log("Using core type %s", coreType); - - const { - core, - disputeKitClassic, - disputeResolver, - disputeTemplateRegistry, - policyRegistry, - chainlinkRng, - randomizerRng, - snapshotProxy, - sortition, - evidence, - } = await getContracts(hre, coreType); - - const updateGovernor = async (contractName: string, contractInstance: any) => { - print.info(`Changing governor for ${contractName}`); - - const spinner = print.spin(`Executing transaction for ${contractName}...`); - try { - const tx = await contractInstance.changeGovernor(newGovernor); - await tx.wait(); - spinner.succeed(`Governor changed for ${contractName}, tx hash: ${tx.hash}`); - } catch (error) { - if (error instanceof Error) { - spinner.fail(`Failed to change governor for ${contractName}: ${error.message}`); - } else { - spinner.fail(`Failed to change governor for ${contractName}: ${String(error)}`); - } - } - }; - - await updateGovernor("KlerosCore", core); - await updateGovernor("DisputeKitClassic", disputeKitClassic); - await updateGovernor("DisputeResolver", disputeResolver); - await updateGovernor("DisputeTemplateRegistry", disputeTemplateRegistry); - await updateGovernor("PolicyRegistry", policyRegistry); - await updateGovernor("KlerosCoreSnapshotProxy", snapshotProxy); - await updateGovernor("SortitionModule", sortition); - await updateGovernor("EvidenceModule", evidence); - if (chainlinkRng) await updateGovernor("ChainlinkRNG", chainlinkRng); - if (randomizerRng) await updateGovernor("RandomizerRNG", randomizerRng); - - print.success("Governor changed successfully"); - }); diff --git a/contracts/scripts/changeOwner.ts b/contracts/scripts/changeOwner.ts new file mode 100644 index 000000000..72eeaeef7 --- /dev/null +++ b/contracts/scripts/changeOwner.ts @@ -0,0 +1,77 @@ +import { task } from "hardhat/config"; +import { prompt, print } from "gluegun"; +import { Cores, getContracts } from "./utils/contracts"; +import { isAddress } from "viem"; + +const { bold } = print.colors; + +task("change-owner", "Changes the owner for all the contracts") + .addPositionalParam("newOwner", "The address of the new owner") + .addOptionalParam("coreType", "The type of core to use between base, neo, university (default: base)", Cores.BASE) + .setAction(async (taskArgs, hre) => { + const newOwner = taskArgs.newOwner; + if (!isAddress(newOwner)) { + throw new Error("Invalid owner address provided"); + } + print.highlight(`💣 Changing owner to ${bold(newOwner)}`); + + const { confirm } = await prompt.ask({ + type: "confirm", + name: "confirm", + message: "Are you sure you want to proceed?", + }); + if (!confirm) { + console.log("Operation cancelled by user."); + return; + } + + const coreType = Cores[taskArgs.coreType.toUpperCase() as keyof typeof Cores]; + if (coreType === undefined) { + console.error("Invalid core type, must be one of base, neo, university"); + return; + } + console.log("Using core type %s", coreType); + + const { + core, + disputeKitClassic, + disputeResolver, + disputeTemplateRegistry, + policyRegistry, + chainlinkRng, + randomizerRng, + snapshotProxy, + sortition, + evidence, + } = await getContracts(hre, coreType); + + const updateOwner = async (contractName: string, contractInstance: any) => { + print.info(`Changing owner for ${contractName}`); + + const spinner = print.spin(`Executing transaction for ${contractName}...`); + try { + const tx = await contractInstance.changeOwner(newOwner); + await tx.wait(); + spinner.succeed(`Owner changed for ${contractName}, tx hash: ${tx.hash}`); + } catch (error) { + if (error instanceof Error) { + spinner.fail(`Failed to change owner for ${contractName}: ${error.message}`); + } else { + spinner.fail(`Failed to change owner for ${contractName}: ${String(error)}`); + } + } + }; + + await updateOwner("KlerosCore", core); + await updateOwner("DisputeKitClassic", disputeKitClassic); + await updateOwner("DisputeResolver", disputeResolver); + await updateOwner("DisputeTemplateRegistry", disputeTemplateRegistry); + await updateOwner("PolicyRegistry", policyRegistry); + await updateOwner("KlerosCoreSnapshotProxy", snapshotProxy); + await updateOwner("SortitionModule", sortition); + await updateOwner("EvidenceModule", evidence); + if (chainlinkRng) await updateOwner("ChainlinkRNG", chainlinkRng); + if (randomizerRng) await updateOwner("RandomizerRNG", randomizerRng); + + print.success("Owner changed successfully"); + }); diff --git a/contracts/scripts/utils/execution.ts b/contracts/scripts/utils/execution.ts index f8fab0207..b35709d5d 100644 --- a/contracts/scripts/utils/execution.ts +++ b/contracts/scripts/utils/execution.ts @@ -5,7 +5,7 @@ import { type BuilderTransaction, template, transaction, transactionBuilderUrl } const governableAbi = [ { inputs: [], - name: "governor", + name: "owner", outputs: [ { internalType: "address", @@ -25,8 +25,8 @@ export const execute = async (tx: ContractTransaction) => { const { ethers } = hre; const contract = await ethers.getContractAt(governableAbi, tx.to); - const governor = await contract.governor(); - const isContract = (await ethers.provider.getCode(governor)).length > 2; + const owner = await contract.owner(); + const isContract = (await ethers.provider.getCode(owner)).length > 2; if (isContract) { // Don't execute, just log the tx. It must be submitted for execution separately. const { to, value, data } = tx; diff --git a/contracts/scripts/utils/tx-builder.ts b/contracts/scripts/utils/tx-builder.ts index 06c7e65ab..fd0b52367 100644 --- a/contracts/scripts/utils/tx-builder.ts +++ b/contracts/scripts/utils/tx-builder.ts @@ -1,6 +1,6 @@ import { arbitrum } from "viem/chains"; -const governor = "0x66e8DE9B42308c6Ca913D1EE041d6F6fD037A57e"; +const owner = "0x66e8DE9B42308c6Ca913D1EE041d6F6fD037A57e"; const deployer = "0xf1C7c037891525E360C59f708739Ac09A7670c59"; // Transaction batch example: https://github.com/safe-global/safe-wallet-monorepo/blob/8bbf3b82edc347b70a038629cd9afd45eb1ed38a/apps/web/cypress/fixtures/test-working-batch.json @@ -12,7 +12,7 @@ export const template = ({ name, transactions }: { name: string; transactions: B name, description: "", // Not used because the Safe app doesn't show it txBuilderVersion: "1.18.0", - createdFromSafeAddress: governor, + createdFromSafeAddress: owner, createdFromOwnerAddress: deployer, }, transactions, @@ -42,4 +42,4 @@ export interface BuilderTransaction { contractInputsValues: null; } -export const transactionBuilderUrl = `https://app.safe.global/apps/open?safe=arb1:${governor}&appUrl=https%3A%2F%2Fapps-portal.safe.global%2Ftx-builder`; +export const transactionBuilderUrl = `https://app.safe.global/apps/open?safe=arb1:${owner}&appUrl=https%3A%2F%2Fapps-portal.safe.global%2Ftx-builder`; diff --git a/contracts/scripts/viemTest.ts b/contracts/scripts/viemTest.ts index bbd08d68f..0346ec900 100644 --- a/contracts/scripts/viemTest.ts +++ b/contracts/scripts/viemTest.ts @@ -15,7 +15,7 @@ const main = async () => { client: client, }); - await disputeKit.read.governor().then(console.log); + await disputeKit.read.owner().then(console.log); // -------------------------------------------------- diff --git a/contracts/src/arbitration/DisputeTemplateRegistry.sol b/contracts/src/arbitration/DisputeTemplateRegistry.sol index e63d7c297..b9354aa0a 100644 --- a/contracts/src/arbitration/DisputeTemplateRegistry.sol +++ b/contracts/src/arbitration/DisputeTemplateRegistry.sol @@ -14,8 +14,8 @@ contract DisputeTemplateRegistry is IDisputeTemplateRegistry, UUPSProxiable, Ini // * Storage * // // ************************************* // - /// @dev The governor of the contract. - address public governor; + /// @dev The owner of the contract. + address public owner; /// @dev The number of templates. uint256 public templates; @@ -24,8 +24,8 @@ contract DisputeTemplateRegistry is IDisputeTemplateRegistry, UUPSProxiable, Ini // * Function Modifiers * // // ************************************* // - modifier onlyByGovernor() { - if (governor != msg.sender) revert GovernorOnly(); + modifier onlyByOwner() { + if (owner != msg.sender) revert OwnerOnly(); _; } @@ -39,9 +39,9 @@ contract DisputeTemplateRegistry is IDisputeTemplateRegistry, UUPSProxiable, Ini } /// @dev Initializer - /// @param _governor Governor of the contract. - function initialize(address _governor) external reinitializer(1) { - governor = _governor; + /// @param _owner Owner of the contract. + function initialize(address _owner) external reinitializer(1) { + owner = _owner; } function initialize2() external reinitializer(2) { @@ -53,15 +53,15 @@ contract DisputeTemplateRegistry is IDisputeTemplateRegistry, UUPSProxiable, Ini // ************************ // /// @dev Access Control to perform implementation upgrades (UUPS Proxiable) - /// Only the governor can perform upgrades (`onlyByGovernor`) - function _authorizeUpgrade(address) internal view override onlyByGovernor { + /// Only the owner can perform upgrades (`onlyByOwner`) + function _authorizeUpgrade(address) internal view override onlyByOwner { // NOP } - /// @dev Changes the governor of the contract. - /// @param _governor The new governor. - function changeGovernor(address _governor) external onlyByGovernor { - governor = _governor; + /// @dev Changes the owner of the contract. + /// @param _owner The new owner. + function changeOwner(address _owner) external onlyByOwner { + owner = _owner; } // ************************************* // @@ -85,5 +85,5 @@ contract DisputeTemplateRegistry is IDisputeTemplateRegistry, UUPSProxiable, Ini // * Errors * // // ************************************* // - error GovernorOnly(); + error OwnerOnly(); } diff --git a/contracts/src/arbitration/KlerosCore.sol b/contracts/src/arbitration/KlerosCore.sol index 3853c6b47..912a57269 100644 --- a/contracts/src/arbitration/KlerosCore.sol +++ b/contracts/src/arbitration/KlerosCore.sol @@ -20,7 +20,7 @@ contract KlerosCore is KlerosCoreBase { } /// @dev Initializer (constructor equivalent for upgradable contracts). - /// @param _governor The governor's address. + /// @param _owner The owner's address. /// @param _guardian The guardian's address. /// @param _pinakion The address of the token contract. /// @param _jurorProsecutionModule The address of the juror prosecution module. @@ -32,7 +32,7 @@ contract KlerosCore is KlerosCoreBase { /// @param _sortitionModuleAddress The sortition module responsible for sortition of the jurors. /// @param _wNative The wrapped native token address, typically wETH. function initialize( - address _governor, + address _owner, address _guardian, IERC20 _pinakion, address _jurorProsecutionModule, @@ -45,7 +45,7 @@ contract KlerosCore is KlerosCoreBase { address _wNative ) external reinitializer(1) { __KlerosCoreBase_initialize( - _governor, + _owner, _guardian, _pinakion, _jurorProsecutionModule, @@ -68,8 +68,8 @@ contract KlerosCore is KlerosCoreBase { // ************************************* // /// @dev Access Control to perform implementation upgrades (UUPS Proxiable) - /// Only the governor can perform upgrades (`onlyByGovernor`) - function _authorizeUpgrade(address) internal view override onlyByGovernor { + /// Only the owner can perform upgrades (`onlyByOwner`) + function _authorizeUpgrade(address) internal view override onlyByOwner { // NOP } } diff --git a/contracts/src/arbitration/KlerosCoreBase.sol b/contracts/src/arbitration/KlerosCoreBase.sol index eb595096e..0a9946bbc 100644 --- a/contracts/src/arbitration/KlerosCoreBase.sol +++ b/contracts/src/arbitration/KlerosCoreBase.sol @@ -90,7 +90,7 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable uint256 private constant NON_PAYABLE_AMOUNT = (2 ** 256 - 2) / 2; // An amount higher than the supply of ETH. - address public governor; // The governor of the contract. + address public owner; // The owner of the contract. address public guardian; // The guardian able to pause asset withdrawals. IERC20 public pinakion; // The Pinakion token contract. address public jurorProsecutionModule; // The module for juror's prosecution. @@ -167,13 +167,13 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable // * Function Modifiers * // // ************************************* // - modifier onlyByGovernor() { - if (governor != msg.sender) revert GovernorOnly(); + modifier onlyByOwner() { + if (owner != msg.sender) revert OwnerOnly(); _; } - modifier onlyByGuardianOrGovernor() { - if (guardian != msg.sender && governor != msg.sender) revert GuardianOrGovernorOnly(); + modifier onlyByGuardianOrOwner() { + if (guardian != msg.sender && owner != msg.sender) revert GuardianOrOwnerOnly(); _; } @@ -192,7 +192,7 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable // ************************************* // function __KlerosCoreBase_initialize( - address _governor, + address _owner, address _guardian, IERC20 _pinakion, address _jurorProsecutionModule, @@ -204,7 +204,7 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable ISortitionModule _sortitionModuleAddress, address _wNative ) internal onlyInitializing { - governor = _governor; + owner = _owner; guardian = _guardian; pinakion = _pinakion; jurorProsecutionModule = _jurorProsecutionModule; @@ -257,65 +257,61 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable // * Governance * // // ************************************* // - /// @dev Pause staking and reward execution. Can only be done by guardian or governor. - function pause() external onlyByGuardianOrGovernor whenNotPaused { + /// @dev Pause staking and reward execution. Can only be done by guardian or owner. + function pause() external onlyByGuardianOrOwner whenNotPaused { paused = true; emit Paused(); } - /// @dev Unpause staking and reward execution. Can only be done by governor. - function unpause() external onlyByGovernor whenPaused { + /// @dev Unpause staking and reward execution. Can only be done by owner. + function unpause() external onlyByOwner whenPaused { paused = false; emit Unpaused(); } - /// @dev Allows the governor to call anything on behalf of the contract. + /// @dev Allows the owner to call anything on behalf of the contract. /// @param _destination The destination of the call. /// @param _amount The value sent with the call. /// @param _data The data sent with the call. - function executeGovernorProposal( - address _destination, - uint256 _amount, - bytes memory _data - ) external onlyByGovernor { + function executeOwnerProposal(address _destination, uint256 _amount, bytes memory _data) external onlyByOwner { (bool success, ) = _destination.call{value: _amount}(_data); if (!success) revert UnsuccessfulCall(); } - /// @dev Changes the `governor` storage variable. - /// @param _governor The new value for the `governor` storage variable. - function changeGovernor(address payable _governor) external onlyByGovernor { - governor = _governor; + /// @dev Changes the `owner` storage variable. + /// @param _owner The new value for the `owner` storage variable. + function changeOwner(address payable _owner) external onlyByOwner { + owner = _owner; } /// @dev Changes the `guardian` storage variable. /// @param _guardian The new value for the `guardian` storage variable. - function changeGuardian(address _guardian) external onlyByGovernor { + function changeGuardian(address _guardian) external onlyByOwner { guardian = _guardian; } /// @dev Changes the `pinakion` storage variable. /// @param _pinakion The new value for the `pinakion` storage variable. - function changePinakion(IERC20 _pinakion) external onlyByGovernor { + function changePinakion(IERC20 _pinakion) external onlyByOwner { pinakion = _pinakion; } /// @dev Changes the `jurorProsecutionModule` storage variable. /// @param _jurorProsecutionModule The new value for the `jurorProsecutionModule` storage variable. - function changeJurorProsecutionModule(address _jurorProsecutionModule) external onlyByGovernor { + function changeJurorProsecutionModule(address _jurorProsecutionModule) external onlyByOwner { jurorProsecutionModule = _jurorProsecutionModule; } /// @dev Changes the `_sortitionModule` storage variable. /// Note that the new module should be initialized for all courts. /// @param _sortitionModule The new value for the `sortitionModule` storage variable. - function changeSortitionModule(ISortitionModule _sortitionModule) external onlyByGovernor { + function changeSortitionModule(ISortitionModule _sortitionModule) external onlyByOwner { sortitionModule = _sortitionModule; } /// @dev Add a new supported dispute kit module to the court. /// @param _disputeKitAddress The address of the dispute kit contract. - function addNewDisputeKit(IDisputeKit _disputeKitAddress) external onlyByGovernor { + function addNewDisputeKit(IDisputeKit _disputeKitAddress) external onlyByOwner { uint256 disputeKitID = disputeKits.length; disputeKits.push(_disputeKitAddress); emit DisputeKitCreated(disputeKitID, _disputeKitAddress); @@ -341,7 +337,7 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable uint256[4] memory _timesPerPeriod, bytes memory _sortitionExtraData, uint256[] memory _supportedDisputeKits - ) external onlyByGovernor { + ) external onlyByOwner { if (courts[_parent].minStake > _minStake) revert MinStakeLowerThanParentCourt(); if (_supportedDisputeKits.length == 0) revert UnsupportedDisputeKit(); if (_parent == FORKING_COURT) revert InvalidForkingCourtAsParent(); @@ -392,7 +388,7 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable uint256 _feeForJuror, uint256 _jurorsForCourtJump, uint256[4] memory _timesPerPeriod - ) external onlyByGovernor { + ) external onlyByOwner { Court storage court = courts[_courtID]; if (_courtID != GENERAL_COURT && courts[court.parent].minStake > _minStake) { revert MinStakeLowerThanParentCourt(); @@ -423,7 +419,7 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable /// @param _courtID The ID of the court. /// @param _disputeKitIDs The IDs of dispute kits which support should be added/removed. /// @param _enable Whether add or remove the dispute kits from the court. - function enableDisputeKits(uint96 _courtID, uint256[] memory _disputeKitIDs, bool _enable) external onlyByGovernor { + function enableDisputeKits(uint96 _courtID, uint256[] memory _disputeKitIDs, bool _enable) external onlyByOwner { for (uint256 i = 0; i < _disputeKitIDs.length; i++) { if (_enable) { if (_disputeKitIDs[i] == 0 || _disputeKitIDs[i] >= disputeKits.length) { @@ -443,7 +439,7 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable /// @dev Changes the supported fee tokens. /// @param _feeToken The fee token. /// @param _accepted Whether the token is supported or not as a method of fee payment. - function changeAcceptedFeeTokens(IERC20 _feeToken, bool _accepted) external onlyByGovernor { + function changeAcceptedFeeTokens(IERC20 _feeToken, bool _accepted) external onlyByOwner { currencyRates[_feeToken].feePaymentAccepted = _accepted; emit AcceptedFeeToken(_feeToken, _accepted); } @@ -452,7 +448,7 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable /// @param _feeToken The fee token. /// @param _rateInEth The new rate of the fee token in ETH. /// @param _rateDecimals The new decimals of the fee token rate. - function changeCurrencyRates(IERC20 _feeToken, uint64 _rateInEth, uint8 _rateDecimals) external onlyByGovernor { + function changeCurrencyRates(IERC20 _feeToken, uint64 _rateInEth, uint8 _rateDecimals) external onlyByOwner { currencyRates[_feeToken].rateInEth = _rateInEth; currencyRates[_feeToken].rateDecimals = _rateDecimals; emit NewCurrencyRate(_feeToken, _rateInEth, _rateDecimals); @@ -795,9 +791,9 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable sortitionModule.setJurorInactive(account); } if (_params.repartition == _params.numberOfVotesInRound - 1 && _params.coherentCount == 0) { - // No one was coherent, send the rewards to the governor. - _transferFeeToken(round.feeToken, payable(governor), round.totalFeesForJurors); - pinakion.safeTransfer(governor, _params.pnkPenaltiesInRound); + // No one was coherent, send the rewards to the owner. + _transferFeeToken(round.feeToken, payable(owner), round.totalFeesForJurors); + pinakion.safeTransfer(owner, _params.pnkPenaltiesInRound); emit LeftoverRewardSent( _params.disputeID, _params.round, @@ -863,16 +859,16 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable round.feeToken ); - // Transfer any residual rewards to the governor. It may happen due to partial coherence of the jurors. + // Transfer any residual rewards to the owner. It may happen due to partial coherence of the jurors. if (_params.repartition == _params.numberOfVotesInRound * 2 - 1) { uint256 leftoverPnkReward = _params.pnkPenaltiesInRound - round.sumPnkRewardPaid; uint256 leftoverFeeReward = round.totalFeesForJurors - round.sumFeeRewardPaid; if (leftoverPnkReward != 0 || leftoverFeeReward != 0) { if (leftoverPnkReward != 0) { - pinakion.safeTransfer(governor, leftoverPnkReward); + pinakion.safeTransfer(owner, leftoverPnkReward); } if (leftoverFeeReward != 0) { - _transferFeeToken(round.feeToken, payable(governor), leftoverFeeReward); + _transferFeeToken(round.feeToken, payable(owner), leftoverFeeReward); } emit LeftoverRewardSent( _params.disputeID, @@ -1217,8 +1213,8 @@ abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable // * Errors * // // ************************************* // - error GovernorOnly(); - error GuardianOrGovernorOnly(); + error OwnerOnly(); + error GuardianOrOwnerOnly(); error DisputeKitOnly(); error SortitionModuleOnly(); error UnsuccessfulCall(); diff --git a/contracts/src/arbitration/KlerosCoreNeo.sol b/contracts/src/arbitration/KlerosCoreNeo.sol index 1d09c2964..a72319fc5 100644 --- a/contracts/src/arbitration/KlerosCoreNeo.sol +++ b/contracts/src/arbitration/KlerosCoreNeo.sol @@ -28,7 +28,7 @@ contract KlerosCoreNeo is KlerosCoreBase { } /// @dev Initializer (constructor equivalent for upgradable contracts). - /// @param _governor The governor's address. + /// @param _owner The owner's address. /// @param _guardian The guardian's address. /// @param _pinakion The address of the token contract. /// @param _jurorProsecutionModule The address of the juror prosecution module. @@ -41,7 +41,7 @@ contract KlerosCoreNeo is KlerosCoreBase { /// @param _jurorNft NFT contract to vet the jurors. /// @param _wNative The wrapped native token address, typically wETH. function initialize( - address _governor, + address _owner, address _guardian, IERC20 _pinakion, address _jurorProsecutionModule, @@ -55,7 +55,7 @@ contract KlerosCoreNeo is KlerosCoreBase { address _wNative ) external reinitializer(2) { __KlerosCoreBase_initialize( - _governor, + _owner, _guardian, _pinakion, _jurorProsecutionModule, @@ -79,21 +79,21 @@ contract KlerosCoreNeo is KlerosCoreBase { // ************************************* // /// @dev Access Control to perform implementation upgrades (UUPS Proxiable) - /// Only the governor can perform upgrades (`onlyByGovernor`) - function _authorizeUpgrade(address) internal view override onlyByGovernor { + /// Only the owner can perform upgrades (`onlyByOwner`) + function _authorizeUpgrade(address) internal view override onlyByOwner { // NOP } /// @dev Changes the `jurorNft` storage variable. /// @param _jurorNft The new value for the `jurorNft` storage variable. - function changeJurorNft(IERC721 _jurorNft) external onlyByGovernor { + function changeJurorNft(IERC721 _jurorNft) external onlyByOwner { jurorNft = _jurorNft; } /// @dev Adds or removes an arbitrable from whitelist. /// @param _arbitrable Arbitrable address. /// @param _allowed Whether add or remove permission. - function changeArbitrableWhitelist(address _arbitrable, bool _allowed) external onlyByGovernor { + function changeArbitrableWhitelist(address _arbitrable, bool _allowed) external onlyByOwner { arbitrableWhitelist[_arbitrable] = _allowed; } diff --git a/contracts/src/arbitration/KlerosGovernor.sol b/contracts/src/arbitration/KlerosGovernor.sol index a0a23061e..11957a745 100644 --- a/contracts/src/arbitration/KlerosGovernor.sol +++ b/contracts/src/arbitration/KlerosGovernor.sol @@ -80,8 +80,8 @@ contract KlerosGovernor is IArbitrableV2 { _; } - modifier onlyByGovernor() { - if (address(this) != msg.sender) revert GovernorOnly(); + modifier onlyByOwner() { + if (address(this) != msg.sender) revert OwnerOnly(); _; } @@ -147,26 +147,26 @@ contract KlerosGovernor is IArbitrableV2 { /// @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 { + function changeSubmissionDeposit(uint256 _submissionBaseDeposit) external onlyByOwner { submissionBaseDeposit = _submissionBaseDeposit; } /// @dev 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. /// @param _submissionTimeout The new duration of the submission period, in seconds. - function changeSubmissionTimeout(uint256 _submissionTimeout) external onlyByGovernor duringSubmissionPeriod { + function changeSubmissionTimeout(uint256 _submissionTimeout) external onlyByOwner duringSubmissionPeriod { submissionTimeout = _submissionTimeout; } /// @dev Changes the time allocated for list's execution. /// @param _executionTimeout The new duration of the execution timeout, in seconds. - function changeExecutionTimeout(uint256 _executionTimeout) external onlyByGovernor { + function changeExecutionTimeout(uint256 _executionTimeout) external onlyByOwner { executionTimeout = _executionTimeout; } /// @dev Changes list withdrawal timeout. Note that withdrawals are only possible in the first half of the submission period. /// @param _withdrawTimeout The new duration of withdraw period, in seconds. - function changeWithdrawTimeout(uint256 _withdrawTimeout) external onlyByGovernor { + function changeWithdrawTimeout(uint256 _withdrawTimeout) external onlyByOwner { withdrawTimeout = _withdrawTimeout; } @@ -176,7 +176,7 @@ contract KlerosGovernor is IArbitrableV2 { function changeArbitrator( IArbitratorV2 _arbitrator, bytes memory _arbitratorExtraData - ) external onlyByGovernor duringSubmissionPeriod { + ) external onlyByOwner duringSubmissionPeriod { arbitrator = _arbitrator; arbitratorExtraData = _arbitratorExtraData; } @@ -187,7 +187,7 @@ contract KlerosGovernor is IArbitrableV2 { function changeDisputeTemplate( string memory _templateData, string memory _templateDataMappings - ) external onlyByGovernor { + ) external onlyByOwner { templateId = templateRegistry.setDisputeTemplate("", _templateData, _templateDataMappings); } @@ -414,7 +414,7 @@ contract KlerosGovernor is IArbitrableV2 { error SubmissionTimeHasEnded(); error ApprovalTimeNotStarted(); - error GovernorOnly(); + error OwnerOnly(); error WrongInputTargetAndValue(); error WrongInputTargetAndDatasize(); error InsufficientDeposit(); diff --git a/contracts/src/arbitration/PolicyRegistry.sol b/contracts/src/arbitration/PolicyRegistry.sol index f4ed36322..acea8d01b 100644 --- a/contracts/src/arbitration/PolicyRegistry.sol +++ b/contracts/src/arbitration/PolicyRegistry.sol @@ -23,16 +23,16 @@ contract PolicyRegistry is UUPSProxiable, Initializable { // * Storage * // // ************************************* // - address public governor; + address public owner; mapping(uint256 => string) public policies; // ************************************* // // * Function Modifiers * // // ************************************* // - /// @dev Requires that the sender is the governor. - modifier onlyByGovernor() { - if (governor != msg.sender) revert GovernorOnly(); + /// @dev Requires that the sender is the owner. + modifier onlyByOwner() { + if (owner != msg.sender) revert OwnerOnly(); _; } @@ -46,9 +46,9 @@ contract PolicyRegistry is UUPSProxiable, Initializable { } /// @dev Constructs the `PolicyRegistry` contract. - /// @param _governor The governor's address. - function initialize(address _governor) external reinitializer(1) { - governor = _governor; + /// @param _owner The owner's address. + function initialize(address _owner) external reinitializer(1) { + owner = _owner; } function initialize2() external reinitializer(2) { @@ -61,16 +61,16 @@ contract PolicyRegistry is UUPSProxiable, Initializable { /** * @dev Access Control to perform implementation upgrades (UUPS Proxiable) - * @dev Only the governor can perform upgrades (`onlyByGovernor`) + * @dev Only the owner can perform upgrades (`onlyByOwner`) */ - function _authorizeUpgrade(address) internal view override onlyByGovernor { + function _authorizeUpgrade(address) internal view override onlyByOwner { // NOP } - /// @dev Changes the `governor` storage variable. - /// @param _governor The new value for the `governor` storage variable. - function changeGovernor(address _governor) external onlyByGovernor { - governor = _governor; + /// @dev Changes the `owner` storage variable. + /// @param _owner The new value for the `owner` storage variable. + function changeOwner(address _owner) external onlyByOwner { + owner = _owner; } // ************************************* // @@ -81,7 +81,7 @@ contract PolicyRegistry is UUPSProxiable, Initializable { /// @param _courtID The ID of the specified court. /// @param _courtName The name of the specified court. /// @param _policy The URI of the policy JSON. - function setPolicy(uint256 _courtID, string calldata _courtName, string calldata _policy) external onlyByGovernor { + function setPolicy(uint256 _courtID, string calldata _courtName, string calldata _policy) external onlyByOwner { policies[_courtID] = _policy; emit PolicyUpdate(_courtID, _courtName, policies[_courtID]); } @@ -90,5 +90,5 @@ contract PolicyRegistry is UUPSProxiable, Initializable { // * Errors * // // ************************************* // - error GovernorOnly(); + error OwnerOnly(); } diff --git a/contracts/src/arbitration/SortitionModule.sol b/contracts/src/arbitration/SortitionModule.sol index 7e881264b..ae89335b0 100644 --- a/contracts/src/arbitration/SortitionModule.sol +++ b/contracts/src/arbitration/SortitionModule.sol @@ -19,19 +19,19 @@ contract SortitionModule is SortitionModuleBase { } /// @dev Initializer (constructor equivalent for upgradable contracts). - /// @param _governor The governor. + /// @param _owner The owner. /// @param _core The KlerosCore. /// @param _minStakingTime Minimal time to stake /// @param _maxDrawingTime Time after which the drawing phase can be switched /// @param _rng The random number generator. function initialize( - address _governor, + address _owner, KlerosCore _core, uint256 _minStakingTime, uint256 _maxDrawingTime, IRNG _rng ) external reinitializer(1) { - __SortitionModuleBase_initialize(_governor, _core, _minStakingTime, _maxDrawingTime, _rng); + __SortitionModuleBase_initialize(_owner, _core, _minStakingTime, _maxDrawingTime, _rng); } function initialize4() external reinitializer(4) { @@ -43,8 +43,8 @@ contract SortitionModule is SortitionModuleBase { // ************************************* // /// @dev Access Control to perform implementation upgrades (UUPS Proxiable) - /// Only the governor can perform upgrades (`onlyByGovernor`) - function _authorizeUpgrade(address) internal view virtual override onlyByGovernor { + /// Only the owner can perform upgrades (`onlyByOwner`) + function _authorizeUpgrade(address) internal view virtual override onlyByOwner { // NOP } } diff --git a/contracts/src/arbitration/SortitionModuleBase.sol b/contracts/src/arbitration/SortitionModuleBase.sol index af4eb6631..ae749fb85 100644 --- a/contracts/src/arbitration/SortitionModuleBase.sol +++ b/contracts/src/arbitration/SortitionModuleBase.sol @@ -44,7 +44,7 @@ abstract contract SortitionModuleBase is ISortitionModule, Initializable, UUPSPr // * Storage * // // ************************************* // - address public governor; // The governor of the contract. + address public owner; // The owner of the contract. KlerosCore public core; // The core arbitrator contract. Phase public phase; // The current phase. uint256 public minStakingTime; // The time after which the phase can be switched to Drawing if there are open disputes. @@ -100,13 +100,13 @@ abstract contract SortitionModuleBase is ISortitionModule, Initializable, UUPSPr // ************************************* // function __SortitionModuleBase_initialize( - address _governor, + address _owner, KlerosCore _core, uint256 _minStakingTime, uint256 _maxDrawingTime, IRNG _rng ) internal onlyInitializing { - governor = _governor; + owner = _owner; core = _core; minStakingTime = _minStakingTime; maxDrawingTime = _maxDrawingTime; @@ -119,8 +119,8 @@ abstract contract SortitionModuleBase is ISortitionModule, Initializable, UUPSPr // * Function Modifiers * // // ************************************* // - modifier onlyByGovernor() { - if (governor != msg.sender) revert GovernorOnly(); + modifier onlyByOwner() { + if (owner != msg.sender) revert OwnerOnly(); _; } @@ -133,27 +133,27 @@ abstract contract SortitionModuleBase is ISortitionModule, Initializable, UUPSPr // * Governance * // // ************************************* // - /// @dev Changes the governor of the contract. - /// @param _governor The new governor. - function changeGovernor(address _governor) external onlyByGovernor { - governor = _governor; + /// @dev Changes the owner of the contract. + /// @param _owner The new owner. + function changeOwner(address _owner) external onlyByOwner { + owner = _owner; } /// @dev Changes the `minStakingTime` storage variable. /// @param _minStakingTime The new value for the `minStakingTime` storage variable. - function changeMinStakingTime(uint256 _minStakingTime) external onlyByGovernor { + function changeMinStakingTime(uint256 _minStakingTime) external onlyByOwner { minStakingTime = _minStakingTime; } /// @dev Changes the `maxDrawingTime` storage variable. /// @param _maxDrawingTime The new value for the `maxDrawingTime` storage variable. - function changeMaxDrawingTime(uint256 _maxDrawingTime) external onlyByGovernor { + function changeMaxDrawingTime(uint256 _maxDrawingTime) external onlyByOwner { maxDrawingTime = _maxDrawingTime; } /// @dev Changes the `rng` storage variable. /// @param _rng The new random number generator. - function changeRandomNumberGenerator(IRNG _rng) external onlyByGovernor { + function changeRandomNumberGenerator(IRNG _rng) external onlyByOwner { rng = _rng; if (phase == Phase.generating) { rng.requestRandomness(); @@ -711,7 +711,7 @@ abstract contract SortitionModuleBase is ISortitionModule, Initializable, UUPSPr // * Errors * // // ************************************* // - error GovernorOnly(); + error OwnerOnly(); error KlerosCoreOnly(); error MinStakingTimeNotPassed(); error NoDisputesThatNeedJurors(); diff --git a/contracts/src/arbitration/SortitionModuleNeo.sol b/contracts/src/arbitration/SortitionModuleNeo.sol index 9758882fe..d106d5d9b 100644 --- a/contracts/src/arbitration/SortitionModuleNeo.sol +++ b/contracts/src/arbitration/SortitionModuleNeo.sol @@ -27,7 +27,7 @@ contract SortitionModuleNeo is SortitionModuleBase { } /// @dev Initializer (constructor equivalent for upgradable contracts). - /// @param _governor The governor. + /// @param _owner The owner. /// @param _core The KlerosCore. /// @param _minStakingTime Minimal time to stake /// @param _maxDrawingTime Time after which the drawing phase can be switched @@ -35,7 +35,7 @@ contract SortitionModuleNeo is SortitionModuleBase { /// @param _maxStakePerJuror The maximum amount of PNK a juror can stake in a court. /// @param _maxTotalStaked The maximum amount of PNK that can be staked in all courts. function initialize( - address _governor, + address _owner, KlerosCore _core, uint256 _minStakingTime, uint256 _maxDrawingTime, @@ -43,7 +43,7 @@ contract SortitionModuleNeo is SortitionModuleBase { uint256 _maxStakePerJuror, uint256 _maxTotalStaked ) external reinitializer(2) { - __SortitionModuleBase_initialize(_governor, _core, _minStakingTime, _maxDrawingTime, _rng); + __SortitionModuleBase_initialize(_owner, _core, _minStakingTime, _maxDrawingTime, _rng); maxStakePerJuror = _maxStakePerJuror; maxTotalStaked = _maxTotalStaked; } @@ -57,16 +57,16 @@ contract SortitionModuleNeo is SortitionModuleBase { // ************************************* // /// @dev Access Control to perform implementation upgrades (UUPS Proxiable) - /// Only the governor can perform upgrades (`onlyByGovernor`) - function _authorizeUpgrade(address) internal view override onlyByGovernor { + /// Only the owner can perform upgrades (`onlyByOwner`) + function _authorizeUpgrade(address) internal view override onlyByOwner { // NOP } - function changeMaxStakePerJuror(uint256 _maxStakePerJuror) external onlyByGovernor { + function changeMaxStakePerJuror(uint256 _maxStakePerJuror) external onlyByOwner { maxStakePerJuror = _maxStakePerJuror; } - function changeMaxTotalStaked(uint256 _maxTotalStaked) external onlyByGovernor { + function changeMaxTotalStaked(uint256 _maxTotalStaked) external onlyByOwner { maxTotalStaked = _maxTotalStaked; } diff --git a/contracts/src/arbitration/arbitrables/ArbitrableExample.sol b/contracts/src/arbitration/arbitrables/ArbitrableExample.sol index b7596566e..4dd60cb82 100644 --- a/contracts/src/arbitration/arbitrables/ArbitrableExample.sol +++ b/contracts/src/arbitration/arbitrables/ArbitrableExample.sol @@ -23,7 +23,7 @@ contract ArbitrableExample is IArbitrableV2 { event Action(string indexed _action); - address public immutable governor; + address public immutable owner; IArbitratorV2 public arbitrator; // Arbitrator is set in constructor. IDisputeTemplateRegistry public templateRegistry; // The dispute template registry. uint256 public templateId; // The current dispute template identifier. @@ -36,8 +36,8 @@ contract ArbitrableExample is IArbitrableV2 { // * Function Modifiers * // // ************************************* // - modifier onlyByGovernor() { - if (governor != msg.sender) revert GovernorOnly(); + modifier onlyByOwner() { + if (owner != msg.sender) revert OwnerOnly(); _; } @@ -60,7 +60,7 @@ contract ArbitrableExample is IArbitrableV2 { IDisputeTemplateRegistry _templateRegistry, IERC20 _weth ) { - governor = msg.sender; + owner = msg.sender; arbitrator = _arbitrator; arbitratorExtraData = _arbitratorExtraData; templateRegistry = _templateRegistry; @@ -73,22 +73,22 @@ contract ArbitrableExample is IArbitrableV2 { // * Governance * // // ************************************* // - function changeArbitrator(IArbitratorV2 _arbitrator) external onlyByGovernor { + function changeArbitrator(IArbitratorV2 _arbitrator) external onlyByOwner { arbitrator = _arbitrator; } - function changeArbitratorExtraData(bytes calldata _arbitratorExtraData) external onlyByGovernor { + function changeArbitratorExtraData(bytes calldata _arbitratorExtraData) external onlyByOwner { arbitratorExtraData = _arbitratorExtraData; } - function changeTemplateRegistry(IDisputeTemplateRegistry _templateRegistry) external onlyByGovernor { + function changeTemplateRegistry(IDisputeTemplateRegistry _templateRegistry) external onlyByOwner { templateRegistry = _templateRegistry; } function changeDisputeTemplate( string memory _templateData, string memory _templateDataMappings - ) external onlyByGovernor { + ) external onlyByOwner { templateId = templateRegistry.setDisputeTemplate("", _templateData, _templateDataMappings); } @@ -156,7 +156,7 @@ contract ArbitrableExample is IArbitrableV2 { // * Errors * // // ************************************* // - error GovernorOnly(); + error OwnerOnly(); error TransferFailed(); error AllowanceIncreaseFailed(); error ArbitratorOnly(); diff --git a/contracts/src/arbitration/arbitrables/DisputeResolver.sol b/contracts/src/arbitration/arbitrables/DisputeResolver.sol index 7248356cd..949d282b2 100644 --- a/contracts/src/arbitration/arbitrables/DisputeResolver.sol +++ b/contracts/src/arbitration/arbitrables/DisputeResolver.sol @@ -23,7 +23,7 @@ contract DisputeResolver is IArbitrableV2 { // * Storage * // // ************************************* // - address public governor; // The governor. + address public owner; // The owner. IArbitratorV2 public arbitrator; // The arbitrator. IDisputeTemplateRegistry public templateRegistry; // The dispute template registry. DisputeStruct[] public disputes; // Local disputes. @@ -36,7 +36,7 @@ contract DisputeResolver is IArbitrableV2 { /// @dev Constructor /// @param _arbitrator Target global arbitrator for any disputes. constructor(IArbitratorV2 _arbitrator, IDisputeTemplateRegistry _templateRegistry) { - governor = msg.sender; + owner = msg.sender; arbitrator = _arbitrator; templateRegistry = _templateRegistry; } @@ -45,20 +45,20 @@ contract DisputeResolver is IArbitrableV2 { // * Governance * // // ************************************* // - /// @dev Changes the governor. - /// @param _governor The address of the new governor. - function changeGovernor(address _governor) external { - if (governor != msg.sender) revert GovernorOnly(); - governor = _governor; + /// @dev Changes the owner. + /// @param _owner The address of the new owner. + function changeOwner(address _owner) external { + if (owner != msg.sender) revert OwnerOnly(); + owner = _owner; } function changeArbitrator(IArbitratorV2 _arbitrator) external { - if (governor != msg.sender) revert GovernorOnly(); + if (owner != msg.sender) revert OwnerOnly(); arbitrator = _arbitrator; } function changeTemplateRegistry(IDisputeTemplateRegistry _templateRegistry) external { - if (governor != msg.sender) revert GovernorOnly(); + if (owner != msg.sender) revert OwnerOnly(); templateRegistry = _templateRegistry; } @@ -151,7 +151,7 @@ contract DisputeResolver is IArbitrableV2 { // * Errors * // // ************************************* // - error GovernorOnly(); + error OwnerOnly(); error ArbitratorOnly(); error RulingOutOfBounds(); error DisputeAlreadyRuled(); diff --git a/contracts/src/arbitration/devtools/DisputeResolverRuler.sol b/contracts/src/arbitration/devtools/DisputeResolverRuler.sol index 05c033c38..eed2c8092 100644 --- a/contracts/src/arbitration/devtools/DisputeResolverRuler.sol +++ b/contracts/src/arbitration/devtools/DisputeResolverRuler.sol @@ -22,7 +22,7 @@ contract DisputeResolverRuler is DisputeResolver { IArbitratorV2 _arbitrator, IDisputeTemplateRegistry _templateRegistry ) DisputeResolver(_arbitrator, _templateRegistry) { - governor = msg.sender; + owner = msg.sender; } // ************************************* // diff --git a/contracts/src/arbitration/devtools/KlerosCoreRuler.sol b/contracts/src/arbitration/devtools/KlerosCoreRuler.sol index 2382970cf..9350ebd57 100644 --- a/contracts/src/arbitration/devtools/KlerosCoreRuler.sol +++ b/contracts/src/arbitration/devtools/KlerosCoreRuler.sol @@ -85,7 +85,7 @@ contract KlerosCoreRuler is IArbitratorV2, UUPSProxiable, Initializable { uint256 private constant NON_PAYABLE_AMOUNT = (2 ** 256 - 2) / 2; // An amount higher than the supply of ETH. - address public governor; // The governor of the contract. + address public owner; // The owner of the contract. IERC20 public pinakion; // The Pinakion token contract. Court[] public courts; // The courts. Dispute[] public disputes; // The disputes. @@ -157,8 +157,8 @@ contract KlerosCoreRuler is IArbitratorV2, UUPSProxiable, Initializable { // * Function Modifiers * // // ************************************* // - modifier onlyByGovernor() { - if (governor != msg.sender) revert GovernorOnly(); + modifier onlyByOwner() { + if (owner != msg.sender) revert OwnerOnly(); _; } @@ -172,15 +172,15 @@ contract KlerosCoreRuler is IArbitratorV2, UUPSProxiable, Initializable { } /// @dev Initializer (constructor equivalent for upgradable contracts). - /// @param _governor The governor's address. + /// @param _owner The owner's address. /// @param _pinakion The address of the token contract. /// @param _courtParameters Numeric parameters of General court (minStake, alpha, feeForJuror and jurorsForCourtJump respectively). function initialize( - address _governor, + address _owner, IERC20 _pinakion, uint256[4] memory _courtParameters ) external reinitializer(1) { - governor = _governor; + owner = _owner; pinakion = _pinakion; // FORKING_COURT @@ -219,34 +219,30 @@ contract KlerosCoreRuler is IArbitratorV2, UUPSProxiable, Initializable { // ************************************* // /* @dev Access Control to perform implementation upgrades (UUPS Proxiable) - * @dev Only the governor can perform upgrades (`onlyByGovernor`) + * @dev Only the owner can perform upgrades (`onlyByOwner`) */ - function _authorizeUpgrade(address) internal view override onlyByGovernor { + function _authorizeUpgrade(address) internal view override onlyByOwner { // NOP } - /// @dev Allows the governor to call anything on behalf of the contract. + /// @dev Allows the owner to call anything on behalf of the contract. /// @param _destination The destination of the call. /// @param _amount The value sent with the call. /// @param _data The data sent with the call. - function executeGovernorProposal( - address _destination, - uint256 _amount, - bytes memory _data - ) external onlyByGovernor { + function executeOwnerProposal(address _destination, uint256 _amount, bytes memory _data) external onlyByOwner { (bool success, ) = _destination.call{value: _amount}(_data); if (!success) revert UnsuccessfulCall(); } - /// @dev Changes the `governor` storage variable. - /// @param _governor The new value for the `governor` storage variable. - function changeGovernor(address payable _governor) external onlyByGovernor { - governor = _governor; + /// @dev Changes the `owner` storage variable. + /// @param _owner The new value for the `owner` storage variable. + function changeOwner(address payable _owner) external onlyByOwner { + owner = _owner; } /// @dev Changes the `pinakion` storage variable. /// @param _pinakion The new value for the `pinakion` storage variable. - function changePinakion(IERC20 _pinakion) external onlyByGovernor { + function changePinakion(IERC20 _pinakion) external onlyByOwner { pinakion = _pinakion; } @@ -266,7 +262,7 @@ contract KlerosCoreRuler is IArbitratorV2, UUPSProxiable, Initializable { uint256 _feeForJuror, uint256 _jurorsForCourtJump, uint256[4] memory _timesPerPeriod - ) external onlyByGovernor { + ) external onlyByOwner { if (_parent == FORKING_COURT) revert InvalidForkingCourtAsParent(); uint256 courtID = courts.length; @@ -303,7 +299,7 @@ contract KlerosCoreRuler is IArbitratorV2, UUPSProxiable, Initializable { uint256 _feeForJuror, uint256 _jurorsForCourtJump, uint256[4] memory _timesPerPeriod - ) external onlyByGovernor { + ) external onlyByOwner { Court storage court = courts[_courtID]; court.minStake = _minStake; court.hiddenVotes = _hiddenVotes; @@ -325,7 +321,7 @@ contract KlerosCoreRuler is IArbitratorV2, UUPSProxiable, Initializable { /// @dev Changes the supported fee tokens. /// @param _feeToken The fee token. /// @param _accepted Whether the token is supported or not as a method of fee payment. - function changeAcceptedFeeTokens(IERC20 _feeToken, bool _accepted) external onlyByGovernor { + function changeAcceptedFeeTokens(IERC20 _feeToken, bool _accepted) external onlyByOwner { currencyRates[_feeToken].feePaymentAccepted = _accepted; emit AcceptedFeeToken(_feeToken, _accepted); } @@ -334,7 +330,7 @@ contract KlerosCoreRuler is IArbitratorV2, UUPSProxiable, Initializable { /// @param _feeToken The fee token. /// @param _rateInEth The new rate of the fee token in ETH. /// @param _rateDecimals The new decimals of the fee token rate. - function changeCurrencyRates(IERC20 _feeToken, uint64 _rateInEth, uint8 _rateDecimals) external onlyByGovernor { + function changeCurrencyRates(IERC20 _feeToken, uint64 _rateInEth, uint8 _rateDecimals) external onlyByOwner { currencyRates[_feeToken].rateInEth = _rateInEth; currencyRates[_feeToken].rateDecimals = _rateDecimals; emit NewCurrencyRate(_feeToken, _rateInEth, _rateDecimals); @@ -675,8 +671,7 @@ contract KlerosCoreRuler is IArbitratorV2, UUPSProxiable, Initializable { // * Errors * // // ************************************* // - error GovernorOnly(); - error GovernorOrInstructorOnly(); + error OwnerOnly(); error RulerOnly(); error NoRulerSet(); error RulingModeNotSet(); diff --git a/contracts/src/arbitration/dispute-kits/DisputeKitClassic.sol b/contracts/src/arbitration/dispute-kits/DisputeKitClassic.sol index 2479ab07d..ce5932c92 100644 --- a/contracts/src/arbitration/dispute-kits/DisputeKitClassic.sol +++ b/contracts/src/arbitration/dispute-kits/DisputeKitClassic.sol @@ -23,11 +23,11 @@ contract DisputeKitClassic is DisputeKitClassicBase { } /// @dev Initializer. - /// @param _governor The governor's address. + /// @param _owner The owner's address. /// @param _core The KlerosCore arbitrator. /// @param _wNative The wrapped native token address, typically wETH. - function initialize(address _governor, KlerosCore _core, address _wNative) external reinitializer(1) { - __DisputeKitClassicBase_initialize(_governor, _core, _wNative); + function initialize(address _owner, KlerosCore _core, address _wNative) external reinitializer(1) { + __DisputeKitClassicBase_initialize(_owner, _core, _wNative); } function reinitialize(address _wNative) external reinitializer(9) { @@ -39,8 +39,8 @@ contract DisputeKitClassic is DisputeKitClassicBase { // ************************ // /// @dev Access Control to perform implementation upgrades (UUPS Proxiable) - /// Only the governor can perform upgrades (`onlyByGovernor`) - function _authorizeUpgrade(address) internal view override onlyByGovernor { + /// Only the owner can perform upgrades (`onlyByOwner`) + function _authorizeUpgrade(address) internal view override onlyByOwner { // NOP } } diff --git a/contracts/src/arbitration/dispute-kits/DisputeKitClassicBase.sol b/contracts/src/arbitration/dispute-kits/DisputeKitClassicBase.sol index a9e96f7eb..f2d7a154c 100644 --- a/contracts/src/arbitration/dispute-kits/DisputeKitClassicBase.sol +++ b/contracts/src/arbitration/dispute-kits/DisputeKitClassicBase.sol @@ -59,7 +59,7 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi uint256 public constant LOSER_STAKE_MULTIPLIER = 20000; // Multiplier of the appeal cost that the loser has to pay as fee stake for a round in basis points. Default is 2x of appeal fee. uint256 public constant LOSER_APPEAL_PERIOD_MULTIPLIER = 5000; // Multiplier of the appeal period for the choice that wasn't voted for in the previous round, in basis points. Default is 1/2 of original appeal period. - address public governor; // The governor of the contract. + address public owner; // The owner of the contract. KlerosCore public core; // The Kleros Core arbitrator Dispute[] public disputes; // Array of the locally created disputes. mapping(uint256 => uint256) public coreDisputeIDToLocal; // Maps the dispute ID in Kleros Core to the local dispute ID. @@ -124,8 +124,8 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi // * Modifiers * // // ************************************* // - modifier onlyByGovernor() { - if (governor != msg.sender) revert GovernorOnly(); + modifier onlyByOwner() { + if (owner != msg.sender) revert OwnerOnly(); _; } @@ -144,15 +144,15 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi // ************************************* // /// @dev Initializer. - /// @param _governor The governor's address. + /// @param _owner The owner's address. /// @param _core The KlerosCore arbitrator. /// @param _wNative The wrapped native token address, typically wETH. function __DisputeKitClassicBase_initialize( - address _governor, + address _owner, KlerosCore _core, address _wNative ) internal onlyInitializing { - governor = _governor; + owner = _owner; core = _core; wNative = _wNative; } @@ -161,28 +161,24 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi // * Governance * // // ************************ // - /// @dev Allows the governor to call anything on behalf of the contract. + /// @dev Allows the owner to call anything on behalf of the contract. /// @param _destination The destination of the call. /// @param _amount The value sent with the call. /// @param _data The data sent with the call. - function executeGovernorProposal( - address _destination, - uint256 _amount, - bytes memory _data - ) external onlyByGovernor { + function executeOwnerProposal(address _destination, uint256 _amount, bytes memory _data) external onlyByOwner { (bool success, ) = _destination.call{value: _amount}(_data); if (!success) revert UnsuccessfulCall(); } - /// @dev Changes the `governor` storage variable. - /// @param _governor The new value for the `governor` storage variable. - function changeGovernor(address payable _governor) external onlyByGovernor { - governor = _governor; + /// @dev Changes the `owner` storage variable. + /// @param _owner The new value for the `owner` storage variable. + function changeOwner(address payable _owner) external onlyByOwner { + owner = _owner; } /// @dev Changes the `core` storage variable. /// @param _core The new value for the `core` storage variable. - function changeCore(address _core) external onlyByGovernor { + function changeCore(address _core) external onlyByOwner { core = KlerosCore(_core); } @@ -755,7 +751,7 @@ abstract contract DisputeKitClassicBase is IDisputeKit, Initializable, UUPSProxi // * Errors * // // ************************************* // - error GovernorOnly(); + error OwnerOnly(); error KlerosCoreOnly(); error DisputeJumpedToParentDK(); error UnsuccessfulCall(); diff --git a/contracts/src/arbitration/dispute-kits/DisputeKitGated.sol b/contracts/src/arbitration/dispute-kits/DisputeKitGated.sol index 037f79585..c0e70f741 100644 --- a/contracts/src/arbitration/dispute-kits/DisputeKitGated.sol +++ b/contracts/src/arbitration/dispute-kits/DisputeKitGated.sol @@ -39,11 +39,11 @@ contract DisputeKitGated is DisputeKitClassicBase { } /// @dev Initializer. - /// @param _governor The governor's address. + /// @param _owner The owner's address. /// @param _core The KlerosCore arbitrator. /// @param _wNative The wrapped native token address, typically wETH. - function initialize(address _governor, KlerosCore _core, address _wNative) external reinitializer(1) { - __DisputeKitClassicBase_initialize(_governor, _core, _wNative); + function initialize(address _owner, KlerosCore _core, address _wNative) external reinitializer(1) { + __DisputeKitClassicBase_initialize(_owner, _core, _wNative); } function reinitialize(address _wNative) external reinitializer(9) { @@ -55,8 +55,8 @@ contract DisputeKitGated is DisputeKitClassicBase { // ************************ // /// @dev Access Control to perform implementation upgrades (UUPS Proxiable) - /// Only the governor can perform upgrades (`onlyByGovernor`) - function _authorizeUpgrade(address) internal view override onlyByGovernor { + /// Only the owner can perform upgrades (`onlyByOwner`) + function _authorizeUpgrade(address) internal view override onlyByOwner { // NOP } diff --git a/contracts/src/arbitration/dispute-kits/DisputeKitGatedShutter.sol b/contracts/src/arbitration/dispute-kits/DisputeKitGatedShutter.sol index 3ad37d56d..c5de2483b 100644 --- a/contracts/src/arbitration/dispute-kits/DisputeKitGatedShutter.sol +++ b/contracts/src/arbitration/dispute-kits/DisputeKitGatedShutter.sol @@ -58,11 +58,11 @@ contract DisputeKitGatedShutter is DisputeKitClassicBase { } /// @dev Initializer. - /// @param _governor The governor's address. + /// @param _owner The owner's address. /// @param _core The KlerosCore arbitrator. /// @param _wNative The wrapped native token address, typically wETH. - function initialize(address _governor, KlerosCore _core, address _wNative) external reinitializer(1) { - __DisputeKitClassicBase_initialize(_governor, _core, _wNative); + function initialize(address _owner, KlerosCore _core, address _wNative) external reinitializer(1) { + __DisputeKitClassicBase_initialize(_owner, _core, _wNative); } function reinitialize(address _wNative) external reinitializer(9) { @@ -74,8 +74,8 @@ contract DisputeKitGatedShutter is DisputeKitClassicBase { // ************************ // /// @dev Access Control to perform implementation upgrades (UUPS Proxiable) - /// Only the governor can perform upgrades (`onlyByGovernor`) - function _authorizeUpgrade(address) internal view override onlyByGovernor { + /// Only the owner can perform upgrades (`onlyByOwner`) + function _authorizeUpgrade(address) internal view override onlyByOwner { // NOP } diff --git a/contracts/src/arbitration/dispute-kits/DisputeKitShutter.sol b/contracts/src/arbitration/dispute-kits/DisputeKitShutter.sol index 057a06921..886f5dbec 100644 --- a/contracts/src/arbitration/dispute-kits/DisputeKitShutter.sol +++ b/contracts/src/arbitration/dispute-kits/DisputeKitShutter.sol @@ -42,11 +42,11 @@ contract DisputeKitShutter is DisputeKitClassicBase { } /// @dev Initializer. - /// @param _governor The governor's address. + /// @param _owner The owner's address. /// @param _core The KlerosCore arbitrator. /// @param _wNative The wrapped native token address, typically wETH. - function initialize(address _governor, KlerosCore _core, address _wNative) external reinitializer(1) { - __DisputeKitClassicBase_initialize(_governor, _core, _wNative); + function initialize(address _owner, KlerosCore _core, address _wNative) external reinitializer(1) { + __DisputeKitClassicBase_initialize(_owner, _core, _wNative); } function reinitialize(address _wNative) external reinitializer(9) { @@ -58,8 +58,8 @@ contract DisputeKitShutter is DisputeKitClassicBase { // ************************ // /// @dev Access Control to perform implementation upgrades (UUPS Proxiable) - /// Only the governor can perform upgrades (`onlyByGovernor`) - function _authorizeUpgrade(address) internal view override onlyByGovernor { + /// Only the owner can perform upgrades (`onlyByOwner`) + function _authorizeUpgrade(address) internal view override onlyByOwner { // NOP } diff --git a/contracts/src/arbitration/dispute-kits/DisputeKitSybilResistant.sol b/contracts/src/arbitration/dispute-kits/DisputeKitSybilResistant.sol index 8568c55af..e213f6d11 100644 --- a/contracts/src/arbitration/dispute-kits/DisputeKitSybilResistant.sol +++ b/contracts/src/arbitration/dispute-kits/DisputeKitSybilResistant.sol @@ -36,17 +36,17 @@ contract DisputeKitSybilResistant is DisputeKitClassicBase { } /// @dev Initializer. - /// @param _governor The governor's address. + /// @param _owner The owner's address. /// @param _core The KlerosCore arbitrator. /// @param _poh The Proof of Humanity registry. /// @param _wNative The wrapped native token address, typically wETH. function initialize( - address _governor, + address _owner, KlerosCore _core, IProofOfHumanity _poh, address _wNative ) external reinitializer(1) { - __DisputeKitClassicBase_initialize(_governor, _core, _wNative); + __DisputeKitClassicBase_initialize(_owner, _core, _wNative); poh = _poh; singleDrawPerJuror = true; } @@ -56,8 +56,8 @@ contract DisputeKitSybilResistant is DisputeKitClassicBase { // ************************ // /// @dev Access Control to perform implementation upgrades (UUPS Proxiable) - /// Only the governor can perform upgrades (`onlyByGovernor`) - function _authorizeUpgrade(address) internal view override onlyByGovernor { + /// Only the owner can perform upgrades (`onlyByOwner`) + function _authorizeUpgrade(address) internal view override onlyByOwner { // NOP } diff --git a/contracts/src/arbitration/evidence/EvidenceModule.sol b/contracts/src/arbitration/evidence/EvidenceModule.sol index 4967597ab..d1eb5f99c 100644 --- a/contracts/src/arbitration/evidence/EvidenceModule.sol +++ b/contracts/src/arbitration/evidence/EvidenceModule.sol @@ -15,14 +15,14 @@ contract EvidenceModule is IEvidence, Initializable, UUPSProxiable { // * Storage * // // ************************************* // - address public governor; // The governor of the contract. + address public owner; // The owner of the contract. // ************************************* // // * Modifiers * // // ************************************* // - modifier onlyByGovernor() { - if (governor != msg.sender) revert GovernorOnly(); + modifier onlyByOwner() { + if (owner != msg.sender) revert OwnerOnly(); _; } @@ -36,9 +36,9 @@ contract EvidenceModule is IEvidence, Initializable, UUPSProxiable { } /// @dev Initializer. - /// @param _governor The governor's address. - function initialize(address _governor) external reinitializer(1) { - governor = _governor; + /// @param _owner The owner's address. + function initialize(address _owner) external reinitializer(1) { + owner = _owner; } function initialize2() external reinitializer(2) { @@ -51,9 +51,9 @@ contract EvidenceModule is IEvidence, Initializable, UUPSProxiable { /** * @dev Access Control to perform implementation upgrades (UUPS Proxiable) - * @dev Only the governor can perform upgrades (`onlyByGovernor`) + * @dev Only the owner can perform upgrades (`onlyByOwner`) */ - function _authorizeUpgrade(address) internal view override onlyByGovernor { + function _authorizeUpgrade(address) internal view override onlyByOwner { // NOP } @@ -72,5 +72,5 @@ contract EvidenceModule is IEvidence, Initializable, UUPSProxiable { // * Errors * // // ************************************* // - error GovernorOnly(); + error OwnerOnly(); } diff --git a/contracts/src/arbitration/evidence/ModeratedEvidenceModule.sol b/contracts/src/arbitration/evidence/ModeratedEvidenceModule.sol index 1c612265f..b2b64a4d3 100644 --- a/contracts/src/arbitration/evidence/ModeratedEvidenceModule.sol +++ b/contracts/src/arbitration/evidence/ModeratedEvidenceModule.sol @@ -51,7 +51,7 @@ contract ModeratedEvidenceModule is IArbitrableV2 { mapping(uint256 => bytes32) public disputeIDtoEvidenceID; // One-to-one relationship between the dispute and the evidence. 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. + address public owner; // 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. @@ -61,8 +61,8 @@ contract ModeratedEvidenceModule is IArbitrableV2 { // * Function Modifiers * // // ************************************* // - modifier onlyGovernor() { - require(msg.sender == governor, "The caller must be the governor"); + modifier onlyOwner() { + require(msg.sender == owner, "The caller must be the owner"); _; } @@ -93,7 +93,7 @@ contract ModeratedEvidenceModule is IArbitrableV2 { /// @dev Constructor. /// @param _arbitrator The trusted arbitrator to resolve potential disputes. - /// @param _governor The trusted governor of the contract. + /// @param _owner The trusted owner of the contract. /// @param _totalCostMultiplier Multiplier of arbitration fees that must be ultimately paid as fee stake. In basis points. /// @param _initialDepositMultiplier Multiplier of arbitration fees that must be paid as initial stake for submitting evidence. In basis points. /// @param _bondTimeout The time in seconds during which the last moderation status can be challenged. @@ -102,7 +102,7 @@ contract ModeratedEvidenceModule is IArbitrableV2 { /// @param _templateDataMappings The dispute template data mappings. constructor( IArbitratorV2 _arbitrator, - address _governor, + address _owner, IDisputeTemplateRegistry _templateRegistry, uint256 _totalCostMultiplier, uint256 _initialDepositMultiplier, @@ -112,7 +112,7 @@ contract ModeratedEvidenceModule is IArbitrableV2 { string memory _templateDataMappings ) { arbitrator = _arbitrator; - governor = _governor; + owner = _owner; templateRegistry = _templateRegistry; totalCostMultiplier = _totalCostMultiplier; // For example 15000, which would provide a 100% reward to the dispute winner. @@ -132,28 +132,28 @@ contract ModeratedEvidenceModule is IArbitrableV2 { // * Governance * // // ************************************* // - /// @dev Change the governor of the contract. - /// @param _governor The address of the new governor. - function changeGovernor(address _governor) external onlyGovernor { - governor = _governor; + /// @dev Change the owner of the contract. + /// @param _owner The address of the new owner. + function changeOwner(address _owner) external onlyOwner { + owner = _owner; } /// @dev Change the proportion of arbitration fees that must be paid as fee stake by parties when there is no winner or loser (e.g. when the arbitrator refused to rule). /// @param _initialDepositMultiplier Multiplier of arbitration fees that must be paid as fee stake. In basis points. - function changeInitialDepositMultiplier(uint256 _initialDepositMultiplier) external onlyGovernor { + function changeInitialDepositMultiplier(uint256 _initialDepositMultiplier) external onlyOwner { initialDepositMultiplier = _initialDepositMultiplier; } /// @dev Change the proportion of arbitration fees that must be paid as fee stake by the winner of the previous round. /// @param _totalCostMultiplier Multiplier of arbitration fees that must be paid as fee stake. In basis points. - function changeTotalCostMultiplier(uint256 _totalCostMultiplier) external onlyGovernor { + function changeTotalCostMultiplier(uint256 _totalCostMultiplier) external onlyOwner { totalCostMultiplier = _totalCostMultiplier; } /// @dev Change the time window within which evidence submissions and removals can be contested. /// Ongoing moderations will start using the latest bondTimeout available after calling moderate() again. /// @param _bondTimeout Multiplier of arbitration fees that must be paid as fee stake. In basis points. - function changeBondTimeout(uint256 _bondTimeout) external onlyGovernor { + function changeBondTimeout(uint256 _bondTimeout) external onlyOwner { bondTimeout = _bondTimeout; } @@ -162,7 +162,7 @@ contract ModeratedEvidenceModule is IArbitrableV2 { function changeDisputeTemplate( string calldata _templateData, string memory _templateDataMappings - ) external onlyGovernor { + ) external onlyOwner { ArbitratorData storage arbitratorData = arbitratorDataList[arbitratorDataList.length - 1]; uint256 newDisputeTemplateId = templateRegistry.setDisputeTemplate("", _templateData, _templateDataMappings); arbitratorDataList.push( @@ -175,7 +175,7 @@ contract ModeratedEvidenceModule is IArbitrableV2 { /// @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. /// @param _arbitratorExtraData The extra data used by the new arbitrator. - function changeArbitratorExtraData(bytes calldata _arbitratorExtraData) external onlyGovernor { + function changeArbitratorExtraData(bytes calldata _arbitratorExtraData) external onlyOwner { ArbitratorData storage arbitratorData = arbitratorDataList[arbitratorDataList.length - 1]; arbitratorDataList.push( ArbitratorData({ diff --git a/contracts/src/arbitration/university/KlerosCoreUniversity.sol b/contracts/src/arbitration/university/KlerosCoreUniversity.sol index 0cd11b2f1..d6366753a 100644 --- a/contracts/src/arbitration/university/KlerosCoreUniversity.sol +++ b/contracts/src/arbitration/university/KlerosCoreUniversity.sol @@ -89,7 +89,7 @@ contract KlerosCoreUniversity is IArbitratorV2, UUPSProxiable, Initializable { uint256 private constant NON_PAYABLE_AMOUNT = (2 ** 256 - 2) / 2; // An amount higher than the supply of ETH. - address public governor; // The governor of the contract. + address public owner; // The owner of the contract. address public instructor; // The instructor who is allowed to choose the jurors. IERC20 public pinakion; // The Pinakion token contract. address public jurorProsecutionModule; // The module for juror's prosecution. @@ -162,8 +162,8 @@ contract KlerosCoreUniversity is IArbitratorV2, UUPSProxiable, Initializable { // * Function Modifiers * // // ************************************* // - modifier onlyByGovernor() { - if (governor != msg.sender) revert GovernorOnly(); + modifier onlyByOwner() { + if (owner != msg.sender) revert OwnerOnly(); _; } @@ -172,8 +172,8 @@ contract KlerosCoreUniversity is IArbitratorV2, UUPSProxiable, Initializable { _; } - modifier onlyByGovernorOrInstructor() { - if (msg.sender != governor && msg.sender != instructor) revert GovernorOrInstructorOnly(); + modifier onlyByOwnerOrInstructor() { + if (msg.sender != owner && msg.sender != instructor) revert OwnerOrInstructorOnly(); _; } @@ -187,7 +187,7 @@ contract KlerosCoreUniversity is IArbitratorV2, UUPSProxiable, Initializable { } /// @dev Initializer (constructor equivalent for upgradable contracts). - /// @param _governor The governor's address. + /// @param _owner The owner's address. /// @param _instructor The address of the instructor. /// @param _pinakion The address of the token contract. /// @param _jurorProsecutionModule The address of the juror prosecution module. @@ -197,7 +197,7 @@ contract KlerosCoreUniversity is IArbitratorV2, UUPSProxiable, Initializable { /// @param _timesPerPeriod The `timesPerPeriod` property value of the general court. /// @param _sortitionModuleAddress The sortition module responsible for sortition of the jurors. function initialize( - address _governor, + address _owner, address _instructor, IERC20 _pinakion, address _jurorProsecutionModule, @@ -207,7 +207,7 @@ contract KlerosCoreUniversity is IArbitratorV2, UUPSProxiable, Initializable { uint256[4] memory _timesPerPeriod, ISortitionModuleUniversity _sortitionModuleAddress ) external reinitializer(1) { - governor = _governor; + owner = _owner; instructor = _instructor; pinakion = _pinakion; jurorProsecutionModule = _jurorProsecutionModule; @@ -255,59 +255,55 @@ contract KlerosCoreUniversity is IArbitratorV2, UUPSProxiable, Initializable { // ************************************* // /* @dev Access Control to perform implementation upgrades (UUPS Proxiable) - * @dev Only the governor can perform upgrades (`onlyByGovernor`) + * @dev Only the owner can perform upgrades (`onlyByOwner`) */ - function _authorizeUpgrade(address) internal view override onlyByGovernor { + function _authorizeUpgrade(address) internal view override onlyByOwner { // NOP } - /// @dev Allows the governor to call anything on behalf of the contract. + /// @dev Allows the owner to call anything on behalf of the contract. /// @param _destination The destination of the call. /// @param _amount The value sent with the call. /// @param _data The data sent with the call. - function executeGovernorProposal( - address _destination, - uint256 _amount, - bytes memory _data - ) external onlyByGovernor { + function executeOwnerProposal(address _destination, uint256 _amount, bytes memory _data) external onlyByOwner { (bool success, ) = _destination.call{value: _amount}(_data); if (!success) revert UnsuccessfulCall(); } - /// @dev Changes the `governor` storage variable. - /// @param _governor The new value for the `governor` storage variable. - function changeGovernor(address payable _governor) external onlyByGovernor { - governor = _governor; + /// @dev Changes the `owner` storage variable. + /// @param _owner The new value for the `owner` storage variable. + function changeOwner(address payable _owner) external onlyByOwner { + owner = _owner; } /// @dev Changes the `instructor` storage variable. /// @param _instructor The new value for the `instructor` storage variable. - function changeInstructor(address _instructor) external onlyByGovernorOrInstructor { + function changeInstructor(address _instructor) external onlyByOwnerOrInstructor { instructor = _instructor; } /// @dev Changes the `pinakion` storage variable. /// @param _pinakion The new value for the `pinakion` storage variable. - function changePinakion(IERC20 _pinakion) external onlyByGovernor { + function changePinakion(IERC20 _pinakion) external onlyByOwner { pinakion = _pinakion; } /// @dev Changes the `jurorProsecutionModule` storage variable. /// @param _jurorProsecutionModule The new value for the `jurorProsecutionModule` storage variable. - function changeJurorProsecutionModule(address _jurorProsecutionModule) external onlyByGovernor { + function changeJurorProsecutionModule(address _jurorProsecutionModule) external onlyByOwner { jurorProsecutionModule = _jurorProsecutionModule; } /// @dev Changes the `_sortitionModule` storage variable. /// Note that the new module should be initialized for all courts. /// @param _sortitionModule The new value for the `sortitionModule` storage variable. - function changeSortitionModule(ISortitionModuleUniversity _sortitionModule) external onlyByGovernor { + function changeSortitionModule(ISortitionModuleUniversity _sortitionModule) external onlyByOwner { sortitionModule = _sortitionModule; } /// @dev Add a new supported dispute kit module to the court. /// @param _disputeKitAddress The address of the dispute kit contract. - function addNewDisputeKit(IDisputeKit _disputeKitAddress) external onlyByGovernor { + function addNewDisputeKit(IDisputeKit _disputeKitAddress) external onlyByOwner { uint256 disputeKitID = disputeKits.length; disputeKits.push(_disputeKitAddress); emit DisputeKitCreated(disputeKitID, _disputeKitAddress); @@ -331,7 +327,7 @@ contract KlerosCoreUniversity is IArbitratorV2, UUPSProxiable, Initializable { uint256 _jurorsForCourtJump, uint256[4] memory _timesPerPeriod, uint256[] memory _supportedDisputeKits - ) external onlyByGovernor { + ) external onlyByOwner { if (courts[_parent].minStake > _minStake) revert MinStakeLowerThanParentCourt(); if (_supportedDisputeKits.length == 0) revert UnsupportedDisputeKit(); if (_parent == FORKING_COURT) revert InvalidForkingCourtAsParent(); @@ -380,7 +376,7 @@ contract KlerosCoreUniversity is IArbitratorV2, UUPSProxiable, Initializable { uint256 _feeForJuror, uint256 _jurorsForCourtJump, uint256[4] memory _timesPerPeriod - ) external onlyByGovernor { + ) external onlyByOwner { Court storage court = courts[_courtID]; if (_courtID != GENERAL_COURT && courts[court.parent].minStake > _minStake) { revert MinStakeLowerThanParentCourt(); @@ -411,7 +407,7 @@ contract KlerosCoreUniversity is IArbitratorV2, UUPSProxiable, Initializable { /// @param _courtID The ID of the court. /// @param _disputeKitIDs The IDs of dispute kits which support should be added/removed. /// @param _enable Whether add or remove the dispute kits from the court. - function enableDisputeKits(uint96 _courtID, uint256[] memory _disputeKitIDs, bool _enable) external onlyByGovernor { + function enableDisputeKits(uint96 _courtID, uint256[] memory _disputeKitIDs, bool _enable) external onlyByOwner { for (uint256 i = 0; i < _disputeKitIDs.length; i++) { if (_enable) { if (_disputeKitIDs[i] == 0 || _disputeKitIDs[i] >= disputeKits.length) { @@ -431,7 +427,7 @@ contract KlerosCoreUniversity is IArbitratorV2, UUPSProxiable, Initializable { /// @dev Changes the supported fee tokens. /// @param _feeToken The fee token. /// @param _accepted Whether the token is supported or not as a method of fee payment. - function changeAcceptedFeeTokens(IERC20 _feeToken, bool _accepted) external onlyByGovernor { + function changeAcceptedFeeTokens(IERC20 _feeToken, bool _accepted) external onlyByOwner { currencyRates[_feeToken].feePaymentAccepted = _accepted; emit AcceptedFeeToken(_feeToken, _accepted); } @@ -440,7 +436,7 @@ contract KlerosCoreUniversity is IArbitratorV2, UUPSProxiable, Initializable { /// @param _feeToken The fee token. /// @param _rateInEth The new rate of the fee token in ETH. /// @param _rateDecimals The new decimals of the fee token rate. - function changeCurrencyRates(IERC20 _feeToken, uint64 _rateInEth, uint8 _rateDecimals) external onlyByGovernor { + function changeCurrencyRates(IERC20 _feeToken, uint64 _rateInEth, uint8 _rateDecimals) external onlyByOwner { currencyRates[_feeToken].rateInEth = _rateInEth; currencyRates[_feeToken].rateDecimals = _rateDecimals; emit NewCurrencyRate(_feeToken, _rateInEth, _rateDecimals); @@ -588,7 +584,7 @@ contract KlerosCoreUniversity is IArbitratorV2, UUPSProxiable, Initializable { /// @dev Draws one juror for the dispute until the number votes paid for is reached. /// @param _disputeID The ID of the dispute. /// @param _juror The address of the juror to draw. - function draw(uint256 _disputeID, address _juror) external onlyByGovernorOrInstructor { + function draw(uint256 _disputeID, address _juror) external onlyByOwnerOrInstructor { Dispute storage dispute = disputes[_disputeID]; uint256 currentRound = dispute.rounds.length - 1; Round storage round = dispute.rounds[currentRound]; @@ -790,15 +786,15 @@ contract KlerosCoreUniversity is IArbitratorV2, UUPSProxiable, Initializable { sortitionModule.setJurorInactive(account); } if (_params.repartition == _params.numberOfVotesInRound - 1 && _params.coherentCount == 0) { - // No one was coherent, send the rewards to the governor. + // No one was coherent, send the rewards to the owner. if (round.feeToken == NATIVE_CURRENCY) { // The dispute fees were paid in ETH - payable(governor).send(round.totalFeesForJurors); + payable(owner).send(round.totalFeesForJurors); } else { // The dispute fees were paid in ERC20 - round.feeToken.safeTransfer(governor, round.totalFeesForJurors); + round.feeToken.safeTransfer(owner, round.totalFeesForJurors); } - pinakion.safeTransfer(governor, _params.pnkPenaltiesInRound); + pinakion.safeTransfer(owner, _params.pnkPenaltiesInRound); emit LeftoverRewardSent( _params.disputeID, _params.round, @@ -870,21 +866,21 @@ contract KlerosCoreUniversity is IArbitratorV2, UUPSProxiable, Initializable { round.feeToken ); - // Transfer any residual rewards to the governor. It may happen due to partial coherence of the jurors. + // Transfer any residual rewards to the owner. It may happen due to partial coherence of the jurors. if (_params.repartition == _params.numberOfVotesInRound * 2 - 1) { uint256 leftoverPnkReward = _params.pnkPenaltiesInRound - round.sumPnkRewardPaid; uint256 leftoverFeeReward = round.totalFeesForJurors - round.sumFeeRewardPaid; if (leftoverPnkReward != 0 || leftoverFeeReward != 0) { if (leftoverPnkReward != 0) { - pinakion.safeTransfer(governor, leftoverPnkReward); + pinakion.safeTransfer(owner, leftoverPnkReward); } if (leftoverFeeReward != 0) { if (round.feeToken == NATIVE_CURRENCY) { // The dispute fees were paid in ETH - payable(governor).send(leftoverFeeReward); + payable(owner).send(leftoverFeeReward); } else { // The dispute fees were paid in ERC20 - round.feeToken.safeTransfer(governor, leftoverFeeReward); + round.feeToken.safeTransfer(owner, leftoverFeeReward); } } emit LeftoverRewardSent( @@ -1157,9 +1153,9 @@ contract KlerosCoreUniversity is IArbitratorV2, UUPSProxiable, Initializable { // * Errors * // // ************************************* // - error GovernorOnly(); + error OwnerOnly(); error InstructorOnly(); - error GovernorOrInstructorOnly(); + error OwnerOrInstructorOnly(); error DisputeKitOnly(); error SortitionModuleOnly(); error UnsuccessfulCall(); diff --git a/contracts/src/arbitration/university/SortitionModuleUniversity.sol b/contracts/src/arbitration/university/SortitionModuleUniversity.sol index e32ca5a77..a7a049bb0 100644 --- a/contracts/src/arbitration/university/SortitionModuleUniversity.sol +++ b/contracts/src/arbitration/university/SortitionModuleUniversity.sol @@ -29,7 +29,7 @@ contract SortitionModuleUniversity is ISortitionModuleUniversity, UUPSProxiable, // * Storage * // // ************************************* // - address public governor; // The governor of the contract. + address public owner; // The owner of the contract. KlerosCoreUniversity public core; // The core arbitrator contract. uint256 public disputesWithoutJurors; // The number of disputes that have not finished drawing jurors. mapping(address account => Juror) public jurors; // The jurors. @@ -66,8 +66,8 @@ contract SortitionModuleUniversity is ISortitionModuleUniversity, UUPSProxiable, // * Function Modifiers * // // ************************************* // - modifier onlyByGovernor() { - if (governor != msg.sender) revert GovernorOnly(); + modifier onlyByOwner() { + if (owner != msg.sender) revert OwnerOnly(); _; } @@ -87,8 +87,8 @@ contract SortitionModuleUniversity is ISortitionModuleUniversity, UUPSProxiable, /// @dev Initializer (constructor equivalent for upgradable contracts). /// @param _core The KlerosCore. - function initialize(address _governor, KlerosCoreUniversity _core) external reinitializer(1) { - governor = _governor; + function initialize(address _owner, KlerosCoreUniversity _core) external reinitializer(1) { + owner = _owner; core = _core; } @@ -98,9 +98,9 @@ contract SortitionModuleUniversity is ISortitionModuleUniversity, UUPSProxiable, /** * @dev Access Control to perform implementation upgrades (UUPS Proxiable) - * @dev Only the governor can perform upgrades (`onlyByGovernor`) + * @dev Only the owner can perform upgrades (`onlyByOwner`) */ - function _authorizeUpgrade(address) internal view override onlyByGovernor { + function _authorizeUpgrade(address) internal view override onlyByOwner { // NOP } @@ -403,7 +403,7 @@ contract SortitionModuleUniversity is ISortitionModuleUniversity, UUPSProxiable, // * Errors * // // ************************************* // - error GovernorOnly(); + error OwnerOnly(); error KlerosCoreOnly(); error NotEligibleForWithdrawal(); } diff --git a/contracts/src/arbitration/view/KlerosCoreSnapshotProxy.sol b/contracts/src/arbitration/view/KlerosCoreSnapshotProxy.sol index 74cdb84ce..70c3c77ce 100644 --- a/contracts/src/arbitration/view/KlerosCoreSnapshotProxy.sol +++ b/contracts/src/arbitration/view/KlerosCoreSnapshotProxy.sol @@ -16,7 +16,7 @@ contract KlerosCoreSnapshotProxy { // ************************************* // IKlerosCore public core; - address public governor; + address public owner; string public constant name = "Staked Pinakion"; string public constant symbol = "stPNK"; uint8 public constant decimals = 18; @@ -25,8 +25,8 @@ contract KlerosCoreSnapshotProxy { // * Modifiers * // // ************************************* // - modifier onlyByGovernor() { - if (governor != msg.sender) revert GovernorOnly(); + modifier onlyByOwner() { + if (owner != msg.sender) revert OwnerOnly(); _; } @@ -35,10 +35,10 @@ contract KlerosCoreSnapshotProxy { // ************************************* // /// @dev Constructor - /// @param _governor The governor of the contract. + /// @param _owner The owner of the contract. /// @param _core KlerosCore to read the balance from. - constructor(address _governor, IKlerosCore _core) { - governor = _governor; + constructor(address _owner, IKlerosCore _core) { + owner = _owner; core = _core; } @@ -46,15 +46,15 @@ contract KlerosCoreSnapshotProxy { // * Governance * // // ************************************* // - /// @dev Changes the `governor` storage variable. - /// @param _governor The new value for the `governor` storage variable. - function changeGovernor(address _governor) external onlyByGovernor { - governor = _governor; + /// @dev Changes the `owner` storage variable. + /// @param _owner The new value for the `owner` storage variable. + function changeOwner(address _owner) external onlyByOwner { + owner = _owner; } /// @dev Changes the `core` storage variable. /// @param _core The new value for the `core` storage variable. - function changeCore(IKlerosCore _core) external onlyByGovernor { + function changeCore(IKlerosCore _core) external onlyByOwner { core = _core; } @@ -74,5 +74,5 @@ contract KlerosCoreSnapshotProxy { // * Errors * // // ************************************* // - error GovernorOnly(); + error OwnerOnly(); } diff --git a/contracts/src/gateway/ForeignGateway.sol b/contracts/src/gateway/ForeignGateway.sol index 1e615936f..712790d0d 100644 --- a/contracts/src/gateway/ForeignGateway.sol +++ b/contracts/src/gateway/ForeignGateway.sol @@ -36,7 +36,7 @@ contract ForeignGateway is IForeignGateway, UUPSProxiable, Initializable { uint256 internal localDisputeID; // The disputeID must start from 1 as the KlerosV1 proxy governor depends on this implementation. We now also depend on localDisputeID not ever being zero. mapping(uint96 courtId => uint256) public feeForJuror; // feeForJuror[v2CourtID], it mirrors the value on KlerosCore. - address public governor; + address public owner; address public veaOutbox; uint256 public override homeChainID; address public override homeGateway; @@ -57,8 +57,8 @@ contract ForeignGateway is IForeignGateway, UUPSProxiable, Initializable { _; } - modifier onlyByGovernor() { - if (governor != msg.sender) revert GovernorOnly(); + modifier onlyByOwner() { + if (owner != msg.sender) revert OwnerOnly(); _; } @@ -72,17 +72,17 @@ contract ForeignGateway is IForeignGateway, UUPSProxiable, Initializable { } /// @dev Constructs the `PolicyRegistry` contract. - /// @param _governor The governor's address. + /// @param _owner The owner's address. /// @param _veaOutbox The address of the VeaOutbox. /// @param _homeChainID The chainID of the home chain. /// @param _homeGateway The address of the home gateway. function initialize( - address _governor, + address _owner, address _veaOutbox, uint256 _homeChainID, address _homeGateway ) external reinitializer(1) { - governor = _governor; + owner = _owner; veaOutbox = _veaOutbox; homeChainID = _homeChainID; homeGateway = _homeGateway; @@ -95,23 +95,23 @@ contract ForeignGateway is IForeignGateway, UUPSProxiable, Initializable { /** * @dev Access Control to perform implementation upgrades (UUPS Proxiable) - * @dev Only the governor can perform upgrades (`onlyByGovernor`) + * @dev Only the owner can perform upgrades (`onlyByOwner`) */ - function _authorizeUpgrade(address) internal view override onlyByGovernor { + function _authorizeUpgrade(address) internal view override onlyByOwner { // NOP } - /// @dev Changes the governor. - /// @param _governor The address of the new governor. - function changeGovernor(address _governor) external { - if (governor != msg.sender) revert GovernorOnly(); - governor = _governor; + /// @dev Changes the owner. + /// @param _owner The address of the new owner. + function changeOwner(address _owner) external { + if (owner != msg.sender) revert OwnerOnly(); + owner = _owner; } /// @dev Changes the outbox. /// @param _veaOutbox The address of the new outbox. /// @param _gracePeriod The duration to accept messages from the deprecated bridge (if at all). - function changeVea(address _veaOutbox, uint256 _gracePeriod) external onlyByGovernor { + function changeVea(address _veaOutbox, uint256 _gracePeriod) external onlyByOwner { // grace period to relay the remaining messages which are still going through the deprecated bridge. deprecatedVeaOutboxExpiration = block.timestamp + _gracePeriod; deprecatedVeaOutbox = veaOutbox; @@ -121,14 +121,14 @@ contract ForeignGateway is IForeignGateway, UUPSProxiable, Initializable { /// @dev Changes the home gateway. /// @param _homeGateway The address of the new home gateway. function changeHomeGateway(address _homeGateway) external { - if (governor != msg.sender) revert GovernorOnly(); + if (owner != msg.sender) revert OwnerOnly(); homeGateway = _homeGateway; } /// @dev Changes the `feeForJuror` property value of a specified court. /// @param _courtID The ID of the court on the v2 arbitrator. Not to be confused with the courtID on KlerosLiquid. /// @param _feeForJuror The new value for the `feeForJuror` property value. - function changeCourtJurorFee(uint96 _courtID, uint256 _feeForJuror) external onlyByGovernor { + function changeCourtJurorFee(uint96 _courtID, uint256 _feeForJuror) external onlyByOwner { feeForJuror[_courtID] = _feeForJuror; emit ArbitrationCostModified(_courtID, _feeForJuror); } @@ -272,7 +272,7 @@ contract ForeignGateway is IForeignGateway, UUPSProxiable, Initializable { // * Errors * // // ************************************* // - error GovernorOnly(); + error OwnerOnly(); error HomeGatewayMessageSenderOnly(); error VeaOutboxOnly(); error ArbitrationFeesNotEnough(); diff --git a/contracts/src/gateway/HomeGateway.sol b/contracts/src/gateway/HomeGateway.sol index 2ef8e606f..d0062dc52 100644 --- a/contracts/src/gateway/HomeGateway.sol +++ b/contracts/src/gateway/HomeGateway.sol @@ -29,7 +29,7 @@ contract HomeGateway is IHomeGateway, UUPSProxiable, Initializable { // * Storage * // // ************************************* // - address public governor; + address public owner; IArbitratorV2 public arbitrator; IVeaInbox public veaInbox; uint256 public override foreignChainID; @@ -43,9 +43,9 @@ contract HomeGateway is IHomeGateway, UUPSProxiable, Initializable { // * Function Modifiers * // // ************************************* // - /// @dev Requires that the sender is the governor. - modifier onlyByGovernor() { - if (governor != msg.sender) revert GovernorOnly(); + /// @dev Requires that the sender is the owner. + modifier onlyByOwner() { + if (owner != msg.sender) revert OwnerOnly(); _; } @@ -59,21 +59,21 @@ contract HomeGateway is IHomeGateway, UUPSProxiable, Initializable { } /// @dev Constructs the `PolicyRegistry` contract. - /// @param _governor The governor's address. + /// @param _owner The owner's address. /// @param _arbitrator The address of the arbitrator. /// @param _veaInbox The address of the vea inbox. /// @param _foreignChainID The ID of the foreign chain. /// @param _foreignGateway The address of the foreign gateway. /// @param _feeToken The address of the fee token. function initialize( - address _governor, + address _owner, IArbitratorV2 _arbitrator, IVeaInbox _veaInbox, uint256 _foreignChainID, address _foreignGateway, IERC20 _feeToken ) external reinitializer(1) { - governor = _governor; + owner = _owner; arbitrator = _arbitrator; veaInbox = _veaInbox; foreignChainID = _foreignChainID; @@ -87,39 +87,39 @@ contract HomeGateway is IHomeGateway, UUPSProxiable, Initializable { /** * @dev Access Control to perform implementation upgrades (UUPS Proxiable) - * @dev Only the governor can perform upgrades (`onlyByGovernor`) + * @dev Only the owner can perform upgrades (`onlyByOwner`) */ - function _authorizeUpgrade(address) internal view override onlyByGovernor { + function _authorizeUpgrade(address) internal view override onlyByOwner { // NOP } - /// @dev Changes the governor. - /// @param _governor The address of the new governor. - function changeGovernor(address _governor) external onlyByGovernor { - governor = _governor; + /// @dev Changes the owner. + /// @param _owner The address of the new owner. + function changeOwner(address _owner) external onlyByOwner { + owner = _owner; } /// @dev Changes the arbitrator. /// @param _arbitrator The address of the new arbitrator. - function changeArbitrator(IArbitratorV2 _arbitrator) external onlyByGovernor { + function changeArbitrator(IArbitratorV2 _arbitrator) external onlyByOwner { arbitrator = _arbitrator; } /// @dev Changes the vea inbox, useful to increase the claim deposit. /// @param _veaInbox The address of the new vea inbox. - function changeVea(IVeaInbox _veaInbox) external onlyByGovernor { + function changeVea(IVeaInbox _veaInbox) external onlyByOwner { veaInbox = _veaInbox; } /// @dev Changes the foreign gateway. /// @param _foreignGateway The address of the new foreign gateway. - function changeForeignGateway(address _foreignGateway) external onlyByGovernor { + function changeForeignGateway(address _foreignGateway) external onlyByOwner { foreignGateway = _foreignGateway; } /// @dev Changes the fee token. /// @param _feeToken The address of the new fee token. - function changeFeeToken(IERC20 _feeToken) external onlyByGovernor { + function changeFeeToken(IERC20 _feeToken) external onlyByOwner { feeToken = _feeToken; } @@ -239,7 +239,7 @@ contract HomeGateway is IHomeGateway, UUPSProxiable, Initializable { // * Errors * // // ************************************* // - error GovernorOnly(); + error OwnerOnly(); error ArbitratorOnly(); error FeesPaidInERC20Only(); error FeesPaidInNativeCurrencyOnly(); diff --git a/contracts/src/kleros-v1/interfaces/IKlerosLiquid.sol b/contracts/src/kleros-v1/interfaces/IKlerosLiquid.sol index 0422c95b3..56d3c7789 100644 --- a/contracts/src/kleros-v1/interfaces/IKlerosLiquid.sol +++ b/contracts/src/kleros-v1/interfaces/IKlerosLiquid.sol @@ -77,7 +77,7 @@ interface IKlerosLiquid is IArbitratorV1 { function changeSubcourtTimesPerPeriod(uint96 _subcourtID, uint256[4] calldata _timesPerPeriod) external; - function executeGovernorProposal(address _destination, uint256 _amount, bytes calldata _data) external; + function executeOwnerProposal(address _destination, uint256 _amount, bytes calldata _data) external; // Getters function getVote( diff --git a/contracts/src/kleros-v1/kleros-liquid-xdai/xKlerosLiquidV2.sol b/contracts/src/kleros-v1/kleros-liquid-xdai/xKlerosLiquidV2.sol index 9a25909b7..59ff80353 100644 --- a/contracts/src/kleros-v1/kleros-liquid-xdai/xKlerosLiquidV2.sol +++ b/contracts/src/kleros-v1/kleros-liquid-xdai/xKlerosLiquidV2.sol @@ -142,7 +142,7 @@ contract xKlerosLiquidV2 is Initializable, ITokenController, IArbitratorV2 { uint256 public constant DEFAULT_NB_OF_JURORS = 3; // The default number of jurors in a dispute. uint256 public constant NON_PAYABLE_AMOUNT = (2 ** 256 - 2) / 2; // An amount higher than the supply of ETH. // General Contracts - address public governor; // The governor of the contract. + address public owner; // The owner of the contract. WrappedPinakion public pinakion; // The Pinakion token contract. IRandomAuRa public RNGenerator; // The random number generator contract. // General Dynamic @@ -197,9 +197,9 @@ contract xKlerosLiquidV2 is Initializable, ITokenController, IArbitratorV2 { _; } - /// @dev Requires that the sender is the governor. Note that the governor is expected to not be malicious. - modifier onlyByGovernor() { - require(governor == msg.sender); + /// @dev Requires that the sender is the owner. Note that the owner is expected to not be malicious. + modifier onlyByOwner() { + require(owner == msg.sender); _; } @@ -208,7 +208,7 @@ contract xKlerosLiquidV2 is Initializable, ITokenController, IArbitratorV2 { // ************************************* // /// @dev Constructs the KlerosLiquid contract. - /// @param _governor The governor's address. + /// @param _owner The owner's address. /// @param _pinakion The address of the token contract. /// @param _RNGenerator The address of the random number generator contract. /// @param _minStakingTime The minimum time that the staking phase should last. @@ -219,7 +219,7 @@ contract xKlerosLiquidV2 is Initializable, ITokenController, IArbitratorV2 { /// @param _sortitionSumTreeK The number of children per node of the general court's sortition sum tree. /// @param _foreignGateway Foreign gateway on xDai. function initialize( - address _governor, + address _owner, WrappedPinakion _pinakion, IRandomAuRa _RNGenerator, uint256 _minStakingTime, @@ -231,7 +231,7 @@ contract xKlerosLiquidV2 is Initializable, ITokenController, IArbitratorV2 { IForeignGateway _foreignGateway ) public initializer { // Initialize contract. - governor = _governor; + owner = _owner; pinakion = _pinakion; RNGenerator = _RNGenerator; minStakingTime = _minStakingTime; @@ -264,34 +264,30 @@ contract xKlerosLiquidV2 is Initializable, ITokenController, IArbitratorV2 { // * Governance * // // ************************************* // - /// @dev Lets the governor call anything on behalf of the contract. + /// @dev Lets the owner call anything on behalf of the contract. /// @param _destination The destination of the call. /// @param _amount The value sent with the call. /// @param _data The data sent with the call. - function executeGovernorProposal( - address _destination, - uint256 _amount, - bytes memory _data - ) external onlyByGovernor { + function executeOwnerProposal(address _destination, uint256 _amount, bytes memory _data) external onlyByOwner { (bool success, ) = _destination.call{value: _amount}(_data); require(success, "Unsuccessful call"); } - /// @dev Changes the `governor` storage variable. - /// @param _governor The new value for the `governor` storage variable. - function changeGovernor(address _governor) external onlyByGovernor { - governor = _governor; + /// @dev Changes the `owner` storage variable. + /// @param _owner The new value for the `owner` storage variable. + function changeOwner(address _owner) external onlyByOwner { + owner = _owner; } /// @dev Changes the `pinakion` storage variable. /// @param _pinakion The new value for the `pinakion` storage variable. - function changePinakion(WrappedPinakion _pinakion) external onlyByGovernor { + function changePinakion(WrappedPinakion _pinakion) external onlyByOwner { pinakion = _pinakion; } /// @dev Changes the `RNGenerator` storage variable. /// @param _RNGenerator The new value for the `RNGenerator` storage variable. - function changeRNGenerator(IRandomAuRa _RNGenerator) external onlyByGovernor { + function changeRNGenerator(IRandomAuRa _RNGenerator) external onlyByOwner { RNGenerator = _RNGenerator; if (phase == Phase.generating) { RNBlock = RNGenerator.nextCommitPhaseStartBlock() + RNGenerator.collectRoundLength(); @@ -300,19 +296,19 @@ contract xKlerosLiquidV2 is Initializable, ITokenController, IArbitratorV2 { /// @dev Changes the `minStakingTime` storage variable. /// @param _minStakingTime The new value for the `minStakingTime` storage variable. - function changeMinStakingTime(uint256 _minStakingTime) external onlyByGovernor { + function changeMinStakingTime(uint256 _minStakingTime) external onlyByOwner { minStakingTime = _minStakingTime; } /// @dev Changes the `maxDrawingTime` storage variable. /// @param _maxDrawingTime The new value for the `maxDrawingTime` storage variable. - function changeMaxDrawingTime(uint256 _maxDrawingTime) external onlyByGovernor { + function changeMaxDrawingTime(uint256 _maxDrawingTime) external onlyByOwner { maxDrawingTime = _maxDrawingTime; } /// @dev Changes the `foreignGateway` storage variable. /// @param _foreignGateway The new value for the `foreignGateway` storage variable. - function changeForeignGateway(IForeignGateway _foreignGateway) external onlyByGovernor { + function changeForeignGateway(IForeignGateway _foreignGateway) external onlyByOwner { foreignGateway = _foreignGateway; } @@ -334,7 +330,7 @@ contract xKlerosLiquidV2 is Initializable, ITokenController, IArbitratorV2 { uint256 _jurorsForCourtJump, uint256[4] memory _timesPerPeriod, uint256 _sortitionSumTreeK - ) external onlyByGovernor { + ) external onlyByOwner { require( courts[_parent].minStake <= _minStake, "A subcourt cannot be a child of a subcourt with a higher minimum stake." @@ -360,7 +356,7 @@ contract xKlerosLiquidV2 is Initializable, ITokenController, IArbitratorV2 { /// @dev Changes the `minStake` property value of a specified subcourt. Don't set to a value lower than its parent's `minStake` property value. /// @param _subcourtID The ID of the subcourt. /// @param _minStake The new value for the `minStake` property value. - function changeSubcourtMinStake(uint96 _subcourtID, uint256 _minStake) external onlyByGovernor { + function changeSubcourtMinStake(uint96 _subcourtID, uint256 _minStake) external onlyByOwner { require(_subcourtID == 0 || courts[courts[_subcourtID].parent].minStake <= _minStake); for (uint256 i = 0; i < courts[_subcourtID].children.length; i++) { require( @@ -375,31 +371,28 @@ contract xKlerosLiquidV2 is Initializable, ITokenController, IArbitratorV2 { /// @dev Changes the `alpha` property value of a specified subcourt. /// @param _subcourtID The ID of the subcourt. /// @param _alpha The new value for the `alpha` property value. - function changeSubcourtAlpha(uint96 _subcourtID, uint256 _alpha) external onlyByGovernor { + function changeSubcourtAlpha(uint96 _subcourtID, uint256 _alpha) external onlyByOwner { courts[_subcourtID].alpha = _alpha; } /// @dev Changes the `feeForJuror` property value of a specified subcourt. /// @param _subcourtID The ID of the subcourt. /// @param _feeForJuror The new value for the `feeForJuror` property value. - function changeSubcourtJurorFee(uint96 _subcourtID, uint256 _feeForJuror) external onlyByGovernor { + function changeSubcourtJurorFee(uint96 _subcourtID, uint256 _feeForJuror) external onlyByOwner { courts[_subcourtID].feeForJuror = _feeForJuror; } /// @dev Changes the `jurorsForCourtJump` property value of a specified subcourt. /// @param _subcourtID The ID of the subcourt. /// @param _jurorsForCourtJump The new value for the `jurorsForCourtJump` property value. - function changeSubcourtJurorsForJump(uint96 _subcourtID, uint256 _jurorsForCourtJump) external onlyByGovernor { + function changeSubcourtJurorsForJump(uint96 _subcourtID, uint256 _jurorsForCourtJump) external onlyByOwner { courts[_subcourtID].jurorsForCourtJump = _jurorsForCourtJump; } /// @dev Changes the `timesPerPeriod` property value of a specified subcourt. /// @param _subcourtID The ID of the subcourt. /// @param _timesPerPeriod The new value for the `timesPerPeriod` property value. - function changeSubcourtTimesPerPeriod( - uint96 _subcourtID, - uint256[4] memory _timesPerPeriod - ) external onlyByGovernor { + function changeSubcourtTimesPerPeriod(uint96 _subcourtID, uint256[4] memory _timesPerPeriod) external onlyByOwner { courts[_subcourtID].timesPerPeriod = _timesPerPeriod; } diff --git a/contracts/src/kleros-v1/kleros-liquid/KlerosLiquidToV2Governor.sol b/contracts/src/kleros-v1/kleros-liquid/KlerosLiquidToV2Governor.sol index 509b85101..def339931 100644 --- a/contracts/src/kleros-v1/kleros-liquid/KlerosLiquidToV2Governor.sol +++ b/contracts/src/kleros-v1/kleros-liquid/KlerosLiquidToV2Governor.sol @@ -26,7 +26,7 @@ contract KlerosLiquidToV2Governor is IArbitrableV2, ITokenController { IArbitratorV2 public immutable foreignGateway; IKlerosLiquid public immutable klerosLiquid; - address public governor; + address public owner; mapping(uint256 disputeId => uint256 gatewayDisputeId) public klerosLiquidDisputeIDtoGatewayDisputeID; mapping(uint256 gatewayDisputeId => DisputeData) public disputes; // disputes[gatewayDisputeID] mapping(address account => uint256 tokenAmount) public frozenTokens; // frozenTokens[account] locked token which shouldn't have been blocked. @@ -36,8 +36,8 @@ contract KlerosLiquidToV2Governor is IArbitrableV2, ITokenController { // * Function Modifiers * // // ************************************* // - modifier onlyByGovernor() { - require(governor == msg.sender); + modifier onlyByOwner() { + require(owner == msg.sender); _; } @@ -45,13 +45,13 @@ contract KlerosLiquidToV2Governor is IArbitrableV2, ITokenController { // * Constructor * // // ************************************* // - /// @dev Constructor. Before this contract is made the new governor of KlerosLiquid, the evidence period of all subcourts has to be set to uint(-1). + /// @dev Constructor. Before this contract is made the new owner of KlerosLiquid, the evidence period of all subcourts has to be set to uint(-1). /// @param _klerosLiquid The trusted arbitrator to resolve potential disputes. - /// @param _governor The trusted governor of the contract. + /// @param _owner The trusted owner of the contract. /// @param _foreignGateway The trusted gateway that acts as an arbitrator, relaying disputes to v2. - constructor(IKlerosLiquid _klerosLiquid, address _governor, IArbitratorV2 _foreignGateway) { + constructor(IKlerosLiquid _klerosLiquid, address _owner, IArbitratorV2 _foreignGateway) { klerosLiquid = _klerosLiquid; - governor = _governor; + owner = _owner; foreignGateway = _foreignGateway; } @@ -59,23 +59,19 @@ contract KlerosLiquidToV2Governor is IArbitrableV2, ITokenController { // * Governance * // // ************************************* // - /// @dev Lets the governor call anything on behalf of the contract. + /// @dev Lets the owner call anything on behalf of the contract. /// @param _destination The destination of the call. /// @param _amount The value sent with the call. /// @param _data The data sent with the call. - function executeGovernorProposal( - address _destination, - uint256 _amount, - bytes calldata _data - ) external onlyByGovernor { + function executeOwnerProposal(address _destination, uint256 _amount, bytes calldata _data) external onlyByOwner { (bool success, ) = _destination.call{value: _amount}(_data); // solium-disable-line security/no-call-value require(success, "Call execution failed."); } - /// @dev Changes the `governor` storage variable. - /// @param _governor The new value for the `governor` storage variable. - function changeGovernor(address _governor) external onlyByGovernor { - governor = _governor; + /// @dev Changes the `owner` storage variable. + /// @param _owner The new value for the `owner` storage variable. + function changeOwner(address _owner) external onlyByOwner { + owner = _owner; } // ************************************* // @@ -94,7 +90,7 @@ contract KlerosLiquidToV2Governor is IArbitrableV2, ITokenController { require(KlerosLiquidDispute.period == IKlerosLiquid.Period.evidence, "Invalid dispute period."); require(votesLengths.length == 1, "Cannot relay appeals."); - klerosLiquid.executeGovernorProposal(address(this), totalFeesForJurors[0], ""); + klerosLiquid.executeOwnerProposal(address(this), totalFeesForJurors[0], ""); uint256 minJurors = votesLengths[0]; bytes memory extraData = abi.encode(KlerosLiquidDispute.subcourtID, minJurors); @@ -125,7 +121,7 @@ contract KlerosLiquidToV2Governor is IArbitrableV2, ITokenController { IKlerosLiquid.Dispute memory klerosLiquidDispute = klerosLiquid.disputes(dispute.klerosLiquidDisputeID); bytes memory data = abi.encodeCall(IArbitrableV2.rule, (dispute.klerosLiquidDisputeID, _ruling)); - klerosLiquid.executeGovernorProposal(klerosLiquidDispute.arbitrated, 0, data); + klerosLiquid.executeOwnerProposal(klerosLiquidDispute.arbitrated, 0, data); } /// @dev Registers jurors' tokens which where locked due to relaying a given dispute. These tokens don't count as locked. diff --git a/contracts/src/proxy/mock/UUPSUpgradeableMocks.sol b/contracts/src/proxy/mock/UUPSUpgradeableMocks.sol index 0764c8cd1..3b2bc7959 100644 --- a/contracts/src/proxy/mock/UUPSUpgradeableMocks.sol +++ b/contracts/src/proxy/mock/UUPSUpgradeableMocks.sol @@ -20,7 +20,7 @@ contract NonUpgradeableMock { contract UUPSUpgradeableMock is UUPSProxiable, NonUpgradeableMock { bool public initialized; - address public governor; + address public owner; uint256[50] __gap; @@ -28,14 +28,14 @@ contract UUPSUpgradeableMock is UUPSProxiable, NonUpgradeableMock { initialized = true; } - function initialize(address _governor) external { + function initialize(address _owner) external { require(!initialized, "Contract instance has already been initialized"); - governor = _governor; + owner = _owner; initialized = true; } function _authorizeUpgrade(address) internal view override { - require(governor == msg.sender, "No privilege to upgrade"); + require(owner == msg.sender, "No privilege to upgrade"); } function version() external pure virtual override returns (string memory) { diff --git a/contracts/src/proxy/mock/by-inheritance/UpgradedByInheritance.sol b/contracts/src/proxy/mock/by-inheritance/UpgradedByInheritance.sol index 2cb9adf03..c5f796995 100644 --- a/contracts/src/proxy/mock/by-inheritance/UpgradedByInheritance.sol +++ b/contracts/src/proxy/mock/by-inheritance/UpgradedByInheritance.sol @@ -12,7 +12,7 @@ contract UpgradedByInheritanceV1Proxy is UUPSProxy { } contract UpgradedByInheritanceV1 is UUPSProxiable, Initializable { - address public governor; + address public owner; uint256 public counter; uint256[50] __gap; @@ -20,13 +20,13 @@ contract UpgradedByInheritanceV1 is UUPSProxiable, Initializable { _disableInitializers(); } - function initialize(address _governor) external virtual reinitializer(1) { - governor = _governor; + function initialize(address _owner) external virtual reinitializer(1) { + owner = _owner; counter = 1; } function _authorizeUpgrade(address) internal view override { - require(governor == msg.sender, "No privilege to upgrade"); + require(owner == msg.sender, "No privilege to upgrade"); } function increment() external { diff --git a/contracts/src/proxy/mock/by-rewrite/UpgradedByRewrite.sol b/contracts/src/proxy/mock/by-rewrite/UpgradedByRewrite.sol index ca0731da8..f5e5eae77 100644 --- a/contracts/src/proxy/mock/by-rewrite/UpgradedByRewrite.sol +++ b/contracts/src/proxy/mock/by-rewrite/UpgradedByRewrite.sol @@ -15,7 +15,7 @@ contract UpgradedByRewrite is UUPSProxiable, Initializable { //------------------------ // V1 State //------------------------ - address public governor; + address public owner; uint256 public counter; uint256[50] __gap; @@ -23,13 +23,13 @@ contract UpgradedByRewrite is UUPSProxiable, Initializable { _disableInitializers(); } - function initialize(address _governor) external virtual reinitializer(1) { - governor = _governor; + function initialize(address _owner) external virtual reinitializer(1) { + owner = _owner; counter = 1; } function _authorizeUpgrade(address) internal view override { - require(governor == msg.sender, "No privilege to upgrade"); + require(owner == msg.sender, "No privilege to upgrade"); } function increment() external { diff --git a/contracts/src/proxy/mock/by-rewrite/UpgradedByRewriteV2.sol b/contracts/src/proxy/mock/by-rewrite/UpgradedByRewriteV2.sol index 1b3c85e0a..5158c73fb 100644 --- a/contracts/src/proxy/mock/by-rewrite/UpgradedByRewriteV2.sol +++ b/contracts/src/proxy/mock/by-rewrite/UpgradedByRewriteV2.sol @@ -10,7 +10,7 @@ contract UpgradedByRewrite is UUPSProxiable, Initializable { //------------------------ // V1 State //------------------------ - address public governor; + address public owner; uint256 public counter; uint256[50] __gap; @@ -29,7 +29,7 @@ contract UpgradedByRewrite is UUPSProxiable, Initializable { } function _authorizeUpgrade(address) internal view override { - require(governor == msg.sender, "No privilege to upgrade"); + require(owner == msg.sender, "No privilege to upgrade"); } function increment() external { diff --git a/contracts/src/rng/BlockhashRNG.sol b/contracts/src/rng/BlockhashRNG.sol index a36501e6e..d104780f4 100644 --- a/contracts/src/rng/BlockhashRNG.sol +++ b/contracts/src/rng/BlockhashRNG.sol @@ -15,7 +15,7 @@ contract BlockHashRNG is IRNG { // * Storage * // // ************************************* // - address public governor; // The address that can withdraw funds. + address public owner; // The address that can withdraw funds. address public consumer; // The address that can request random numbers. uint256 public immutable lookaheadTime; // Minimal time in seconds between requesting and obtaining a random number. uint256 public requestTimestamp; // Timestamp of the current request @@ -25,8 +25,8 @@ contract BlockHashRNG is IRNG { // * Function Modifiers * // // ************************************* // - modifier onlyByGovernor() { - if (governor != msg.sender) revert GovernorOnly(); + modifier onlyByOwner() { + if (owner != msg.sender) revert OwnerOnly(); _; } @@ -40,11 +40,11 @@ contract BlockHashRNG is IRNG { // ************************************* // /// @dev Constructor. - /// @param _governor The Governor of the contract. + /// @param _owner The Owner of the contract. /// @param _consumer The address that can request random numbers. /// @param _lookaheadTime The time lookahead in seconds for the random number. - constructor(address _governor, address _consumer, uint256 _lookaheadTime) { - governor = _governor; + constructor(address _owner, address _consumer, uint256 _lookaheadTime) { + owner = _owner; consumer = _consumer; lookaheadTime = _lookaheadTime; } @@ -53,15 +53,15 @@ contract BlockHashRNG is IRNG { // * Governance * // // ************************************* // - /// @dev Changes the governor of the contract. - /// @param _governor The new governor. - function changeGovernor(address _governor) external onlyByGovernor { - governor = _governor; + /// @dev Changes the owner of the contract. + /// @param _owner The new owner. + function changeOwner(address _owner) external onlyByOwner { + owner = _owner; } /// @dev Changes the consumer of the RNG. /// @param _consumer The new consumer. - function changeConsumer(address _consumer) external onlyByGovernor { + function changeConsumer(address _consumer) external onlyByOwner { consumer = _consumer; } diff --git a/contracts/src/rng/ChainlinkConsumerBaseV2Plus.sol b/contracts/src/rng/ChainlinkConsumerBaseV2Plus.sol new file mode 100644 index 000000000..73df28caf --- /dev/null +++ b/contracts/src/rng/ChainlinkConsumerBaseV2Plus.sol @@ -0,0 +1,169 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.24; + +// This contract is adapted from `@chainlink/contracts/src/v0.8/vrf/dev/VRFConsumerBaseV2Plus.sol` to remove the `ConfirmedOwner` dependency. + +import {IVRFCoordinatorV2Plus} from "@chainlink/contracts/src/v0.8/vrf/dev/interfaces/IVRFCoordinatorV2Plus.sol"; +import {IVRFMigratableConsumerV2Plus} from "@chainlink/contracts/src/v0.8/vrf/dev/interfaces/IVRFMigratableConsumerV2Plus.sol"; + +/** **************************************************************************** + * @notice Interface for contracts using VRF randomness + * ***************************************************************************** + * @dev PURPOSE + * + * @dev Reggie the Random Oracle (not his real job) wants to provide randomness + * @dev to Vera the verifier in such a way that Vera can be sure he's not + * @dev making his output up to suit himself. Reggie provides Vera a public key + * @dev to which he knows the secret key. Each time Vera provides a seed to + * @dev Reggie, he gives back a value which is computed completely + * @dev deterministically from the seed and the secret key. + * + * @dev Reggie provides a proof by which Vera can verify that the output was + * @dev correctly computed once Reggie tells it to her, but without that proof, + * @dev the output is indistinguishable to her from a uniform random sample + * @dev from the output space. + * + * @dev The purpose of this contract is to make it easy for unrelated contracts + * @dev to talk to Vera the verifier about the work Reggie is doing, to provide + * @dev simple access to a verifiable source of randomness. It ensures 2 things: + * @dev 1. The fulfillment came from the VRFCoordinatorV2Plus. + * @dev 2. The consumer contract implements fulfillRandomWords. + * ***************************************************************************** + * @dev USAGE + * + * @dev Calling contracts must inherit from VRFConsumerBaseV2Plus, and can + * @dev initialize VRFConsumerBaseV2Plus's attributes in their constructor as + * @dev shown: + * + * @dev contract VRFConsumerV2Plus is VRFConsumerBaseV2Plus { + * @dev constructor(, address _vrfCoordinator, address _subOwner) + * @dev VRFConsumerBaseV2Plus(_vrfCoordinator, _subOwner) public { + * @dev + * @dev } + * @dev } + * + * @dev The oracle will have given you an ID for the VRF keypair they have + * @dev committed to (let's call it keyHash). Create a subscription, fund it + * @dev and your consumer contract as a consumer of it (see VRFCoordinatorInterface + * @dev subscription management functions). + * @dev Call requestRandomWords(keyHash, subId, minimumRequestConfirmations, + * @dev callbackGasLimit, numWords, extraArgs), + * @dev see (IVRFCoordinatorV2Plus for a description of the arguments). + * + * @dev Once the VRFCoordinatorV2Plus has received and validated the oracle's response + * @dev to your request, it will call your contract's fulfillRandomWords method. + * + * @dev The randomness argument to fulfillRandomWords is a set of random words + * @dev generated from your requestId and the blockHash of the request. + * + * @dev If your contract could have concurrent requests open, you can use the + * @dev requestId returned from requestRandomWords to track which response is associated + * @dev with which randomness request. + * @dev See "SECURITY CONSIDERATIONS" for principles to keep in mind, + * @dev if your contract could have multiple requests in flight simultaneously. + * + * @dev Colliding `requestId`s are cryptographically impossible as long as seeds + * @dev differ. + * + * ***************************************************************************** + * @dev SECURITY CONSIDERATIONS + * + * @dev A method with the ability to call your fulfillRandomness method directly + * @dev could spoof a VRF response with any random value, so it's critical that + * @dev it cannot be directly called by anything other than this base contract + * @dev (specifically, by the VRFConsumerBaseV2Plus.rawFulfillRandomness method). + * + * @dev For your users to trust that your contract's random behavior is free + * @dev from malicious interference, it's best if you can write it so that all + * @dev behaviors implied by a VRF response are executed *during* your + * @dev fulfillRandomness method. If your contract must store the response (or + * @dev anything derived from it) and use it later, you must ensure that any + * @dev user-significant behavior which depends on that stored value cannot be + * @dev manipulated by a subsequent VRF request. + * + * @dev Similarly, both miners and the VRF oracle itself have some influence + * @dev over the order in which VRF responses appear on the blockchain, so if + * @dev your contract could have multiple VRF requests in flight simultaneously, + * @dev you must ensure that the order in which the VRF responses arrive cannot + * @dev be used to manipulate your contract's user-significant behavior. + * + * @dev Since the block hash of the block which contains the requestRandomness + * @dev call is mixed into the input to the VRF *last*, a sufficiently powerful + * @dev miner could, in principle, fork the blockchain to evict the block + * @dev containing the request, forcing the request to be included in a + * @dev different block with a different hash, and therefore a different input + * @dev to the VRF. However, such an attack would incur a substantial economic + * @dev cost. This cost scales with the number of blocks the VRF oracle waits + * @dev until it calls responds to a request. It is for this reason that + * @dev that you can signal to an oracle you'd like them to wait longer before + * @dev responding to the request (however this is not enforced in the contract + * @dev and so remains effective only in the case of unmodified oracle software). + */ +abstract contract VRFConsumerBaseV2Plus is IVRFMigratableConsumerV2Plus { + error OnlyCoordinatorCanFulfill(address have, address want); + error OnlyOwnerOrCoordinator(address have, address owner, address coordinator); + error ZeroAddress(); + + address public owner; + + // s_vrfCoordinator should be used by consumers to make requests to vrfCoordinator + // so that coordinator reference is updated after migration + IVRFCoordinatorV2Plus public s_vrfCoordinator; + + /** + * @param _vrfCoordinator address of VRFCoordinator contract + */ + constructor(address _owner, address _vrfCoordinator) { + owner = _owner; + if (_vrfCoordinator == address(0)) { + revert ZeroAddress(); + } + s_vrfCoordinator = IVRFCoordinatorV2Plus(_vrfCoordinator); + } + + /** + * @notice fulfillRandomness handles the VRF response. Your contract must + * @notice implement it. See "SECURITY CONSIDERATIONS" above for important + * @notice principles to keep in mind when implementing your fulfillRandomness + * @notice method. + * + * @dev VRFConsumerBaseV2Plus expects its subcontracts to have a method with this + * @dev signature, and will call it once it has verified the proof + * @dev associated with the randomness. (It is triggered via a call to + * @dev rawFulfillRandomness, below.) + * + * @param requestId The Id initially returned by requestRandomness + * @param randomWords the VRF output expanded to the requested number of words + */ + // solhint-disable-next-line chainlink-solidity/prefix-internal-functions-with-underscore + function fulfillRandomWords(uint256 requestId, uint256[] calldata randomWords) internal virtual; + + // rawFulfillRandomness is called by VRFCoordinator when it receives a valid VRF + // proof. rawFulfillRandomness then calls fulfillRandomness, after validating + // the origin of the call + function rawFulfillRandomWords(uint256 requestId, uint256[] calldata randomWords) external { + if (msg.sender != address(s_vrfCoordinator)) { + revert OnlyCoordinatorCanFulfill(msg.sender, address(s_vrfCoordinator)); + } + fulfillRandomWords(requestId, randomWords); + } + + /** + * @inheritdoc IVRFMigratableConsumerV2Plus + */ + function setCoordinator(address _vrfCoordinator) external override onlyOwnerOrCoordinator { + if (_vrfCoordinator == address(0)) { + revert ZeroAddress(); + } + s_vrfCoordinator = IVRFCoordinatorV2Plus(_vrfCoordinator); + + emit CoordinatorSet(_vrfCoordinator); + } + + modifier onlyOwnerOrCoordinator() { + if (msg.sender != owner && msg.sender != address(s_vrfCoordinator)) { + revert OnlyOwnerOrCoordinator(msg.sender, owner, address(s_vrfCoordinator)); + } + _; + } +} diff --git a/contracts/src/rng/ChainlinkRNG.sol b/contracts/src/rng/ChainlinkRNG.sol index a5bff291f..744bc5248 100644 --- a/contracts/src/rng/ChainlinkRNG.sol +++ b/contracts/src/rng/ChainlinkRNG.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.24; -import {VRFConsumerBaseV2Plus, IVRFCoordinatorV2Plus} from "@chainlink/contracts/src/v0.8/vrf/dev/VRFConsumerBaseV2Plus.sol"; +import {VRFConsumerBaseV2Plus, IVRFCoordinatorV2Plus} from "./ChainlinkConsumerBaseV2Plus.sol"; import {VRFV2PlusClient} from "@chainlink/contracts/src/v0.8/vrf/dev/libraries/VRFV2PlusClient.sol"; import "./IRNG.sol"; @@ -14,7 +14,6 @@ contract ChainlinkRNG is IRNG, VRFConsumerBaseV2Plus { // * Storage * // // ************************************* // - address public governor; // The address that can withdraw funds. address public consumer; // The address that can request random numbers. bytes32 public keyHash; // The gas lane key hash value - Defines the maximum gas price you are willing to pay for a request in wei (ID of the off-chain VRF job). uint256 public subscriptionId; // The unique identifier of the subscription used for funding requests. @@ -41,8 +40,8 @@ contract ChainlinkRNG is IRNG, VRFConsumerBaseV2Plus { // * Function Modifiers * // // ************************************* // - modifier onlyByGovernor() { - if (governor != msg.sender) revert GovernorOnly(); + modifier onlyByOwner() { + if (owner != msg.sender) revert OwnerOnly(); _; } @@ -56,7 +55,7 @@ contract ChainlinkRNG is IRNG, VRFConsumerBaseV2Plus { // ************************************* // /// @dev Constructor, initializing the implementation to reduce attack surface. - /// @param _governor The Governor of the contract. + /// @param _owner The owner of the contract. /// @param _consumer The address that can request random numbers. /// @param _vrfCoordinator The address of the VRFCoordinator contract. /// @param _keyHash The gas lane key hash value - Defines the maximum gas price you are willing to pay for a request in wei (ID of the off-chain VRF job). @@ -65,15 +64,14 @@ contract ChainlinkRNG is IRNG, VRFConsumerBaseV2Plus { /// @param _callbackGasLimit The limit for how much gas to use for the callback request to the contract's fulfillRandomWords() function. /// @dev https://docs.chain.link/vrf/v2-5/subscription/get-a-random-number constructor( - address _governor, + address _owner, address _consumer, address _vrfCoordinator, bytes32 _keyHash, uint256 _subscriptionId, uint16 _requestConfirmations, uint32 _callbackGasLimit - ) VRFConsumerBaseV2Plus(_vrfCoordinator) { - governor = _governor; + ) VRFConsumerBaseV2Plus(_owner, _vrfCoordinator) { consumer = _consumer; keyHash = _keyHash; subscriptionId = _subscriptionId; @@ -85,46 +83,46 @@ contract ChainlinkRNG is IRNG, VRFConsumerBaseV2Plus { // * Governance * // // ************************************* // - /// @dev Changes the governor of the contract. - /// @param _governor The new governor. - function changeGovernor(address _governor) external onlyByGovernor { - governor = _governor; + /// @dev Changes the owner of the contract. + /// @param _owner The new owner. + function changeOwner(address _owner) external onlyByOwner { + owner = _owner; } /// @dev Changes the consumer of the RNG. /// @param _consumer The new consumer. - function changeConsumer(address _consumer) external onlyByGovernor { + function changeConsumer(address _consumer) external onlyByOwner { consumer = _consumer; } /// @dev Changes the VRF Coordinator of the contract. /// @param _vrfCoordinator The new VRF Coordinator. - function changeVrfCoordinator(address _vrfCoordinator) external onlyByGovernor { + function changeVrfCoordinator(address _vrfCoordinator) external onlyByOwner { s_vrfCoordinator = IVRFCoordinatorV2Plus(_vrfCoordinator); emit CoordinatorSet(_vrfCoordinator); } /// @dev Changes the key hash of the contract. /// @param _keyHash The new key hash. - function changeKeyHash(bytes32 _keyHash) external onlyByGovernor { + function changeKeyHash(bytes32 _keyHash) external onlyByOwner { keyHash = _keyHash; } /// @dev Changes the subscription ID of the contract. /// @param _subscriptionId The new subscription ID. - function changeSubscriptionId(uint256 _subscriptionId) external onlyByGovernor { + function changeSubscriptionId(uint256 _subscriptionId) external onlyByOwner { subscriptionId = _subscriptionId; } /// @dev Changes the request confirmations of the contract. /// @param _requestConfirmations The new request confirmations. - function changeRequestConfirmations(uint16 _requestConfirmations) external onlyByGovernor { + function changeRequestConfirmations(uint16 _requestConfirmations) external onlyByOwner { requestConfirmations = _requestConfirmations; } /// @dev Changes the callback gas limit of the contract. /// @param _callbackGasLimit The new callback gas limit. - function changeCallbackGasLimit(uint32 _callbackGasLimit) external onlyByGovernor { + function changeCallbackGasLimit(uint32 _callbackGasLimit) external onlyByOwner { callbackGasLimit = _callbackGasLimit; } diff --git a/contracts/src/rng/IRNG.sol b/contracts/src/rng/IRNG.sol index 1a767fee0..c407b763f 100644 --- a/contracts/src/rng/IRNG.sol +++ b/contracts/src/rng/IRNG.sol @@ -11,6 +11,6 @@ interface IRNG { /// @return randomNumber Random number or 0 if not available function receiveRandomness() external returns (uint256 randomNumber); - error GovernorOnly(); + error OwnerOnly(); error ConsumerOnly(); } diff --git a/contracts/src/rng/RNGWithFallback.sol b/contracts/src/rng/RNGWithFallback.sol index c47f9eb53..8501d4db9 100644 --- a/contracts/src/rng/RNGWithFallback.sol +++ b/contracts/src/rng/RNGWithFallback.sol @@ -11,7 +11,7 @@ contract RNGWithFallback is IRNG { // ************************************* // IRNG public immutable rng; // RNG address. - address public governor; // Governor address + address public owner; // Owner address address public consumer; // Consumer address uint256 public fallbackTimeoutSeconds; // Time in seconds to wait before falling back to next RNG uint256 public requestTimestamp; // Timestamp of the current request @@ -27,14 +27,14 @@ contract RNGWithFallback is IRNG { // * Constructor * // // ************************************* // - /// @param _governor Governor address + /// @param _owner Owner address /// @param _consumer Consumer address /// @param _fallbackTimeoutSeconds Time in seconds to wait before falling back to next RNG /// @param _rng The RNG address (e.g. Chainlink) - constructor(address _governor, address _consumer, uint256 _fallbackTimeoutSeconds, IRNG _rng) { + constructor(address _owner, address _consumer, uint256 _fallbackTimeoutSeconds, IRNG _rng) { if (address(_rng) == address(0)) revert InvalidDefaultRNG(); - governor = _governor; + owner = _owner; consumer = _consumer; fallbackTimeoutSeconds = _fallbackTimeoutSeconds; rng = _rng; @@ -44,8 +44,8 @@ contract RNGWithFallback is IRNG { // * Function Modifiers * // // ************************************* // - modifier onlyByGovernor() { - if (governor != msg.sender) revert GovernorOnly(); + modifier onlyByOwner() { + if (owner != msg.sender) revert OwnerOnly(); _; } @@ -58,21 +58,21 @@ contract RNGWithFallback is IRNG { // * Governance Functions * // // ************************************* // - /// @dev Change the governor - /// @param _newGovernor Address of the new governor - function changeGovernor(address _newGovernor) external onlyByGovernor { - governor = _newGovernor; + /// @dev Change the owner + /// @param _newOwner Address of the new owner + function changeOwner(address _newOwner) external onlyByOwner { + owner = _newOwner; } /// @dev Change the consumer /// @param _consumer Address of the new consumer - function changeConsumer(address _consumer) external onlyByGovernor { + function changeConsumer(address _consumer) external onlyByOwner { consumer = _consumer; } /// @dev Change the fallback timeout /// @param _fallbackTimeoutSeconds New timeout in seconds - function changeFallbackTimeout(uint256 _fallbackTimeoutSeconds) external onlyByGovernor { + function changeFallbackTimeout(uint256 _fallbackTimeoutSeconds) external onlyByOwner { fallbackTimeoutSeconds = _fallbackTimeoutSeconds; emit FallbackTimeoutChanged(_fallbackTimeoutSeconds); } diff --git a/contracts/src/rng/RandomizerRNG.sol b/contracts/src/rng/RandomizerRNG.sol index 96cbe6321..648ce5c3d 100644 --- a/contracts/src/rng/RandomizerRNG.sol +++ b/contracts/src/rng/RandomizerRNG.sol @@ -12,7 +12,7 @@ contract RandomizerRNG is IRNG { // * Storage * // // ************************************* // - address public governor; // The address that can withdraw funds. + address public owner; // The address that can withdraw funds. address public consumer; // The address that can request random numbers. IRandomizer public randomizer; // Randomizer address. uint256 public callbackGasLimit; // Gas limit for the Randomizer.ai callback. @@ -36,8 +36,8 @@ contract RandomizerRNG is IRNG { // * Function Modifiers * // // ************************************* // - modifier onlyByGovernor() { - if (governor != msg.sender) revert GovernorOnly(); + modifier onlyByOwner() { + if (owner != msg.sender) revert OwnerOnly(); _; } @@ -51,11 +51,11 @@ contract RandomizerRNG is IRNG { // ************************************* // /// @dev Constructor - /// @param _governor The Governor of the contract. + /// @param _owner The Owner of the contract. /// @param _consumer The address that can request random numbers. /// @param _randomizer The Randomizer.ai oracle contract. - constructor(address _governor, address _consumer, IRandomizer _randomizer) { - governor = _governor; + constructor(address _owner, address _consumer, IRandomizer _randomizer) { + owner = _owner; consumer = _consumer; randomizer = _randomizer; callbackGasLimit = 50000; @@ -65,33 +65,33 @@ contract RandomizerRNG is IRNG { // * Governance * // // ************************ // - /// @dev Changes the governor of the contract. - /// @param _governor The new governor. - function changeGovernor(address _governor) external onlyByGovernor { - governor = _governor; + /// @dev Changes the owner of the contract. + /// @param _owner The new owner. + function changeOwner(address _owner) external onlyByOwner { + owner = _owner; } /// @dev Changes the consumer of the RNG. /// @param _consumer The new consumer. - function changeConsumer(address _consumer) external onlyByGovernor { + function changeConsumer(address _consumer) external onlyByOwner { consumer = _consumer; } /// @dev Change the Randomizer callback gas limit. /// @param _callbackGasLimit the new limit. - function setCallbackGasLimit(uint256 _callbackGasLimit) external onlyByGovernor { + function setCallbackGasLimit(uint256 _callbackGasLimit) external onlyByOwner { callbackGasLimit = _callbackGasLimit; } /// @dev Change the Randomizer address. /// @param _randomizer the new Randomizer address. - function setRandomizer(address _randomizer) external onlyByGovernor { + function setRandomizer(address _randomizer) external onlyByOwner { randomizer = IRandomizer(_randomizer); } - /// @dev Allows the governor to withdraw randomizer funds. + /// @dev Allows the owner to withdraw randomizer funds. /// @param _amount Amount to withdraw in wei. - function randomizerWithdraw(uint256 _amount) external onlyByGovernor { + function randomizerWithdraw(uint256 _amount) external onlyByOwner { randomizer.clientWithdrawTo(msg.sender, _amount); } diff --git a/contracts/src/token/Faucet.sol b/contracts/src/token/Faucet.sol index 092f93891..b64a7e2ab 100644 --- a/contracts/src/token/Faucet.sol +++ b/contracts/src/token/Faucet.sol @@ -10,7 +10,7 @@ contract Faucet { // ************************************* // IERC20 public token; - address public governor; + address public owner; mapping(address => bool) public withdrewAlready; uint256 public amount = 10_000 ether; @@ -18,8 +18,8 @@ contract Faucet { // * Function Modifiers * // // ************************************* // - modifier onlyByGovernor() { - require(address(governor) == msg.sender, "Access not allowed: Governor only."); + modifier onlyByOwner() { + require(address(owner) == msg.sender, "Access not allowed: Owner only."); _; } @@ -29,23 +29,23 @@ contract Faucet { constructor(IERC20 _token) { token = _token; - governor = msg.sender; + owner = msg.sender; } // ************************************* // // * Governance * // // ************************************* // - function changeGovernor(address _governor) public onlyByGovernor { - governor = _governor; + function changeOwner(address _owner) public onlyByOwner { + owner = _owner; } - function changeAmount(uint256 _amount) public onlyByGovernor { + function changeAmount(uint256 _amount) public onlyByOwner { amount = _amount; } - function withdraw() public onlyByGovernor { - token.transfer(governor, token.balanceOf(address(this))); + function withdraw() public onlyByOwner { + token.transfer(owner, token.balanceOf(address(this))); } // ************************************* // diff --git a/contracts/test/arbitration/staking-neo.ts b/contracts/test/arbitration/staking-neo.ts index 696935b40..5537742a6 100644 --- a/contracts/test/arbitration/staking-neo.ts +++ b/contracts/test/arbitration/staking-neo.ts @@ -359,8 +359,8 @@ describe("Staking", async () => { await deploy(); }); - it("Should not allow anyone except the guardian or the governor to pause", async () => { - await expect(core.connect(juror).pause()).to.be.revertedWithCustomError(core, "GuardianOrGovernorOnly"); + it("Should not allow anyone except the guardian or the owner to pause", async () => { + await expect(core.connect(juror).pause()).to.be.revertedWithCustomError(core, "GuardianOrOwnerOnly"); }); it("Should allow the guardian to pause", async () => { @@ -368,7 +368,7 @@ describe("Staking", async () => { expect(await core.paused()).to.equal(true); }); - it("Should allow the governor to pause", async () => { + it("Should allow the owner to pause", async () => { expect(await core.pause()).to.emit(core, "Paused"); expect(await core.paused()).to.equal(true); }); @@ -384,8 +384,8 @@ describe("Staking", async () => { await core.connect(guardian).pause(); }); - it("Should allow only the governor to unpause", async () => { - await expect(core.connect(guardian).unpause()).to.be.revertedWithCustomError(core, "GovernorOnly"); + it("Should allow only the owner to unpause", async () => { + await expect(core.connect(guardian).unpause()).to.be.revertedWithCustomError(core, "OwnerOnly"); expect(await core.unpause()).to.emit(core, "Unpaused"); expect(await core.paused()).to.equal(false); }); diff --git a/contracts/test/evidence/index.ts b/contracts/test/evidence/index.ts index bc3f4ff3b..60c1cb0f5 100644 --- a/contracts/test/evidence/index.ts +++ b/contracts/test/evidence/index.ts @@ -67,7 +67,7 @@ describe("Home Evidence contract", async () => { const EvidenceModule = await ethers.getContractFactory("ModeratedEvidenceModule"); evidenceModule = await EvidenceModule.deploy( arbitrator.target, - deployer.address, // governor + deployer.address, // owner disputeTemplateRegistry.target, totalCostMultiplier, initialDepositMultiplier, @@ -80,10 +80,10 @@ describe("Home Evidence contract", async () => { describe("Governance", async () => { it("Should change parameters correctly", async () => { - const newGovernor = await user2.getAddress(); - await evidenceModule.changeGovernor(newGovernor); - expect(await evidenceModule.governor()).to.equal(newGovernor); - await evidenceModule.connect(user2).changeGovernor(await deployer.getAddress()); + const newOwner = await user2.getAddress(); + await evidenceModule.changeOwner(newOwner); + expect(await evidenceModule.owner()).to.equal(newOwner); + await evidenceModule.connect(user2).changeOwner(await deployer.getAddress()); await evidenceModule.changeInitialDepositMultiplier(1); expect(await evidenceModule.initialDepositMultiplier()).to.equal(1); @@ -117,29 +117,29 @@ describe("Home Evidence contract", async () => { expect(newArbitratorData.arbitratorExtraData).to.equal(newArbitratorExtraData, "Wrong extraData"); }); - it("Should revert if the caller is not the governor", async () => { - await expect(evidenceModule.connect(user2).changeGovernor(await user2.getAddress())).to.be.revertedWith( - "The caller must be the governor" + it("Should revert if the caller is not the owner", async () => { + await expect(evidenceModule.connect(user2).changeOwner(await user2.getAddress())).to.be.revertedWith( + "The caller must be the owner" ); await expect(evidenceModule.connect(user2).changeInitialDepositMultiplier(0)).to.be.revertedWith( - "The caller must be the governor" + "The caller must be the owner" ); await expect(evidenceModule.connect(user2).changeTotalCostMultiplier(0)).to.be.revertedWith( - "The caller must be the governor" + "The caller must be the owner" ); await expect(evidenceModule.connect(user2).changeBondTimeout(0)).to.be.revertedWith( - "The caller must be the governor" + "The caller must be the owner" ); await expect(evidenceModule.connect(user2).changeDisputeTemplate(disputeTemplate, "")).to.be.revertedWith( - "The caller must be the governor" + "The caller must be the owner" ); await expect(evidenceModule.connect(user2).changeArbitratorExtraData(arbitratorExtraData)).to.be.revertedWith( - "The caller must be the governor" + "The caller must be the owner" ); }); }); diff --git a/contracts/test/foundry/KlerosCore.t.sol b/contracts/test/foundry/KlerosCore.t.sol index 62a0b4de1..30e84abdc 100644 --- a/contracts/test/foundry/KlerosCore.t.sol +++ b/contracts/test/foundry/KlerosCore.t.sol @@ -33,7 +33,7 @@ contract KlerosCoreTest is Test { TestERC20 wNative; ArbitrableExample arbitrable; DisputeTemplateRegistry registry; - address governor; + address owner; address guardian; address staker1; address staker2; @@ -69,7 +69,7 @@ contract KlerosCoreTest is Test { feeToken = new TestERC20("Test", "TST"); wNative = new TestERC20("wrapped ETH", "wETH"); - governor = msg.sender; + owner = msg.sender; guardian = vm.addr(1); staker1 = vm.addr(2); staker2 = vm.addr(3); @@ -103,7 +103,7 @@ contract KlerosCoreTest is Test { bytes memory initDataDk = abi.encodeWithSignature( "initialize(address,address,address)", - governor, + owner, address(proxyCore), address(wNative) ); @@ -113,7 +113,7 @@ contract KlerosCoreTest is Test { bytes memory initDataSm = abi.encodeWithSignature( "initialize(address,address,uint256,uint256,address)", - governor, + owner, address(proxyCore), minStakingTime, maxDrawingTime, @@ -122,12 +122,12 @@ contract KlerosCoreTest is Test { UUPSProxy proxySm = new UUPSProxy(address(smLogic), initDataSm); sortitionModule = SortitionModuleMock(address(proxySm)); - vm.prank(governor); + vm.prank(owner); rng.changeConsumer(address(sortitionModule)); core = KlerosCoreMock(address(proxyCore)); core.initialize( - governor, + owner, guardian, pinakion, jurorProsecutionModule, @@ -148,7 +148,7 @@ contract KlerosCoreTest is Test { templateDataMappings = "BBB"; arbitratorExtraData = abi.encodePacked(uint256(GENERAL_COURT), DEFAULT_NB_OF_JURORS, DISPUTE_KIT_CLASSIC); - bytes memory initDataRegistry = abi.encodeWithSignature("initialize(address)", governor); + bytes memory initDataRegistry = abi.encodeWithSignature("initialize(address)", owner); UUPSProxy proxyRegistry = new UUPSProxy(address(registryLogic), initDataRegistry); registry = DisputeTemplateRegistry(address(proxyRegistry)); @@ -163,7 +163,7 @@ contract KlerosCoreTest is Test { } function test_initialize() public { - assertEq(core.governor(), msg.sender, "Wrong governor"); + assertEq(core.owner(), msg.sender, "Wrong owner"); assertEq(core.guardian(), guardian, "Wrong guardian"); assertEq(address(core.pinakion()), address(pinakion), "Wrong pinakion address"); assertEq(core.jurorProsecutionModule(), jurorProsecutionModule, "Wrong jurorProsecutionModule address"); @@ -228,16 +228,16 @@ contract KlerosCoreTest is Test { assertEq(pinakion.name(), "Pinakion", "Wrong token name"); assertEq(pinakion.symbol(), "PNK", "Wrong token symbol"); assertEq(pinakion.totalSupply(), 1000000 ether, "Wrong total supply"); - assertEq(pinakion.balanceOf(msg.sender), 999998 ether, "Wrong token balance of governor"); + assertEq(pinakion.balanceOf(msg.sender), 999998 ether, "Wrong token balance of owner"); assertEq(pinakion.balanceOf(staker1), 1 ether, "Wrong token balance of staker1"); assertEq(pinakion.allowance(staker1, address(core)), 1 ether, "Wrong allowance for staker1"); assertEq(pinakion.balanceOf(staker2), 1 ether, "Wrong token balance of staker2"); assertEq(pinakion.allowance(staker2, address(core)), 1 ether, "Wrong allowance for staker2"); - assertEq(disputeKit.governor(), msg.sender, "Wrong DK governor"); + assertEq(disputeKit.owner(), msg.sender, "Wrong DK owner"); assertEq(address(disputeKit.core()), address(core), "Wrong core in DK"); - assertEq(sortitionModule.governor(), msg.sender, "Wrong SM governor"); + assertEq(sortitionModule.owner(), msg.sender, "Wrong SM owner"); assertEq(address(sortitionModule.core()), address(core), "Wrong core in SM"); assertEq(uint256(sortitionModule.phase()), uint256(ISortitionModule.Phase.staking), "Phase should be 0"); assertEq(sortitionModule.minStakingTime(), 18, "Wrong minStakingTime"); @@ -264,7 +264,7 @@ contract KlerosCoreTest is Test { DisputeKitClassic dkLogic = new DisputeKitClassic(); pinakion = new PNK(); - governor = msg.sender; + owner = msg.sender; guardian = vm.addr(1); staker1 = vm.addr(2); other = vm.addr(9); @@ -290,7 +290,7 @@ contract KlerosCoreTest is Test { bytes memory initDataDk = abi.encodeWithSignature( "initialize(address,address,address)", - governor, + owner, address(proxyCore), address(wNative) ); @@ -300,7 +300,7 @@ contract KlerosCoreTest is Test { bytes memory initDataSm = abi.encodeWithSignature( "initialize(address,address,uint256,uint256,address)", - governor, + owner, address(proxyCore), minStakingTime, maxDrawingTime, @@ -309,7 +309,7 @@ contract KlerosCoreTest is Test { UUPSProxy proxySm = new UUPSProxy(address(smLogic), initDataSm); sortitionModule = SortitionModuleMock(address(proxySm)); - vm.prank(governor); + vm.prank(owner); rng.changeConsumer(address(sortitionModule)); core = KlerosCoreMock(address(proxyCore)); @@ -333,7 +333,7 @@ contract KlerosCoreTest is Test { vm.expectEmit(true, true, true, true); emit KlerosCoreBase.DisputeKitEnabled(GENERAL_COURT, DISPUTE_KIT_CLASSIC, true); core.initialize( - governor, + owner, guardian, pinakion, jurorProsecutionModule, @@ -352,109 +352,109 @@ contract KlerosCoreTest is Test { // ****************************************** // function test_pause() public { - vm.expectRevert(KlerosCoreBase.GuardianOrGovernorOnly.selector); + vm.expectRevert(KlerosCoreBase.GuardianOrOwnerOnly.selector); vm.prank(other); core.pause(); - // Note that we must explicitly switch to the governor/guardian address to make the call, otherwise Foundry treats UUPS proxy as msg.sender. + // Note that we must explicitly switch to the owner/guardian address to make the call, otherwise Foundry treats UUPS proxy as msg.sender. vm.prank(guardian); vm.expectEmit(true, true, true, true); emit KlerosCoreBase.Paused(); core.pause(); assertEq(core.paused(), true, "Wrong paused value"); - // Switch between governor and guardian to test both. WhenNotPausedOnly modifier is triggered after governor's check. - vm.prank(governor); + // Switch between owner and guardian to test both. WhenNotPausedOnly modifier is triggered after owner's check. + vm.prank(owner); vm.expectRevert(KlerosCoreBase.WhenNotPausedOnly.selector); core.pause(); } function test_unpause() public { - vm.expectRevert(KlerosCoreBase.GovernorOnly.selector); + vm.expectRevert(KlerosCoreBase.OwnerOnly.selector); vm.prank(other); core.unpause(); vm.expectRevert(KlerosCoreBase.WhenPausedOnly.selector); - vm.prank(governor); + vm.prank(owner); core.unpause(); - vm.prank(governor); + vm.prank(owner); core.pause(); - vm.prank(governor); + vm.prank(owner); vm.expectEmit(true, true, true, true); emit KlerosCoreBase.Unpaused(); core.unpause(); assertEq(core.paused(), false, "Wrong paused value"); } - function test_executeGovernorProposal() public { - bytes memory data = abi.encodeWithSignature("changeGovernor(address)", other); - vm.expectRevert(KlerosCoreBase.GovernorOnly.selector); + function test_executeOwnerProposal() public { + bytes memory data = abi.encodeWithSignature("changeOwner(address)", other); + vm.expectRevert(KlerosCoreBase.OwnerOnly.selector); vm.prank(other); - core.executeGovernorProposal(address(core), 0, data); + core.executeOwnerProposal(address(core), 0, data); vm.expectRevert(KlerosCoreBase.UnsuccessfulCall.selector); - vm.prank(governor); - core.executeGovernorProposal(address(core), 0, data); // It'll fail because the core is not its own governor + vm.prank(owner); + core.executeOwnerProposal(address(core), 0, data); // It'll fail because the core is not its own owner - vm.prank(governor); - core.changeGovernor(payable(address(core))); + vm.prank(owner); + core.changeOwner(payable(address(core))); vm.prank(address(core)); - core.executeGovernorProposal(address(core), 0, data); - assertEq(core.governor(), other, "Wrong governor"); + core.executeOwnerProposal(address(core), 0, data); + assertEq(core.owner(), other, "Wrong owner"); } - function test_changeGovernor() public { - vm.expectRevert(KlerosCoreBase.GovernorOnly.selector); + function test_changeOwner() public { + vm.expectRevert(KlerosCoreBase.OwnerOnly.selector); vm.prank(other); - core.changeGovernor(payable(other)); - vm.prank(governor); - core.changeGovernor(payable(other)); - assertEq(core.governor(), other, "Wrong governor"); + core.changeOwner(payable(other)); + vm.prank(owner); + core.changeOwner(payable(other)); + assertEq(core.owner(), other, "Wrong owner"); } function test_changeGuardian() public { - vm.expectRevert(KlerosCoreBase.GovernorOnly.selector); + vm.expectRevert(KlerosCoreBase.OwnerOnly.selector); vm.prank(other); core.changeGuardian(other); - vm.prank(governor); + vm.prank(owner); core.changeGuardian(other); assertEq(core.guardian(), other, "Wrong guardian"); } function test_changePinakion() public { PNK fakePNK = new PNK(); - vm.expectRevert(KlerosCoreBase.GovernorOnly.selector); + vm.expectRevert(KlerosCoreBase.OwnerOnly.selector); vm.prank(other); core.changePinakion(fakePNK); - vm.prank(governor); + vm.prank(owner); core.changePinakion(fakePNK); assertEq(address(core.pinakion()), address(fakePNK), "Wrong PNK"); } function test_changeJurorProsecutionModule() public { - vm.expectRevert(KlerosCoreBase.GovernorOnly.selector); + vm.expectRevert(KlerosCoreBase.OwnerOnly.selector); vm.prank(other); core.changeJurorProsecutionModule(other); - vm.prank(governor); + vm.prank(owner); core.changeJurorProsecutionModule(other); assertEq(core.jurorProsecutionModule(), other, "Wrong jurorProsecutionModule"); } function test_changeSortitionModule() public { SortitionModuleMock fakeSM = new SortitionModuleMock(); - vm.expectRevert(KlerosCoreBase.GovernorOnly.selector); + vm.expectRevert(KlerosCoreBase.OwnerOnly.selector); vm.prank(other); core.changeSortitionModule(fakeSM); - vm.prank(governor); + vm.prank(owner); core.changeSortitionModule(fakeSM); assertEq(address(core.sortitionModule()), address(fakeSM), "Wrong sortitionModule"); } function test_addNewDisputeKit() public { DisputeKitSybilResistant newDK = new DisputeKitSybilResistant(); - vm.expectRevert(KlerosCoreBase.GovernorOnly.selector); + vm.expectRevert(KlerosCoreBase.OwnerOnly.selector); vm.prank(other); core.addNewDisputeKit(newDK); - vm.prank(governor); + vm.prank(owner); vm.expectEmit(true, true, true, true); emit KlerosCoreBase.DisputeKitCreated(2, newDK); core.addNewDisputeKit(newDK); @@ -463,7 +463,7 @@ contract KlerosCoreTest is Test { } function test_createCourt() public { - vm.expectRevert(KlerosCoreBase.GovernorOnly.selector); + vm.expectRevert(KlerosCoreBase.OwnerOnly.selector); vm.prank(other); uint256[] memory supportedDK = new uint256[](2); supportedDK[0] = DISPUTE_KIT_CLASSIC; @@ -481,7 +481,7 @@ contract KlerosCoreTest is Test { ); vm.expectRevert(KlerosCoreBase.MinStakeLowerThanParentCourt.selector); - vm.prank(governor); + vm.prank(owner); core.createCourt( GENERAL_COURT, true, // Hidden votes @@ -495,7 +495,7 @@ contract KlerosCoreTest is Test { ); vm.expectRevert(KlerosCoreBase.UnsupportedDisputeKit.selector); - vm.prank(governor); + vm.prank(owner); uint256[] memory emptySupportedDK = new uint256[](0); core.createCourt( GENERAL_COURT, @@ -510,7 +510,7 @@ contract KlerosCoreTest is Test { ); vm.expectRevert(KlerosCoreBase.InvalidForkingCourtAsParent.selector); - vm.prank(governor); + vm.prank(owner); core.createCourt( FORKING_COURT, true, // Hidden votes @@ -527,7 +527,7 @@ contract KlerosCoreTest is Test { badSupportedDK[0] = NULL_DISPUTE_KIT; // Include NULL_DK to check that it reverts badSupportedDK[1] = DISPUTE_KIT_CLASSIC; vm.expectRevert(KlerosCoreBase.WrongDisputeKitIndex.selector); - vm.prank(governor); + vm.prank(owner); core.createCourt( GENERAL_COURT, true, // Hidden votes @@ -543,7 +543,7 @@ contract KlerosCoreTest is Test { badSupportedDK[0] = DISPUTE_KIT_CLASSIC; badSupportedDK[1] = 2; // Check out of bounds index vm.expectRevert(KlerosCoreBase.WrongDisputeKitIndex.selector); - vm.prank(governor); + vm.prank(owner); core.createCourt( GENERAL_COURT, true, // Hidden votes @@ -558,12 +558,12 @@ contract KlerosCoreTest is Test { // Add new DK to check the requirement for classic DK DisputeKitSybilResistant newDK = new DisputeKitSybilResistant(); - vm.prank(governor); + vm.prank(owner); core.addNewDisputeKit(newDK); badSupportedDK = new uint256[](1); badSupportedDK[0] = 2; // Include only sybil resistant dk vm.expectRevert(KlerosCoreBase.MustSupportDisputeKitClassic.selector); - vm.prank(governor); + vm.prank(owner); core.createCourt( GENERAL_COURT, true, // Hidden votes @@ -576,7 +576,7 @@ contract KlerosCoreTest is Test { badSupportedDK ); - vm.prank(governor); + vm.prank(owner); vm.expectEmit(true, true, true, true); emit KlerosCoreBase.DisputeKitEnabled(2, DISPUTE_KIT_CLASSIC, true); vm.expectEmit(true, true, true, true); @@ -641,7 +641,7 @@ contract KlerosCoreTest is Test { function test_changeCourtParameters() public { // Create a 2nd court to check the minStake requirements - vm.prank(governor); + vm.prank(owner); uint96 newCourtID = 2; uint256[] memory supportedDK = new uint256[](1); supportedDK[0] = DISPUTE_KIT_CLASSIC; @@ -657,7 +657,7 @@ contract KlerosCoreTest is Test { supportedDK ); - vm.expectRevert(KlerosCoreBase.GovernorOnly.selector); + vm.expectRevert(KlerosCoreBase.OwnerOnly.selector); vm.prank(other); core.changeCourtParameters( GENERAL_COURT, @@ -669,7 +669,7 @@ contract KlerosCoreTest is Test { [uint256(10), uint256(20), uint256(30), uint256(40)] // Times per period ); vm.expectRevert(KlerosCoreBase.MinStakeLowerThanParentCourt.selector); - vm.prank(governor); + vm.prank(owner); // Min stake of a parent became higher than of a child core.changeCourtParameters( GENERAL_COURT, @@ -682,7 +682,7 @@ contract KlerosCoreTest is Test { ); // Min stake of a child became lower than of a parent vm.expectRevert(KlerosCoreBase.MinStakeLowerThanParentCourt.selector); - vm.prank(governor); + vm.prank(owner); core.changeCourtParameters( newCourtID, true, // Hidden votes @@ -693,7 +693,7 @@ contract KlerosCoreTest is Test { [uint256(10), uint256(20), uint256(30), uint256(40)] // Times per period ); - vm.prank(governor); + vm.prank(owner); vm.expectEmit(true, true, true, true); emit KlerosCoreBase.CourtModified( GENERAL_COURT, @@ -740,38 +740,38 @@ contract KlerosCoreTest is Test { function test_enableDisputeKits() public { DisputeKitSybilResistant newDK = new DisputeKitSybilResistant(); uint256 newDkID = 2; - vm.prank(governor); + vm.prank(owner); core.addNewDisputeKit(newDK); - vm.expectRevert(KlerosCoreBase.GovernorOnly.selector); + vm.expectRevert(KlerosCoreBase.OwnerOnly.selector); vm.prank(other); uint256[] memory supportedDK = new uint256[](1); supportedDK[0] = newDkID; core.enableDisputeKits(GENERAL_COURT, supportedDK, true); vm.expectRevert(KlerosCoreBase.WrongDisputeKitIndex.selector); - vm.prank(governor); + vm.prank(owner); supportedDK[0] = NULL_DISPUTE_KIT; core.enableDisputeKits(GENERAL_COURT, supportedDK, true); vm.expectRevert(KlerosCoreBase.WrongDisputeKitIndex.selector); - vm.prank(governor); + vm.prank(owner); supportedDK[0] = 3; // Out of bounds core.enableDisputeKits(GENERAL_COURT, supportedDK, true); vm.expectRevert(KlerosCoreBase.CannotDisableClassicDK.selector); - vm.prank(governor); + vm.prank(owner); supportedDK[0] = DISPUTE_KIT_CLASSIC; core.enableDisputeKits(GENERAL_COURT, supportedDK, false); - vm.prank(governor); + vm.prank(owner); vm.expectEmit(true, true, true, true); emit KlerosCoreBase.DisputeKitEnabled(GENERAL_COURT, newDkID, true); supportedDK[0] = newDkID; core.enableDisputeKits(GENERAL_COURT, supportedDK, true); assertEq(core.isSupported(GENERAL_COURT, newDkID), true, "New DK should be supported by General court"); - vm.prank(governor); + vm.prank(owner); vm.expectEmit(true, true, true, true); emit KlerosCoreBase.DisputeKitEnabled(GENERAL_COURT, newDkID, false); core.enableDisputeKits(GENERAL_COURT, supportedDK, false); @@ -779,14 +779,14 @@ contract KlerosCoreTest is Test { } function test_changeAcceptedFeeTokens() public { - vm.expectRevert(KlerosCoreBase.GovernorOnly.selector); + vm.expectRevert(KlerosCoreBase.OwnerOnly.selector); vm.prank(other); core.changeAcceptedFeeTokens(feeToken, true); (bool accepted, , ) = core.currencyRates(feeToken); assertEq(accepted, false, "Token should not be accepted yet"); - vm.prank(governor); + vm.prank(owner); vm.expectEmit(true, true, true, true); emit IArbitratorV2.AcceptedFeeToken(feeToken, true); core.changeAcceptedFeeTokens(feeToken, true); @@ -795,7 +795,7 @@ contract KlerosCoreTest is Test { } function test_changeCurrencyRates() public { - vm.expectRevert(KlerosCoreBase.GovernorOnly.selector); + vm.expectRevert(KlerosCoreBase.OwnerOnly.selector); vm.prank(other); core.changeCurrencyRates(feeToken, 100, 200); @@ -803,7 +803,7 @@ contract KlerosCoreTest is Test { assertEq(rateInEth, 0, "rateInEth should be 0"); assertEq(rateDecimals, 0, "rateDecimals should be 0"); - vm.prank(governor); + vm.prank(owner); vm.expectEmit(true, true, true, true); emit IArbitratorV2.NewCurrencyRate(feeToken, 100, 200); core.changeCurrencyRates(feeToken, 100, 200); @@ -833,7 +833,7 @@ contract KlerosCoreTest is Test { assertEq(disputeKitID, DISPUTE_KIT_CLASSIC, "Wrong disputeKitID"); // Custom values. - vm.startPrank(governor); + vm.startPrank(owner); core.addNewDisputeKit(disputeKit); core.addNewDisputeKit(disputeKit); core.addNewDisputeKit(disputeKit); @@ -852,12 +852,12 @@ contract KlerosCoreTest is Test { // *************************************** // function test_setStake_increase() public { - vm.prank(governor); + vm.prank(owner); core.pause(); vm.expectRevert(KlerosCoreBase.WhenNotPausedOnly.selector); vm.prank(staker1); core.setStake(GENERAL_COURT, 1000); - vm.prank(governor); + vm.prank(owner); core.unpause(); vm.expectRevert(KlerosCoreBase.StakingNotPossibleInThisCourt.selector); @@ -898,8 +898,8 @@ contract KlerosCoreTest is Test { assertEq(pinakion.balanceOf(staker1), 999999999999998999, "Wrong token balance of staker1"); // 1 eth - 1001 wei assertEq(pinakion.allowance(staker1, address(core)), 999999999999998999, "Wrong allowance for staker1"); - vm.expectRevert(KlerosCoreBase.StakingTransferFailed.selector); // This error will be caught because governor didn't approve any tokens for KlerosCore - vm.prank(governor); + vm.expectRevert(KlerosCoreBase.StakingTransferFailed.selector); // This error will be caught because owner didn't approve any tokens for KlerosCore + vm.prank(owner); core.setStake(GENERAL_COURT, 1000); // Increase stake one more time to verify the correct behavior @@ -985,7 +985,7 @@ contract KlerosCoreTest is Test { // Create 4 courts to check the require for (uint96 i = GENERAL_COURT; i <= 4; i++) { - vm.prank(governor); + vm.prank(owner); core.createCourt( GENERAL_COURT, true, @@ -1219,7 +1219,7 @@ contract KlerosCoreTest is Test { sortitionModule.passPhase(); // Staking. Delayed stakes can be executed now vm.prank(address(core)); - pinakion.transfer(governor, 10000); // Dispose of the tokens of 2nd staker to make the execution fail for the 2nd delayed stake + pinakion.transfer(owner, 10000); // Dispose of the tokens of 2nd staker to make the execution fail for the 2nd delayed stake assertEq(pinakion.balanceOf(address(core)), 0, "Wrong token balance of the core"); // 2 events should be emitted but the 2nd stake supersedes the first one in the end. @@ -1257,7 +1257,7 @@ contract KlerosCoreTest is Test { function test_setStakeBySortitionModule() public { // Note that functionality of this function was checked during delayed stakes execution vm.expectRevert(KlerosCoreBase.SortitionModuleOnly.selector); - vm.prank(governor); + vm.prank(owner); core.setStakeBySortitionModule(staker1, GENERAL_COURT, 1000); } @@ -1265,27 +1265,27 @@ contract KlerosCoreTest is Test { vm.prank(staker1); core.setStake(GENERAL_COURT, 12346); - KlerosCoreSnapshotProxy snapshotProxy = new KlerosCoreSnapshotProxy(governor, IKlerosCore(address(core))); + KlerosCoreSnapshotProxy snapshotProxy = new KlerosCoreSnapshotProxy(owner, IKlerosCore(address(core))); assertEq(snapshotProxy.name(), "Staked Pinakion", "Wrong name of the proxy token"); assertEq(snapshotProxy.symbol(), "stPNK", "Wrong symbol of the proxy token"); assertEq(snapshotProxy.decimals(), 18, "Wrong decimals of the proxy token"); - assertEq(snapshotProxy.governor(), msg.sender, "Wrong governor"); + assertEq(snapshotProxy.owner(), msg.sender, "Wrong owner"); assertEq(address(snapshotProxy.core()), address(core), "Wrong core in snapshot proxy"); assertEq(snapshotProxy.balanceOf(staker1), 12346, "Wrong stPNK balance"); vm.prank(other); - vm.expectRevert(KlerosCoreSnapshotProxy.GovernorOnly.selector); + vm.expectRevert(KlerosCoreSnapshotProxy.OwnerOnly.selector); snapshotProxy.changeCore(IKlerosCore(other)); - vm.prank(governor); + vm.prank(owner); snapshotProxy.changeCore(IKlerosCore(other)); assertEq(address(snapshotProxy.core()), other, "Wrong core in snapshot proxy after change"); vm.prank(other); - vm.expectRevert(KlerosCoreSnapshotProxy.GovernorOnly.selector); - snapshotProxy.changeGovernor(other); - vm.prank(governor); - snapshotProxy.changeGovernor(other); - assertEq(snapshotProxy.governor(), other, "Wrong governor after change"); + vm.expectRevert(KlerosCoreSnapshotProxy.OwnerOnly.selector); + snapshotProxy.changeOwner(other); + vm.prank(owner); + snapshotProxy.changeOwner(other); + assertEq(snapshotProxy.owner(), other, "Wrong owner after change"); } // *************************************** // @@ -1302,9 +1302,9 @@ contract KlerosCoreTest is Test { supportedDK[0] = DISPUTE_KIT_CLASSIC; bytes memory newExtraData = abi.encodePacked(uint256(newCourtID), newNbJurors, newDkID); - vm.prank(governor); + vm.prank(owner); core.addNewDisputeKit(disputeKit); // Just add the same dk to avoid dealing with initialization - vm.prank(governor); + vm.prank(owner); core.createCourt( GENERAL_COURT, true, // Hidden votes @@ -1327,7 +1327,7 @@ contract KlerosCoreTest is Test { vm.prank(disputer); arbitrable.createDispute{value: 0.04 ether}("Action"); - vm.prank(governor); + vm.prank(owner); supportedDK = new uint256[](1); supportedDK[0] = newDkID; core.enableDisputeKits(newCourtID, supportedDK, true); @@ -1401,9 +1401,9 @@ contract KlerosCoreTest is Test { vm.prank(disputer); arbitrable.createDispute("Action", 0.18 ether); - vm.prank(governor); + vm.prank(owner); core.changeAcceptedFeeTokens(feeToken, true); - vm.prank(governor); + vm.prank(owner); core.changeCurrencyRates(feeToken, 500, 3); vm.expectRevert(KlerosCoreBase.ArbitrationFeesNotEnough.selector); @@ -1491,7 +1491,7 @@ contract KlerosCoreTest is Test { uint256 roundID = 0; // Create a child court and stake exclusively there to check that parent courts hold drawing power. - vm.prank(governor); + vm.prank(owner); uint256[] memory supportedDK = new uint256[](1); supportedDK[0] = DISPUTE_KIT_CLASSIC; core.createCourt( @@ -1542,7 +1542,7 @@ contract KlerosCoreTest is Test { function test_castCommit() public { // Change hidden votes in general court uint256 disputeID = 0; - vm.prank(governor); + vm.prank(owner); core.changeCourtParameters( GENERAL_COURT, true, // Hidden votes @@ -1653,7 +1653,7 @@ contract KlerosCoreTest is Test { function test_castCommit_timeoutCheck() public { // Change hidden votes in general court uint256 disputeID = 0; - vm.prank(governor); + vm.prank(owner); core.changeCourtParameters( GENERAL_COURT, true, // Hidden votes @@ -1857,7 +1857,7 @@ contract KlerosCoreTest is Test { function test_castVote_quickPassPeriod() public { // Change hidden votes in general court uint256 disputeID = 0; - vm.prank(governor); + vm.prank(owner); core.changeCourtParameters( GENERAL_COURT, true, // Hidden votes @@ -2116,7 +2116,7 @@ contract KlerosCoreTest is Test { // Create a new DK and court to check the switch bytes memory initDataDk = abi.encodeWithSignature( "initialize(address,address,address)", - governor, + owner, address(core), address(wNative) ); @@ -2130,9 +2130,9 @@ contract KlerosCoreTest is Test { supportedDK[0] = DISPUTE_KIT_CLASSIC; bytes memory newExtraData = abi.encodePacked(uint256(newCourtID), DEFAULT_NB_OF_JURORS, newDkID); - vm.prank(governor); + vm.prank(owner); core.addNewDisputeKit(newDisputeKit); - vm.prank(governor); + vm.prank(owner); core.createCourt( GENERAL_COURT, hiddenVotes, @@ -2147,7 +2147,7 @@ contract KlerosCoreTest is Test { arbitrable.changeArbitratorExtraData(newExtraData); - vm.prank(governor); + vm.prank(owner); supportedDK = new uint256[](1); supportedDK[0] = newDkID; core.enableDisputeKits(newCourtID, supportedDK, true); @@ -2308,11 +2308,11 @@ contract KlerosCoreTest is Test { vm.warp(block.timestamp + timesPerPeriod[3]); core.passPeriod(disputeID); // Execution - vm.prank(governor); + vm.prank(owner); core.pause(); vm.expectRevert(KlerosCoreBase.WhenNotPausedOnly.selector); core.execute(disputeID, 0, 1); - vm.prank(governor); + vm.prank(owner); core.unpause(); assertEq(disputeKit.getCoherentCount(disputeID, 0), 2, "Wrong coherent count"); @@ -2446,8 +2446,8 @@ contract KlerosCoreTest is Test { assertEq(disputeKit.getDegreeOfCoherencePenalty(disputeID, 0, 1, 0, 0), 0, "Wrong penalty coherence 1 vote ID"); assertEq(disputeKit.getDegreeOfCoherencePenalty(disputeID, 0, 2, 0, 0), 0, "Wrong penalty coherence 2 vote ID"); - uint256 governorBalance = governor.balance; - uint256 governorTokenBalance = pinakion.balanceOf(governor); + uint256 ownerBalance = owner.balance; + uint256 ownerTokenBalance = pinakion.balanceOf(owner); vm.expectEmit(true, true, true, true); emit KlerosCoreBase.LeftoverRewardSent(disputeID, 0, 3000, 0.09 ether, IERC20(address(0))); @@ -2460,16 +2460,16 @@ contract KlerosCoreTest is Test { assertEq(address(core).balance, 0, "Wrong balance of the core"); assertEq(staker1.balance, 0, "Wrong balance of the staker1"); - assertEq(governor.balance, governorBalance + 0.09 ether, "Wrong balance of the governor"); + assertEq(owner.balance, ownerBalance + 0.09 ether, "Wrong balance of the owner"); assertEq(pinakion.balanceOf(address(core)), 17000, "Wrong token balance of the core"); assertEq(pinakion.balanceOf(staker1), 999999999999980000, "Wrong token balance of staker1"); - assertEq(pinakion.balanceOf(governor), governorTokenBalance + 3000, "Wrong token balance of governor"); + assertEq(pinakion.balanceOf(owner), ownerTokenBalance + 3000, "Wrong token balance of owner"); } function test_execute_UnstakeInactive() public { // Create a 2nd court so unstaking is done in multiple courts. - vm.prank(governor); + vm.prank(owner); uint256[] memory supportedDK = new uint256[](1); supportedDK[0] = DISPUTE_KIT_CLASSIC; core.createCourt( @@ -2517,7 +2517,7 @@ contract KlerosCoreTest is Test { vm.warp(block.timestamp + timesPerPeriod[3]); core.passPeriod(disputeID); // Execution - uint256 governorTokenBalance = pinakion.balanceOf(governor); + uint256 ownerTokenBalance = pinakion.balanceOf(owner); // Note that these events are emitted only after the first iteration of execute() therefore the juror has been penalized only for 1000 PNK her. vm.expectEmit(true, true, true, true); @@ -2527,8 +2527,8 @@ contract KlerosCoreTest is Test { core.execute(disputeID, 0, 3); assertEq(pinakion.balanceOf(address(core)), 0, "Wrong token balance of the core"); - assertEq(pinakion.balanceOf(staker1), 999999999999997000, "Wrong token balance of staker1"); // 3000 locked PNK was withheld by the contract and given to governor. - assertEq(pinakion.balanceOf(governor), governorTokenBalance + 3000, "Wrong token balance of governor"); + assertEq(pinakion.balanceOf(staker1), 999999999999997000, "Wrong token balance of staker1"); // 3000 locked PNK was withheld by the contract and given to owner. + assertEq(pinakion.balanceOf(owner), ownerTokenBalance + 3000, "Wrong token balance of owner"); (, , , nbCourts) = sortitionModule.getJurorBalance(staker1, GENERAL_COURT); assertEq(nbCourts, 0, "Should unstake from all courts"); @@ -2658,7 +2658,7 @@ contract KlerosCoreTest is Test { assertEq(pinakion.balanceOf(staker1), 999999999999999000, "Wrong token balance of staker1"); vm.expectRevert(KlerosCoreBase.SortitionModuleOnly.selector); - vm.prank(governor); + vm.prank(owner); core.transferBySortitionModule(staker1, 1000); vm.expectEmit(true, true, true, true); @@ -2680,9 +2680,9 @@ contract KlerosCoreTest is Test { vm.prank(disputer); feeToken.approve(address(arbitrable), 1 ether); - vm.prank(governor); + vm.prank(owner); core.changeAcceptedFeeTokens(feeToken, true); - vm.prank(governor); + vm.prank(owner); core.changeCurrencyRates(feeToken, 500, 3); vm.prank(disputer); @@ -2734,9 +2734,9 @@ contract KlerosCoreTest is Test { vm.prank(disputer); feeToken.approve(address(arbitrable), 1 ether); - vm.prank(governor); + vm.prank(owner); core.changeAcceptedFeeTokens(feeToken, true); - vm.prank(governor); + vm.prank(owner); core.changeCurrencyRates(feeToken, 500, 3); vm.prank(disputer); @@ -2773,7 +2773,7 @@ contract KlerosCoreTest is Test { assertEq(feeToken.balanceOf(address(core)), 0, "Wrong token balance of the core"); assertEq(feeToken.balanceOf(staker1), 0, "Wrong token balance of staker1"); assertEq(feeToken.balanceOf(disputer), 0.82 ether, "Wrong token balance of disputer"); - assertEq(feeToken.balanceOf(governor), 0.18 ether, "Wrong token balance of governor"); + assertEq(feeToken.balanceOf(owner), 0.18 ether, "Wrong token balance of owner"); } function test_executeRuling() public { @@ -2911,11 +2911,11 @@ contract KlerosCoreTest is Test { core.executeRuling(disputeID); - vm.prank(governor); + vm.prank(owner); core.pause(); vm.expectRevert(DisputeKitClassicBase.CoreIsPaused.selector); disputeKit.withdrawFeesAndRewards(disputeID, payable(staker1), 0, 1); - vm.prank(governor); + vm.prank(owner); core.unpause(); assertEq(crowdfunder1.balance, 9.37 ether, "Wrong balance of the crowdfunder1"); @@ -2940,7 +2940,7 @@ contract KlerosCoreTest is Test { // Create a new DK to check castVote. bytes memory initDataDk = abi.encodeWithSignature( "initialize(address,address,address)", - governor, + owner, address(core), address(wNative) ); @@ -2948,14 +2948,14 @@ contract KlerosCoreTest is Test { UUPSProxy proxyDk = new UUPSProxy(address(dkLogic), initDataDk); DisputeKitClassic newDisputeKit = DisputeKitClassic(address(proxyDk)); - vm.prank(governor); + vm.prank(owner); core.addNewDisputeKit(newDisputeKit); uint256 newDkID = 2; uint256[] memory supportedDK = new uint256[](1); bytes memory newExtraData = abi.encodePacked(uint256(GENERAL_COURT), DEFAULT_NB_OF_JURORS, newDkID); - vm.prank(governor); + vm.prank(owner); vm.expectEmit(true, true, true, true); emit KlerosCoreBase.DisputeKitEnabled(GENERAL_COURT, newDkID, true); supportedDK[0] = newDkID; @@ -3039,13 +3039,13 @@ contract KlerosCoreTest is Test { uint256 fallbackTimeout = 100; RNGMock rngMock = new RNGMock(); rngFallback = new RNGWithFallback(msg.sender, address(sortitionModule), fallbackTimeout, rngMock); - assertEq(rngFallback.governor(), msg.sender, "Wrong governor"); + assertEq(rngFallback.owner(), msg.sender, "Wrong owner"); assertEq(rngFallback.consumer(), address(sortitionModule), "Wrong sortition module address"); assertEq(address(rngFallback.rng()), address(rngMock), "Wrong RNG in fallback contract"); assertEq(rngFallback.fallbackTimeoutSeconds(), fallbackTimeout, "Wrong fallback timeout"); assertEq(rngFallback.requestTimestamp(), 0, "Request timestamp should be 0"); - vm.prank(governor); + vm.prank(owner); sortitionModule.changeRandomNumberGenerator(rngFallback); assertEq(address(sortitionModule.rng()), address(rngFallback), "Wrong RNG address"); @@ -3079,7 +3079,7 @@ contract KlerosCoreTest is Test { RNGMock rngMock = new RNGMock(); rngFallback = new RNGWithFallback(msg.sender, address(sortitionModule), fallbackTimeout, rngMock); - vm.prank(governor); + vm.prank(owner); sortitionModule.changeRandomNumberGenerator(rngFallback); assertEq(address(sortitionModule.rng()), address(rngFallback), "Wrong RNG address"); @@ -3107,36 +3107,36 @@ contract KlerosCoreTest is Test { rngFallback = new RNGWithFallback(msg.sender, address(sortitionModule), fallbackTimeout, rngMock); vm.expectRevert(IRNG.ConsumerOnly.selector); - vm.prank(governor); + vm.prank(owner); rngFallback.requestRandomness(); vm.expectRevert(IRNG.ConsumerOnly.selector); - vm.prank(governor); + vm.prank(owner); rngFallback.receiveRandomness(); - vm.expectRevert(IRNG.GovernorOnly.selector); + vm.expectRevert(IRNG.OwnerOnly.selector); vm.prank(other); - rngFallback.changeGovernor(other); - vm.prank(governor); - rngFallback.changeGovernor(other); - assertEq(rngFallback.governor(), other, "Wrong governor"); + rngFallback.changeOwner(other); + vm.prank(owner); + rngFallback.changeOwner(other); + assertEq(rngFallback.owner(), other, "Wrong owner"); - // Change governor back for convenience + // Change owner back for convenience vm.prank(other); - rngFallback.changeGovernor(governor); + rngFallback.changeOwner(owner); - vm.expectRevert(IRNG.GovernorOnly.selector); + vm.expectRevert(IRNG.OwnerOnly.selector); vm.prank(other); rngFallback.changeConsumer(other); - vm.prank(governor); + vm.prank(owner); rngFallback.changeConsumer(other); assertEq(rngFallback.consumer(), other, "Wrong consumer"); - vm.expectRevert(IRNG.GovernorOnly.selector); + vm.expectRevert(IRNG.OwnerOnly.selector); vm.prank(other); rngFallback.changeFallbackTimeout(5); - vm.prank(governor); + vm.prank(owner); vm.expectEmit(true, true, true, true); emit RNGWithFallback.FallbackTimeoutChanged(5); rngFallback.changeFallbackTimeout(5); diff --git a/contracts/test/proxy/index.ts b/contracts/test/proxy/index.ts index 12ba6313c..a58886789 100644 --- a/contracts/test/proxy/index.ts +++ b/contracts/test/proxy/index.ts @@ -46,7 +46,7 @@ describe("Upgradability", async () => { }); describe("Initialization", async () => { - it("Governor cannot re-initialize the proxy", async () => { + it("Owner cannot re-initialize the proxy", async () => { await expect(proxy.connect(deployer).initialize(deployer.address)).to.be.revertedWith( "Contract instance has already been initialized" ); @@ -79,7 +79,7 @@ describe("Upgradability", async () => { .withArgs(nonUpgradeableMock.target); }); it("Should revert if upgrade is performed directly through the implementation", async () => { - // In the implementation, the `governor` storage slot is not initialized so `governor === address(0)`, which fails _authorizeUpgrade() + // In the implementation, the `owner` storage slot is not initialized so `owner === address(0)`, which fails _authorizeUpgrade() const UUPSUpgradeableMockV2Factory = await ethers.getContractFactory("UUPSUpgradeableMockV2"); const newImplementation = await UUPSUpgradeableMockV2Factory.connect(deployer).deploy(); await expect( @@ -89,7 +89,7 @@ describe("Upgradability", async () => { }); describe("Authentication", async () => { - it("Only the governor (deployer here) can perform upgrades", async () => { + it("Only the owner (deployer here) can perform upgrades", async () => { // Unauthorized user try to upgrade the implementation const UUPSUpgradeableMockV2Factory = await ethers.getContractFactory("UUPSUpgradeableMockV2"); let upgradable = await UUPSUpgradeableMockV2Factory.connect(user1).deploy(); @@ -97,7 +97,7 @@ describe("Upgradability", async () => { "No privilege to upgrade" ); - // Governor updates the implementation + // Owner updates the implementation upgradable = await UUPSUpgradeableMockV2Factory.connect(deployer).deploy(); await expect(proxy.connect(deployer).upgradeToAndCall(upgradable.target, "0x")) .to.emit(proxy, "Upgraded") @@ -134,7 +134,7 @@ describe("Upgradability", async () => { implementation = await ethers.getContract("UpgradedByRewrite_Implementation"); - expect(await proxy.governor()).to.equal(deployer.address); + expect(await proxy.owner()).to.equal(deployer.address); expect(await proxy.counter()).to.equal(1); await proxy.increment(); @@ -157,7 +157,7 @@ describe("Upgradability", async () => { throw new Error("No implementation address"); } proxy = await ethers.getContract("UpgradedByRewrite"); - expect(await proxy.governor()).to.equal(deployer.address); + expect(await proxy.owner()).to.equal(deployer.address); expect(await proxy.counter()).to.equal(3); await proxy.increment(); @@ -188,7 +188,7 @@ describe("Upgradability", async () => { implementation = await ethers.getContract("UpgradedByInheritanceV1_Implementation"); - expect(await proxy.governor()).to.equal(deployer.address); + expect(await proxy.owner()).to.equal(deployer.address); expect(await proxy.counter()).to.equal(1); await proxy.increment(); @@ -211,7 +211,7 @@ describe("Upgradability", async () => { proxy = await ethers.getContract("UpgradedByInheritanceV1"); - expect(await proxy.governor()).to.equal(deployer.address); + expect(await proxy.owner()).to.equal(deployer.address); expect(await proxy.counter()).to.equal(3); await proxy.increment(); diff --git a/contracts/test/rng/index.ts b/contracts/test/rng/index.ts index 351a2d460..f61ec9b95 100644 --- a/contracts/test/rng/index.ts +++ b/contracts/test/rng/index.ts @@ -40,7 +40,7 @@ describe("BlockHashRNG", async () => { await deployments.delete("BlockHashRNG"); await deployments.deploy("BlockHashRNG", { from: deployer.address, - args: [deployer.address, deployer.address, 10], // governor, consumer, lookaheadTime (seconds) + args: [deployer.address, deployer.address, 10], // owner, consumer, lookaheadTime (seconds) }); rng = await ethers.getContract("BlockHashRNG"); });