Skip to content

Commit 9cdda4e

Browse files
authored
improve(deploy): Improve SpokePool deployment UX (#577)
The majority of SpokePool deployment scripts have been updated to support deploying only implementation contracts. This is done with the knowledge that there are already pre-existing deployments on these chains, but it introduces a risk that using one of these scripts as the template for a new chain will inadvertently result in skipping deployment of the proxy contact. Instead, whether to deploy a new proxy or not can be inferred by whether the contract exists in deployments.json.
1 parent 1471664 commit 9cdda4e

15 files changed

+43
-39
lines changed

deploy/003_deploy_optimism_spokepool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
2828
L2_ADDRESS_MAP[spokeChainId].l2Usdc,
2929
L2_ADDRESS_MAP[spokeChainId].cctpTokenMessenger,
3030
];
31-
await deployNewProxy("Optimism_SpokePool", constructorArgs, initArgs, spokeChainId === 10);
31+
await deployNewProxy("Optimism_SpokePool", constructorArgs, initArgs);
3232
};
3333
module.exports = func;
3434
func.tags = ["OptimismSpokePool", "optimism"];

deploy/005_deploy_arbitrum_spokepool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
2929
L2_ADDRESS_MAP[spokeChainId].l2Usdc,
3030
L2_ADDRESS_MAP[spokeChainId].cctpTokenMessenger,
3131
];
32-
await deployNewProxy("Arbitrum_SpokePool", constructorArgs, initArgs, spokeChainId === 42161);
32+
await deployNewProxy("Arbitrum_SpokePool", constructorArgs, initArgs);
3333
};
3434
module.exports = func;
3535
func.tags = ["ArbitrumSpokePool", "arbitrum"];

deploy/007_deploy_ethereum_spokepool.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1+
import { HardhatRuntimeEnvironment } from "hardhat/types";
12
import { DeployFunction } from "hardhat-deploy/types";
2-
import { deployNewProxy } from "../utils/utils.hre";
3+
import { deployNewProxy, getSpokePoolDeploymentInfo } from "../utils/utils.hre";
34
import { L1_ADDRESS_MAP } from "./consts";
4-
import { HardhatRuntimeEnvironment } from "hardhat/types";
55

66
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
7-
const { deployments, getChainId } = hre;
8-
const chainId = await getChainId();
9-
const hubPool = await deployments.get("HubPool");
10-
console.log(`Using chain ${chainId} HubPool @ ${hubPool.address}`);
7+
const { hubPool, spokeChainId } = await getSpokePoolDeploymentInfo(hre);
8+
console.log(`Using HubPool @ ${hubPool.address}`);
119

1210
// Initialize deposit counter to very high number of deposits to avoid duplicate deposit ID's
1311
// with deprecated spoke pool.
@@ -17,8 +15,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
1715
// * A WETH address of the WETH address
1816
// * A depositQuoteTimeBuffer of 1 hour
1917
// * A fillDeadlineBuffer of 6 hours
20-
const constructorArgs = [L1_ADDRESS_MAP[chainId].weth, 3600, 21600];
21-
await deployNewProxy("Ethereum_SpokePool", constructorArgs, initArgs, chainId === "1");
18+
const constructorArgs = [L1_ADDRESS_MAP[spokeChainId].weth, 3600, 21600];
19+
await deployNewProxy("Ethereum_SpokePool", constructorArgs, initArgs);
2220

2321
// Transfer ownership to hub pool.
2422
};

deploy/011_deploy_polygon_spokepool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
3232
L2_ADDRESS_MAP[spokeChainId].l2Usdc,
3333
L2_ADDRESS_MAP[spokeChainId].cctpTokenMessenger,
3434
];
35-
await deployNewProxy("Polygon_SpokePool", constructorArgs, initArgs, spokeChainId === 137);
35+
await deployNewProxy("Polygon_SpokePool", constructorArgs, initArgs);
3636
};
3737

3838
module.exports = func;

deploy/016_deploy_zksync_spokepool.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import * as zk from "zksync-web3";
22
import { Deployer as zkDeployer } from "@matterlabs/hardhat-zksync-deploy";
33
import { DeployFunction, DeploymentSubmission } from "hardhat-deploy/types";
4-
import { L2_ADDRESS_MAP } from "./consts";
54
import { HardhatRuntimeEnvironment } from "hardhat/types";
5+
import { getDeployedAddress } from "../src/DeploymentUtils";
66
import { getSpokePoolDeploymentInfo } from "../utils/utils.hre";
7+
import { L2_ADDRESS_MAP } from "./consts";
78

