Skip to content

Commit d622a55

Browse files
test: deploy central arbitrator for adhoc tests
1 parent f8c1a4f commit d622a55

File tree

3 files changed

+54
-6
lines changed

3 files changed

+54
-6
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ const deployArbitration: DeployFunction = async (hre: HardhatRuntimeEnvironment)
5050
).address
5151
);
5252
}
53+
const centralizedArbitrator = await deploy("CentralizedArbitrator", {
54+
from: deployer,
55+
args: [0, 0, 0],
56+
log: true,
57+
});
58+
5359
const pnk = pnkByChain.get(Number(await getChainId())) ?? AddressZero;
5460
const minStake = BigNumber.from(10).pow(20).mul(2);
5561
const alpha = 10000;

contracts/deploy/01-foreign-chain.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
6363
nonce += 1; // HomeGatewayToEthereum deploy tx will the third tx after this on its home network, so we add two to the current nonce.
6464
}
6565
const { deposit, epochPeriod, homeChainId, arbInbox, genesis } = paramsByChainId[chainId];
66-
const bridgeAlpha = 5000;
6766
const homeChainIdAsBytes32 = hexZeroPad(homeChainId, 32);
6867
const chainIdAsBytes32 = hexZeroPad("0x" + chainId.toString(16), 32);
6968

7069
const homeGatewayAddress = getContractAddress(deployer, nonce);
7170
console.log("calculated future HomeGatewayToEthereum address for nonce %d: %s", nonce, homeGatewayAddress);
72-
nonce -= 1;
73-
const fastBridgeSenderAddress = getContractAddress(deployer, nonce);
71+
const homeGatewayCentralizedArbitratorAddress = getContractAddress(deployer, nonce+1);
72+
console.log("calculated future HomeGatewayToEthereum address for nonce %d: %s", nonce, homeGatewayAddress);
73+
const fastBridgeSenderAddress = getContractAddress(deployer, nonce-1);
7474
console.log("calculated future fastBridgeSender address for nonce %d: %s", nonce, fastBridgeSenderAddress);
7575

7676
const fastBridgeReceiver = await deploy("FastBridgeReceiverOnEthereum", {
@@ -80,13 +80,14 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
8080
deposit,
8181
epochPeriod,
8282
fastBridgeSenderAddress,
83-
genesis // sample genesis time
83+
genesis
8484
],
8585
log: true,
8686
});
8787

8888
const foreignGateway = await deploy("ForeignGatewayOnEthereum", {
8989
from: deployer,
90+
contract: "ForeignGatewayOnEthereum",
9091
args: [
9192
deployer,
9293
fastBridgeReceiver.address,
@@ -98,13 +99,34 @@ const deployForeignGateway: DeployFunction = async (hre: HardhatRuntimeEnvironme
9899
log: true,
99100
});
100101

102+
const foreignGatewayCentralizedArbitrator = await deploy("ForeignGatewayOnEthereumCentralizedArbitrator", {
103+
from: deployer,
104+
contract: "ForeignGatewayOnEthereum",
105+
args: [
106+
deployer,
107+
fastBridgeReceiver.address,
108+
[ethers.BigNumber.from(10).pow(17)],
109+
homeGatewayCentralizedArbitratorAddress,
110+
homeChainIdAsBytes32,
111+
chainIdAsBytes32
112+
],
113+
log: true,
114+
});
115+
101116
const metaEvidenceUri =
102117
"https://raw.githubusercontent.com/kleros/kleros-v2/master/contracts/deployments/rinkeby/MetaEvidence_ArbitrableExample.json";
103118
const arbitrable = await deploy("ArbitrableExample", {
104119
from: deployer,
105120
args: [foreignGateway.address, metaEvidenceUri],
106121
log: true,
107122
});
123+
124+
const arbitrableCentralizedArbitrator = await deploy("ArbitrableExampleCentralizedArbitrator", {
125+
from: deployer,
126+
contract: "ArbitrableExample",
127+
args: [foreignGateway.address, metaEvidenceUri],
128+
log: true,
129+
});
108130
};
109131

110132
deployForeignGateway.tags = ["ForeignChain", "ForeignGateway"];

contracts/deploy/02-home-chain.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,26 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
2020
chainId === 31337
2121
? await deployments.get("FastBridgeReceiverOnEthereum")
2222
: await hre.companionNetworks.foreign.deployments.get("FastBridgeReceiverOnEthereum");
23-
//const genesisSynchronization = fastBridgeReceiver.
23+
24+
const genesisSynchronization = 1652709415; // sample genesis time
25+
const epochPeriod = 120;
26+
2427
const fastBridgeSender = await deploy("FastBridgeSenderToEthereum", {
2528
from: deployer,
26-
args: [fastBridgeReceiver.address, 120, 1652709415],
29+
args: [fastBridgeReceiver.address, epochPeriod, genesisSynchronization],
2730
log: true,
2831
}); // nonce+0
2932

3033
const klerosCore = await deployments.get("KlerosCore");
34+
const centralizedArbitrator = await deployments.get("CentralizedArbitrator");
3135
const foreignGateway =
3236
chainId === 31337
3337
? await deployments.get("ForeignGatewayOnEthereum")
3438
: await hre.companionNetworks.foreign.deployments.get("ForeignGatewayOnEthereum");
3539
const foreignChainId = chainId === 31337 ? 31337 : Number(await hre.companionNetworks.foreign.getChainId());
3640
const homeGateway = await deploy("HomeGatewayToEthereum", {
3741
from: deployer,
42+
contract: "HomeGatewayToEthereum",
3843
args: [
3944
deployer,
4045
klerosCore.address,
@@ -46,6 +51,21 @@ const deployHomeGateway: DeployFunction = async (hre: HardhatRuntimeEnvironment)
4651
log: true,
4752
}); // nonce+1
4853

54+
const homeGatewayCentralizedArbitrator = await deploy("HomeGatewayToEthereumCentralizedArbitrator", {
55+
from: deployer,
56+
contract: "HomeGatewayToEthereum",
57+
args: [
58+
deployer,
59+
centralizedArbitrator.address,
60+
fastBridgeSender.address,
61+
foreignGateway.address,
62+
foreignChainId,
63+
chainId
64+
],
65+
log: true,
66+
}); // nonce+1
67+
68+
// comment out and call manually if gas calculation errors
4969
const safeBridgeSender = await hre.ethers
5070
.getContractAt("FastBridgeReceiverOnEthereum", fastBridgeReceiver.address)
5171
.then((contract) => contract.safeBridgeSender());

0 commit comments

Comments
 (0)