Skip to content

Commit b3902bb

Browse files
committed
test(arbToGno): deployment scripts for HRE
1 parent 5e64c2a commit b3902bb

File tree

3 files changed

+100
-33
lines changed

3 files changed

+100
-33
lines changed

contracts/deploy/01-outbox/01-arb-to-gnosis-outbox.ts

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ const paramsByChainId = {
3636
sequencerLimit: 86400, // 24 hours
3737
},
3838
HARDHAT: {
39-
deposit: parseEther("5"), // 120 xDAI budget for timeout
39+
deposit: parseEther("10"), // 120 xDAI budget for timeout
4040
// Average happy path wait time is 22.5 mins, assume no censorship
4141
epochPeriod: 600, // 10 min
42-
challengePeriod: 600, // 10 min (assume no sequencer backdating)
43-
numEpochTimeout: 24, // 6 hours
42+
minChallengePeriod: 600, // 10 min (assume no sequencer backdating)
43+
numEpochTimeout: 21600, // 6 hours
4444
claimDelay: 2,
4545
amb: ethers.constants.AddressZero,
4646
routerAddress: ethers.constants.AddressZero,
4747
maxMissingBlocks: 10000000000000,
4848
routerChainId: 31337,
49-
sequencerLimit: 86400, // 24 hours
49+
sequencerLimit: 864,
5050
},
5151
};
5252

