Skip to content

Commit f14971b

Browse files
committed
chore: gateways deployment to ArbitrumGoerli and Chiado
1 parent 9875d89 commit f14971b

19 files changed

+1946
-58
lines changed

contracts/README.md

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ The ones below are optional:
8282

8383
- `ETHERSCAN_API_KEY`: to verify the source of the newly deployed contracts on **Etherscan**.
8484
- `ARBISCAN_API_KEY`: to verify the source of the newly deployed contracts on **Arbitrum**.
85+
- `GNOSISSCAN_API_KEY`: to verify the source of the newly deployed contracts on **Gnosis chain**.
8586

8687
#### 1. Update the Constructor Parameters (optional)
8788

@@ -100,20 +101,25 @@ yarn hardhat node --tags nothing
100101
**Shell 2: the deploy script**
101102

102103
```bash
103-
yarn deploy --network localhost --tags <Arbitration|VeaMock>
104+
yarn deploy --network localhost --tags <Arbitration|VeaMock|ForeignGatewayOnEthereum|HomeGateway>
104105
```
105106

106107
#### 3. Deploy to Public Testnets
107108

108109
```bash
110+
# ArbitrumGoerli to Chiado
111+
yarn deploy --network arbitrumGoerli --tags Arbitration
112+
yarn deploy --network chiado --tags ForeignGatewayOnGnosis
113+
yarn deploy --network chiado --tags KlerosLiquidOnGnosis
114+
yarn deploy --network arbitrumGoerli --tags HomeGatewayToGnosis
115+
109116
# Goerli
110117
yarn deploy --network arbitrumGoerli --tags Arbitration
111-
yarn deploy --network goerli --tags ForeignGateway
112-
yarn deploy --network arbitrumGoerli --tags HomeGateway
118+
yarn deploy --network goerli --tags ForeignGatewayOnEthereum
119+
yarn deploy --network arbitrumGoerli --tags HomeGatewayToEthereum
113120
```
114121

115-
The deployed addresses should be output to the screen after the deployment is complete.
116-
If you miss that, you can always go to the `deployments/<network>` directory and look for the respective file.
122+
The deployed addresses should be displayed to the screen after the deployment is complete. If you missed them, you can always go to the `deployments/<network>` directory and look for the respective file.
117123

118124
#### Running Test Fixtures
119125

@@ -134,7 +140,7 @@ yarn test --network localhost
134140
This must be done for each network separately.
135141

136142
```bash
137-
yarn etherscan-verify --network <arbitrumGoerli|arbitrumRinkeby|arbitrum|goerli|rinkeby|mainnet>
143+
yarn etherscan-verify --network <arbitrumGoerli|arbitrum|chiado|gnosischain|goerli|mainnet>
138144
```
139145

140146
## Ad-hoc procedures
@@ -153,7 +159,7 @@ done
153159

154160
#### 2/ Import the data to V2 - Local Network
155161

156-
:warning: This script populates only from `*.mainnet.json`, but not from `*.gnosischain.json` at this time.
162+
:warning: By default this script populates from `*.mainnet.json`. To populate from `*.gnosischain.json`, set the variable `USE_GNOSIS` to true inside [scripts/populateCourts.ts](scripts/populateCourts.ts).
157163

158164
:warning: It is possible to switch to testnet-friendly court parameters by setting the variable `TESTING_PARAMETERS` to true inside [scripts/populateCourts.ts](scripts/populateCourts.ts).
159165

