Skip to content

Commit 48d7018

Browse files
pxrlnicholaspaidohaki
authored
refactor: Consolidate new SpokePool/proxy deployment (#277)
* feat: Support deployment and verification of upgradeable SpokePools `hardhat-upgrades` has some useful libraries we can use to deploy and verify proxies. I've tested these all out on prod. * Update deployment files * Update SpokePool.Fixture.ts * Update deployments.json * fix Signed-off-by: nicholaspai <[email protected]> * fix tests Signed-off-by: nicholaspai <[email protected]> * Update package.json * WIP * add arbitrum goerli redeployment * Update package.json * build: workaround @uma/common package browser compatibility (#273) * Move utils to src/utils * Update publish.yml * Update package.json * Update test/SpokePool.SlowRelay.ts Co-authored-by: Paul <[email protected]> * WIP * WIP * WIP * Update upgradeTo.ts * WIP * Deploy mainnet * bump OZ-contracts-upgradeable version * Update package.json * Update package.json * fix: Execute fill with updated message and recipient When sped up, updated message and recipient are not used * Update SpokePool.Relay.ts * WIP * Update test/SpokePool.SlowRelay.ts Co-authored-by: Paul <[email protected]> * Update yarn.lock * Add signer to getContractFactory call * Update Arbitrum_Adapter.json * Delete d89e3488271f97cf1ea0bdb289d28ad2.json * refactor: Consolidate new SpokePool/proxy deployment * Post-merge cleanup * lint --------- Signed-off-by: nicholaspai <[email protected]> Co-authored-by: nicholaspai <[email protected]> Co-authored-by: Dong-Ha Kim <[email protected]> Co-authored-by: nicholaspai <[email protected]>
1 parent d793fb6 commit 48d7018

7 files changed

+47
-161
lines changed
+5-27
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,17 @@
11
import "hardhat-deploy";
22
import hre from "hardhat";
3-
import { getContractFactory } from "../utils";
3+
import { deployNewProxy } from "../utils";
44

55
const func = async function () {
6-
const { upgrades, companionNetworks, run, getNamedAccounts } = hre;
7-
const { deployer } = await getNamedAccounts();
8-
9-
// Grab L1 addresses:
10-
const { deployments: l1Deployments } = companionNetworks.l1;
11-
const hubPool = await l1Deployments.get("HubPool");
12-
console.log(`Using l1 hub pool @ ${hubPool.address}`);
6+
const hubPool = await hre.companionNetworks.l1.deployments.get("HubPool");
7+
const chainId = await hre.getChainId();
8+
console.log(`Using L1 (chainId ${chainId}) hub pool @ ${hubPool.address}`);
139

1410
// Initialize deposit counter to very high number of deposits to avoid duplicate deposit ID's
1511
// with deprecated spoke pool.
1612
// Set hub pool as cross domain admin since it delegatecalls the Adapter logic.
1713
const constructorArgs = [1_000_000, hubPool.address, hubPool.address];
18-
const spokePool = await upgrades.deployProxy(
19-
await getContractFactory("Optimism_SpokePool", deployer),
20-
constructorArgs,
21-
{
22-
kind: "uups",
23-
}
24-
);
25-
const instance = await spokePool.deployed();
26-
console.log(`SpokePool deployed @ ${instance.address}`);
27-
const implementationAddress = await upgrades.erc1967.getImplementationAddress(instance.address);
28-
console.log(`Implementation deployed @ ${implementationAddress}`);
29-
30-
// hardhat-upgrades overrides the `verify` task that ships with `hardhat` so that if the address passed
31-
// is a proxy, hardhat will first verify the implementation and then the proxy and also link the proxy
32-
// to the implementation's ABI on etherscan.
33-
// https://docs.openzeppelin.com/upgrades-plugins/1.x/api-hardhat-upgrades#verify
34-
await run("verify:verify", {
35-
address: instance.address,
36-
});
14+
await deployNewProxy("Optimism_SpokePool", constructorArgs);
3715
};
3816
module.exports = func;
3917
func.tags = ["OptimismSpokePool", "optimism"];
+5-29
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
import "hardhat-deploy";
22
import hre from "hardhat";
33
import { L2_ADDRESS_MAP } from "./consts";
4-
import { getContractFactory } from "../utils";
4+
import { deployNewProxy } from "../utils";
55

66
const func = async function () {
7-
const { upgrades, companionNetworks, run, getChainId, getNamedAccounts } = hre;
8-
9-
// Grab L1 addresses:
10-
const { deployments: l1Deployments } = companionNetworks.l1;
11-
const hubPool = await l1Deployments.get("HubPool");
12-
console.log(`Using l1 hub pool @ ${hubPool.address}`);
13-
14-
const chainId = parseInt(await getChainId());
15-
const { deployer } = await getNamedAccounts();
7+
const hubPool = await hre.companionNetworks.l1.deployments.get("HubPool");
8+
const chainId = await hre.getChainId();
9+
console.log(`Using L1 (chainId ${chainId}) hub pool @ ${hubPool.address}`);
1610

1711
// Initialize deposit counter to very high number of deposits to avoid duplicate deposit ID's
1812
// with deprecated spoke pool.
@@ -24,25 +18,7 @@ const func = async function () {
2418
hubPool.address,
2519
L2_ADDRESS_MAP[chainId].l2Weth,
2620
];
27-
const spokePool = await upgrades.deployProxy(
28-
await getContractFactory("Arbitrum_SpokePool", deployer),
29-
constructorArgs,
30-
{
31-
kind: "uups",
32-
}
33-
);
34-
const instance = await spokePool.deployed();
35-
console.log(`SpokePool deployed @ ${instance.address}`);
36-
const implementationAddress = await upgrades.erc1967.getImplementationAddress(instance.address);
37-
console.log(`Implementation deployed @ ${implementationAddress}`);
38-
39-
// hardhat-upgrades overrides the `verify` task that ships with `hardhat` so that if the address passed
40-
// is a proxy, hardhat will first verify the implementation and then the proxy and also link the proxy
41-
// to the implementation's ABI on etherscan.
42-
// https://docs.openzeppelin.com/upgrades-plugins/1.x/api-hardhat-upgrades#verify
43-
await run("verify:verify", {
44-
address: instance.address,
45-
});
21+
await deployNewProxy("Arbitrum_SpokePool", constructorArgs);
4622
};
4723
module.exports = func;
4824
func.tags = ["ArbitrumSpokePool", "arbitrum"];

deploy/007_deploy_ethereum_spokepool.ts

+5-29
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,19 @@
11
import "hardhat-deploy";
2-
32
import hre from "hardhat";
4-
import { getContractFactory } from "../utils";
5-
3+
import { deployNewProxy } from "../utils";
64
import { L1_ADDRESS_MAP } from "./consts";
75

86
export async function printProxyVerificationInstructions() {}
97

108
const func = async function () {
11-
const { deployments, getChainId, upgrades, run, getNamedAccounts } = hre;
12-
13-
const chainId = parseInt(await getChainId());
14-
const { deployer } = await getNamedAccounts();
15-
16-
const hubPool = await deployments.get("HubPool");
17-
console.log(`Using l1 hub pool @ ${hubPool.address}`);
9+
const hubPool = await hre.companionNetworks.l1.deployments.get("HubPool");
10+
const chainId = await hre.getChainId();
11+
console.log(`Using L1 (chainId ${chainId}) hub pool @ ${hubPool.address}`);
1812

1913
// Initialize deposit counter to very high number of deposits to avoid duplicate deposit ID's
2014
// with deprecated spoke pool.
2115
const constructorArgs = [1_000_000, hubPool.address, L1_ADDRESS_MAP[chainId].weth];
22-
const spokePool = await upgrades.deployProxy(
23-
await getContractFactory("Ethereum_SpokePool", deployer),
24-
constructorArgs,
25-
{
26-
kind: "uups",
27-
}
28-
);
29-
const instance = await spokePool.deployed();
30-
console.log(`SpokePool deployed @ ${instance.address}`);
31-
const implementationAddress = await upgrades.erc1967.getImplementationAddress(instance.address);
32-
console.log(`Implementation deployed @ ${implementationAddress}`);
33-
34-
// hardhat-upgrades overrides the `verify` task that ships with `hardhat` so that if the address passed
35-
// is a proxy, hardhat will first verify the implementation and then the proxy and also link the proxy
36-
// to the implementation's ABI on etherscan.
37-
// https://docs.openzeppelin.com/upgrades-plugins/1.x/api-hardhat-upgrades#verify
38-
await run("verify:verify", {
39-
address: instance.address,
40-
});
16+
await deployNewProxy("Ethereum_SpokePool", constructorArgs);
4117

4218
// Transfer ownership to hub pool.
4319
};

deploy/011_deploy_polygon_spokepool.ts

+4-24
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import "hardhat-deploy";
22
import hre from "hardhat";
33
import { L2_ADDRESS_MAP } from "./consts";
4-
import { getContractFactory } from "../utils";
4+
import { deployNewProxy } from "../utils";
55

66
const func = async function () {
7-
const { upgrades, run, getChainId, getNamedAccounts } = hre;
8-
9-
const chainId = parseInt(await getChainId());
107
const hubPool = await hre.companionNetworks.l1.deployments.get("HubPool");
11-
const { deployer } = await getNamedAccounts();
8+
const chainId = await hre.getChainId();
9+
console.log(`Using L1 (chainId ${chainId}) hub pool @ ${hubPool.address}`);
1210

1311
// Initialize deposit counter to very high number of deposits to avoid duplicate deposit ID's
1412
// with deprecated spoke pool.
@@ -23,25 +21,7 @@ const func = async function () {
2321
L2_ADDRESS_MAP[chainId].wMatic,
2422
L2_ADDRESS_MAP[chainId].fxChild,
2523
];
26-
const spokePool = await upgrades.deployProxy(
27-
await getContractFactory("Polygon_SpokePool", deployer),
28-
constructorArgs,
29-
{
30-
kind: "uups",
31-
}
32-
);
33-
const instance = await spokePool.deployed();
34-
console.log(`SpokePool deployed @ ${instance.address}`);
35-
const implementationAddress = await upgrades.erc1967.getImplementationAddress(instance.address);
36-
console.log(`Implementation deployed @ ${implementationAddress}`);
37-
38-
// hardhat-upgrades overrides the `verify` task that ships with `hardhat` so that if the address passed
39-
// is a proxy, hardhat will first verify the implementation and then the proxy and also link the proxy
40-
// to the implementation's ABI on etherscan.
41-
// https://docs.openzeppelin.com/upgrades-plugins/1.x/api-hardhat-upgrades#verify
42-
await run("verify:verify", {
43-
address: instance.address,
44-
});
24+
await deployNewProxy("Polygon_SpokePool", constructorArgs);
4525
};
4626

4727
module.exports = func;

deploy/013_deploy_boba_spokepool.ts

+5-23
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,17 @@
11
import "hardhat-deploy";
22
import hre from "hardhat";
3-
import { getContractFactory } from "../utils";
3+
import { deployNewProxy } from "../utils";
44

55
const func = async function () {
6-
const { upgrades, companionNetworks, run, getNamedAccounts } = hre;
7-
8-
// Grab L1 addresses:
9-
const { deployments: l1Deployments } = companionNetworks.l1;
10-
const hubPool = await l1Deployments.get("HubPool");
11-
console.log(`Using l1 hub pool @ ${hubPool.address}`);
6+
const hubPool = await hre.companionNetworks.l1.deployments.get("HubPool");
7+
const chainId = await hre.getChainId();
8+
console.log(`Using L1 (chainId ${chainId}) hub pool @ ${hubPool.address}`);
129

1310
// Initialize deposit counter to very high number of deposits to avoid duplicate deposit ID's
1411
// with deprecated spoke pool.
1512
// Set hub pool as cross domain admin since it delegatecalls the Adapter logic.
16-
const { deployer } = await getNamedAccounts();
1713
const constructorArgs = [1_000_000, hubPool.address, hubPool.address];
18-
const spokePool = await upgrades.deployProxy(await getContractFactory("Boba_SpokePool", deployer), constructorArgs, {
19-
kind: "uups",
20-
});
21-
const instance = await spokePool.deployed();
22-
console.log(`SpokePool deployed @ ${instance.address}`);
23-
const implementationAddress = await upgrades.erc1967.getImplementationAddress(instance.address);
24-
console.log(`Implementation deployed @ ${implementationAddress}`);
25-
26-
// hardhat-upgrades overrides the `verify` task that ships with `hardhat` so that if the address passed
27-
// is a proxy, hardhat will first verify the implementation and then the proxy and also link the proxy
28-
// to the implementation's ABI on etherscan.
29-
// https://docs.openzeppelin.com/upgrades-plugins/1.x/api-hardhat-upgrades#verify
30-
await run("verify:verify", {
31-
address: instance.address,
32-
});
14+
await deployNewProxy("Boba_SpokePool", constructorArgs);
3315
};
3416
module.exports = func;
3517
func.tags = ["BobaSpokePool", "boba"];

deploy/016_deploy_zksync_spokepool.ts

+5-29
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
import "hardhat-deploy";
22
import hre from "hardhat";
33
import { L2_ADDRESS_MAP } from "./consts";
4-
import { getContractFactory } from "../utils";
4+
import { deployNewProxy } from "../utils";
55

66
const func = async function () {
7-
const { upgrades, companionNetworks, run, getChainId, getNamedAccounts } = hre;
8-
9-
// Grab L1 addresses:
10-
const { deployments: l1Deployments } = companionNetworks.l1;
11-
const hubPool = await l1Deployments.get("HubPool");
12-
console.log(`Using l1 hub pool @ ${hubPool.address}`);
13-
14-
const chainId = parseInt(await getChainId());
15-
const { deployer } = await getNamedAccounts();
7+
const hubPool = await hre.companionNetworks.l1.deployments.get("HubPool");
8+
const chainId = await hre.getChainId();
9+
console.log(`Using L1 (chainId ${chainId}) hub pool @ ${hubPool.address}`);
1610

1711
// Set hub pool as cross domain admin since it delegatecalls the Adapter logic.
1812
const constructorArgs = [
@@ -23,25 +17,7 @@ const func = async function () {
2317
hubPool.address,
2418
L2_ADDRESS_MAP[chainId].l2Weth,
2519
];
26-
const spokePool = await upgrades.deployProxy(
27-
await getContractFactory("ZkSync_SpokePool", deployer),
28-
constructorArgs,
29-
{
30-
kind: "uups",
31-
}
32-
);
33-
const instance = await spokePool.deployed();
34-
console.log(`SpokePool deployed @ ${instance.address}`);
35-
const implementationAddress = await upgrades.erc1967.getImplementationAddress(instance.address);
36-
console.log(`Implementation deployed @ ${implementationAddress}`);
37-
38-
// hardhat-upgrades overrides the `verify` task that ships with `hardhat` so that if the address passed
39-
// is a proxy, hardhat will first verify the implementation and then the proxy and also link the proxy
40-
// to the implementation's ABI on etherscan.
41-
// https://docs.openzeppelin.com/upgrades-plugins/1.x/api-hardhat-upgrades#verify
42-
await run("verify:verify", {
43-
address: instance.address,
44-
});
20+
await deployNewProxy("ZkSync_SpokePool", constructorArgs);
4521
};
4622
module.exports = func;
4723
func.tags = ["ZkSyncSpokePool", "zksync"];

utils/utils.ts

+18
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,24 @@ export async function getContractFactory(
5454
}
5555
}
5656

57+
export async function deployNewProxy(name: string, args: (number | string)[]): Promise<void> {
58+
const { run, upgrades } = hre;
59+
60+
const proxy = await upgrades.deployProxy(await getContractFactory(name, {}), args, { kind: "uups" });
61+
const instance = await proxy.deployed();
62+
console.log(`New ${name} proxy deployed @ ${instance.address}`);
63+
const implementationAddress = await upgrades.erc1967.getImplementationAddress(instance.address);
64+
console.log(`${name} implementation deployed @ ${implementationAddress}`);
65+
66+
// hardhat-upgrades overrides the `verify` task that ships with `hardhat` so that if the address passed
67+
// is a proxy, hardhat will first verify the implementation and then the proxy and also link the proxy
68+
// to the implementation's ABI on etherscan.
69+
// https://docs.openzeppelin.com/upgrades-plugins/1.x/api-hardhat-upgrades#verify
70+
await run("verify:verify", {
71+
address: instance.address,
72+
});
73+
}
74+
5775
// Arbitrum does not export any of their artifacts nicely, so we have to do this manually. The methods that follow can
5876
// be re-used if we end up requiring to import contract artifacts from other projects that dont export cleanly.
5977
function getArbitrumArtifact(contractName: string) {

0 commit comments

Comments
 (0)