Skip to content

Commit ecd49cd

Browse files
authored
Merge branch 'dev' into feat(web)/update-graphql-codegen
2 parents 31af882 + 2fead6a commit ecd49cd

File tree

124 files changed

+7274
-2558
lines changed

Some content is hidden

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

124 files changed

+7274
-2558
lines changed

contracts/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@ Smart contracts for Kleros v2
66

77
Refresh the list of deployed contracts by running `./scripts/generateDeploymentsMarkdown.sh`.
88

9-
### v2-alpha-1
10-
119
#### Chiado
1210

13-
- [ArbitrableExample](https://blockscout.com/gnosis/chiado/address/0xc0fcc96BFd78e36550FCaB434A9EE1210B57225b)
14-
- [ForeignGatewayOnGnosis](https://blockscout.com/gnosis/chiado/address/0x573bcD6ee4aEe152eCC9Cafd2c0820Dc548AF6cC)
11+
- [ArbitrableExample](https://blockscout.com/gnosis/chiado/address/0xf534e055758884c71304028814Ba25B2CE6903e5)
12+
- [DisputeResolver](https://blockscout.com/gnosis/chiado/address/0x433eD78895df1df7668C40b3e82d54410331F942)
13+
- [ForeignGatewayOnGnosis](https://blockscout.com/gnosis/chiado/address/0x2357ef115E98d171b083105E9b398231206989A3)
1514
- [SortitionSumTreeFactory](https://blockscout.com/gnosis/chiado/address/0xc7e3BF90299f6BD9FA7c3703837A9CAbB5743636)
1615
- [TokenBridge](https://blockscout.com/gnosis/chiado/address/0xbb3c86f9918C3C1d83668fA84e79E876d147fFf2)
1716
- [WETH](https://blockscout.com/gnosis/chiado/address/0x2DFC9c3141268e6eac04a7D6d98Fbf64BDe836a8)
@@ -23,20 +22,20 @@ Refresh the list of deployed contracts by running `./scripts/generateDeployments
2322
#### Goerli
2423

2524
- [PNK](https://goerli.etherscan.io/token/0xA3B02bA6E10F55fb177637917B1b472da0110CcC)
26-
- [ArbitrableExample](https://goerli.etherscan.io/address/0xd78dcdde2c5a2bd4bb246bc7db6994b95f7c442c)
2725

2826
#### Arbitrum Goerli
2927

3028
- [PNK](https://goerli.arbiscan.io/token/0x4DEeeFD054434bf6721eF39Aa18EfB3fd0D12610/token-transfers)
31-
- [ArbitrableExampleEthFee](https://goerli.arbiscan.io/address/0x1fF31be1924f55804350ADe4945f3B3a6a2e15d2)
3229
- [BlockHashRNG](https://goerli.arbiscan.io/address/0x68eE49dfD9d76f3386257a3D0e0A85c0A5519bBD)
33-
- [DisputeKitClassic](https://goerli.arbiscan.io/address/0xcBE3aD699919Cf59efDF715e4B41AF30A0E4c92d)
34-
- [DisputeResolver](https://goerli.arbiscan.io/address/0x3B4edEFd12a467D1C71506ae2eE88828145202b1)
30+
- [DAI](https://goerli.arbiscan.io/address/0x70A704Dce4cCC00568Cc142C86D07Ec71C944a39)
31+
- [DisputeKitClassic](https://goerli.arbiscan.io/address/0x0245A93ABd9c5b2d767B2D98cE6d5e612208E474)
32+
- [DisputeResolver](https://goerli.arbiscan.io/address/0xcDC05c8d2EEEe384359Bd22E8631528B6b0564e9)
3533
- [HomeGatewayToGnosis](https://goerli.arbiscan.io/address/0xD60CD2151e118Dd796efcb1ceFFcF892226F9b3a)
36-
- [KlerosCore](https://goerli.arbiscan.io/address/0xA429667Abb1A6c530BAd1083df4C69FBce86D696)
34+
- [KlerosCore](https://goerli.arbiscan.io/address/0x8Af82E2F8890acb4AB84cbaB3c4C4Eb3E965CF24)
3735
- [PolicyRegistry](https://goerli.arbiscan.io/address/0xED503aBA65B28D81444294D1eAa5d84CeFdC2C58)
3836
- [RandomizerRNG](https://goerli.arbiscan.io/address/0xa90f7D2e35718FDE9AD96c8B6667AFcAa4BEfd4d)
39-
- [SortitionModule](https://goerli.arbiscan.io/address/0xa65D3ED6494ec5fcAa115A39D625B2F01786F094)
37+
- [SortitionModule](https://goerli.arbiscan.io/address/0x5Ae75Db8B66B574b2c5C29eE4D32cc9Fe62bfdEE)
38+
- [WETH](https://goerli.arbiscan.io/address/0xddE1b84E43505432Fdf5F810ebB9373dD37e9230)
4039

4140
## Getting Started
4241

@@ -121,6 +120,7 @@ yarn deploy --network localhost --tags <Arbitration|VeaMock|ForeignGatewayOnEthe
121120
yarn deploy --network arbitrumGoerli --tags Arbitration
122121
yarn deploy --network chiado --tags ForeignGatewayOnGnosis
123122
yarn deploy --network chiado --tags KlerosLiquidOnGnosis
123+
yarn deploy --network chiado --tags ForeignArbitrable
124124
yarn deploy --network arbitrumGoerli --tags HomeGatewayToGnosis
125125

126126
# Goerli

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { HardhatRuntimeEnvironment } from "hardhat/types";
22
import { DeployFunction } from "hardhat-deploy/types";
3+
import disputeTemplate from "../../kleros-sdk/config/v2-disputetemplate/simple/NewDisputeTemplate.simple.json";
34

45
enum HomeChains {
56
ARBITRUM_ONE = 42161,
@@ -17,13 +18,19 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
1718
console.log("Deploying to %s with deployer %s", HomeChains[chainId], deployer);
1819

1920
const klerosCore = await deployments.get("KlerosCore");
21+
const extraData =
22+
"0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003"; // General court, 3 jurors
23+
const weth = await deployments.get("WETH");
2024

21-
await deploy("ArbitrableExampleEthFee", {
25+
await deploy("ArbitrableExample", {
2226
from: deployer,
23-
args: [
24-
klerosCore.address,
25-
"https://cloudflare-ipfs.com/ipfs/bafkreifteme6tusnjwyzajk75fyvzdmtyycxctf7yhfijb6rfigz3n4lvq",
26-
],
27+
args: [klerosCore.address, disputeTemplate, extraData, weth.address],
28+
log: true,
29+
});
30+
31+
await deploy("DisputeResolver", {
32+
from: deployer,
33+
args: [klerosCore.address],
2734
log: true,
2835
});
2936
};

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

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ const randomizerByChain = new Map<HomeChains, string>([
2020
[HomeChains.ARBITRUM_GOERLI, "0x923096Da90a3b60eb7E12723fA2E1547BA9236Bc"],
2121
]);
2222

23+
const daiByChain = new Map<HomeChains, string>([[HomeChains.ARBITRUM_ONE, "??"]]);
24+
const wethByChain = new Map<HomeChains, string>([[HomeChains.ARBITRUM_ONE, "??"]]);
25+
2326
const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
2427
const { ethers, deployments, getNamedAccounts, getChainId } = hre;
2528
const { deploy, execute } = deployments;
@@ -31,26 +34,26 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
3134
const chainId = Number(await getChainId());
3235
console.log("Deploying to %s with deployer %s", HomeChains[chainId], deployer);
3336

34-
if (chainId === HomeChains.HARDHAT) {
35-
pnkByChain.set(
36-
HomeChains.HARDHAT,
37-
(
38-
await deploy("PNK", {
39-
from: deployer,
40-
log: true,
41-
})
42-
).address
43-
);
44-
randomizerByChain.set(
45-
HomeChains.HARDHAT,
46-
(
47-
await deploy("RandomizerMock", {
48-
from: deployer,
49-
args: [],
50-
log: true,
51-
})
52-
).address
53-
);
37+
if (!pnkByChain.get(chainId)) {
38+
const erc20Address = await deployERC20(hre, deployer, "PNK");
39+
pnkByChain.set(HomeChains[HomeChains[chainId]], erc20Address);
40+
}
41+
if (!daiByChain.get(chainId)) {
42+
const erc20Address = await deployERC20(hre, deployer, "DAI");
43+
daiByChain.set(HomeChains[HomeChains[chainId]], erc20Address);
44+
}
45+
if (!wethByChain.get(chainId)) {
46+
const erc20Address = await deployERC20(hre, deployer, "WETH");
47+
wethByChain.set(HomeChains[HomeChains[chainId]], erc20Address);
48+
}
49+
50+
if (!randomizerByChain.get(chainId)) {
51+
const randomizerMock = await deploy("RandomizerMock", {
52+
from: deployer,
53+
args: [],
54+
log: true,
55+
});
56+
randomizerByChain.set(HomeChains[HomeChains[chainId]], randomizerMock.address);
5457
}
5558

5659
await deploy("PolicyRegistry", {
@@ -83,6 +86,8 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
8386
});
8487

8588
const pnk = pnkByChain.get(chainId) ?? AddressZero;
89+
const dai = daiByChain.get(chainId) ?? AddressZero;
90+
const weth = wethByChain.get(chainId) ?? AddressZero;
8691
const minStake = BigNumber.from(10).pow(20).mul(2);
8792
const alpha = 10000;
8893
const feeForJuror = BigNumber.from(10).pow(17);
@@ -108,6 +113,14 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
108113
await execute("DisputeKitClassic", { from: deployer, log: true }, "changeCore", klerosCore.address);
109114
}
110115

116+
await execute("KlerosCore", { from: deployer, log: true }, "changeAcceptedFeeTokens", pnk, true);
117+
await execute("KlerosCore", { from: deployer, log: true }, "changeAcceptedFeeTokens", dai, true);
118+
await execute("KlerosCore", { from: deployer, log: true }, "changeAcceptedFeeTokens", weth, true);
119+
120+
await execute("KlerosCore", { from: deployer, log: true }, "changeCurrencyRates", pnk, 12225583, 12);
121+
await execute("KlerosCore", { from: deployer, log: true }, "changeCurrencyRates", dai, 60327783, 11);
122+
await execute("KlerosCore", { from: deployer, log: true }, "changeCurrencyRates", weth, 1, 1);
123+
111124
await deploy("DisputeResolver", {
112125
from: deployer,
113126
args: [klerosCore.address],
@@ -121,4 +134,16 @@ deployArbitration.skip = async ({ getChainId }) => {
121134
return !HomeChains[chainId];
122135
};
123136

137+
const deployERC20 = async (hre: HardhatRuntimeEnvironment, deployer: string, ticker: string) => {
138+
const { deploy } = hre.deployments;
139+
const erc20 = await deploy(ticker, {
140+
from: deployer,
141+
contract: "TestERC20",
142+
args: [ticker, ticker],
143+
log: true,
144+
});
145+
console.log("Deployed %s at %s", ticker, erc20.address);
146+
return erc20.address;
147+
};
148+
124149
export default deployArbitration;

contracts/deploy/01-foreign-gateway-on-ethereum.ts

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { HardhatRuntimeEnvironment } from "hardhat/types";
22
import { DeployFunction } from "hardhat-deploy/types";
33
import getContractAddress from "../deploy-helpers/getContractAddress";
4+
import { KlerosCore__factory } from "../typechain-types";
45

56
enum ForeignChains {
67
ETHEREUM_MAINNET = 1,
@@ -28,37 +29,30 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
2829
const homeChainProvider = new ethers.providers.JsonRpcProvider(homeNetworks[ForeignChains[chainId]].url);
2930
let nonce = await homeChainProvider.getTransactionCount(deployer);
3031
nonce += 2; // HomeGatewayToEthereum deploy tx will the third tx after this on its home network, so we add two to the current nonce.
31-
const homeChainId = (await homeChainProvider.getNetwork()).chainId;
32-
const homeChainIdAsBytes32 = hexZeroPad(hexlify(homeChainId), 32);
3332
const homeGatewayAddress = getContractAddress(deployer, nonce);
3433
console.log("Calculated future HomeGatewayToEthereum address for nonce %d: %s", nonce, homeGatewayAddress);
3534

3635
const veaOutbox = await deployments.get("VeaOutboxArbToEthDevnet");
3736
console.log("Using VeaOutboxArbToEthDevnet at %s", veaOutbox.address);
3837

39-
const foreignGateway = await deploy("ForeignGatewayOnEthereum", {
38+
const homeChainId = (await homeChainProvider.getNetwork()).chainId;
39+
const homeChainIdAsBytes32 = hexZeroPad(hexlify(homeChainId), 32);
40+
await deploy("ForeignGatewayOnEthereum", {
4041
from: deployer,
4142
contract: "ForeignGateway",
4243
args: [deployer, veaOutbox.address, homeChainIdAsBytes32, homeGatewayAddress],
4344
gasLimit: 4000000,
4445
log: true,
4546
});
4647

47-
await execute(
48-
"ForeignGatewayOnEthereum",
49-
{ from: deployer, log: true },
50-
"changeCourtJurorFee",
51-
0,
52-
ethers.BigNumber.from(10).pow(17)
53-
);
54-
55-
const metaEvidenceUri = `https://raw.githubusercontent.com/kleros/kleros-v2/master/contracts/deployments/${hre.network.name}/MetaEvidence_ArbitrableExample.json`;
56-
57-
await deploy("ArbitrableExample", {
58-
from: deployer,
59-
args: [foreignGateway.address, metaEvidenceUri],
60-
log: true,
61-
});
48+
// TODO: disable the gateway until fully initialized with the correct fees OR allow disputeCreators to add funds again if necessary.
49+
const coreDeployment = await hre.companionNetworks.home.deployments.get("KlerosCore");
50+
const core = await KlerosCore__factory.connect(coreDeployment.address, homeChainProvider);
51+
// TODO: set up the correct fees for the FORKING_COURT
52+
const courtId = await core.GENERAL_COURT();
53+
const fee = (await core.courts(courtId)).feeForJuror;
54+
await execute("ForeignGatewayOnGnosis", { from: deployer, log: true }, "changeCourtJurorFee", courtId, fee);
55+
// TODO: set up the correct fees for the lower courts
6256
};
6357

6458
deployForeignGateway.tags = ["ForeignGatewayOnEthereum"];

contracts/deploy/01-foreign-gateway-on-gnosis.ts

Lines changed: 10 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@ import { parseUnits } from "ethers/lib/utils";
22
import { HardhatRuntimeEnvironment } from "hardhat/types";
33
import { DeployFunction } from "hardhat-deploy/types";
44
import getContractAddress from "../deploy-helpers/getContractAddress";
5+
import { KlerosCore__factory } from "../typechain-types";
56

67
enum ForeignChains {
78
GNOSIS_MAINNET = 100,
89
GNOSIS_CHIADO = 10200,
910
HARDHAT = 31337,
1011
}
1112

12-
const wethByChain = new Map<ForeignChains, string>([
13-
[ForeignChains.GNOSIS_MAINNET, "0x6A023CCd1ff6F2045C3309768eAd9E68F978f6e1"],
14-
]);
15-
1613
const ONE_GWEI = parseUnits("1", "gwei");
1714

1815
const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
@@ -41,47 +38,25 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
4138
const veaOutbox = await deployments.get("VeaOutboxArbToGnosisDevnet");
4239
console.log("Using VeaOutboxArbToGnosisDevnet at %s", veaOutbox.address);
4340

44-
if (!wethByChain.get(chainId)) {
45-
const weth = await deploy("WETH", {
46-
from: deployer,
47-
log: true,
48-
maxFeePerGas: ONE_GWEI,
49-
maxPriorityFeePerGas: ONE_GWEI,
50-
});
51-
52-
wethByChain.set(ForeignChains[ForeignChains[chainId]], weth.address);
53-
54-
await deploy("WETHFaucet", {
55-
from: deployer,
56-
contract: "Faucet",
57-
args: [weth.address],
58-
log: true,
59-
maxFeePerGas: ONE_GWEI,
60-
maxPriorityFeePerGas: ONE_GWEI,
61-
});
62-
}
63-
64-
const wethAddress = wethByChain.get(ForeignChains[ForeignChains[chainId]]);
6541
const homeChainId = (await homeChainProvider.getNetwork()).chainId;
6642
const homeChainIdAsBytes32 = hexZeroPad(hexlify(homeChainId), 32);
67-
6843
await deploy("ForeignGatewayOnGnosis", {
6944
from: deployer,
70-
contract: "ForeignGatewayOnGnosis",
71-
args: [deployer, veaOutbox.address, homeChainIdAsBytes32, homeGatewayAddress, wethAddress],
45+
contract: "ForeignGateway",
46+
args: [deployer, veaOutbox.address, homeChainIdAsBytes32, homeGatewayAddress],
7247
log: true,
7348
maxFeePerGas: ONE_GWEI,
7449
maxPriorityFeePerGas: ONE_GWEI,
7550
});
7651

7752
// TODO: disable the gateway until fully initialized with the correct fees OR allow disputeCreators to add funds again if necessary.
78-
await execute(
79-
"ForeignGatewayOnGnosis",
80-
{ from: deployer, log: true },
81-
"changeCourtJurorFee",
82-
0,
83-
ethers.utils.parseEther("0.00001")
84-
);
53+
const coreDeployment = await hre.companionNetworks.home.deployments.get("KlerosCore");
54+
const core = await KlerosCore__factory.connect(coreDeployment.address, homeChainProvider);
55+
// TODO: set up the correct fees for the FORKING_COURT
56+
const courtId = await core.GENERAL_COURT();
57+
const fee = (await core.courts(courtId)).feeForJuror;
58+
await execute("ForeignGatewayOnGnosis", { from: deployer, log: true }, "changeCourtJurorFee", courtId, fee);
59+
// TODO: set up the correct fees for the lower courts
8560
};
8661

8762
deployForeignGateway.tags = ["ForeignGatewayOnGnosis"];

contracts/deploy/03-vea-mock.ts

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { HardhatRuntimeEnvironment } from "hardhat/types";
22
import { DeployFunction } from "hardhat-deploy/types";
3-
import { ethers } from "hardhat";
43
import getContractAddress from "../deploy-helpers/getContractAddress";
4+
import { KlerosCore__factory } from "../typechain-types";
5+
import disputeTemplate from "../../kleros-sdk/config/v2-disputetemplate/simple/NewDisputeTemplate.simple.json";
56

67
const HARDHAT_NETWORK = 31337;
78

@@ -39,24 +40,34 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
3940
await deploy("HomeGatewayToEthereum", {
4041
from: deployer,
4142
contract: "HomeGateway",
42-
args: [deployer, klerosCore.address, vea.address, HARDHAT_NETWORK, foreignGateway.address],
43+
args: [
44+
deployer,
45+
klerosCore.address,
46+
vea.address,
47+
HARDHAT_NETWORK,
48+
foreignGateway.address,
49+
ethers.constants.AddressZero, // feeToken
50+
],
4351
gasLimit: 4000000,
4452
log: true,
4553
}); // nonce+1
4654

47-
await execute(
48-
"ForeignGatewayOnEthereum",
49-
{ from: deployer, log: true },
50-
"changeCourtJurorFee",
51-
0,
52-
ethers.BigNumber.from(10).pow(17)
53-
);
55+
// TODO: disable the gateway until fully initialized with the correct fees OR allow disputeCreators to add funds again if necessary.
56+
const signer = (await hre.ethers.getSigners())[0];
57+
const core = await KlerosCore__factory.connect(klerosCore.address, signer);
58+
// TODO: set up the correct fees for the FORKING_COURT
59+
const courtId = await core.GENERAL_COURT();
60+
const fee = (await core.courts(courtId)).feeForJuror;
61+
await execute("ForeignGatewayOnEthereum", { from: deployer, log: true }, "changeCourtJurorFee", courtId, fee);
62+
// TODO: set up the correct fees for the lower courts
5463

55-
const metaEvidenceUri = `https://raw.githubusercontent.com/kleros/kleros-v2/master/contracts/deployments/goerli/MetaEvidence_ArbitrableExample.json`;
56-
57-
await deploy("ArbitrableExampleEthFee", {
64+
// TODO: debug why this extraData fails but "0x00" works
65+
// const extraData =
66+
// "0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003"; // General court, 3 jurors
67+
const extraData = "0x00";
68+
await deploy("ArbitrableExample", {
5869
from: deployer,
59-
args: [foreignGateway.address, metaEvidenceUri],
70+
args: [foreignGateway.address, disputeTemplate, extraData, ethers.constants.AddressZero],
6071
log: true,
6172
});
6273
};

0 commit comments

Comments
 (0)