Skip to content

Commit 64a7a9c

Browse files
committed
chore: deployment of xKlerosLiquidV2 and wrapped pnk
1 parent 51da6df commit 64a7a9c

18 files changed

+3990
-102
lines changed

contracts/README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@ Refresh the list of deployed contracts by running `./scripts/generateDeployments
1010

1111
#### Chiado
1212

13-
- [ForeignGatewayOnGnosis](https://blockscout.com/gnosis/chiado/address/0x8F1a2B8F9b04320375856580Fc6B1669Cb12a9EE)
13+
- [ArbitrableExample](https://blockscout.com/gnosis/chiado/address/0x823D972BAcBa033BFca208738847cC7135573316)
14+
- [ForeignGatewayOnGnosis](https://blockscout.com/gnosis/chiado/address/0x87142b7E9C7D026776499120D902AF8896C07894)
15+
- [SortitionSumTreeFactory](https://blockscout.com/gnosis/chiado/address/0xc7e3BF90299f6BD9FA7c3703837A9CAbB5743636)
1416
- [TokenBridge](https://blockscout.com/gnosis/chiado/address/0xbb3c86f9918C3C1d83668fA84e79E876d147fFf2)
1517
- [WETH](https://blockscout.com/gnosis/chiado/address/0x014A442480DbAD767b7615E55E271799889FA1a7)
1618
- [WETHFaucet](https://blockscout.com/gnosis/chiado/address/0x395014fddc3b12F9a78ED8E57DA162Fd77E12bE3)
19+
- [WPNKFaucet](https://blockscout.com/gnosis/chiado/address/0xcFc0b84419583ff7b32fD5139B789cE858517d4C)
20+
- [WrappedPinakion](https://blockscout.com/gnosis/chiado/address/0x04Fb43F2Ce076867b5ba38750Ecb2cc6BDe78D61)
21+
- [xKlerosLiquidV2](https://blockscout.com/gnosis/chiado/address/0xf637A0a4415CCFB97407846486b6be663d3C33ef)
1722

1823
#### Goerli
1924

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
2727
// fallback to hardhat node signers on local network
2828
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
2929
const chainId = Number(await getChainId());
30-
console.log("deploying to %s with deployer %s", HomeChains[chainId], deployer);
30+
console.log("Deploying to %s with deployer %s", HomeChains[chainId], deployer);
3131

3232
if (chainId === HomeChains.HARDHAT) {
3333
pnkByChain.set(
@@ -79,6 +79,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
7979
const minStake = BigNumber.from(10).pow(20).mul(2);
8080
const alpha = 10000;
8181
const feeForJuror = BigNumber.from(10).pow(17);
82+
const sortitionSumTreeK = 3;
8283
const klerosCore = await deploy("KlerosCore", {
8384
from: deployer,
8485
libraries: {
@@ -93,7 +94,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
9394
false,
9495
[minStake, alpha, feeForJuror, 3], // minStake, alpha, feeForJuror, jurorsForCourtJump
9596
[0, 0, 0, 0], // evidencePeriod, commitPeriod, votePeriod, appealPeriod
96-
3,
97+
sortitionSumTreeK,
9798
],
9899
log: true,
99100
});

contracts/deploy/00-rng.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
2828
// fallback to hardhat node signers on local network
2929
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
3030
const chainId = Number(await getChainId());
31-
console.log("deploying to %s with deployer %s", HomeChains[chainId], deployer);
31+
console.log("Deploying to %s with deployer %s", HomeChains[chainId], deployer);
3232

3333
if (chainId === HomeChains.HARDHAT) {
3434
pnkByChain.set(

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { parseEther } from "ethers/lib/utils";
21
import { HardhatRuntimeEnvironment } from "hardhat/types";
32
import { DeployFunction } from "hardhat-deploy/types";
43
import getContractAddress from "../deploy-helpers/getContractAddress";
@@ -16,7 +15,7 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
1615
// fallback to hardhat node signers on local network
1716
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
1817
const chainId = Number(await getChainId());
19-
console.log("deploying to chainId %s with deployer %s", chainId, deployer);
18+
console.log("Deploying to chainId %s with deployer %s", chainId, deployer);
2019

2120
const homeNetworks = {
2221
ETHEREUM_MAINNET: config.networks.arbitrum,
@@ -32,7 +31,7 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
3231
const homeChainId = (await homeChainProvider.getNetwork()).chainId;
3332
const homeChainIdAsBytes32 = hexZeroPad(hexlify(homeChainId), 32);
3433
const homeGatewayAddress = getContractAddress(deployer, nonce);
35-
console.log("calculated future HomeGatewayToEthereum address for nonce %d: %s", nonce, homeGatewayAddress);
34+
console.log("Calculated future HomeGatewayToEthereum address for nonce %d: %s", nonce, homeGatewayAddress);
3635

3736
const veaReceiver = await deployments.get("FastBridgeReceiverOnEthereum");
3837

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

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { parseEther } from "ethers/lib/utils";
1+
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";
@@ -13,6 +13,8 @@ const wethByChain = new Map<ForeignChains, string>([
1313
[ForeignChains.GNOSIS_MAINNET, "0x6A023CCd1ff6F2045C3309768eAd9E68F978f6e1"],
1414
]);
1515

16+
const ONE_GWEI = parseUnits("1", "gwei");
17+
1618
const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
1719
const { ethers, deployments, getNamedAccounts, getChainId, config } = hre;
1820
const { deploy, execute } = deployments;
@@ -21,7 +23,7 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
2123
// fallback to hardhat node signers on local network
2224
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
2325
const chainId = Number(await getChainId());
24-
console.log("deploying to chainId %s with deployer %s", chainId, deployer);
26+
console.log("Deploying to chainId %s with deployer %s", chainId, deployer);
2527

2628
const homeNetworks = {
2729
GNOSIS_MAINNET: config.networks.arbitrum,
@@ -32,14 +34,12 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
3234
// Hack to predict the deployment address on the home chain.
3335
// TODO: use deterministic deployments
3436
const homeChainProvider = new ethers.providers.JsonRpcProvider(homeNetworks[ForeignChains[chainId]].url);
35-
let nonce = await homeChainProvider.getTransactionCount(deployer);
37+
const nonce = await homeChainProvider.getTransactionCount(deployer);
3638
const homeGatewayAddress = getContractAddress(deployer, nonce); // HomeGateway deploy tx will be the next tx home network
37-
console.log("calculated future HomeGatewayToEthereum address for nonce %d: %s", nonce, homeGatewayAddress);
39+
console.log("Calculated future HomeGatewayToEthereum address for nonce %d: %s", nonce, homeGatewayAddress);
3840

3941
const veaReceiver = await deployments.get("FastBridgeReceiverOnGnosis");
40-
console.log("using FastBridgeReceiverOnGnosis at %s", veaReceiver.address);
41-
42-
const ONE_GWEI = ethers.utils.parseUnits("1", "gwei");
42+
console.log("Using FastBridgeReceiverOnGnosis at %s", veaReceiver.address);
4343

4444
if (!wethByChain.get(chainId)) {
4545
const weth = await deploy("WETH", {
@@ -75,13 +75,13 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
7575
});
7676

7777
// 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-
// );
78+
await execute(
79+
"ForeignGatewayOnGnosis",
80+
{ from: deployer, log: true },
81+
"changeCourtJurorFee",
82+
0,
83+
ethers.utils.parseEther("0.00001")
84+
);
8585
};
8686

8787
deployForeignGateway.tags = ["ForeignGatewayOnGnosis"];

contracts/deploy/02-home-gateway-to-ethereum.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
1616
// fallback to hardhat node signers on local network
1717
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
1818
const chainId = Number(await getChainId());
19-
console.log("deploying to chainId %s with deployer %s", chainId, deployer);
19+
console.log("Deploying to chainId %s with deployer %s", chainId, deployer);
2020

2121
const veaSender = await deployments.get("FastBridgeSenderToEthereum");
2222
const klerosCore = await deployments.get("KlerosCore");

contracts/deploy/03-vea-mock.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
1414

1515
// fallback to hardhat node signers on local network
1616
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
17-
console.log("deploying to chainId %s with deployer %s", HARDHAT_NETWORK, deployer);
17+
console.log("Deploying to chainId %s with deployer %s", HARDHAT_NETWORK, deployer);
1818

1919
const klerosCore = await deployments.get("KlerosCore");
2020

@@ -25,7 +25,7 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
2525

2626
const nonce = await ethers.provider.getTransactionCount(deployer);
2727
const homeGatewayAddress = getContractAddress(deployer, nonce + 1);
28-
console.log("calculated future HomeGatewayToEthereum address for nonce %d: %s", nonce, homeGatewayAddress);
28+
console.log("Calculated future HomeGatewayToEthereum address for nonce %d: %s", nonce, homeGatewayAddress);
2929

3030
const homeChainIdAsBytes32 = hexZeroPad(hexlify(HARDHAT_NETWORK), 32);
3131
const foreignGateway = await deploy("ForeignGatewayOnEthereum", {

contracts/deploy/04-klerosliquid-to-v2-gnosis.ts

+104-67
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,148 @@
1-
import { parseEther } from "ethers/lib/utils";
1+
import { parseUnits, parseEther } from "ethers/lib/utils";
22
import { HardhatRuntimeEnvironment } from "hardhat/types";
33
import { DeployFunction } from "hardhat-deploy/types";
4-
import getContractAddress from "../deploy-helpers/getContractAddress";
5-
import { util } from "chai";
6-
import { rng } from "../typechain-types/src";
74

85
enum ForeignChains {
96
GNOSIS_MAINNET = 100,
107
GNOSIS_CHIADO = 10200,
118
HARDHAT = 31337,
129
}
1310

14-
const wethByChain = new Map<ForeignChains, string>([
15-
[ForeignChains.GNOSIS_MAINNET, "0x6A023CCd1ff6F2045C3309768eAd9E68F978f6e1"],
11+
const wrappedPNKByChain = new Map<ForeignChains, string>([
12+
[ForeignChains.GNOSIS_MAINNET, "0xcb3231aBA3b451343e0Fddfc45883c842f223846"],
1613
]);
1714

18-
const xPinakionByChain = new Map<ForeignChains, string>([
19-
[ForeignChains.GNOSIS_MAINNET, "0x37b60f4E9A31A64cCc0024dce7D0fD07eAA0F7B3"],
20-
[ForeignChains.GNOSIS_CHIADO, "0x00"],
21-
]);
22-
23-
const tokenBridgeByChain = new Map<ForeignChains, string>([
24-
[ForeignChains.GNOSIS_MAINNET, "0xf6A78083ca3e2a662D6dd1703c939c8aCE2e268d"],
25-
[ForeignChains.GNOSIS_CHIADO, "0xbb3c86f9918C3C1d83668fA84e79E876d147fFf2"],
26-
]);
15+
const ONE_GWEI = parseUnits("1", "gwei");
2716

2817
const deployKlerosLiquid: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
29-
const { ethers, deployments, getNamedAccounts, getChainId, config } = hre;
18+
const { ethers, deployments, getNamedAccounts, getChainId } = hre;
3019
const { deploy, execute } = deployments;
31-
const { hexZeroPad, hexlify } = ethers.utils;
3220

3321
// fallback to hardhat node signers on local network
3422
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
3523
const chainId = Number(await getChainId());
36-
console.log("deploying to chainId %s with deployer %s", chainId, deployer);
37-
38-
const homeNetworks = {
39-
1: config.networks.arbitrum,
40-
5: config.networks.arbitrumGoerli,
41-
};
42-
43-
// Hack to predict the deployment address on the home chain.
44-
// TODO: use deterministic deployments
45-
const homeChainProvider = new ethers.providers.JsonRpcProvider(homeNetworks[chainId].url);
46-
let nonce = await homeChainProvider.getTransactionCount(deployer);
47-
nonce += 2; // HomeGatewayToEthereum deploy tx will the third tx after this on its home network, so we add two to the current nonce.
48-
const homeChainId = (await homeChainProvider.getNetwork()).chainId;
49-
const homeChainIdAsBytes32 = hexZeroPad(hexlify(homeChainId), 32);
50-
const homeGatewayAddress = getContractAddress(deployer, nonce);
51-
console.log("calculated future HomeGatewayToEthereum address for nonce %d: %s", nonce, homeGatewayAddress);
52-
53-
const veaReceiver = await deployments.get("FastBridgeReceiverOnGnosis");
54-
55-
// const wEth = await deployments.get("WETH");
56-
const wEth = wethByChain[chainId];
57-
58-
// const xPnk = await deployments.get("WPNK");
59-
const xPnk = xPinakionByChain[chainId];
60-
61-
const tokenBridge = tokenBridgeByChain[chainId];
62-
const rnGenerator = ethers.constants.AddressZero;
63-
64-
// TODO: deploy mocks for xPinakion and tokenBridge for Hardhat network
24+
console.log("Deploying to chainId %s with deployer %s", chainId, deployer);
25+
26+
if (!wrappedPNKByChain.get(chainId)) {
27+
const wPnk = await deploy("WrappedPinakion", {
28+
from: deployer,
29+
log: true,
30+
maxFeePerGas: ONE_GWEI,
31+
maxPriorityFeePerGas: ONE_GWEI,
32+
});
33+
34+
wrappedPNKByChain.set(ForeignChains[ForeignChains[chainId]], wPnk.address);
35+
36+
await deploy("WPNKFaucet", {
37+
from: deployer,
38+
contract: "Faucet",
39+
args: [wPnk.address],
40+
log: true,
41+
maxFeePerGas: ONE_GWEI,
42+
maxPriorityFeePerGas: ONE_GWEI,
43+
});
44+
}
45+
46+
const wPnkAddress = wrappedPNKByChain.get(ForeignChains[ForeignChains[chainId]]);
47+
const rng = ethers.constants.AddressZero;
48+
const minStakingTime = 99999999;
49+
const maxFreezingTime = 0;
50+
const minStake = parseEther("9999999");
51+
const alpha = 10000;
52+
const feeForJuror = 0;
53+
const jurorsForCourtJump = 9999999;
54+
const sortitionSumTreeK = 3;
55+
const foreignGateway = await deployments.get("ForeignGatewayOnGnosis");
56+
const weth = await deployments.get("WETH");
57+
58+
console.log(
59+
"Using: \nwPNK at %s, \nForeignGateway at %s, \nWETH at %s",
60+
wPnkAddress,
61+
foreignGateway.address,
62+
weth.address
63+
);
6564

66-
const wPnk = await deploy("WrappedPinakion", {
65+
const sortitionSumTreeLibrary = await deploy("SortitionSumTreeFactory", {
6766
from: deployer,
6867
log: true,
68+
maxFeePerGas: ONE_GWEI,
69+
maxPriorityFeePerGas: ONE_GWEI,
6970
});
7071

71-
await execute(
72-
"WrappedPinakion",
73-
{ from: deployer, log: true },
74-
"initialize",
75-
"Staking PNK on xDai",
76-
"stPNK",
77-
xPnk,
78-
tokenBridge
79-
);
80-
81-
const xKlerosLiquidV2 = await deploy("xKlerosLiquidV2", {
72+
await deploy("xKlerosLiquidV2", {
8273
from: deployer,
8374
log: true,
75+
libraries: {
76+
SortitionSumTreeFactory: sortitionSumTreeLibrary.address,
77+
},
78+
maxFeePerGas: ONE_GWEI,
79+
maxPriorityFeePerGas: ONE_GWEI,
8480
});
8581

8682
await execute(
8783
"xKlerosLiquidV2",
88-
{ from: deployer, log: true },
84+
{
85+
from: deployer,
86+
log: true,
87+
maxFeePerGas: ONE_GWEI,
88+
maxPriorityFeePerGas: ONE_GWEI,
89+
},
8990
"initialize",
9091
deployer,
91-
wPnk,
92-
rnGenerator,
93-
99999999,
94-
0,
92+
wPnkAddress,
93+
rng,
94+
minStakingTime,
95+
maxFreezingTime,
9596
false,
96-
[999999999, 0, 0, 9999999],
97-
[]
97+
[minStake, alpha, feeForJuror, jurorsForCourtJump], // minStake, alpha, feeForJuror, jurorsForCourtJump
98+
[0, 0, 0, 0], // evidencePeriod, commitPeriod, votePeriod, appealPeriod
99+
sortitionSumTreeK,
100+
foreignGateway.address,
101+
weth.address
98102
);
99103

100-
const metaEvidenceUri = `https://raw.githubusercontent.com/kleros/kleros-v2/master/contracts/deployments/${hre.network.name}/MetaEvidence_ArbitrableExample.json`;
101-
104+
const metaEvidenceUri = "INIT ME";
102105
await deploy("ArbitrableExample", {
103106
from: deployer,
104107
args: [foreignGateway.address, metaEvidenceUri],
105108
log: true,
109+
maxFeePerGas: ONE_GWEI,
110+
maxPriorityFeePerGas: ONE_GWEI,
106111
});
107112
};
108113

