Skip to content

Commit 582b674

Browse files
committed
Merge branch 'dev' into fix/penalties-reduce-drawing-odds
2 parents 1aae950 + f734873 commit 582b674

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1009
-734
lines changed

contracts/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ The format is based on [Common Changelog](https://common-changelog.org/).
88

99
### Changed
1010

11+
- **Breaking:** Stake the juror's PNK rewards instead of transferring them out ([#2099](https://github.com/kleros/kleros-v2/issues/2099))
1112
- **Breaking:** Replace `require()` with `revert()` and custom errors outside KlerosCore for consistency and smaller bytecode ([#2084](https://github.com/kleros/kleros-v2/issues/2084))
1213
- **Breaking:** Rename the interface from `RNG` to `IRNG` ([#2054](https://github.com/kleros/kleros-v2/issues/2054))
1314
- **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))
15+
- **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))
1416
- 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))
1517
- 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))
1618
- 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))
@@ -22,6 +24,10 @@ The format is based on [Common Changelog](https://common-changelog.org/).
2224
- Bump `hardhat` to v2.26.2 ([#2069](https://github.com/kleros/kleros-v2/issues/2069))
2325
- Bump `@kleros/vea-contracts` to v0.7.0 ([#2073](https://github.com/kleros/kleros-v2/issues/2073))
2426

27+
### Added
28+
29+
- Allow the dispute kits to force an early court jump and to override the number of votes after an appeal (future-proofing) ([#2110](https://github.com/kleros/kleros-v2/issues/2110))
30+
2531
### Fixed
2632

2733
- Do not pass to Voting period if all the commits are cast because it breaks the current Shutter auto-reveal process. ([#2085](https://github.com/kleros/kleros-v2/issues/2085))

contracts/deploy/00-home-chain-arbitration-ruler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
2929
await deployUpgradable(deployments, "KlerosCoreRuler", {
3030
from: deployer,
3131
args: [
32-
deployer, // governor
32+
deployer, // owner
3333
pnk.target,
3434
[minStake, alpha, feeForJuror, jurorsForCourtJump],
3535
],

contracts/deploy/00-home-chain-arbitration-university.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
5050
const klerosCore = await deployUpgradable(deployments, "KlerosCoreUniversity", {
5151
from: deployer,
5252
args: [
53-
deployer, // governor
53+
deployer, // owner
5454
deployer, // instructor
5555
pnk.target,
5656
ZeroAddress, // KlerosCore is configured later

contracts/hardhat.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import "hardhat-contract-sizer";
1515
import "hardhat-tracer";
1616
require("./scripts/populatePolicyRegistry");
1717
require("./scripts/populateCourts");
18-
require("./scripts/changeGovernor");
18+
require("./scripts/changeOwner");
1919
require("./scripts/getDisputeTemplate");
2020
require("./scripts/compareStorageLayout");
2121
require("./scripts/storage-layout");

contracts/scripts/changeGovernor.ts

Lines changed: 0 additions & 77 deletions
This file was deleted.

contracts/scripts/changeOwner.ts

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import { task } from "hardhat/config";
2+
import { prompt, print } from "gluegun";
3+
import { Cores, getContracts } from "./utils/contracts";
4+
import { isAddress } from "viem";
5+
6+
const { bold } = print.colors;
7+
8+
task("change-owner", "Changes the owner for all the contracts")
9+
.addPositionalParam("newOwner", "The address of the new owner")
10+
.addOptionalParam("coreType", "The type of core to use between base, neo, university (default: base)", Cores.BASE)
11+
.setAction(async (taskArgs, hre) => {
12+
const newOwner = taskArgs.newOwner;
13+
if (!isAddress(newOwner)) {
14+
throw new Error("Invalid owner address provided");
15+
}
16+
print.highlight(`💣 Changing owner to ${bold(newOwner)}`);
17+
18+
const { confirm } = await prompt.ask({
19+
type: "confirm",
20+
name: "confirm",
21+
message: "Are you sure you want to proceed?",
22+
});
23+
if (!confirm) {
24+
console.log("Operation cancelled by user.");
25+
return;
26+
}
27+
28+
const coreType = Cores[taskArgs.coreType.toUpperCase() as keyof typeof Cores];
29+
if (coreType === undefined) {
30+
console.error("Invalid core type, must be one of base, neo, university");
31+
return;
32+
}
33+
console.log("Using core type %s", coreType);
34+
35+
const {
36+
core,
37+
disputeKitClassic,
38+
disputeResolver,
39+
disputeTemplateRegistry,
40+
policyRegistry,
41+
chainlinkRng,
42+
randomizerRng,
43+
snapshotProxy,
44+
sortition,
45+
evidence,
46+
} = await getContracts(hre, coreType);
47+
48+
const updateOwner = async (contractName: string, contractInstance: any) => {
49+
print.info(`Changing owner for ${contractName}`);
50+
51+
const spinner = print.spin(`Executing transaction for ${contractName}...`);
52+
try {
53+
const tx = await contractInstance.changeOwner(newOwner);
54+
await tx.wait();
55+
spinner.succeed(`Owner changed for ${contractName}, tx hash: ${tx.hash}`);
56+
} catch (error) {
57+
if (error instanceof Error) {
58+
spinner.fail(`Failed to change owner for ${contractName}: ${error.message}`);
59+
} else {
60+
spinner.fail(`Failed to change owner for ${contractName}: ${String(error)}`);
61+
}
62+
}
63+
};
64+
65+
await updateOwner("KlerosCore", core);
66+
await updateOwner("DisputeKitClassic", disputeKitClassic);
67+
await updateOwner("DisputeResolver", disputeResolver);
68+
await updateOwner("DisputeTemplateRegistry", disputeTemplateRegistry);
69+
await updateOwner("PolicyRegistry", policyRegistry);
70+
await updateOwner("KlerosCoreSnapshotProxy", snapshotProxy);
71+
await updateOwner("SortitionModule", sortition);
72+
await updateOwner("EvidenceModule", evidence);
73+
if (chainlinkRng) await updateOwner("ChainlinkRNG", chainlinkRng);
74+
if (randomizerRng) await updateOwner("RandomizerRNG", randomizerRng);
75+
76+
print.success("Owner changed successfully");
77+
});

contracts/scripts/utils/execution.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { type BuilderTransaction, template, transaction, transactionBuilderUrl }
55
const governableAbi = [
66
{
77
inputs: [],
8-
name: "governor",
8+
name: "owner",
99
outputs: [
1010
{
1111
internalType: "address",
@@ -25,8 +25,8 @@ export const execute = async (tx: ContractTransaction) => {
2525
const { ethers } = hre;
2626

2727
const contract = await ethers.getContractAt(governableAbi, tx.to);
28-
const governor = await contract.governor();
29-
const isContract = (await ethers.provider.getCode(governor)).length > 2;
28+
const owner = await contract.owner();
29+
const isContract = (await ethers.provider.getCode(owner)).length > 2;
3030
if (isContract) {
3131
// Don't execute, just log the tx. It must be submitted for execution separately.
3232
const { to, value, data } = tx;

contracts/scripts/utils/tx-builder.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { arbitrum } from "viem/chains";
22

3-
const governor = "0x66e8DE9B42308c6Ca913D1EE041d6F6fD037A57e";
3+
const owner = "0x66e8DE9B42308c6Ca913D1EE041d6F6fD037A57e";
44
const deployer = "0xf1C7c037891525E360C59f708739Ac09A7670c59";
55

66
// 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
1212
name,
1313
description: "", // Not used because the Safe app doesn't show it
1414
txBuilderVersion: "1.18.0",
15-
createdFromSafeAddress: governor,
15+
createdFromSafeAddress: owner,
1616
createdFromOwnerAddress: deployer,
1717
},
1818
transactions,
@@ -42,4 +42,4 @@ export interface BuilderTransaction {
4242
contractInputsValues: null;
4343
}
4444

45-
export const transactionBuilderUrl = `https://app.safe.global/apps/open?safe=arb1:${governor}&appUrl=https%3A%2F%2Fapps-portal.safe.global%2Ftx-builder`;
45+
export const transactionBuilderUrl = `https://app.safe.global/apps/open?safe=arb1:${owner}&appUrl=https%3A%2F%2Fapps-portal.safe.global%2Ftx-builder`;

contracts/scripts/viemTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const main = async () => {
1515
client: client,
1616
});
1717

18-
await disputeKit.read.governor().then(console.log);
18+
await disputeKit.read.owner().then(console.log);
1919

2020
// --------------------------------------------------
2121

contracts/src/arbitration/DisputeTemplateRegistry.sol

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ contract DisputeTemplateRegistry is IDisputeTemplateRegistry, UUPSProxiable, Ini
1414
// * Storage * //
1515
// ************************************* //
1616

17-
/// @dev The governor of the contract.
18-
address public governor;
17+
/// @dev The owner of the contract.
18+
address public owner;
1919

2020
/// @dev The number of templates.
2121
uint256 public templates;
@@ -24,8 +24,8 @@ contract DisputeTemplateRegistry is IDisputeTemplateRegistry, UUPSProxiable, Ini
2424
// * Function Modifiers * //
2525
// ************************************* //
2626

27-
modifier onlyByGovernor() {
28-
if (governor != msg.sender) revert GovernorOnly();
27+
modifier onlyByOwner() {
28+
if (owner != msg.sender) revert OwnerOnly();
2929
_;
3030
}
3131

@@ -39,9 +39,9 @@ contract DisputeTemplateRegistry is IDisputeTemplateRegistry, UUPSProxiable, Ini
3939
}
4040

4141
/// @dev Initializer
42-
/// @param _governor Governor of the contract.
43-
function initialize(address _governor) external reinitializer(1) {
44-
governor = _governor;
42+
/// @param _owner Owner of the contract.
43+
function initialize(address _owner) external reinitializer(1) {
44+
owner = _owner;
4545
}
4646

4747
function initialize2() external reinitializer(2) {
@@ -53,15 +53,15 @@ contract DisputeTemplateRegistry is IDisputeTemplateRegistry, UUPSProxiable, Ini
5353
// ************************ //
5454

5555
/// @dev Access Control to perform implementation upgrades (UUPS Proxiable)
56-
/// Only the governor can perform upgrades (`onlyByGovernor`)
57-
function _authorizeUpgrade(address) internal view override onlyByGovernor {
56+
/// Only the owner can perform upgrades (`onlyByOwner`)
57+
function _authorizeUpgrade(address) internal view override onlyByOwner {
5858
// NOP
5959
}
6060

61-
/// @dev Changes the governor of the contract.
62-
/// @param _governor The new governor.
63-
function changeGovernor(address _governor) external onlyByGovernor {
64-
governor = _governor;
61+
/// @dev Changes the owner of the contract.
62+
/// @param _owner The new owner.
63+
function changeOwner(address _owner) external onlyByOwner {
64+
owner = _owner;
6565
}
6666

6767
// ************************************* //
@@ -85,5 +85,5 @@ contract DisputeTemplateRegistry is IDisputeTemplateRegistry, UUPSProxiable, Ini
8585
// * Errors * //
8686
// ************************************* //
8787

88-
error GovernorOnly();
88+
error OwnerOnly();
8989
}

0 commit comments

Comments
 (0)