Skip to content

Commit 1596088

Browse files
committed
Merge branch 'dev' into feat(web)/cases-filtering
2 parents 61c67b6 + acb94e9 commit 1596088

File tree

147 files changed

+13073
-4477
lines changed

Some content is hidden

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

147 files changed

+13073
-4477
lines changed

.github/workflows/contracts-testing.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ on:
1515
pull_request:
1616
branches:
1717
- "*"
18-
paths-ignore:
19-
- "kleros-sdk/**"
20-
- "services/**"
21-
- "subgraph/**"
22-
- "web/**"
2318

2419
permissions: # added using https://github.com/step-security/secure-workflows
2520
contents: read

contracts/README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Refresh the list of deployed contracts by running `./scripts/generateDeployments
5353
- [ArbitrableExample](https://gnosis-chiado.blockscout.com/address/0xB56A23b396E0eae85414Ce5815da448ba529Cb4A)
5454
- [DisputeResolver](https://gnosis-chiado.blockscout.com/address/0x16f20604a51Ac1e68c9aAd1C0E53e951B62CC1Cb)
5555
- [DisputeTemplateRegistry](https://gnosis-chiado.blockscout.com/address/0x96E49552669ea81B8E9cE8694F7E4A55D8bFb957)
56-
- [ForeignGatewayOnGnosis](https://gnosis-chiado.blockscout.com/address/0x83F393F2aE68FA6A6701D7c65CBbFf3225f3fDf9)
56+
- [ForeignGatewayOnGnosis: proxy](https://gnosis-chiado.blockscout.com/address/0x078dAd05373d19d7fd6829735b765F12242a4300), [implementation](https://gnosis-chiado.blockscout.com/address/0xA4096fDA5291D5bbDD5Ed0D6CF2AF98229168Ace)
5757
- [WETH](https://gnosis-chiado.blockscout.com/address/0x2DFC9c3141268e6eac04a7D6d98Fbf64BDe836a8)
5858
- [WETHFaucet](https://gnosis-chiado.blockscout.com/address/0x22CB016c4b57413ca4DF5F1AC44a0E0d3c69811F)
5959
- [WPNKFaucet](https://gnosis-chiado.blockscout.com/address/0x5898aeE045A25B276369914c3448B72a41758B2c)
@@ -66,19 +66,18 @@ Refresh the list of deployed contracts by running `./scripts/generateDeployments
6666
#### Arbitrum Goerli
6767