114+
// TODO: mock deployment on the hardhat network
115+
// const xPinakionByChain = new Map<ForeignChains, string>([
116+
// [ForeignChains.GNOSIS_MAINNET, "0x37b60f4E9A31A64cCc0024dce7D0fD07eAA0F7B3"],
117+
// [ForeignChains.GNOSIS_CHIADO, "0x00"],
118+
// ]);
119+
// const tokenBridgeByChain = new Map<ForeignChains, string>([
120+
// [ForeignChains.GNOSIS_MAINNET, "0xf6A78083ca3e2a662D6dd1703c939c8aCE2e268d"],
121+
// [ForeignChains.GNOSIS_CHIADO, "0xbb3c86f9918C3C1d83668fA84e79E876d147fFf2"],
122+
// ]);
123+
// const hardhatDeployer = () => {
124+
// // TODO: deploy mocks for xPinakion and tokenBridge for Hardhat network
125+
// const wEth = await deployments.get("WETH");
126+
// const wEth = wethByChain[chainId];
127+
// // const xPnk = await deployments.get("WPNK");
128+
// const xPnk = xPinakionByChain[chainId];
129+
// const tokenBridge = tokenBridgeByChain[chainId];
130+
// const wPnk = await deploy("WrappedPinakion", {
131+
// from: deployer,
132+
// log: true,
133+
// });
134+
135+
// await execute(
136+
// "WrappedPinakion",
137+
// { from: deployer, log: true },
138+
// "initialize",
139+
// "Staking PNK on xDai",
140+
// "stPNK",
141+
// xPnk,
142+
// tokenBridge
143+
// );
144+
// };
145+
109146
deployKlerosLiquid.tags = ["KlerosLiquidOnGnosis"];
110147
deployKlerosLiquid.skip = async ({ getChainId }) => {
111148
const chainId = Number(await getChainId());

0 commit comments

Comments
 (0)