@@ -84,27 +84,50 @@ const deployOutbox: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
8484
// ----------------------------------------------------------------------------------------------
8585
const hardhatDeployer = async () => {
8686
let nonce = await ethers.provider.getTransactionCount(deployer);
87-
nonce += 4; // SenderGatewayToEthereum deploy tx will be the 5th after this, same network for both sender/receiver.
8887

89-
const routerAddress = getContractAddress(deployer, nonce);
90-
console.log("calculated future router for nonce %d: %s", nonce, routerAddress);
88+
const routerAddress = getContractAddress(deployer, nonce + 10);
89+
console.log("calculated future router for nonce %d: %s", nonce + 10, routerAddress);
90+
91+
const senderGatewayAddress = getContractAddress(deployer, nonce + 6); // with the current order of transaction ,nonce for sender gateway would be 14.
92+
console.log("calculated future SenderGatewayToGnosis address for nonce %d: %s", nonce, senderGatewayAddress);
93+
94+
const ambMock = await deploy("MockAMB", {
95+
from: deployer,
96+
args: [],
97+
log: true,
98+
});
99+
100+
const wethMock = await deploy("MockWETH", {
101+
from: deployer,
102+
args: [],
103+
log: true,
104+
});
91105

92-
await deploy("VeaOutboxGnosisMock", {
106+
const veaOutbox = await deploy("VeaOutboxArbToGnosis", {
93107
from: deployer,
108+
contract: "VeaOutboxArbToGnosis",
94109
args: [
95110
deposit,
96111
epochPeriod,
97112
minChallengePeriod,
98113
numEpochTimeout,
99-
amb,
100-
ethers.constants.AddressZero,
114+
ambMock.address,
115+
routerAddress,
101116
sequencerLimit,
102117
maxMissingBlocks,
103118
routerChainId,
104-
WETH,
119+
wethMock.address,
105120
],
106121
log: true,
107122
});
123+
124+
await deploy("ArbToGnosisReceiverGateway", {
125+
from: deployer,
126+
contract: "ReceiverGatewayMock",
127+
args: [veaOutbox.address, senderGatewayAddress],
128+
gasLimit: 4000000,
129+
log: true,
130+
});
108131
};
109132

110133
// ----------------------------------------------------------------------------------------------

contracts/deploy/02-inbox/02-arb-to-gnosis-inbox.ts

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { HardhatRuntimeEnvironment } from "hardhat/types";
22
import { DeployFunction } from "hardhat-deploy/types";
33
import getContractAddress from "../../deploy-helpers/getContractAddress";
4+
import { ethers } from "hardhat";
45

56
enum SenderChains {
67
ARBITRUM = 42161,
78
ARBITRUM_SEPOLIA = 421614,
89
HARDHAT = 31337,
910
}
11+
1012
const paramsByChainId = {
1113
ARBITRUM: {
1214
epochPeriod: 3600, // 1 hours
@@ -16,41 +18,65 @@ const paramsByChainId = {
1618
},
1719
HARDHAT: {
1820
epochPeriod: 600, // 10 minutes
21+
routerAddress: ethers.constants.AddressZero,
1922
},
2023
};
2124

22-
// TODO: use deterministic deployments
2325
const deployInbox: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
2426
const { ethers, deployments, getNamedAccounts, getChainId, config } = hre;
2527
const { deploy } = deployments;
26-
const chainId = Number(await getChainId());
27-
const { providers } = ethers;
2828

29-
const deployer = (await getNamedAccounts()).deployer;
30-
console.log("deployer: %s", deployer);
29+
// fallback to hardhat node signers on local network
30+
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
31+
const chainId = Number(await getChainId());
3132

3233
const { epochPeriod } = paramsByChainId[SenderChains[chainId]];
3334

34-
const routerNetworks = {
35-
ARBITRUM: config.networks.mainnet,
36-
ARBITRUM_SEPOLIA: config.networks.sepolia,
37-
HARDHAT: config.networks.localhost,
38-
};
35+
// Hack to predict the deployment address on the sender chain.
36+
// TODO: use deterministic deployments
3937

4038
// ----------------------------------------------------------------------------------------------
39+
const hardhatDeployer = async () => {
40+
let nonce = await ethers.provider.getTransactionCount(deployer);
41+
42+
const arbitrumBridgeAddress = getContractAddress(deployer, nonce + 5);
43+
44+
const arbSysMock = await deploy("ArbSysMock", {
45+
from: deployer,
46+
contract: "ArbSysMockWithBridge",
47+
args: [arbitrumBridgeAddress],
48+
log: true,
49+
});
4150

42-
const routerChainProvider = new providers.JsonRpcProvider(routerNetworks[SenderChains[chainId]].url);
43-
let nonceRouter = await routerChainProvider.getTransactionCount(deployer);
51+
const routerAddress = getContractAddress(deployer, nonce + 6);
52+
console.log("calculated future router for nonce %d: %s", nonce + 6, routerAddress);
4453

45-
const routerAddress = getContractAddress(deployer, nonceRouter);
46-
console.log("calculated future router for nonce %d: %s", nonceRouter, routerAddress);
54+
const receiverGateway = await deployments.get("ArbToGnosisReceiverGateway");
55+
const veaInbox = await deploy("VeaInboxArbToGnosis", {
56+
from: deployer,
57+
contract: "VeaInboxArbToGnosisMock",
58+
args: [epochPeriod, routerAddress, arbSysMock.address],
59+
log: true,
60+
});
4761

48-
await deploy("VeaInboxArbToGnosis" + (chainId === 42161 ? "" : "Testnet"), {
49-
contract: "VeaInboxArbToGnosis",
50-
from: deployer,
51-
args: [epochPeriod, routerAddress],
52-
log: true,
53-
});
62+
await deploy("ArbToGnosisSenderGateway", {
63+
from: deployer,
64+
contract: "SenderGatewayMock",
65+
args: [veaInbox.address, receiverGateway.address],
66+
gasLimit: 4000000,
67+
log: true,
68+
});
69+
};
70+
71+
// ----------------------------------------------------------------------------------------------
72+
const liveDeployer = async () => {};
73+
74+
// ----------------------------------------------------------------------------------------------
75+
if (chainId === 31337) {
76+
await hardhatDeployer();
77+
} else {
78+
await liveDeployer();
79+
}
5480
};
5581

5682
deployInbox.tags = ["ArbToGnosisInbox"];

contracts/deploy/03-routers/03-arb-to-gnosis-router.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,30 @@ const deployRouter: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
3939
const hardhatDeployer = async () => {
4040
const veaOutbox = await deployments.get("VeaOutboxArbToGnosis");
4141
const veaInbox = await deployments.get("VeaInboxArbToGnosis");
42+
const amb = await deployments.get("MockAMB");
43+
//const ArbSysMock = await deployments.get('arbSysMock');
44+
45+
const sequencerInbox = await deploy("SequencerInboxMock", {
46+
from: deployer,
47+
contract: "SequencerInboxMock",
48+
args: ["10"],
49+
});
50+
const outbox = await deploy("OutboxMock", {
51+
from: deployer,
52+
args: [veaInbox.address],
53+
log: true,
54+
});
55+
56+
const arbitrumBridge = await deploy("BridgeMock", {
57+
from: deployer,
58+
contract: "BridgeMock",
59+
args: [outbox.address, sequencerInbox.address],
60+
});
4261

4362
const router = await deploy("RouterArbToGnosis", {
4463
from: deployer,
4564
contract: "RouterArbToGnosis",
46-
args: [arbitrumBridge, amb, veaInbox.address, veaOutbox.address],
65+
args: [arbitrumBridge.address, amb.address, veaInbox.address, veaOutbox.address],
4766
});
4867
};
4968

@@ -73,7 +92,6 @@ const deployRouter: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
7392
deployRouter.tags = ["ArbToGnosisRouter"];
7493
deployRouter.skip = async ({ getChainId }) => {
7594
const chainId = Number(await getChainId());
76-
console.log(chainId);
7795
return !RouterChains[chainId];
7896
};
7997
deployRouter.runAtTheEnd = true;

0 commit comments

Comments
 (0)