Skip to content

Commit 4b5aff4

Browse files
committed
Merge remote-tracking branch 'origin/master' into feat/arbitration-phases
2 parents c8bd206 + 61b5066 commit 4b5aff4

File tree

15 files changed

+1605
-680
lines changed

15 files changed

+1605
-680
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ tags
173173
.history
174174
.ionide
175175

176+
# Ignore the .DS_Store file
177+
.DS_Store
178+
176179
# Support for Project snippet scope
177180
!.vscode/*.code-snippets
178181

contracts/deploy/01-foreign-chain.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,19 @@ const paramsByChainId = {
1515
claimDeposit: parseEther("0.1"),
1616
challengeDuration: 86400, // 1 day
1717
homeChainId: 42161,
18+
arbitrumInbox: "0x4Dbd4fc535Ac27206064B68FfCf827b0A60BAB3f",
1819
},
1920
4: {
2021
claimDeposit: parseEther("0.1"),
2122
challengeDuration: 120, // 2 min
2223
homeChainId: 421611,
24+
arbitrumInbox: "0x578BAde599406A8fE3d24Fd7f7211c0911F5B29e",
2325
},
2426
31337: {
2527
claimDeposit: parseEther("0.1"),
2628
challengeDuration: 120, // 2 min
2729
homeChainId: 31337,
30+
arbitrumInbox: "0x00",
2831
},
2932
};
3033

@@ -50,26 +53,35 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
5053
let nonce;
5154
if (chainId === ForeignChains.HARDHAT) {
5255
nonce = await ethers.provider.getTransactionCount(deployer);
53-
nonce += 4; // HomeGatewayToEthereum deploy tx will be the 6th after this, same network for both home/foreign.
56+
nonce += 5; // HomeGatewayToEthereum deploy tx will be the 6th after this, same network for both home/foreign.
5457
} else {
5558
const homeChainProvider = new providers.JsonRpcProvider(homeNetworks[chainId].url);
5659
nonce = await homeChainProvider.getTransactionCount(deployer);
5760
nonce += 1; // HomeGatewayToEthereum deploy tx will the third tx after this on its home network, so we add two to the current nonce.
5861
}
59-
const { claimDeposit, challengeDuration, homeChainId } = paramsByChainId[chainId];
62+
const { claimDeposit, challengeDuration, homeChainId, arbitrumInbox } = paramsByChainId[chainId];
6063
const challengeDeposit = claimDeposit;
6164
const bridgeAlpha = 5000;
6265
const homeChainIdAsBytes32 = hexZeroPad(homeChainId, 32);
6366

6467
const homeGatewayAddress = getContractAddress(deployer, nonce);
6568
console.log("calculated future HomeGatewayToEthereum address for nonce %d: %s", nonce, homeGatewayAddress);
69+
nonce -= 1;
70+
71+
const fastBridgeSenderAddress = getContractAddress(deployer, nonce);
72+
console.log("calculated future FastSender for nonce %d: %s", nonce, fastBridgeSenderAddress);
73+
74+
nonce += 5;
75+
76+
const inboxAddress = chainId === ForeignChains.HARDHAT ? getContractAddress(deployer, nonce) : arbitrumInbox;
77+
console.log("calculated future inboxAddress for nonce %d: %s", nonce, inboxAddress);
6678

6779
const fastBridgeReceiver = await deploy("FastBridgeReceiverOnEthereum", {
6880
from: deployer,
6981
args: [
7082
deployer,
71-
ethers.constants.AddressZero, // should be safeBridgeSender
72-
ethers.constants.AddressZero, // should be Arbitrum Inbox
83+
fastBridgeSenderAddress,
84+
inboxAddress,
7385
claimDeposit,
7486
challengeDeposit,
7587
challengeDuration,
@@ -87,12 +99,14 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
8799
homeGatewayAddress,
88100
homeChainIdAsBytes32,
89101
],
102+
gasLimit: 4000000,
90103
log: true,
91104
});
92105

93106
const metaEvidenceUri =
94107
"https://raw.githubusercontent.com/kleros/kleros-v2/master/contracts/deployments/rinkeby/MetaEvidence_ArbitrableExample.json";
95-
const arbitrable = await deploy("ArbitrableExample", {
108+
109+
await deploy("ArbitrableExample", {
96110
from: deployer,
97111
args: [foreignGateway.address, metaEvidenceUri],
98112
log: true,

contracts/deploy/02-home-chain.ts

Lines changed: 97 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { HardhatRuntimeEnvironment } from "hardhat/types";
22
import { DeployFunction } from "hardhat-deploy/types";
3-
import { Address } from "ethereumjs-util";
43
import { ethers } from "hardhat";
54

65
const HOME_CHAIN_IDS = [42161, 421611, 31337]; // ArbOne, ArbRinkeby, Hardhat
76

7+
// TODO: use deterministic deployments
8+
89
const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
910
const { deployments, getNamedAccounts, getChainId } = hre;
1011
const { deploy, execute } = deployments;
@@ -14,35 +15,101 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
1415
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
1516
console.log("deployer: %s", deployer);
1617

17-
// The object below is not available when launching the hardhat node.
18-
// TODO: use deterministic deployments
19-
const fastBridgeReceiver =
20-
chainId === 31337
21-
? await deployments.get("FastBridgeReceiverOnEthereum")
22-
: await hre.companionNetworks.foreign.deployments.get("FastBridgeReceiverOnEthereum");
23-
const fastBridgeSender = await deploy("FastBridgeSenderToEthereum", {
24-
from: deployer,
25-
args: [deployer, fastBridgeReceiver.address, ethers.constants.AddressZero],
26-
log: true,
27-
}); // nonce+0
28-
29-
const klerosCore = await deployments.get("KlerosCore");
30-
const foreignGateway =
31-
chainId === 31337
32-
? await deployments.get("ForeignGatewayOnEthereum")
33-
: await hre.companionNetworks.foreign.deployments.get("ForeignGatewayOnEthereum");
34-
const foreignChainId = chainId === 31337 ? 31337 : Number(await hre.companionNetworks.foreign.getChainId());
35-
const homeGateway = await deploy("HomeGatewayToEthereum", {
36-
from: deployer,
37-
args: [klerosCore.address, fastBridgeSender.address, foreignGateway.address, foreignChainId],
38-
log: true,
39-
}); // nonce+1
40-
41-
const fastSender = await hre.ethers
42-
.getContractAt("FastBridgeSenderToEthereum", fastBridgeSender.address)
43-
.then((contract) => contract.fastBridgeSender());
44-
if (fastSender === ethers.constants.AddressZero) {
45-
await execute("FastBridgeSenderToEthereum", { from: deployer, log: true }, "changeFastSender", homeGateway.address);
18+
// ----------------------------------------------------------------------------------------------
19+
const hardhatDeployer = async () => {
20+
const fastBridgeReceiver = await deployments.get("FastBridgeReceiverOnEthereum");
21+
const arbSysMock = await deploy("ArbSysMock", { from: deployer, log: true });
22+
23+
const fastBridgeSender = await deploy("FastBridgeSenderToEthereumMock", {
24+
from: deployer,
25+
args: [deployer, fastBridgeReceiver.address, ethers.constants.AddressZero, arbSysMock.address],
26+
log: true,
27+
}); // nonce+0
28+
29+
const klerosCore = await deployments.get("KlerosCore");
30+
const foreignGateway = await deployments.get("ForeignGatewayOnEthereum");
31+
const foreignChainId = 31337;
32+
33+
const homeGateway = await deploy("HomeGatewayToEthereum", {
34+
from: deployer,
35+
args: [klerosCore.address, fastBridgeSender.address, foreignGateway.address, foreignChainId],
36+
gasLimit: 4000000,
37+
log: true,
38+
}); // nonce+1
39+
40+
const fastSender = await hre.ethers
41+
.getContractAt("FastBridgeSenderToEthereumMock", fastBridgeSender.address)
42+
.then((contract) => contract.fastBridgeSender());
43+
44+
if (fastSender === ethers.constants.AddressZero) {
45+
await execute(
46+
"FastBridgeSenderToEthereumMock",
47+
{
48+
from: deployer,
49+
log: true,
50+
},
51+
"changeFastSender",
52+
homeGateway.address
53+
);
54+
55+
const outbox = await deploy("OutboxMock", {
56+
from: deployer,
57+
args: [fastBridgeSender.address],
58+
log: true,
59+
});
60+
61+
const bridge = await deploy("BridgeMock", {
62+
from: deployer,
63+
args: [outbox.address],
64+
log: true,
65+
});
66+
67+
await deploy("InboxMock", {
68+
from: deployer,
69+
args: [bridge.address],
70+
log: true,
71+
});
72+
}
73+
};
74+
75+
// ----------------------------------------------------------------------------------------------
76+
const liveDeployer = async () => {
77+
const fastBridgeReceiver = await hre.companionNetworks.foreign.deployments.get("FastBridgeReceiverOnEthereum");
78+
79+
const fastBridgeSender = await deploy("FastBridgeSenderToEthereum", {
80+
from: deployer,
81+
args: [deployer, fastBridgeReceiver.address, ethers.constants.AddressZero],
82+
log: true,
83+
}); // nonce+0
84+
85+
const klerosCore = await deployments.get("KlerosCore");
86+
const foreignGateway = await hre.companionNetworks.foreign.deployments.get("ForeignGatewayOnEthereum");
87+
const foreignChainId = Number(await hre.companionNetworks.foreign.getChainId());
88+
const homeGateway = await deploy("HomeGatewayToEthereum", {
89+
from: deployer,
90+
args: [klerosCore.address, fastBridgeSender.address, foreignGateway.address, foreignChainId],
91+
log: true,
92+
}); // nonce+1
93+
94+
const fastSender = await hre.ethers
95+
.getContractAt("FastBridgeSenderToEthereum", fastBridgeSender.address)
96+
.then((contract) => contract.fastBridgeSender());
97+
98+
if (fastSender === ethers.constants.AddressZero) {
99+
await execute(
100+
"FastBridgeSenderToEthereum",
101+
{ from: deployer, log: true },
102+
"changeFastSender",
103+
homeGateway.address
104+
);
105+
}
106+
};
107+
108+
// ----------------------------------------------------------------------------------------------
109+
if (chainId === 31337) {
110+
await hardhatDeployer();
111+
} else {
112+
await liveDeployer();
46113
}
47114
};
48115

contracts/hardhat.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dotenv.config();
1616

1717
const config: HardhatUserConfig = {
1818
solidity: {
19-
version: "0.8.10",
19+
version: "0.8.9",
2020
settings: {
2121
optimizer: {
2222
enabled: true,

contracts/package.json

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,37 +22,37 @@
2222
"devDependencies": {
2323
"@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers@0.3.0-beta.13",
2424
"@nomiclabs/hardhat-waffle": "^2.0.3",
25-
"@openzeppelin/contracts": "^4.5.0",
25+
"@openzeppelin/contracts": "^4.6.0",
2626
"@tenderly/hardhat-tenderly": "^1.0.13",
27-
"@typechain/ethers-v5": "^9.0.0",
28-
"@typechain/hardhat": "^5.0.0",
29-
"@types/chai": "^4.3.0",
30-
"@types/mocha": "^9.1.0",
31-
"@types/node": "^16.11.7",
32-
"@typescript-eslint/eslint-plugin": "^5.15.0",
33-
"@typescript-eslint/parser": "^5.15.0",
27+
"@typechain/ethers-v5": "^10.0.0",
28+
"@typechain/hardhat": "^6.0.0",
29+
"@types/chai": "^4.3.1",
30+
"@types/mocha": "^9.1.1",
31+
"@types/node": "^16",
32+
"@typescript-eslint/eslint-plugin": "^5.26.0",
33+
"@typescript-eslint/parser": "^5.26.0",
3434
"chai": "^4.3.6",
3535
"chai-ethers": "^0.0.1",
36-
"dotenv": "^16.0.0",
37-
"ethereum-waffle": "^3.4.0",
36+
"dotenv": "^16.0.1",
37+
"ethereum-waffle": "^3.4.4",
3838
"ethereumjs-util": "^7.1.4",
39-
"ethers": "^5.6.1",
40-
"follow-redirects": "^1.14.9",
41-
"hardhat": "^2.9.1",
42-
"hardhat-contract-sizer": "^2.5.0",
43-
"hardhat-deploy": "^0.11.0",
39+
"ethers": "^5.6.7",
40+
"follow-redirects": "^1.15.0",
41+
"hardhat": "^2.9.6",
42+
"hardhat-contract-sizer": "^2.5.1",
43+
"hardhat-deploy": "^0.11.10",
4444
"hardhat-deploy-ethers": "^0.3.0-beta.13",
4545
"hardhat-docgen": "^1.3.0",
4646
"hardhat-gas-reporter": "^1.0.8",
47-
"hardhat-watcher": "^2.1.1",
47+
"hardhat-watcher": "^2.3.0",
4848
"json-schema": "^0.4.0",
49-
"mocha": "^9.2.0",
49+
"mocha": "^10.0.0",
5050
"npm-run-all": "^4.1.5",
51-
"shelljs": "0.8.5",
52-
"solhint": "^3.3.6",
53-
"solidity-coverage": "^0.7.17",
54-
"ts-node": "^10.4.0",
55-
"typechain": "^7.0.0",
56-
"typescript": "^4.5.5"
51+
"shelljs": "^0.8.5",
52+
"solhint": "^3.3.7",
53+
"solidity-coverage": "^0.7.21",
54+
"ts-node": "^10.8.0",
55+
"typechain": "^8.0.0",
56+
"typescript": "^4.6.4"
5757
}
5858
}

0 commit comments

Comments
 (0)