@@ -177,6 +183,20 @@ yarn hardhat run scripts/populatePolicyRegistry.ts --network arbitrumGoerli
177183
yarn hardhat run scripts/populateCourts.ts --network arbitrumGoerli
178184
```
179185

186+
### Generate deployment artifacts for existing contracts
187+
188+
#### Usage
189+
190+
```bash
191+
scripts/generateDeploymentArtifact.sh <network> <address>
192+
```
193+
194+
#### Example: WETH on Gnosis chain
195+
196+
```bash
197+
scripts/generateDeploymentArtifact.sh gnosischain 0xf8d1677c8a0c961938bf2f9adc3f3cfda759a9d9 > deployments/gnosischain/WETH.json
198+
```
199+
180200
### Push the contracts to a Tenderly project
181201

182202
Ensure that your `$TENDERLY_PROJECT` and `$TENDERLY_USERNAME` is set correctly in `.env`.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
111111
});
112112
};
113113

114-
deployArbitration.tags = ["HomeChain", "Arbitration"];
114+
deployArbitration.tags = ["Arbitration"];
115115
deployArbitration.skip = async ({ getChainId }) => {
116116
const chainId = Number(await getChainId());
117117
return !HomeChains[chainId];

contracts/deploy/00-rng.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
6363
await disputeKit.changeRandomNumberGenerator(rng.address, RNG_LOOKAHEAD);
6464
};
6565

66-
deployArbitration.tags = ["HomeChain", "RNG"];
66+
deployArbitration.tags = ["RNG"];
6767
deployArbitration.skip = async ({ getChainId }) => {
6868
const chainId = Number(await getChainId());
6969
return !HomeChains[chainId];

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
1919
console.log("deploying to chainId %s with deployer %s", chainId, deployer);
2020

2121
const homeNetworks = {
22-
1: config.networks.arbitrum,
23-
5: config.networks.arbitrumGoerli,
22+
ETHEREUM_MAINNET: config.networks.arbitrum,
23+
ETHEREUM_GOERLI: config.networks.arbitrumGoerli,
24+
HARDHAT: config.networks.localhost,
2425
};
2526

2627
// Hack to predict the deployment address on the home chain.
2728
// TODO: use deterministic deployments
28-
const homeChainProvider = new ethers.providers.JsonRpcProvider(homeNetworks[chainId].url);
29+
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.
3132
const homeChainId = (await homeChainProvider.getNetwork()).chainId;
@@ -60,7 +61,7 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
6061
});
6162
};
6263

63-
deployForeignGateway.tags = ["ForeignChain", "ForeignGateway"];
64+
deployForeignGateway.tags = ["ForeignGatewayOnEthereum"];
6465
deployForeignGateway.skip = async ({ getChainId }) => {
6566
const chainId = Number(await getChainId());
6667
return !ForeignChains[chainId];

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

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,56 +24,67 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
2424
console.log("deploying to chainId %s with deployer %s", chainId, deployer);
2525

2626
const homeNetworks = {
27-
1: config.networks.arbitrum,
28-
5: config.networks.arbitrumGoerli,
27+
GNOSIS_MAINNET: config.networks.arbitrum,
28+
GNOSIS_CHIADO: config.networks.arbitrumGoerli,
29+
HARDHAT: config.networks.localhost,
2930
};
3031

3132
// Hack to predict the deployment address on the home chain.
3233
// TODO: use deterministic deployments
33-
const homeChainProvider = new ethers.providers.JsonRpcProvider(homeNetworks[chainId].url);
34+
const homeChainProvider = new ethers.providers.JsonRpcProvider(homeNetworks[ForeignChains[chainId]].url);
3435
let nonce = await homeChainProvider.getTransactionCount(deployer);
35-
nonce += 2; // HomeGatewayToEthereum deploy tx will the third tx after this on its home network, so we add two to the current nonce.
36-
const homeChainId = (await homeChainProvider.getNetwork()).chainId;
37-
const homeChainIdAsBytes32 = hexZeroPad(hexlify(homeChainId), 32);
38-
const homeGatewayAddress = getContractAddress(deployer, nonce);
36+
const homeGatewayAddress = getContractAddress(deployer, nonce); // HomeGateway deploy tx will be the next tx home network
3937
console.log("calculated future HomeGatewayToEthereum address for nonce %d: %s", nonce, homeGatewayAddress);
4038

4139
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");
4243

4344
if (!wethByChain.get(chainId)) {
4445
const weth = await deploy("WETH", {
4546
from: deployer,
4647
log: true,
48+
maxFeePerGas: ONE_GWEI,
49+
maxPriorityFeePerGas: ONE_GWEI,
4750
});
4851

4952
wethByChain.set(ForeignChains[ForeignChains[chainId]], weth.address);
5053

5154
await deploy("WETHFaucet", {
5255
from: deployer,
5356
contract: "Faucet",
54-
args: [weth],
57+
args: [weth.address],
5558
log: true,
59+
maxFeePerGas: ONE_GWEI,
60+
maxPriorityFeePerGas: ONE_GWEI,
5661
});
5762
}
5863

59-
const foreignGateway = await deploy("xForeignGateway", {
64+
const wethAddress = wethByChain.get(ForeignChains[ForeignChains[chainId]]);
65+
const homeChainId = (await homeChainProvider.getNetwork()).chainId;
66+
const homeChainIdAsBytes32 = hexZeroPad(hexlify(homeChainId), 32);
67+
68+
await deploy("ForeignGatewayOnGnosis", {
6069
from: deployer,
61-
contract: "xForeignGateway",
62-
args: [deployer, veaReceiver.address, homeGatewayAddress, homeChainIdAsBytes32, wethByChain[chainId]],
63-
gasLimit: 4000000,
70+
contract: "ForeignGatewayOnGnosis",
71+
args: [deployer, veaReceiver.address, homeGatewayAddress, homeChainIdAsBytes32, wethAddress],
6472
log: true,
73+
maxFeePerGas: ONE_GWEI,
74+
maxPriorityFeePerGas: ONE_GWEI,
6575
});
6676

67-
await execute(
68-
"xForeignGateway",
69-
{ from: deployer, log: true },
70-
"changeCourtJurorFee",
71-
0,
72-
ethers.utils.parseEther("0.00001") // TODO: fix this from xKlerosLiquid xDAI -> ETH amount
73-
);
77+
// 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+
// );
7485
};
7586

76-
deployForeignGateway.tags = ["ForeignChain", "ForeignGatewayOnGnosis"];
87+
deployForeignGateway.tags = ["ForeignGatewayOnGnosis"];
7788
deployForeignGateway.skip = async ({ getChainId }) => {
7889
const chainId = Number(await getChainId());
7990
return !ForeignChains[chainId];

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
1818
const chainId = Number(await getChainId());
1919
console.log("deploying to chainId %s with deployer %s", chainId, deployer);
2020

21-
const veaSender = await deployments.get("FastBridgeSender");
21+
const veaSender = await deployments.get("FastBridgeSenderToEthereum");
2222
const klerosCore = await deployments.get("KlerosCore");
2323

24-
const foreignGateway = await hre.companionNetworks.foreign.deployments.get("ForeignGatewayOnEthereum");
25-
const foreignChainId = Number(await hre.companionNetworks.foreign.getChainId());
24+
const foreignGateway = await hre.companionNetworks.foreignGoerli.deployments.get("ForeignGatewayOnEthereum");
25+
const foreignChainId = Number(await hre.companionNetworks.foreignGoerli.getChainId());
26+
const foreignChainName = await hre.companionNetworks.foreignGoerli.deployments.getNetworkName();
27+
console.log("Using ForeignGateway %s on chainId %s (%s)", foreignGateway.address, foreignChainId, foreignChainName);
28+
2629
await deploy("HomeGatewayToEthereum", {
2730
from: deployer,
2831
contract: "HomeGateway",
@@ -31,7 +34,7 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
3134
}); // nonce+0
3235
};
3336

34-
deployHomeGateway.tags = ["HomeChain", "HomeGateway"];
37+
deployHomeGateway.tags = ["HomeGatewayToEthereum"];
3538
deployHomeGateway.skip = async ({ getChainId }) => {
3639
const chainId = Number(await getChainId());
3740
return !HomeChains[chainId];
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { HardhatRuntimeEnvironment } from "hardhat/types";
2+
import { DeployFunction } from "hardhat-deploy/types";
3+
4+
enum HomeChains {
5+
ARBITRUM_ONE = 42161,
6+
ARBITRUM_GOERLI = 421613,
7+
}
8+
9+
// TODO: use deterministic deployments
10+
11+
const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
12+
const { deployments, getNamedAccounts, getChainId } = hre;
13+
const { deploy } = deployments;
14+
15+
// fallback to hardhat node signers on local network
16+
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
17+
const chainId = Number(await getChainId());
18+
console.log("Deploying to chainId %s with deployer %s", chainId, deployer);
19+
20+
const veaSender = await deployments.get("FastBridgeSenderToGnosis");
21+
const klerosCore = await deployments.get("KlerosCore");
22+
23+
const foreignGateway = await hre.companionNetworks.foreignChiado.deployments.get("ForeignGatewayOnGnosis");
24+
const foreignChainId = Number(await hre.companionNetworks.foreignChiado.getChainId());
25+
const foreignChainName = await hre.companionNetworks.foreignChiado.deployments.getNetworkName();
26+
console.log("Using ForeignGateway %s on chainId %s (%s)", foreignGateway.address, foreignChainId, foreignChainName);
27+
28+
await deploy("HomeGatewayToGnosis", {
29+
from: deployer,
30+
contract: "HomeGateway",
31+
args: [deployer, klerosCore.address, veaSender.address, foreignGateway.address, foreignChainId],
32+
log: true,
33+
}); // nonce+0
34+
};
35+
36+
deployHomeGateway.tags = ["HomeGatewayToGnosis"];
37+
deployHomeGateway.skip = async ({ getChainId }) => {
38+
const chainId = Number(await getChainId());
39+
return !HomeChains[chainId];
40+
};
41+
42+
export default deployHomeGateway;

contracts/deploy/03-vea-mock.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
6161
});
6262
};
6363

64-
deployHomeGateway.tags = ["HomeChain", "VeaMock"];
64+
deployHomeGateway.tags = ["VeaMock"];
6565
deployHomeGateway.skip = async ({ getChainId }) => HARDHAT_NETWORK !== Number(await getChainId());
6666

6767
export default deployHomeGateway;

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const tokenBridgeByChain = new Map<ForeignChains, string>([
2525
[ForeignChains.GNOSIS_CHIADO, "0xbb3c86f9918C3C1d83668fA84e79E876d147fFf2"],
2626
]);
2727

28-
const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
28+
const deployKlerosLiquid: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
2929
const { ethers, deployments, getNamedAccounts, getChainId, config } = hre;
3030
const { deploy, execute } = deployments;
3131
const { hexZeroPad, hexlify } = ethers.utils;
@@ -78,13 +78,13 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
7878
tokenBridge
7979
);
8080

81-
const xKlerosLiquidToV2 = await deploy("xKlerosLiquidToV2", {
81+
const xKlerosLiquidV2 = await deploy("xKlerosLiquidV2", {
8282
from: deployer,
8383
log: true,
8484
});
8585

8686
await execute(
87-
"xKlerosLiquidToV2",
87+
"xKlerosLiquidV2",
8888
{ from: deployer, log: true },
8989
"initialize",
9090
deployer,
@@ -106,10 +106,10 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
106106
});
107107
};
108108

109-
deployForeignGateway.tags = ["ForeignChain", "KlerosLiquidOnGnosis"];
110-
deployForeignGateway.skip = async ({ getChainId }) => {
109+
deployKlerosLiquid.tags = ["KlerosLiquidOnGnosis"];
110+
deployKlerosLiquid.skip = async ({ getChainId }) => {
111111
const chainId = Number(await getChainId());
112112
return !ForeignChains[chainId];
113113
};
114114

115-
export default deployForeignGateway;
115+
export default deployKlerosLiquid;

0 commit comments

Comments
 (0)