From d2e7f6d6a2902386067bf6d214157ff74c523d34 Mon Sep 17 00:00:00 2001 From: Michalina Date: Wed, 22 Nov 2023 10:57:39 +0100 Subject: [PATCH] Add Sepolia / Optimism Sepolia support for Optimism cross-chain MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Goerli testnet currently used by Threshold/Keep for development purposes is planned to become deprecated with the end of year 2023. The testnet that was created to replace it is called [Holešky](https://github.com/eth-clients/holesky), however it will take some time until it gets integrated with by some of the projects we rely on. As a solution, we decided to switch first to another testnet that is currently live - Sepolia. This testnet's EOL is planned for 2026, which gives us plenty of time to move to Holešky before Sepolia gets deprecated. Until Görli is not dead we want to support both testnets. The Goerli -> Sepolia migration means that also L2 testnet basing on Goerli (Optimism Goerli) needs to be migrated to Sepolia-based chain (Optimism Sepolia). At the moment Optimism Sepolia is not supported by Wormhole, so deployment of our contracts on that testnet is yet not possible. But we're already adding changes that prepare us for the moment when it will be supported. Once support is confirmed, we'll need to verify if `wormholeChainID` we use in the config is correct for the testnet. --- cross-chain/optimism/.gitignore | 1 + cross-chain/optimism/README.adoc | 6 ++-- ...update_self_in_wormhole_gateway_mapping.ts | 2 ++ ...th_arbitrum_in_wormhole_gateway_mapping.ts | 2 ++ ...e_with_base_in_wormhole_gateway_mapping.ts | 2 ++ cross-chain/optimism/hardhat.config.ts | 33 +++++++++++++++++++ cross-chain/optimism/package.json | 1 + 7 files changed, 44 insertions(+), 3 deletions(-) diff --git a/cross-chain/optimism/.gitignore b/cross-chain/optimism/.gitignore index 64240eb35..9ed245ce0 100644 --- a/cross-chain/optimism/.gitignore +++ b/cross-chain/optimism/.gitignore @@ -10,6 +10,7 @@ !/deployments/mainnet/ !/deployments/optimism/ !/deployments/optimismGoerli/ +!/deployments/optimismSepolia/ # OZ /.openzeppelin/unknown-*.json diff --git a/cross-chain/optimism/README.adoc b/cross-chain/optimism/README.adoc index 0970bd560..29884e230 100644 --- a/cross-chain/optimism/README.adoc +++ b/cross-chain/optimism/README.adoc @@ -27,7 +27,7 @@ Wormhole-specific tBTC representation into the canonical `OptimismTBTC` token. The deployment scripts are responsible for managing updates of the tBTC gateway addresses across various chains. These addresses are stored in the `external/` -directory for a specific network, such as `optimismGoerli/ArbitrumWormholeGateway.json.` +directory for a specific network, such as `optimismSepolia/ArbitrumWormholeGateway.json.` It is important to note that these addresses should remain constant for the mainnet network. However, there may be instances where a new version of a cross-chain module is deployed to the testing network, which would require a @@ -42,7 +42,7 @@ yarn deploy --network Supported networks: - `hardhat` - for local development -- `optimismGoerli` - L2 testing network +- `optimismSepolia` - L2 testing network - `optimism` - L2 mainnet Currently, this module does not deploy any contracts on L1. All the existing @@ -54,6 +54,6 @@ the contracts before running the deployment script. This command produces an `export.json` file containing contract deployment info. Note that for the chains other than `hardhat` the following environment variables are needed: -- `L2_CHAIN_API_URL` - URL to access blockchain services, e.g. `https://opt-goerli.g.alchemy.com/v2/` +- `L2_CHAIN_API_URL` - URL to access blockchain services, e.g. `https://optimism-sepolia.infura.io/v3/` - `L2_ACCOUNTS_PRIVATE_KEYS` - Private keys for the deployer and council `<0xOwnerPrivKey,0xCouncilPrivKey>` - `OPTIMISM_ETHERSCAN_API_KEY` - Optimism Etherscan API key diff --git a/cross-chain/optimism/deploy_l2/12_update_self_in_wormhole_gateway_mapping.ts b/cross-chain/optimism/deploy_l2/12_update_self_in_wormhole_gateway_mapping.ts index 320dd6c9b..bce2aebe5 100644 --- a/cross-chain/optimism/deploy_l2/12_update_self_in_wormhole_gateway_mapping.ts +++ b/cross-chain/optimism/deploy_l2/12_update_self_in_wormhole_gateway_mapping.ts @@ -8,6 +8,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { // See https://book.wormhole.com/reference/contracts.html // This ID is valid for both Optimism Goerli and Mainnet + // TODO: check if id is correct for Optimism Sepolia as well (once Wormhole + // supports that testnet) const wormholeChainID = 24 const optimismWormholeGateway = await deployments.get( diff --git a/cross-chain/optimism/deploy_l2/13_update_with_arbitrum_in_wormhole_gateway_mapping.ts b/cross-chain/optimism/deploy_l2/13_update_with_arbitrum_in_wormhole_gateway_mapping.ts index 32767e21e..225821daa 100644 --- a/cross-chain/optimism/deploy_l2/13_update_with_arbitrum_in_wormhole_gateway_mapping.ts +++ b/cross-chain/optimism/deploy_l2/13_update_with_arbitrum_in_wormhole_gateway_mapping.ts @@ -12,6 +12,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { // See https://book.wormhole.com/reference/contracts.html // This ID is valid for both Arbitrum Goerli and Mainnet + // TODO: check if id is correct for Arbitrum Sepolia as well (once Wormhole + // supports that testnet) const arbitrumWormholeChainID = 23 const arbitrumWormholeGateway = await deployments.getOrNull( diff --git a/cross-chain/optimism/deploy_l2/15_update_with_base_in_wormhole_gateway_mapping.ts b/cross-chain/optimism/deploy_l2/15_update_with_base_in_wormhole_gateway_mapping.ts index 8c69bec2a..533ce0010 100644 --- a/cross-chain/optimism/deploy_l2/15_update_with_base_in_wormhole_gateway_mapping.ts +++ b/cross-chain/optimism/deploy_l2/15_update_with_base_in_wormhole_gateway_mapping.ts @@ -11,6 +11,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { // See https://docs.wormhole.com/wormhole/blockchain-environments/evm#base // This ID is valid for both Base Testnet and Mainnet + // TODO: check if id is correct for Arbitrum Sepolia as well (once Wormhole + // supports that testnet) const baseWormholeChainID = 30 const baseWormholeGateway = await deployments.getOrNull("BaseWormholeGateway") diff --git a/cross-chain/optimism/hardhat.config.ts b/cross-chain/optimism/hardhat.config.ts index 62fd7f58f..7ab960a83 100644 --- a/cross-chain/optimism/hardhat.config.ts +++ b/cross-chain/optimism/hardhat.config.ts @@ -44,6 +44,15 @@ const config: HardhatUserConfig = { : undefined, tags: ["etherscan"], }, + sepolia: { + url: process.env.L1_CHAIN_API_URL || "", + chainId: 11155111, + deploy: ["deploy_l1"], + accounts: process.env.L1_ACCOUNTS_PRIVATE_KEYS + ? process.env.L1_ACCOUNTS_PRIVATE_KEYS.split(",") + : undefined, + tags: ["etherscan"], + }, mainnet: { url: process.env.L1_CHAIN_API_URL || "", chainId: 1, @@ -65,6 +74,20 @@ const config: HardhatUserConfig = { // l1: "goerli", // }, }, + optimismSepolia: { + url: process.env.L2_CHAIN_API_URL || "", + chainId: 11155420, + deploy: ["deploy_l2"], + accounts: process.env.L2_ACCOUNTS_PRIVATE_KEYS + ? process.env.L2_ACCOUNTS_PRIVATE_KEYS.split(",") + : undefined, + // TODO: uncomment below line once `hardhat-verify` supports OP Sepolia + // (tracked in https://github.com/NomicFoundation/hardhat/issues/4607) + // tags: ["optimism_etherscan"], + // companionNetworks: { + // l1: "sepolia", + // }, + }, optimism: { url: process.env.L2_CHAIN_API_URL || "", chainId: 10, @@ -82,24 +105,30 @@ const config: HardhatUserConfig = { external: { deployments: { goerli: ["./external/goerli"], + sepolia: ["./external/sepolia"], mainnet: ["./external/mainnet"], optimismGoerli: ["./external/optimismGoerli"], + optimismSepolia: ["./external/optimismSepolia"], optimism: ["./external/optimism"], }, }, deploymentArtifactsExport: { goerli: "artifacts/l1", + sepolia: "artifacts/l1", mainnet: "artifacts/l1", optimismGoerli: "artifacts/l2", + optimismSepolia: "artifacts/l2", optimism: "artifacts/l2", }, etherscan: { apiKey: { goerli: process.env.ETHERSCAN_API_KEY, + sepolia: process.env.ETHERSCAN_API_KEY, mainnet: process.env.ETHERSCAN_API_KEY, optimisticGoerli: process.env.OPTIMISM_ETHERSCAN_API_KEY, + optimisticSepolia: process.env.OPTIMISM_ETHERSCAN_API_KEY, optimisticEthereum: process.env.OPTIMISM_ETHERSCAN_API_KEY, }, }, @@ -108,14 +137,18 @@ const config: HardhatUserConfig = { deployer: { default: 1, goerli: 0, + sepolia: 0, optimismGoerli: 0, + optimismSepolia: 0, mainnet: "0x123694886DBf5Ac94DDA07135349534536D14cAf", optimism: "0x123694886DBf5Ac94DDA07135349534536D14cAf", }, governance: { default: 2, goerli: 0, + sepolia: 0, optimismGoerli: 0, + optimismSepolia: 0, mainnet: "0x9f6e831c8f8939dc0c830c6e492e7cef4f9c2f5f", optimism: "0x7fB50BBabeDEE52b8760Ba15c0c199aF33Fc2EfA", }, diff --git a/cross-chain/optimism/package.json b/cross-chain/optimism/package.json index 6d1c8e009..017ecca40 100644 --- a/cross-chain/optimism/package.json +++ b/cross-chain/optimism/package.json @@ -31,6 +31,7 @@ "lint:config:fix": "prettier --write '**/*.@(json|yaml)'", "prepack": "tsc -p tsconfig.export.json && hardhat export-artifacts export/artifacts", "export-artifacts:goerli": "yarn hardhat export-deployment-artifacts --network optimismGoerli", + "export-artifacts:sepolia": "yarn hardhat export-deployment-artifacts --network optimismSepolia", "export-artifacts:mainnet": "yarn hardhat export-deployment-artifacts --network optimism", "prepublishOnly": "npm run export-artifacts:$npm_config_network", "test": "hardhat test"