Skip to content

Commit 58794e7

Browse files
authored
Merge pull request #81 from kleros/feat/challenge-path-4-with-merkle-root
Feat/challenge path 4 with merkle root
2 parents d751b6c + 121ce42 commit 58794e7

File tree

70 files changed

+4313
-667
lines changed

Some content is hidden

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

70 files changed

+4313
-667
lines changed

contracts/deploy/01-foreign-chain.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,23 @@ enum ForeignChains {
1212
}
1313
const paramsByChainId = {
1414
1: {
15-
claimDeposit: parseEther("0.1"),
16-
challengeDuration: 86400, // 1 day
15+
deposit: parseEther("0.1"),
16+
epochPeriod: 86400, // 24 hours
17+
challengePeriod: 14400, // 4 hours
1718
homeChainId: 42161,
1819
arbitrumInbox: "0x4Dbd4fc535Ac27206064B68FfCf827b0A60BAB3f",
1920
},
2021
4: {
21-
claimDeposit: parseEther("0.1"),
22-
challengeDuration: 120, // 2 min
22+
deposit: parseEther("0.1"),
23+
epochPeriod: 86400, // 24 hours
24+
challengePeriod: 14400, // 4 hours
2325
homeChainId: 421611,
2426
arbitrumInbox: "0x578BAde599406A8fE3d24Fd7f7211c0911F5B29e",
2527
},
2628
31337: {
27-
claimDeposit: parseEther("0.1"),
28-
challengeDuration: 120, // 2 min
29+
deposit: parseEther("0.1"),
30+
epochPeriod: 86400, // 24 hours
31+
challengePeriod: 14400, // 4 hours
2932
homeChainId: 31337,
3033
arbitrumInbox: "0x00",
3134
},
@@ -59,9 +62,7 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
5962
nonce = await homeChainProvider.getTransactionCount(deployer);
6063
nonce += 1; // HomeGatewayToEthereum deploy tx will the third tx after this on its home network, so we add two to the current nonce.
6164
}
62-
const { claimDeposit, challengeDuration, homeChainId, arbitrumInbox } = paramsByChainId[chainId];
63-
const challengeDeposit = claimDeposit;
64-
const bridgeAlpha = 5000;
65+
const { deposit, epochPeriod, challengePeriod, homeChainId, arbitrumInbox } = paramsByChainId[chainId];
6566
const homeChainIdAsBytes32 = hexZeroPad(homeChainId, 32);
6667

6768
const homeGatewayAddress = getContractAddress(deployer, nonce);
@@ -71,27 +72,26 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
7172
const fastBridgeSenderAddress = getContractAddress(deployer, nonce);
7273
console.log("calculated future FastSender for nonce %d: %s", nonce, fastBridgeSenderAddress);
7374

74-
nonce += 5;
75+
nonce += 4;
7576

7677
const inboxAddress = chainId === ForeignChains.HARDHAT ? getContractAddress(deployer, nonce) : arbitrumInbox;
7778
console.log("calculated future inboxAddress for nonce %d: %s", nonce, inboxAddress);
7879

7980
const fastBridgeReceiver = await deploy("FastBridgeReceiverOnEthereum", {
8081
from: deployer,
8182
args: [
82-
deployer,
83+
deposit,
84+
epochPeriod,
85+
challengePeriod,
8386
fastBridgeSenderAddress,
84-
inboxAddress,
85-
claimDeposit,
86-
challengeDeposit,
87-
challengeDuration,
88-
bridgeAlpha,
87+
inboxAddress
8988
],
9089
log: true,
9190
});
9291

9392
const foreignGateway = await deploy("ForeignGatewayOnEthereum", {
9493
from: deployer,
94+
contract: "ForeignGateway",
9595
args: [
9696
deployer,
9797
fastBridgeReceiver.address,

contracts/deploy/02-home-chain.ts

Lines changed: 27 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { DeployFunction } from "hardhat-deploy/types";
33
import { ethers } from "hardhat";
44

55
const HOME_CHAIN_IDS = [42161, 421611, 31337]; // ArbOne, ArbRinkeby, Hardhat
6+
const epochPeriod = 86400; // 24 hours
67

78
// TODO: use deterministic deployments
89

@@ -22,7 +23,8 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
2223

2324
const fastBridgeSender = await deploy("FastBridgeSenderToEthereumMock", {
2425
from: deployer,
25-
args: [deployer, fastBridgeReceiver.address, ethers.constants.AddressZero, arbSysMock.address],
26+
contract: "FastBridgeSenderMock",
27+
args: [epochPeriod, fastBridgeReceiver.address, arbSysMock.address],
2628
log: true,
2729
}); // nonce+0
2830

@@ -32,44 +34,29 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
3234

3335
const homeGateway = await deploy("HomeGatewayToEthereum", {
3436
from: deployer,
35-
args: [klerosCore.address, fastBridgeSender.address, foreignGateway.address, foreignChainId],
37+
contract: "HomeGateway",
38+
args: [deployer, klerosCore.address, fastBridgeSender.address, foreignGateway.address, foreignChainId],
3639
gasLimit: 4000000,
3740
log: true,
3841
}); // nonce+1
3942

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-
}
43+
const outbox = await deploy("OutboxMock", {
44+
from: deployer,
45+
args: [fastBridgeSender.address],
46+
log: true,
47+
});
48+
49+
const bridge = await deploy("BridgeMock", {
50+
from: deployer,
51+
args: [outbox.address],
52+
log: true,
53+
});
54+
55+
await deploy("InboxMock", {
56+
from: deployer,
57+
args: [bridge.address],
58+
log: true,
59+
});
7360
};
7461

7562
// ----------------------------------------------------------------------------------------------
@@ -78,7 +65,8 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
7865

7966
const fastBridgeSender = await deploy("FastBridgeSenderToEthereum", {
8067
from: deployer,
81-
args: [deployer, fastBridgeReceiver.address, ethers.constants.AddressZero],
68+
contract: "FastBridgeSender",
69+
args: [epochPeriod, fastBridgeReceiver.address],
8270
log: true,
8371
}); // nonce+0
8472

@@ -87,22 +75,10 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
8775
const foreignChainId = Number(await hre.companionNetworks.foreign.getChainId());
8876
const homeGateway = await deploy("HomeGatewayToEthereum", {
8977
from: deployer,
90-
args: [klerosCore.address, fastBridgeSender.address, foreignGateway.address, foreignChainId],
78+
contract: "HomeGateway",
79+
args: [deployer, klerosCore.address, fastBridgeSender.address, foreignGateway.address, foreignChainId],
9180
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-
}
81+
}); // nonce+
10682
};
10783

10884
// ----------------------------------------------------------------------------------------------

contracts/hardhat.config.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,15 @@ const config: HardhatUserConfig = {
141141
relayer: {
142142
default: 1,
143143
},
144+
bridger: {
145+
default: 2,
146+
},
147+
challenger: {
148+
default: 3,
149+
},
144150
},
145151
gasReporter: {
146-
enabled: process.env.REPORT_GAS !== undefined,
152+
enabled: process.env.REPORT_GAS !== undefined ? process.env.REPORT_GAS === "true" : false,
147153
currency: "USD",
148154
},
149155
verify: {
@@ -166,7 +172,7 @@ const config: HardhatUserConfig = {
166172
},
167173
},
168174
docgen: {
169-
path: './docs',
175+
path: "./docs",
170176
clear: true,
171177
runOnCompile: false,
172178
},

0 commit comments

Comments
 (0)