Skip to content

Commit 2682977

Browse files
authored
Merge branch 'dev' into fix/use-answer-id-in-voting
2 parents 3b6f17e + 4ed43ef commit 2682977

Some content is hidden

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

47 files changed

+1220
-1491
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
7373
deployer,
7474
deployer,
7575
pnk.target,
76-
ZeroAddress, // KlerosCore is configured later
76+
ZeroAddress, // jurorProsecutionModule is not implemented yet
7777
disputeKit.address,
7878
false,
7979
[minStake, alpha, feeForJuror, jurorsForCourtJump],
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { HardhatRuntimeEnvironment } from "hardhat/types";
2+
import { DeployFunction } from "hardhat-deploy/types";
3+
import { deployUpgradable } from "./utils/deployUpgradable";
4+
import { HomeChains, isSkipped } from "./utils";
5+
6+
const deployUpgradeDisputeKit: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
7+
const { deployments, getNamedAccounts, getChainId } = hre;
8+
9+
// fallback to hardhat node signers on local network
10+
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
11+
const chainId = Number(await getChainId());
12+
console.log("upgrading on %s with deployer %s", HomeChains[chainId], deployer);
13+
14+
try {
15+
console.log("upgrading DisputeKitClassicNeo...");
16+
await deployUpgradable(deployments, "DisputeKitClassicNeo", {
17+
contract: "DisputeKitClassic",
18+
initializer: "initialize",
19+
from: deployer,
20+
// Warning: do not reinitialize everything, only the new variables
21+
args: [],
22+
});
23+
} catch (err) {
24+
console.error(err);
25+
throw err;
26+
}
27+
};
28+
29+
deployUpgradeDisputeKit.tags = ["Upgrade", "DisputeKit"];
30+
deployUpgradeDisputeKit.skip = async ({ network }) => {
31+
return isSkipped(network, !HomeChains[network.config.chainId ?? 0]);
32+
};
33+
34+
export default deployUpgradeDisputeKit;

contracts/deploy/upgrade-kleros-core.ts

+8-23
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,21 @@ import { deployUpgradable } from "./utils/deployUpgradable";
44
import { HomeChains, isSkipped } from "./utils";
55

66
const deployUpgradeKlerosCore: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
7-
const { ethers, deployments, getNamedAccounts, getChainId } = hre;
8-
const { ZeroAddress } = hre.ethers;
7+
const { deployments, getNamedAccounts, getChainId } = hre;
98

109
// fallback to hardhat node signers on local network
1110
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
1211
const chainId = Number(await getChainId());
13-
console.log("upgrading to %s with deployer %s", HomeChains[chainId], deployer);
12+
console.log("upgrading on %s with deployer %s", HomeChains[chainId], deployer);
1413

