Skip to content

Commit ba231ff

Browse files
committed
Merge branch 'dev'
2 parents 0b1d63e + 690069b commit ba231ff

Some content is hidden

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

49 files changed

+3395
-1371
lines changed

.dockerignore

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
.yarn/install-state.gz
33

44
contracts/.env
5+
contracts/.env.*
56
contracts/test
67
contracts/lib
78
contracts/cache
89
contracts/cache_hardhat
9-
contracts/config
1010
contracts/tenderly.yaml
1111

1212
*/.DS_Store
13-
*/*.log
13+
*/*.log

contracts/README.md

+9-8
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,17 @@ Refresh the list of deployed contracts by running `./scripts/generateDeployments
2929
- [BlockHashRNG](https://sepolia.arbiscan.io/address/0x0298a3EFa6Faf90865725E2b48Cf0F66e5d52754)
3030
- [DAI](https://sepolia.arbiscan.io/address/0xc34aeFEa232956542C5b2f2EE55fD5c378B35c03)
3131
- [DAIFaucet](https://sepolia.arbiscan.io/address/0x1Fa58B52326488D62A406E71DBaD839560e810fF)
32-
- [DisputeKitClassic: proxy](https://sepolia.arbiscan.io/address/0x10bDc76B491BFcA466AB5C74431880C086b07c67), [implementation](https://sepolia.arbiscan.io/address/0x718a6FB3b6f8dc8205e9052E6B745Ff0c23205dD)
33-
- [DisputeResolver](https://sepolia.arbiscan.io/address/0xa5A7F0F8e5f90eb8738C7Ee1be37A9794024Bc1B)
34-
- [DisputeTemplateRegistry: proxy](https://sepolia.arbiscan.io/address/0xf2833d188269Df7c7B6951f9114DA0bD6BAE70af), [implementation](https://sepolia.arbiscan.io/address/0xa04d631e5660635D8e8f724F799A4e83Bb1EDb18)
35-
- [EvidenceModule: proxy](https://sepolia.arbiscan.io/address/0xFA4Df75ab27525e65Db073a9aF195cd6B7707046), [implementation](https://sepolia.arbiscan.io/address/0xA1280FA86a65c4Fe6e22586066A89372C22AA03f)
36-
- [KlerosCore: proxy](https://sepolia.arbiscan.io/address/0x8ab813348fA90DE51A87131365c458D43ca03F9c), [implementation](https://sepolia.arbiscan.io/address/0xea9cc831DA99C2d9EeC82aA8d281Bb3e26572e52)
32+
- [DisputeKitClassic: proxy](https://sepolia.arbiscan.io/address/0x0c38f115D001d3b5bBec5e8D44f78C7B61A27D94), [implementation](https://sepolia.arbiscan.io/address/0xDb0B7908C46E2Bb08459bf9b3155b9bb8F8713E1)
33+
- [DisputeResolver](https://sepolia.arbiscan.io/address/0xed31bEE8b1F7cE89E93033C0d3B2ccF4cEb27652)
34+
- [DisputeTemplateRegistry: proxy](https://sepolia.arbiscan.io/address/0xe763d31Cb096B4bc7294012B78FC7F148324ebcb), [implementation](https://sepolia.arbiscan.io/address/0x7283c07CC5224B20f431B1fa0E6d6db3cA02de34)
35+
- [EvidenceModule: proxy](https://sepolia.arbiscan.io/address/0xA88A9a25cE7f1d8b3941dA3b322Ba91D009E1397), [implementation](https://sepolia.arbiscan.io/address/0x63CF56e1c99E65E4a9eCDCC805F4735E016F2dc8)
36+
- [KlerosCore: proxy](https://sepolia.arbiscan.io/address/0xE8442307d36e9bf6aB27F1A009F95CE8E11C3479), [implementation](https://sepolia.arbiscan.io/address/0x0766e4B8c4a3aAC9371a5A9D6119E8125Adcfd55)
3737
- [PNKFaucet](https://sepolia.arbiscan.io/address/0x9f6ffc13B685A68ae359fCA128dfE776458Df464)
3838
- [PinakionV2](https://sepolia.arbiscan.io/address/0x34B944D42cAcfC8266955D07A80181D2054aa225)
39-
- [PolicyRegistry: proxy](https://sepolia.arbiscan.io/address/0xb177AC8827146AC74C412688c6b10676ca170096), [implementation](https://sepolia.arbiscan.io/address/0xd543D50dcba2c3E067296210D64c8F91206Df908)
40-
- [RandomizerRNG: proxy](https://sepolia.arbiscan.io/address/0x1E2960117f570f48c773154C0A63919c12Db0Cc2), [implementation](https://sepolia.arbiscan.io/address/0x0974eF19c9202141D20ce50D60c5A3c522e7A9Ae)
41-
- [SortitionModule: proxy](https://sepolia.arbiscan.io/address/0xa156fAC2e209126273f841E81490DA7D4381Cc03), [implementation](https://sepolia.arbiscan.io/address/0xF506eA3E25ed3BFc9aFa30c81e0254cb0E4E0A35)
39+
- [PolicyRegistry: proxy](https://sepolia.arbiscan.io/address/0x2668c46A14af8997417138B064ca1bEB70769585), [implementation](https://sepolia.arbiscan.io/address/0xB958113f96950C7806d584eFBed964288d46a0B8)
40+
- [RandomizerRNG: proxy](https://sepolia.arbiscan.io/address/0x51a97ad9F0aA818e75819da3cA20CAc319580627), [implementation](https://sepolia.arbiscan.io/address/0x1237F02bBeFDAEA20cE3A66aCAe458C4106Ae203)
41+
- [SortitionModule: proxy](https://sepolia.arbiscan.io/address/0xbAA5068F0bD1417046250A3eDe2B1F27e31383BD), [implementation](https://sepolia.arbiscan.io/address/0xA418a7E63DC8Aa0F379487E4445f86543C16A0E9)
42+
- [TransactionBatcher](https://sepolia.arbiscan.io/address/0x35f93986950804ac1F93519BF68C2a7Dd776db0E)
4243
- [WETH](https://sepolia.arbiscan.io/address/0xAEE953CC26DbDeA52beBE3F97f281981f2B9d511)
4344
- [WETHFaucet](https://sepolia.arbiscan.io/address/0x922B84134e41BC5c9EDE7D5EFCE22Ba3D0e71835)
4445

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

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
2323
const weth = await deployERC20AndFaucet(hre, deployer, "WETH");
2424
const nft = await deployERC721(hre, deployer, "Kleros V2 Neo Early User", "KlerosV2NeoEarlyUser");
2525

26+
await getContractOrDeploy(hre, "TransactionBatcher", { from: deployer, args: [], log: true });
27+
2628
const randomizerOracle = await getContractOrDeploy(hre, "RandomizerOracle", {
2729
from: deployer,
2830
contract: "RandomizerMock",

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { DeployFunction } from "hardhat-deploy/types";
33
import { deployUpgradable } from "./utils/deployUpgradable";
44
import { HomeChains, isSkipped } from "./utils";
55
import { deployERC20AndFaucet } from "./utils/deployTokens";
6-
import { KlerosCore, KlerosCoreRuler } from "../typechain-types";
7-
import { getContractOrDeployUpgradable } from "./utils/getContractOrDeploy";
6+
import { KlerosCoreRuler } from "../typechain-types";
7+
import { getContractOrDeploy, getContractOrDeployUpgradable } from "./utils/getContractOrDeploy";
88
import { changeCurrencyRate } from "./utils/klerosCoreHelper";
99

1010
const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
@@ -20,6 +20,8 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
2020
const dai = await deployERC20AndFaucet(hre, deployer, "DAI");
2121
const weth = await deployERC20AndFaucet(hre, deployer, "WETH");
2222

23+
await getContractOrDeploy(hre, "TransactionBatcher", { from: deployer, args: [], log: true });
24+
2325
const minStake = 0;
2426
const alpha = 10000;
2527
const feeForJuror = 10n ** 17n;

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { changeCurrencyRate } from "./utils/klerosCoreHelper";
66
import { ETH, HomeChains, PNK, isSkipped } from "./utils";
77
import { deployERC20AndFaucet } from "./utils/deployTokens";
88
import { DisputeKitClassic, KlerosCore, KlerosCoreUniversity } from "../typechain-types";
9-
import { getContractOrDeployUpgradable } from "./utils/getContractOrDeploy";
9+
import { getContractOrDeploy, getContractOrDeployUpgradable } from "./utils/getContractOrDeploy";
1010

1111
const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
1212
const { ethers, deployments, getNamedAccounts, getChainId } = hre;
@@ -22,6 +22,8 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
2222
const dai = await deployERC20AndFaucet(hre, deployer, "DAI");
2323
const weth = await deployERC20AndFaucet(hre, deployer, "WETH");
2424

25+
await getContractOrDeploy(hre, "TransactionBatcher", { from: deployer, args: [], log: true });
26+
2527
const disputeKit = await deployUpgradable(deployments, "DisputeKitClassicUniversity", {
2628
from: deployer,
2729
contract: "DisputeKitClassic",

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

+15-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { DeployFunction } from "hardhat-deploy/types";
33
import { getContractAddress } from "./utils/getContractAddress";
44
import { deployUpgradable } from "./utils/deployUpgradable";
55
import { changeCurrencyRate } from "./utils/klerosCoreHelper";
6-
import { HomeChains, isSkipped, isDevnet, PNK, ETH } from "./utils";
6+
import { HomeChains, isSkipped, isDevnet, isMainnet, PNK, ETH } from "./utils";
77
import { getContractOrDeploy, getContractOrDeployUpgradable } from "./utils/getContractOrDeploy";
88
import { deployERC20AndFaucet } from "./utils/deployTokens";
99
import { DisputeKitClassic, KlerosCore } from "../typechain-types";
@@ -22,6 +22,8 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
2222
const dai = await deployERC20AndFaucet(hre, deployer, "DAI");
2323
const weth = await deployERC20AndFaucet(hre, deployer, "WETH");
2424

25+
await getContractOrDeploy(hre, "TransactionBatcher", { from: deployer, args: [], log: true });
26+
2527
await getContractOrDeployUpgradable(hre, "PolicyRegistry", { from: deployer, args: [deployer], log: true });
2628

2729
await getContractOrDeployUpgradable(hre, "EvidenceModule", { from: deployer, args: [deployer], log: true });
@@ -34,12 +36,22 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
3436
log: true,
3537
});
3638

37-
const rng = await deployUpgradable(deployments, "RandomizerRNG", {
39+
const randomizerRng = await getContractOrDeployUpgradable(hre, "RandomizerRNG", {
3840
from: deployer,
3941
args: [randomizerOracle.target, deployer],
4042
log: true,
4143
});
4244

45+
const blockhashRng = await getContractOrDeploy(hre, "BlockHashRNG", {
46+
from: deployer,
47+
args: [],
48+
log: true,
49+
});
50+
51+
// RNG fallback on Arbitrum Sepolia because the Randomizer.ai oracle contract is unverified and not officially supported.
52+
const rng = isMainnet(hre.network) ? randomizerRng : blockhashRng;
53+
console.log(isMainnet(hre.network) ? "using RandomizerRNG on mainnet" : "using BlockHashRNG on testnet/devnet");
54+
4355
const disputeKit = await deployUpgradable(deployments, "DisputeKitClassic", {
4456
from: deployer,
4557
args: [deployer, ZeroAddress],
@@ -57,7 +69,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
5769
const maxFreezingTime = devnet ? 600 : 1800;
5870
const sortitionModule = await deployUpgradable(deployments, "SortitionModule", {
5971
from: deployer,
60-
args: [deployer, klerosCoreAddress, minStakingTime, maxFreezingTime, rng.address, RNG_LOOKAHEAD],
72+
args: [deployer, klerosCoreAddress, minStakingTime, maxFreezingTime, rng.target, RNG_LOOKAHEAD],
6173
log: true,
6274
}); // nonce (implementation), nonce+1 (proxy)
6375

contracts/deploy/00-transaction-batcher.ts

-26
This file was deleted.

contracts/deploy/utils/deployUpgradable.ts

+31-13
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,47 @@ import {
77
} from "hardhat-deploy/types";
88

99
// Rationale: https://github.com/kleros/kleros-v2/pull/1214#issue-1879116629
10-
const PROXY_OPTIONS: ProxyOptions = {
11-
proxyContract: "UUPSProxy",
12-
proxyArgs: ["{implementation}", "{data}"],
13-
checkProxyAdmin: false, // Not relevant for UUPSProxy
14-
checkABIConflict: false, // Not relevant for UUPSProxy
15-
upgradeFunction: {
16-
methodName: "upgradeToAndCall",
17-
upgradeArgs: ["{implementation}", "{data}"],
18-
},
19-
};
10+
function proxyOptions(proxyContract: string): ProxyOptions {
11+
return {
12+
proxyContract,
13+
proxyArgs: ["{implementation}", "{data}"],
14+
checkProxyAdmin: false, // Not relevant for UUPSProxy
15+
checkABIConflict: false, // Not relevant for UUPSProxy
16+
upgradeFunction: {
17+
methodName: "upgradeToAndCall",
18+
upgradeArgs: ["{implementation}", "{data}"],
19+
},
20+
};
21+
}
2022

21-
type DeployUpgradableOptions = {
23+
export type DeployUpgradableOptions = {
2224
newImplementation?: string;
2325
initializer?: string;
26+
proxyAlias?: string;
2427
} & DeployOptionsBase;
2528

29+
/**
30+
* Deploy a contract with an upgradable proxy
31+
* NOTE: This function assumes the existence of a proxy contract with the name `${proxy}Proxy`, if there is none add the option `proxyAlias: "UUPSProxy"`
32+
* @param deployments - The deployments extension
33+
* @param proxy - The name of the proxy contract
34+
* @param options - The options for the deployment
35+
* @returns The deployment result
36+
*/
2637
export const deployUpgradable = async (
2738
deployments: DeploymentsExtension,
2839
proxy: string,
2940
options: DeployUpgradableOptions
3041
): Promise<DeployResult> => {
3142
const { deploy } = deployments;
32-
const { newImplementation, initializer, args: initializerArgs, proxy: proxyOverrides, ...otherOptions } = options;
43+
const {
44+
newImplementation,
45+
initializer,
46+
args: initializerArgs,
47+
proxy: proxyOverrides,
48+
proxyAlias,
49+
...otherOptions
50+
} = options;
3351

3452
const methodName = initializer ?? "initialize";
3553
const args = initializerArgs ?? [];
@@ -50,7 +68,7 @@ export const deployUpgradable = async (
5068
...otherOptions,
5169
...contract,
5270
proxy: {
53-
...PROXY_OPTIONS,
71+
...proxyOptions(proxyAlias ?? `${proxy}Proxy`),
5472
...implementationName,
5573
...((proxyOverrides as ProxyOptions) ?? {}),
5674
execute: {

contracts/deploy/utils/getContractOrDeploy.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { DeployOptions } from "hardhat-deploy/types";
22
import { HardhatRuntimeEnvironment } from "hardhat/types";
33
import { deployUpgradable } from "./deployUpgradable";
44
import { Contract } from "ethers";
5+
56
export const getContractOrDeploy = async (
67
hre: HardhatRuntimeEnvironment,
78
contractName: string,

contracts/deploy/utils/klerosCoreHelper.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ export const changeCurrencyRate = async (
1111
const pnkRate = await core.currencyRates(erc20);
1212
if (pnkRate.feePaymentAccepted !== accepted) {
1313
console.log(`core.changeAcceptedFeeTokens(${erc20}, ${accepted})`);
14-
await core.changeAcceptedFeeTokens(erc20, accepted);
14+
const tx = await core.changeAcceptedFeeTokens(erc20, accepted);
15+
await tx.wait();
1516
}
1617
if (pnkRate.rateInEth !== toBigInt(rateInEth) || pnkRate.rateDecimals !== rateDecimals) {
1718
console.log(`core.changeCurrencyRates(${erc20}, ${rateInEth}, ${rateDecimals})`);
18-
await core.changeCurrencyRates(erc20, rateInEth, rateDecimals);
19+
const tx = await core.changeCurrencyRates(erc20, rateInEth, rateDecimals);
20+
await tx.wait();
1921
}
2022
};

contracts/deployments/arbitrum.ts

+53-2
Original file line numberDiff line numberDiff line change
@@ -2412,7 +2412,7 @@ export default {
24122412
],
24132413
},
24142414
DisputeResolverNeo: {
2415-
address: "0x95eCE455bD817D6adB92F2383617d36eBE10D6EB",
2415+
address: "0x3645F9e08D80E47c82aD9E33fCB4EA703822C831",
24162416
abi: [
24172417
{
24182418
inputs: [
@@ -2442,7 +2442,7 @@ export default {
24422442
{
24432443
indexed: true,
24442444
internalType: "uint256",
2445-
name: "_arbitrableDisputeID",
2445+
name: "_arbitratorDisputeID",
24462446
type: "uint256",
24472447
},
24482448
{
@@ -12144,6 +12144,57 @@ export default {
1214412144
},
1214512145
],
1214612146
},
12147+
TransactionBatcher: {
12148+
address: "0xBC5ef8d9ad307154447AE148c088f083d2dEa4eF",
12149+
abi: [
12150+
{
12151+
inputs: [
12152+
{
12153+
internalType: "address[]",
12154+
name: "targets",
12155+
type: "address[]",
12156+
},
12157+
{
12158+
internalType: "uint256[]",
12159+
name: "values",
12160+
type: "uint256[]",
12161+
},
12162+
{
12163+
internalType: "bytes[]",
12164+
name: "datas",
12165+
type: "bytes[]",
12166+
},
12167+
],
12168+
name: "batchSend",
12169+
outputs: [],
12170+
stateMutability: "payable",
12171+
type: "function",
12172+
},
12173+
{
12174+
inputs: [
12175+
{
12176+
internalType: "address[]",
12177+
name: "targets",
12178+
type: "address[]",
12179+
},
12180+
{
12181+
internalType: "uint256[]",
12182+
name: "values",
12183+
type: "uint256[]",
12184+
},
12185+
{
12186+
internalType: "bytes[]",
12187+
name: "datas",
12188+
type: "bytes[]",
12189+
},
12190+
],
12191+
name: "batchSendUnchecked",
12192+
outputs: [],
12193+
stateMutability: "payable",
12194+
type: "function",
12195+
},
12196+
],
12197+
},
1214712198
WETH: {
1214812199
address: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
1214912200
abi: [

0 commit comments

Comments
 (0)