6868
- [PNK](https://goerli.arbiscan.io/token/0x3483FA1b87792cd5BE4100822C4eCEC8D3E531ee)
69-
- [ArbitrableExample](https://goerli.arbiscan.io/address/0x9B958EBe8057DCe5b9c1a30c935b790826bb511e)
69+
- [ArbitrableExample](https://goerli.arbiscan.io/address/0x5d96ede4D4Dd4c245d6879A4D790fF0AB1F476cC)
7070
- [DAI](https://goerli.arbiscan.io/address/0xB755843e26F2cD1c6A46659cEBb67CcFAE0f2EeE)
7171
- [DAIFaucet](https://goerli.arbiscan.io/address/0xCEBF1e0A5921767dd97b999ed14801A3770afAfd)
72-
- [DisputeKitClassic](https://goerli.arbiscan.io/address/0x89807AeD661954080dB0ca7e8AcA72Af96E344e5)
73-
- [DisputeResolver](https://goerli.arbiscan.io/address/0x36DabdE2b4Fe2C50775835B703687193D09DF8E0)
74-
- [DisputeTemplateRegistry](https://goerli.arbiscan.io/address/0xB01eC32bB0ba461ebEA9A61A6172Aba0DDE2B640)
75-
- [HomeGatewayToGnosis](https://goerli.arbiscan.io/address/0x12633ad7bd757858ada24738a94aeeba08727f1b)
76-
- [KlerosCore](https://goerli.arbiscan.io/address/0x5a2bC1477ABE705dB4955Cda7DE064eA79D563d1)
72+
- [DisputeKitClassic: proxy](https://goerli.arbiscan.io/address/0x6394A70cADD1376FdE5C38bA331761256DDd03E2), [implementation](https://goerli.arbiscan.io/address/0x9755b94c2c8AB04dDc7d102A6F8c974f538481fb)
73+
- [DisputeResolver](https://goerli.arbiscan.io/address/0xE4af4D800Ce12149199FA6f8870cD650cD8f3164)
74+
- [DisputeTemplateRegistry: proxy](https://goerli.arbiscan.io/address/0xBf5AF2c2938B3EE689d9A4f5324F144d9a617a2A), [implementation](https://goerli.arbiscan.io/address/0x93bf43132b6805E215d3c8305232ec3A174Ef146)
75+
- [KlerosCore: proxy](https://goerli.arbiscan.io/address/0x813DCc76dbA91DD9f6bDD038aea0877FC95656bE), [implementation](https://goerli.arbiscan.io/address/0xEE08d6427F4f23E602C4114B8F2B7f6d6D3F4206)
7776
- [PNKFaucet](https://goerli.arbiscan.io/address/0x05648Ee14941630a649082e0dA5cb80D29cC9002)
7877
- [PinakionV2](https://goerli.arbiscan.io/address/0x3483FA1b87792cd5BE4100822C4eCEC8D3E531ee)
79-
- [PolicyRegistry](https://goerli.arbiscan.io/address/0xa3556bF00c4f9ea235D6D4Bcb1B1c32121C0e935)
80-
- [RandomizerRNG](https://goerli.arbiscan.io/address/0x0FE3869EA01Febb895Bc76DaB143858F84C67024)
81-
- [SortitionModule](https://goerli.arbiscan.io/address/0xc3A8621DA59B35dDCD3e01504F182D9AC9F36b5B)
78+
- [PolicyRegistry: proxy](https://goerli.arbiscan.io/address/0x0d7EeA661C1f9cB1AD389c9Df90B3beDE86a1529), [implementation](https://goerli.arbiscan.io/address/0xF9128Ae440A9d4BABc6B66f9385C5Ba6ADf11D89)
79+
- [RandomizerRNG: proxy](https://goerli.arbiscan.io/address/0xF67D956988cb11449db7aeA80E6339b95b160593), [implementation](https://goerli.arbiscan.io/address/0xc1C85d303B4995Cb543C2b449C1b3dF490d49ebE)
80+
- [SortitionModule: proxy](https://goerli.arbiscan.io/address/0xA7e5D4C3E6C593cF6A367C3A415BB8E4A065E62E), [implementation](https://goerli.arbiscan.io/address/0xA472Dfb104696E5CE82E46148c33Cd5FeE2C3b7d)
8281
- [WETH](https://goerli.arbiscan.io/address/0xbB5839497dE7e6d4ddaFde093F69abA9be782E07)
8382
- [WETHFaucet](https://goerli.arbiscan.io/address/0xD2d862B060986b25996aaeDB54813002AB791013)
8483

contracts/deploy/00-ethereum-pnk.ts

Lines changed: 3 additions & 3 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 disputeTemplate from "../test/fixtures/DisputeTemplate.simple.json";
4+
import { isSkipped } from "./utils";
45

56
enum Chains {
67
GOERLI = 5,
@@ -24,9 +25,8 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
2425
};
2526

2627
deployArbitration.tags = ["Pinakion"];
27-
deployArbitration.skip = async ({ getChainId }) => {
28-
const chainId = Number(await getChainId());
29-
return !Chains[chainId];
28+
deployArbitration.skip = async ({ network }) => {
29+
return isSkipped(network, !Chains[network.config.chainId ?? 0]);
3030
};
3131

3232
export default deployArbitration;

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import { HardhatRuntimeEnvironment } from "hardhat/types";
22
import { DeployFunction } from "hardhat-deploy/types";
33
import disputeTemplate from "../test/fixtures/DisputeTemplate.simple.json";
4-
5-
enum HomeChains {
6-
ARBITRUM_ONE = 42161,
7-
ARBITRUM_GOERLI = 421613,
8-
HARDHAT = 31337,
9-
}
4+
import { HomeChains, isSkipped } from "./utils";
5+
import { deployUpgradable } from "./utils/deployUpgradable";
106

117
const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
128
const { deployments, getNamedAccounts, getChainId } = hre;
@@ -22,9 +18,9 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
2218
"0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003"; // General court, 3 jurors
2319
const weth = await deployments.get("WETH");
2420

25-
const disputeTemplateRegistry = await deploy("DisputeTemplateRegistry", {
21+
const disputeTemplateRegistry = await deployUpgradable(hre, "DisputeTemplateRegistry", {
2622
from: deployer,
27-
args: [],
23+
args: [deployer],
2824
log: true,
2925
});
3026

@@ -50,9 +46,8 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
5046

5147
deployArbitration.tags = ["HomeArbitrable"];
5248
deployArbitration.dependencies = ["Arbitration"];
53-
deployArbitration.skip = async ({ getChainId }) => {
54-
const chainId = Number(await getChainId());
55-
return !HomeChains[chainId];
49+
deployArbitration.skip = async ({ network }) => {
50+
return isSkipped(network, !HomeChains[network.config.chainId ?? 0]);
5651
};
5752

5853
export default deployArbitration;

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

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
import { HardhatRuntimeEnvironment } from "hardhat/types";
22
import { DeployFunction } from "hardhat-deploy/types";
33
import { BigNumber } from "ethers";
4-
import getContractAddress from "../deploy-helpers/getContractAddress";
5-
6-
enum HomeChains {
7-
ARBITRUM_ONE = 42161,
8-
ARBITRUM_GOERLI = 421613,
9-
HARDHAT = 31337,
10-
}
4+
import getContractAddress from "./utils/getContractAddress";
5+
import { deployUpgradable } from "./utils/deployUpgradable";
6+
import { HomeChains, isSkipped } from "./utils";
117

128
const pnkByChain = new Map<HomeChains, string>([
139
[HomeChains.ARBITRUM_ONE, "0x330bD769382cFc6d50175903434CCC8D206DCAE5"],
@@ -56,43 +52,44 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
5652
randomizerByChain.set(HomeChains[HomeChains[chainId]], randomizerMock.address);
5753
}
5854

59-
await deploy("PolicyRegistry", {
60-
from: deployer,
61-
args: [deployer],
62-
log: true,
63-
});
55+
await deployUpgradable(hre, "PolicyRegistry", { from: deployer, args: [deployer], log: true });
6456

6557
const randomizer = randomizerByChain.get(Number(await getChainId())) ?? AddressZero;
66-
const rng = await deploy("RandomizerRNG", {
67-
skipIfAlreadyDeployed: true,
68-
from: deployer,
69-
args: [randomizer, deployer],
70-
log: true,
71-
});
58+
const rng = await deployUpgradable(hre, "RandomizerRNG", { from: deployer, args: [randomizer, deployer], log: true });
7259

73-
const disputeKit = await deploy("DisputeKitClassic", {
60+
const disputeKit = await deployUpgradable(hre, "DisputeKitClassic", {
7461
from: deployer,
7562
args: [deployer, AddressZero],
7663
log: true,
7764
});
7865

79-
const nonce = await ethers.provider.getTransactionCount(deployer);
80-
const KlerosCoreAddress = getContractAddress(deployer, nonce + 1);
81-
console.log("calculated future KlerosCore address for nonce %d: %s", nonce, KlerosCoreAddress);
66+
let klerosCoreAddress = await deployments.getOrNull("KlerosCore").then((deployment) => deployment?.address);
67+
if (!klerosCoreAddress) {
68+
const nonce = await ethers.provider.getTransactionCount(deployer);
69+
klerosCoreAddress = getContractAddress(deployer, nonce + 3); // deployed on the 4th tx (nonce+3): SortitionModule Impl tx, SortitionModule Proxy tx, KlerosCore Impl tx, KlerosCore Proxy tx
70+
console.log("calculated future KlerosCore address for nonce %d: %s", nonce + 3, klerosCoreAddress);
71+
}
8272

83-
const sortitionModule = await deploy("SortitionModule", {
73+
const sortitionModule = await deployUpgradable(hre, "SortitionModule", {
8474
from: deployer,
85-
args: [deployer, KlerosCoreAddress, 1800, 1800, rng.address, RNG_LOOKAHEAD], // minStakingTime, maxFreezingTime
75+
args: [
76+
deployer,
77+
klerosCoreAddress,
78+
1800, // minStakingTime
79+
1800, // maxFreezingTime
80+
rng.address,
81+
RNG_LOOKAHEAD,
82+
],
8683
log: true,
87-
});
84+
}); // nonce (implementation), nonce+1 (proxy)
8885

8986
const pnk = pnkByChain.get(chainId) ?? AddressZero;
9087
const dai = daiByChain.get(chainId) ?? AddressZero;
9188
const weth = wethByChain.get(chainId) ?? AddressZero;
9289
const minStake = BigNumber.from(10).pow(20).mul(2);
9390
const alpha = 10000;
9491
const feeForJuror = BigNumber.from(10).pow(17);
95-
const klerosCore = await deploy("KlerosCore", {
92+
const klerosCore = await deployUpgradable(hre, "KlerosCore", {
9693
from: deployer,
9794
args: [
9895
deployer,
@@ -106,7 +103,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
106103
sortitionModule.address,
107104
],
108105
log: true,
109-
});
106+
}); // nonce+2 (implementation), nonce+3 (proxy)
110107

111108
// execute DisputeKitClassic.changeCore() only if necessary
112109
const currentCore = await hre.ethers.getContractAt("DisputeKitClassic", disputeKit.address).then((dk) => dk.core());
@@ -124,12 +121,15 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
124121
};
125122

126123
deployArbitration.tags = ["Arbitration"];
127-
deployArbitration.skip = async ({ getChainId }) => {
128-
const chainId = Number(await getChainId());
129-
return !HomeChains[chainId];
124+
deployArbitration.skip = async ({ network }) => {
125+
return isSkipped(network, !HomeChains[network.config.chainId ?? 0]);
130126
};
131127

132-
const deployERC20AndFaucet = async (hre: HardhatRuntimeEnvironment, deployer: string, ticker: string) => {
128+
const deployERC20AndFaucet = async (
129+
hre: HardhatRuntimeEnvironment,
130+
deployer: string,
131+
ticker: string
132+
): Promise<string> => {
133133
const { deploy } = hre.deployments;
134134
const erc20 = await deploy(ticker, {
135135
from: deployer,
@@ -143,15 +143,14 @@ const deployERC20AndFaucet = async (hre: HardhatRuntimeEnvironment, deployer: st
143143
args: [erc20.address],
144144
log: true,
145145
});
146-
const funding = hre.ethers.utils.parseUnits("100000", "ether");
146+
const funding = hre.ethers.utils.parseUnits("100000");
147147
const erc20Instance = await hre.ethers.getContract(ticker);
148-
// TODO: skip if already funded
149-
await erc20Instance.balanceOf(deployer).then((balance) => {
150-
if (balance.gte(funding)) {
151-
console.log("Funding %sFaucet with %d", ticker, funding);
152-
return erc20Instance.transfer(faucet.address, funding);
153-
}
154-
});
148+
const faucetBalance = await erc20Instance.balanceOf(faucet.address);
149+
const deployerBalance = await erc20Instance.balanceOf(deployer);
150+
if (deployerBalance.gte(funding) && faucetBalance.isZero()) {
151+
console.log("Funding %sFaucet with %d", ticker, funding);
152+
await erc20Instance.transfer(faucet.address, funding);
153+
}
155154
return erc20.address;
156155
};
157156

contracts/deploy/00-home-chain-pnk-faucet.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import { HardhatRuntimeEnvironment } from "hardhat/types";
22
import { DeployFunction } from "hardhat-deploy/types";
3-
4-
enum HomeChains {
5-
ARBITRUM_ONE = 42161,
6-
ARBITRUM_GOERLI = 421613,
7-
HARDHAT = 31337,
8-
}
3+
import { HomeChains, isSkipped } from "./utils";
94

105
const pnkByChain = new Map<HomeChains, string>([
116
[HomeChains.ARBITRUM_ONE, "0x330bD769382cFc6d50175903434CCC8D206DCAE5"],
@@ -39,9 +34,8 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
3934
};
4035

4136
deployArbitration.tags = ["PnkFaucet"];
42-
deployArbitration.skip = async ({ getChainId }) => {
43-
const chainId = Number(await getChainId());
44-
return !HomeChains[chainId];
37+
deployArbitration.skip = async ({ network }) => {
38+
return isSkipped(network, !HomeChains[network.config.chainId ?? 0]);
4539
};
4640

4741
export default deployArbitration;

contracts/deploy/00-rng.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import { HardhatRuntimeEnvironment } from "hardhat/types";
22
import { DeployFunction } from "hardhat-deploy/types";
33
import { SortitionModule, RandomizerRNG } from "../typechain-types";
4-
5-
enum HomeChains {
6-
ARBITRUM_ONE = 42161,
7-
ARBITRUM_GOERLI = 421613,
8-
HARDHAT = 31337,
9-
}
4+
import { HomeChains, isSkipped } from "./utils";
105

116
const pnkByChain = new Map<HomeChains, string>([
127
[HomeChains.ARBITRUM_ONE, "0x330bD769382cFc6d50175903434CCC8D206DCAE5"],
@@ -63,9 +58,8 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
6358
};
6459

6560
deployArbitration.tags = ["RNG"];
66-
deployArbitration.skip = async ({ getChainId }) => {
67-
const chainId = Number(await getChainId());
68-
return !HomeChains[chainId];
61+
deployArbitration.skip = async ({ network }) => {
62+
return isSkipped(network, !HomeChains[network.config.chainId ?? 0]);
6963
};
7064

7165
export default deployArbitration;
Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
import { HardhatRuntimeEnvironment } from "hardhat/types";
1+
import { HardhatRuntimeEnvironment, HttpNetworkConfig } from "hardhat/types";
22
import { DeployFunction } from "hardhat-deploy/types";
3-
import getContractAddress from "../deploy-helpers/getContractAddress";
3+
import getContractAddress from "./utils/getContractAddress";
44
import { KlerosCore__factory } from "../typechain-types";
5-
6-
enum ForeignChains {
7-
ETHEREUM_MAINNET = 1,
8-
ETHEREUM_GOERLI = 5,
9-
}
5+
import { Courts, ForeignChains, isSkipped } from "./utils";
6+
import { deployUpgradable } from "./utils/deployUpgradable";
107

118
const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
129
const { ethers, deployments, getNamedAccounts, getChainId, config } = hre;
@@ -18,17 +15,13 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
1815
const chainId = Number(await getChainId());
1916
console.log("Deploying to chainId %s with deployer %s", chainId, deployer);
2017

21-
const homeNetworks = {
22-
ETHEREUM_MAINNET: config.networks.arbitrum,
23-
ETHEREUM_GOERLI: config.networks.arbitrumGoerli,
24-
HARDHAT: config.networks.localhost,
25-
};
26-
2718
// Hack to predict the deployment address on the home chain.
2819
// TODO: use deterministic deployments
29-
const homeChainProvider = new ethers.providers.JsonRpcProvider(homeNetworks[ForeignChains[chainId]].url);
20+
const network = config.networks[hre.network.name];
21+
const homeNetwork = config.networks[network.companionNetworks.home] as HttpNetworkConfig;
22+
const homeChainProvider = new ethers.providers.JsonRpcProvider(homeNetwork.url);
3023
let nonce = await homeChainProvider.getTransactionCount(deployer);
31-
nonce += 2; // HomeGatewayToEthereum deploy tx will the third tx after this on its home network, so we add two to the current nonce.
24+
nonce += 1; // HomeGatewayToEthereum Proxy deploy tx will be the 2nd tx after this on its home network, so we add 1 to the current nonce.
3225
const homeGatewayAddress = getContractAddress(deployer, nonce);
3326
console.log("Calculated future HomeGatewayToEthereum address for nonce %d: %s", nonce, homeGatewayAddress);
3427

@@ -37,7 +30,7 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
3730

3831
const homeChainId = (await homeChainProvider.getNetwork()).chainId;
3932
const homeChainIdAsBytes32 = hexZeroPad(hexlify(homeChainId), 32);
40-
await deploy("ForeignGatewayOnEthereum", {
33+
await deployUpgradable(hre, "ForeignGatewayOnEthereum", {
4134
from: deployer,
4235
contract: "ForeignGateway",
4336
args: [deployer, veaOutbox.address, homeChainIdAsBytes32, homeGatewayAddress],
@@ -49,16 +42,14 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
4942
const coreDeployment = await hre.companionNetworks.home.deployments.get("KlerosCore");
5043
const core = await KlerosCore__factory.connect(coreDeployment.address, homeChainProvider);
5144
// 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);
45+
const fee = (await core.courts(Courts.GENERAL)).feeForJuror;
46+
await execute("ForeignGatewayOnEthereum", { from: deployer, log: true }, "changeCourtJurorFee", Courts.GENERAL, fee);
5547
// TODO: set up the correct fees for the lower courts
5648
};
5749

5850
deployForeignGateway.tags = ["ForeignGatewayOnEthereum"];
59-
deployForeignGateway.skip = async ({ getChainId }) => {
60-
const chainId = Number(await getChainId());
61-
return !ForeignChains[chainId];
51+
deployForeignGateway.skip = async ({ network }) => {
52+
return isSkipped(network, !ForeignChains[network.config.chainId ?? 0]);
6253
};
6354

6455
export default deployForeignGateway;

0 commit comments

Comments
 (0)