1514
try {
16-
const pnk = await deployments.get("PNK");
17-
const disputeKit = await deployments.get("DisputeKitClassic");
18-
const minStake = 2n * 10n ** 20n;
19-
const alpha = 10000;
20-
const feeForJuror = 10n * 17n;
21-
const sortitionModule = await deployments.get("SortitionModule");
22-
23-
console.log("upgrading the KlerosCore...");
24-
await deployUpgradable(deployments, "KlerosCore", {
15+
console.log("upgrading KlerosCoreNeo...");
16+
await deployUpgradable(deployments, "KlerosCoreNeo", {
17+
newImplementation: "KlerosCoreNeo",
18+
initializer: "initialize",
2519
from: deployer,
26-
args: [
27-
deployer,
28-
pnk,
29-
ZeroAddress,
30-
disputeKit.address,
31-
false,
32-
[minStake, alpha, feeForJuror, 256], // minStake, alpha, feeForJuror, jurorsForCourtJump
33-
[0, 0, 0, 10], // evidencePeriod, commitPeriod, votePeriod, appealPeriod
34-
ethers.toBeHex(5), // Extra data for sortition module will return the default value of K
35-
sortitionModule.address,
36-
],
20+
// Warning: do not reinitialize everything, only the new variables
21+
args: [],
3722
});
3823
} catch (err) {
3924
console.error(err);

contracts/deploy/upgrade-sortition-module.ts

+7-16
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,20 @@ import { HomeChains, isSkipped } from "./utils";
55

66
const deployUpgradeSortitionModule: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
77
const { deployments, getNamedAccounts, getChainId } = hre;
8-
const RNG_LOOKAHEAD = 20;
98

109
// fallback to hardhat node signers on local network
1110
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
1211
const chainId = Number(await getChainId());
13-
console.log("upgrading to %s with deployer %s", HomeChains[chainId], deployer);
12+
console.log("upgrading on %s with deployer %s", HomeChains[chainId], deployer);
1413

1514
try {
16-
const rng = await deployments.get("RandomizerRNG");
17-
const klerosCore = await deployments.get("KlerosCore");
18-
const klerosCoreAddress = klerosCore.address;
19-
20-
console.log("upgrading the SortitionModule...");
21-
await deployUpgradable(deployments, "SortitionModule", {
15+
console.log("upgrading SortitionModuleNeo...");
16+
await deployUpgradable(deployments, "SortitionModuleNeo", {
17+
newImplementation: "SortitionModuleNeo",
18+
initializer: "initialize",
2219
from: deployer,
23-
args: [
24-
deployer,
25-
klerosCoreAddress,
26-
1800, // minStakingTime
27-
1800, // maxFreezingTime
28-
rng.address,
29-
RNG_LOOKAHEAD,
30-
],
20+
// Warning: do not reinitialize everything, only the new variables
21+
args: [],
3122
});
3223
} catch (err) {
3324
console.error(err);

contracts/hardhat.config.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ const config: HardhatUserConfig = {
9595
// Home chain ---------------------------------------------------------------------------------
9696
arbitrumSepolia: {
9797
chainId: 421614,
98-
url: process.env.ARBITRUM_SEPOLIA_RPC ?? "https://sepolia-rollup.arbitrum.io/rpc",
98+
url: process.env.ARBITRUM_SEPOLIA_RPC ?? `https://arbitrum-sepolia.infura.io/v3/${process.env.INFURA_API_KEY}`,
9999
accounts:
100100
(process.env.ARB_GOERLI_PRIVATE_KEY_WALLET_1 && [
101101
process.env.ARB_GOERLI_PRIVATE_KEY_WALLET_1 as string,
@@ -121,7 +121,7 @@ const config: HardhatUserConfig = {
121121
},
122122
arbitrumSepoliaDevnet: {
123123
chainId: 421614,
124-
url: process.env.ARBITRUM_SEPOLIA_RPC ?? "https://sepolia-rollup.arbitrum.io/rpc",
124+
url: process.env.ARBITRUM_SEPOLIA_RPC ?? `https://arbitrum-sepolia.infura.io/v3/${process.env.INFURA_API_KEY}`,
125125
accounts:
126126
(process.env.ARB_GOERLI_PRIVATE_KEY_WALLET_1 && [
127127
process.env.ARB_GOERLI_PRIVATE_KEY_WALLET_1 as string,
@@ -147,7 +147,7 @@ const config: HardhatUserConfig = {
147147
},
148148
arbitrum: {
149149
chainId: 42161,
150-
url: "https://arb1.arbitrum.io/rpc",
150+
url: process.env.ARBITRUM_RPC ?? `https://arbitrum-mainnet.infura.io/v3/${process.env.INFURA_API_KEY}`,
151151
accounts: process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
152152
live: true,
153153
saveDeployments: true,

contracts/package.json

+8-6
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"start-local": "hardhat node --tags Arbitration,HomeArbitrable --hostname 0.0.0.0",
2828
"deploy": "hardhat deploy",
2929
"deploy-local": "hardhat deploy --tags Arbitration,HomeArbitrable --network localhost",
30+
"validate-upgrades": "openzeppelin-upgrades-core validate --exclude 'src/proxy/mock/**/*.sol' --exclude 'src/test/**/*.sol' artifacts/build-info",
3031
"simulate": "hardhat simulate:all",
3132
"simulate-local": "hardhat simulate:all --network localhost",
3233
"viem:generate-devnet": "NODE_NO_WARNINGS=1 wagmi generate -c wagmi.config.devnet.ts",
@@ -69,6 +70,7 @@
6970
"@nomicfoundation/hardhat-chai-matchers": "^2.0.8",
7071
"@nomicfoundation/hardhat-ethers": "^3.0.8",
7172
"@nomiclabs/hardhat-solhint": "^4.0.1",
73+
"@openzeppelin/upgrades-core": "^1.41.0",
7274
"@typechain/ethers-v6": "^0.5.1",
7375
"@typechain/hardhat": "^9.1.0",
7476
"@types/chai": "^4.3.20",
@@ -80,23 +82,23 @@
8082
"dotenv": "^16.4.5",
8183
"eslint": "^9.15.0",
8284
"ethereumjs-util": "^7.1.5",
83-
"ethers": "^6.13.4",
85+
"ethers": "^6.13.5",
8486
"graphql": "^16.9.0",
8587
"graphql-request": "^7.1.2",
86-
"hardhat": "2.22.16",
88+
"hardhat": "2.22.18",
8789
"hardhat-contract-sizer": "^2.10.0",
8890
"hardhat-deploy": "^0.14.0",
8991
"hardhat-deploy-ethers": "^0.4.2",
90-
"hardhat-deploy-tenderly": "^0.2.0",
92+
"hardhat-deploy-tenderly": "^0.2.1",
9193
"hardhat-docgen": "^1.3.0",
92-
"hardhat-gas-reporter": "^2.2.1",
94+
"hardhat-gas-reporter": "^2.2.2",
9395
"hardhat-tracer": "^3.1.0",
9496
"hardhat-watcher": "^2.5.0",
9597
"node-fetch": "^3.3.2",
9698
"pino": "^8.21.0",
9799
"pino-pretty": "^10.3.1",
98100
"prettier": "^3.3.3",
99-
"prettier-plugin-solidity": "^1.4.1",
101+
"prettier-plugin-solidity": "^1.4.2",
100102
"shelljs": "^0.8.5",
101103
"solhint-plugin-prettier": "^0.1.0",
102104
"solidity-coverage": "^0.8.13",
@@ -107,7 +109,7 @@
107109
"dependencies": {
108110
"@chainlink/contracts": "^1.3.0",
109111
"@kleros/vea-contracts": "^0.4.0",
110-
"@openzeppelin/contracts": "^5.1.0",
112+
"@openzeppelin/contracts": "^5.2.0",
111113
"viem": "^2.21.48"
112114
}
113115
}

contracts/src/arbitration/DisputeTemplateRegistry.sol

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import "./interfaces/IDisputeTemplateRegistry.sol";
88
/// @title Dispute Template Registry
99
/// @dev A contract to maintain a registry of dispute templates.
1010
contract DisputeTemplateRegistry is IDisputeTemplateRegistry, UUPSProxiable, Initializable {
11+
string public constant override version = "0.8.0";
12+
1113
// ************************************* //
1214
// * Storage * //
1315
// ************************************* //
@@ -31,7 +33,7 @@ contract DisputeTemplateRegistry is IDisputeTemplateRegistry, UUPSProxiable, Ini
3133
// * Constructor * //
3234
// ************************************* //
3335

34-
/// @dev Constructor, initializing the implementation to reduce attack surface.
36+
/// @custom:oz-upgrades-unsafe-allow constructor
3537
constructor() {
3638
_disableInitializers();
3739
}

contracts/src/arbitration/KlerosCore.sol

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88

99
pragma solidity 0.8.24;
1010

11-
import "./KlerosCoreBase.sol";
12-
import {UUPSProxiable} from "../proxy/UUPSProxiable.sol";
13-
import {Initializable} from "../proxy/Initializable.sol";
11+
import {KlerosCoreBase, IDisputeKit, ISortitionModule, IERC20} from "./KlerosCoreBase.sol";
1412

1513
/// @title KlerosCore
1614
/// Core arbitrator contract for Kleros v2.
1715
/// Note that this contract trusts the PNK token, the dispute kit and the sortition module contracts.
18-
contract KlerosCore is KlerosCoreBase, UUPSProxiable, Initializable {
16+
contract KlerosCore is KlerosCoreBase {
17+
string public constant override version = "0.8.0";
18+
1919
// ************************************* //
2020
// * Constructor * //
2121
// ************************************* //
2222

23-
/// @dev Constructor, initializing the implementation to reduce attack surface.
23+
/// @custom:oz-upgrades-unsafe-allow constructor
2424
constructor() {
2525
_disableInitializers();
2626
}
@@ -48,7 +48,7 @@ contract KlerosCore is KlerosCoreBase, UUPSProxiable, Initializable {
4848
bytes memory _sortitionExtraData,
4949
ISortitionModule _sortitionModuleAddress
5050
) external reinitializer(1) {
51-
_initialize(
51+
__KlerosCoreBase_initialize(
5252
_governor,
5353
_guardian,
5454
_pinakion,

contracts/src/arbitration/KlerosCoreBase.sol

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ pragma solidity 0.8.24;
1111
import {IArbitrableV2, IArbitratorV2} from "./interfaces/IArbitratorV2.sol";
1212
import {IDisputeKit} from "./interfaces/IDisputeKit.sol";
1313
import {ISortitionModule} from "./interfaces/ISortitionModule.sol";
14+
import {Initializable} from "../proxy/Initializable.sol";
15+
import {UUPSProxiable} from "../proxy/UUPSProxiable.sol";
1416
import {SafeERC20, IERC20} from "../libraries/SafeERC20.sol";
1517
import "../libraries/Constants.sol";
1618

1719
/// @title KlerosCoreBase
1820
/// Core arbitrator contract for Kleros v2.
1921
/// Note that this contract trusts the PNK token, the dispute kit and the sortition module contracts.
20-
abstract contract KlerosCoreBase is IArbitratorV2 {
22+
abstract contract KlerosCoreBase is IArbitratorV2, Initializable, UUPSProxiable {
2123
using SafeERC20 for IERC20;
2224

2325
// ************************************* //
@@ -193,7 +195,7 @@ abstract contract KlerosCoreBase is IArbitratorV2 {
193195
// * Constructor * //
194196
// ************************************* //
195197

196-
function _initialize(
198+
function __KlerosCoreBase_initialize(
197199
address _governor,
198200
address _guardian,
199201
IERC20 _pinakion,
@@ -204,7 +206,7 @@ abstract contract KlerosCoreBase is IArbitratorV2 {
204206
uint256[4] memory _timesPerPeriod,
205207
bytes memory _sortitionExtraData,
206208
ISortitionModule _sortitionModuleAddress
207-
) internal {
209+
) internal onlyInitializing {
208210
governor = _governor;
209211
guardian = _guardian;
210212
pinakion = _pinakion;

contracts/src/arbitration/KlerosCoreNeo.sol

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88

99
pragma solidity 0.8.24;
1010

11-
import "./KlerosCoreBase.sol";
12-
import {UUPSProxiable} from "../proxy/UUPSProxiable.sol";
13-
import {Initializable} from "../proxy/Initializable.sol";
11+
import {KlerosCoreBase, IDisputeKit, ISortitionModule, IERC20, OnError, StakingResult} from "./KlerosCoreBase.sol";
1412
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
1513

1614
/// @title KlerosCoreNeo
1715
/// Core arbitrator contract for Kleros v2.
1816
/// Note that this contract trusts the PNK token, the dispute kit and the sortition module contracts.
19-
contract KlerosCoreNeo is KlerosCoreBase, UUPSProxiable, Initializable {
17+
contract KlerosCoreNeo is KlerosCoreBase {
18+
string public constant override version = "0.8.0";
19+
2020
// ************************************* //
2121
// * Storage * //
2222
// ************************************* //
@@ -28,7 +28,7 @@ contract KlerosCoreNeo is KlerosCoreBase, UUPSProxiable, Initializable {
2828
// * Constructor * //
2929
// ************************************* //
3030

31-
/// @dev Constructor, initializing the implementation to reduce attack surface.
31+
/// @custom:oz-upgrades-unsafe-allow constructor
3232
constructor() {
3333
_disableInitializers();
3434
}
@@ -58,7 +58,7 @@ contract KlerosCoreNeo is KlerosCoreBase, UUPSProxiable, Initializable {
5858
ISortitionModule _sortitionModuleAddress,
5959
IERC721 _jurorNft
6060
) external reinitializer(2) {
61-
super._initialize(
61+
__KlerosCoreBase_initialize(
6262
_governor,
6363
_guardian,
6464
_pinakion,

contracts/src/arbitration/PolicyRegistry.sol

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import "../proxy/Initializable.sol";
77
/// @title PolicyRegistry
88
/// @dev A contract to maintain a policy for each court.
99
contract PolicyRegistry is UUPSProxiable, Initializable {
10+
string public constant override version = "0.8.0";
11+
1012
// ************************************* //
1113
// * Events * //
1214
// ************************************* //
@@ -38,7 +40,7 @@ contract PolicyRegistry is UUPSProxiable, Initializable {
3840
// * Constructor * //
3941
// ************************************* //
4042

41-
/// @dev Constructor, initializing the implementation to reduce attack surface.
43+
/// @custom:oz-upgrades-unsafe-allow constructor
4244
constructor() {
4345
_disableInitializers();
4446
}

contracts/src/arbitration/SortitionModule.sol

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@
1010

1111
pragma solidity 0.8.24;
1212

13-
import "./SortitionModuleBase.sol";
14-
import "../proxy/UUPSProxiable.sol";
15-
import "../proxy/Initializable.sol";
13+
import {SortitionModuleBase, KlerosCore, RNG} from "./SortitionModuleBase.sol";
1614

1715
/// @title SortitionModule
1816
/// @dev A factory of trees that keeps track of staked values for sortition.
19-
contract SortitionModule is SortitionModuleBase, UUPSProxiable, Initializable {
17+
contract SortitionModule is SortitionModuleBase {
18+
string public constant override version = "0.8.0";
19+
2020
// ************************************* //
2121
// * Constructor * //
2222
// ************************************* //
2323

24-
/// @dev Constructor, initializing the implementation to reduce attack surface.
24+
/// @custom:oz-upgrades-unsafe-allow constructor
2525
constructor() {
2626
_disableInitializers();
2727
}
@@ -41,7 +41,7 @@ contract SortitionModule is SortitionModuleBase, UUPSProxiable, Initializable {
4141
RNG _rng,
4242
uint256 _rngLookahead
4343
) external reinitializer(1) {
44-
super._initialize(_governor, _core, _minStakingTime, _maxDrawingTime, _rng, _rngLookahead);
44+
__SortitionModuleBase_initialize(_governor, _core, _minStakingTime, _maxDrawingTime, _rng, _rngLookahead);
4545
}
4646

4747
// ************************************* //

0 commit comments

Comments
 (0)