89
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
910
const contractName = "ZkSync_SpokePool";
@@ -29,10 +30,14 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
2930
// * A fillDeadlineBuffer of 6 hours
3031
const constructorArgs = [L2_ADDRESS_MAP[spokeChainId].l2Weth, 3600, 21600];
3132

32-
let newAddress;
33+
let newAddress: string;
3334
// On production, we'll rarely want to deploy a new proxy contract so we'll default to deploying a new implementation
3435
// contract.
35-
if (spokeChainId === 324) {
36+
// If a SpokePool can be found in deployments/deployments.json, then only deploy an implementation contract.
37+
const proxy = getDeployedAddress("SpokePool", spokeChainId, false);
38+
const implementationOnly = proxy !== undefined;
39+
if (implementationOnly) {
40+
console.log(`${name} deployment already detected @ ${proxy}, deploying new implementation.`);
3641
const _deployment = await deployer.deploy(artifact, constructorArgs);
3742
newAddress = _deployment.address;
3843
console.log(`New ${contractName} implementation deployed @ ${newAddress}`);

deploy/025_deploy_base_spokepool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
2727
L2_ADDRESS_MAP[spokeChainId].l2Usdc,
2828
L2_ADDRESS_MAP[spokeChainId].cctpTokenMessenger,
2929
];
30-
await deployNewProxy("Base_SpokePool", constructorArgs, initArgs, spokeChainId === 8453);
30+
await deployNewProxy("Base_SpokePool", constructorArgs, initArgs);
3131
};
3232
module.exports = func;
3333
func.tags = ["BaseSpokePool", "base"];

deploy/029_deploy_linea_spokepool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
2121
];
2222
const constructorArgs = [L2_ADDRESS_MAP[chainId].l2Weth, 3600, 21600];
2323

24-
await deployNewProxy("Linea_SpokePool", constructorArgs, initArgs, chainId === 59144);
24+
await deployNewProxy("Linea_SpokePool", constructorArgs, initArgs);
2525
};
2626
module.exports = func;
2727
func.tags = ["LineaSpokePool", "linea"];

deploy/036_deploy_blast_spokepool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
3535
"0x8bA929bE3462a809AFB3Bf9e100Ee110D2CFE531",
3636
L1_ADDRESS_MAP[hubChainId].blastDaiRetriever, // Address of mainnet retriever contract to facilitate USDB finalizations.
3737
];
38-
await deployNewProxy("Blast_SpokePool", constructorArgs, initArgs, spokeChainId === 81457);
38+
await deployNewProxy("Blast_SpokePool", constructorArgs, initArgs);
3939
};
4040
module.exports = func;
4141
func.tags = ["BlastSpokePool", "blast"];

deploy/039_deploy_mode_spokepool.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import { deployNewProxy, getSpokePoolDeploymentInfo } from "../utils/utils.hre";
22
import { DeployFunction } from "hardhat-deploy/types";
33
import { HardhatRuntimeEnvironment } from "hardhat/types";
4-
import { L2_ADDRESS_MAP } from "./consts";
54
import { ZERO_ADDRESS } from "@uma/common";
65

76
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
8-
const { hubPool, spokeChainId } = await getSpokePoolDeploymentInfo(hre);
7+
const { hubPool } = await getSpokePoolDeploymentInfo(hre);
98

109
const initArgs = [
1110
1,
@@ -29,7 +28,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
2928
// the cctpTokenMessenger to the zero address.
3029
ZERO_ADDRESS,
3130
];
32-
await deployNewProxy("Mode_SpokePool", constructorArgs, initArgs, spokeChainId === 34443);
31+
await deployNewProxy("Mode_SpokePool", constructorArgs, initArgs);
3332
};
3433
module.exports = func;
3534
func.tags = ["ModeSpokePool", "mode"];

deploy/043_deploy_lisk_spokepool.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { HardhatRuntimeEnvironment } from "hardhat/types";
44
import { ZERO_ADDRESS } from "@uma/common";
55

66
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
7-
const { hubPool, spokeChainId } = await getSpokePoolDeploymentInfo(hre);
7+
const { hubPool } = await getSpokePoolDeploymentInfo(hre);
88

99
const initArgs = [
1010
1,
@@ -28,7 +28,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
2828
// the cctpTokenMessenger to the zero address.
2929
ZERO_ADDRESS,
3030
];
31-
await deployNewProxy("Lisk_SpokePool", constructorArgs, initArgs, spokeChainId === 1135);
31+
await deployNewProxy("Lisk_SpokePool", constructorArgs, initArgs);
3232
};
3333
module.exports = func;
3434
func.tags = ["LiskSpokePool", "lisk"];

0 commit comments

Comments
 (0)