Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 39 additions & 11 deletions deploy/016_deploy_zksync_spokepool.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,51 @@
import { DeployFunction } from "hardhat-deploy/types";
import * as zk from "zksync-web3";
import { Deployer as zkDeployer } from "@matterlabs/hardhat-zksync-deploy";
import { DeployFunction, DeploymentSubmission } from "hardhat-deploy/types";
import { L2_ADDRESS_MAP } from "./consts";
import { deployNewProxy } from "../utils/utils.hre";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { getSpokePoolDeploymentInfo } from "../utils/utils.hre";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const hubPool = await hre.companionNetworks.l1.deployments.get("HubPool");
const chainId = await hre.getChainId();
console.log(`Using L1 (chainId ${chainId}) hub pool @ ${hubPool.address}`);
const contractName = "ZkSync_SpokePool";
const { deployments, zkUpgrades } = hre;

// Set hub pool as cross domain admin since it delegatecalls the Adapter logic.
const constructorArgs = [
const { hubPool, hubChainId, spokeChainId } = await getSpokePoolDeploymentInfo(hre);
console.log(`Using chain ${hubChainId} HubPool @ ${hubPool.address}`);

const mnemonic = hre.network.config.accounts.mnemonic;
const wallet = zk.Wallet.fromMnemonic(mnemonic);
const deployer = new zkDeployer(hre, wallet);

const artifact = await deployer.loadArtifact(contractName);
const initArgs = [
0, // Start at 0 since this first time we're deploying this spoke pool. On future upgrades increase this.
L2_ADDRESS_MAP[chainId].zkErc20Bridge,
L2_ADDRESS_MAP[chainId].zkEthBridge,
L2_ADDRESS_MAP[spokeChainId].zkErc20Bridge,
hubPool.address,
hubPool.address,
L2_ADDRESS_MAP[chainId].l2Weth,
L2_ADDRESS_MAP[spokeChainId].l2Weth,
];
await deployNewProxy("ZkSync_SpokePool", constructorArgs);

const proxy = await zkUpgrades.deployProxy(deployer.zkWallet, artifact, initArgs, {
initializer: "initialize",
kind: "uups",
unsafeAllow: ["delegatecall"], // Remove after upgrading openzeppelin-contracts-upgradeable post v4.9.3.
});
console.log(`Deployment transaction hash: ${proxy.deployTransaction.hash}.`);
await proxy.deployed();
console.log(`${contractName} deployed to chain ID ${spokeChainId} @ ${proxy.address}.`);

// Save the deployment manually because OZ's hardhat-upgrades packages bypasses hardhat-deploy.
// See also: https://stackoverflow.com/questions/74870472
const extendedArtifact = await deployments.getExtendedArtifact(contractName);
const deployment: DeploymentSubmission = {
address: proxy.address,
...extendedArtifact,
};
await deployments.save(contractName, deployment);

// Verify the proxy + implementation contract.
await hre.run("verify:verify", { address: proxy.address });
};

module.exports = func;
func.tags = ["ZkSyncSpokePool", "zksync"];
9 changes: 6 additions & 3 deletions deploy/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,12 @@ export const L2_ADDRESS_MAP: { [key: number]: { [contractName: string]: string }
fxChild: "0xCf73231F28B7331BBe3124B907840A94851f9f11",
},
280: {
zkErc20Bridge: "0x92131f10c54f9b251a5deaf3c05815f7659bbe02",
zkEthBridge: "0x2c5d8a991f399089f728f1ae40bd0b11acd0fb62",
l2Weth: "0xD3765838f9600Ccff3d01EFA83496599E0984BD2",
l2Weth: "0x20b28B1e4665FFf290650586ad76E977EAb90c5D",
zkErc20Bridge: "0x00ff932A6d70E2B8f1Eb4919e1e09C1923E7e57b",
},
324: {
l2Weth: "0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91",
zkErc20Bridge: "0x11f943b2c77b743AB90f4A0Ae7d5A4e7FCA3E102",
},
};

Expand Down
2 changes: 2 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const config: HardhatUserConfig = {
url: "https://testnet.era.zksync.dev",
saveDeployments: true,
accounts: { mnemonic },
ethNetwork: "goerli",
companionNetworks: { l1: "goerli" },
zksync: true,
verifyURL: "https://zksync2-testnet-explorer.zksync.dev/contract_verification",
Expand All @@ -77,6 +78,7 @@ const config: HardhatUserConfig = {
url: "https://mainnet.era.zksync.io",
saveDeployments: true,
accounts: { mnemonic },
ethNetwork: "mainnet",
companionNetworks: { l1: "mainnet" },
zksync: true,
verifyURL: "https://zksync2-mainnet-explorer.zksync.io/contract_verification",
Expand Down