Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Sepolia / Optimism Sepolia support for Optimism cross-chain #752

Merged
merged 13 commits into from
Feb 19, 2024
Merged
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
1 change: 1 addition & 0 deletions cross-chain/optimism/.gitignore
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
!/deployments/mainnet/
!/deployments/optimism/
!/deployments/optimismGoerli/
!/deployments/optimismSepolia/

# OZ
/.openzeppelin/unknown-*.json
6 changes: 3 additions & 3 deletions cross-chain/optimism/README.adoc
Original file line number Diff line number Diff line change
@@ -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 <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/<alchemy_api_key>`
- `L2_CHAIN_API_URL` - URL to access blockchain services, e.g. `https://optimism-sepolia.infura.io/v3/<infura_api_key>`
- `L2_ACCOUNTS_PRIVATE_KEYS` - Private keys for the deployer and council `<0xOwnerPrivKey,0xCouncilPrivKey>`
- `OPTIMISM_ETHERSCAN_API_KEY` - Optimism Etherscan API key
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import type { HardhatRuntimeEnvironment } from "hardhat/types"
import type { DeployFunction } from "hardhat-deploy/types"

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

Check warning on line 4 in cross-chain/optimism/deploy_l2/12_update_self_in_wormhole_gateway_mapping.ts

GitHub Actions / contracts-format

Unexpected unnamed async function
const { deployments, getNamedAccounts, ethers } = hre
const { execute } = deployments
const { deployer } = await getNamedAccounts()

// See https://book.wormhole.com/reference/contracts.html
// This ID is valid for both Optimism Goerli and Mainnet
const wormholeChainID = 24
// See https://docs.wormhole.com/wormhole/blockchain-environments/evm#optimism
// and https://docs.wormhole.com/wormhole/blockchain-environments/evm#optimism-sepolia
// The value `24` is valid for both Optimism Goerli and Optimism Mainnet. The
// value for Optimism Sepolia is `10005`.
const wormholeChainID = hre.network.name === "optimismSepolia" ? 10005 : 24

const optimismWormholeGateway = await deployments.get(
"OptimismWormholeGateway"
Original file line number Diff line number Diff line change
@@ -10,9 +10,12 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const fakeArbitrumWormholeGateway =
"0x1af5DC16568EFF2d480a43A77E6C409e497FcFb9"

// See https://book.wormhole.com/reference/contracts.html
// This ID is valid for both Arbitrum Goerli and Mainnet
const arbitrumWormholeChainID = 23
// See https://docs.wormhole.com/wormhole/blockchain-environments/evm#arbitrum
// and https://docs.wormhole.com/wormhole/blockchain-environments/evm#arbitrum-sepolia
// The value `23` is valid for both Arbitrum Goerli and Arbitrum Mainnet. The
// value for Arbitrum Sepolia is `10003`.
const arbitrumWormholeChainID =
hre.network.name === "optimismSepolia" ? 10003 : 23

const arbitrumWormholeGateway = await deployments.getOrNull(
"ArbitrumWormholeGateway"
@@ -38,4 +41,4 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
export default func

func.tags = ["SetArbitrumGatewayAddress"]
func.dependencies = ["OptimismWormholeGateway"]
func.dependencies = ["OptimismWormholeGateway", "ArbitrumWormholeGateway"]
Original file line number Diff line number Diff line change
@@ -10,8 +10,10 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const fakePolygonWormholeGateway =
"0x1af5DC16568EFF2d480a43A77E6C409e497FcFb9"

// See https://book.wormhole.com/reference/contracts.html
// This ID is valid for both Polygon Testnet (Mumbai) and Mainnet
// See https://docs.wormhole.com/wormhole/blockchain-environments/evm#polygon
// This ID is valid for both Polygonn Goerli-based Testnet (Mumbai) and
// Mainnet. Wormhole does not support the Sepolia-based Amoy Testnet yet.
// TODO: Update the ID once the support is added.
const polygonWormholeChainID = 5

const polygonWormholeGateway = await deployments.getOrNull(
@@ -36,4 +38,4 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
export default func

func.tags = ["SetPolygonGatewayAddress"]
func.dependencies = ["OptimismWormholeGateway"]
func.dependencies = ["OptimismWormholeGateway", "PolygonWormholeGateway"]
Original file line number Diff line number Diff line change
@@ -9,9 +9,12 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
// Fake BaseWormholeGateway for local development purposes only.
const fakeBaseWormholeGateway = "0x1af5DC16568EFF2d480a43A77E6C409e497FcFb9"

// See https://docs.wormhole.com/wormhole/blockchain-environments/evm#base
// This ID is valid for both Base Testnet and Mainnet
const baseWormholeChainID = 30
// See https://docs.wormhole.com/wormhole/blockchain-environments/evm#base and
// https://docs.wormhole.com/wormhole/blockchain-environments/evm#base-sepolia
// The value `30` is valid for both Base Goerli and Base Mainnet. The value
// for Base Sepolia is `10004`.
const baseWormholeChainID =
hre.network.name === "optimismSepolia" ? 10004 : 30

const baseWormholeGateway = await deployments.getOrNull("BaseWormholeGateway")

@@ -33,4 +36,4 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
export default func

func.tags = ["SetBaseGatewayAddress"]
func.dependencies = ["BaseWormholeGateway"]
func.dependencies = ["BaseWormholeGateway", "OptimismWormholeGateway"]
1 change: 1 addition & 0 deletions cross-chain/optimism/deployments/optimismSepolia/.chainId
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
11155420
863 changes: 863 additions & 0 deletions cross-chain/optimism/deployments/optimismSepolia/OptimismTBTC.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"address": "0xc3d46e0266d95215589de639cc4e93b79f88fc6c"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"address": "0xc3d46e0266d95215589de639cc4e93b79f88fc6c"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"address": "0x99737Ec4B815d816c49A385943baf0380e75c0Ac"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"address": "0x2133a5132c962f11f1ed6ca709132eef146d1b1c"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"address": "0x69a22dc2e01ecd2ae40864822d4406ff8aed4e2b8932385dabe818422ff67e1b"
}
3 changes: 3 additions & 0 deletions cross-chain/optimism/external/sepolia/TokenBridge.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"address": "0xDB5492265f6038831E89f495670FF909aDe94bd9"
}
44 changes: 44 additions & 0 deletions cross-chain/optimism/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -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,21 @@ 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,
tags: ["optimism_etherscan"],
// In case of deployment failing with underpriced transaction error set
// the `gasPrice` parameter.
// gasPrice: 1000000000,
// companionNetworks: {
// l1: "sepolia",
// },
},
optimism: {
url: process.env.L2_CHAIN_API_URL || "",
chainId: 10,
@@ -82,40 +106,60 @@ 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,
},
customChains: [
{
network: "optimisticSepolia",
chainId: 11155420,
urls: {
apiURL: "https://api-sepolia-optimistic.etherscan.io/api",
browserURL: "https://sepolia-optimism.etherscan.io/",
},
},
],
},

namedAccounts: {
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",
},
1 change: 1 addition & 0 deletions cross-chain/optimism/package.json
Original file line number Diff line number Diff line change
@@ -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"

Unchanged files with check annotations Beta

import type { HardhatRuntimeEnvironment } from "hardhat/types"
import type { DeployFunction } from "hardhat-deploy/types"
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

Check warning on line 4 in cross-chain/optimism/deploy_l2/00_resolve_arbitrum_wormhole_gateway.ts

GitHub Actions / contracts-format

Unexpected unnamed async function
const { helpers, deployments } = hre
const { log } = deployments
import type { HardhatRuntimeEnvironment } from "hardhat/types"
import type { DeployFunction } from "hardhat-deploy/types"
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

Check warning on line 4 in cross-chain/optimism/deploy_l2/00_resolve_base_wormhole_gateway.ts

GitHub Actions / contracts-format

Unexpected unnamed async function
const { helpers, deployments } = hre
const { log } = deployments
import type { HardhatRuntimeEnvironment } from "hardhat/types"
import type { DeployFunction } from "hardhat-deploy/types"
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

Check warning on line 4 in cross-chain/optimism/deploy_l2/00_resolve_optimism_token_bridge.ts

GitHub Actions / contracts-format

Unexpected unnamed async function
const { helpers, deployments } = hre
const { log } = deployments
import type { HardhatRuntimeEnvironment } from "hardhat/types"
import type { DeployFunction } from "hardhat-deploy/types"
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

Check warning on line 4 in cross-chain/optimism/deploy_l2/00_resolve_optimism_wormhole_tbtc.ts

GitHub Actions / contracts-format

Unexpected unnamed async function
const { helpers, deployments } = hre
const { log } = deployments
import type { HardhatRuntimeEnvironment } from "hardhat/types"
import type { DeployFunction } from "hardhat-deploy/types"
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

Check warning on line 4 in cross-chain/optimism/deploy_l2/00_resolve_polygon_wormhole_gateway.ts

GitHub Actions / contracts-format

Unexpected unnamed async function
const { helpers, deployments } = hre
const { log } = deployments
import type { HardhatRuntimeEnvironment } from "hardhat/types"
import type { DeployFunction } from "hardhat-deploy/types"
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

Check warning on line 4 in cross-chain/optimism/deploy_l2/00_resolve_solana_wormhole_gateway.ts

GitHub Actions / contracts-format

Unexpected unnamed async function
const { helpers, deployments } = hre
const { log } = deployments
import type { HardhatRuntimeEnvironment } from "hardhat/types"
import type { DeployFunction } from "hardhat-deploy/types"
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

Check warning on line 4 in cross-chain/optimism/deploy_l2/01_deploy_optimism_tbtc_token.ts

GitHub Actions / contracts-format

Unexpected unnamed async function
const { ethers, getNamedAccounts, helpers } = hre
const { deployer } = await getNamedAccounts()
import type { HardhatRuntimeEnvironment } from "hardhat/types"
import type { DeployFunction } from "hardhat-deploy/types"
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

Check warning on line 4 in cross-chain/optimism/deploy_l2/02_deploy_optimism_wormhole_gateway.ts

GitHub Actions / contracts-format

Unexpected unnamed async function
const { ethers, getNamedAccounts, helpers, deployments } = hre
const { log } = deployments
const { deployer } = await getNamedAccounts()
import type { HardhatRuntimeEnvironment } from "hardhat/types"
import type { DeployFunction } from "hardhat-deploy/types"
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {

Check warning on line 4 in cross-chain/optimism/deploy_l2/11_authorize_wormhole_gateway_as_minter.ts

GitHub Actions / contracts-format

Unexpected unnamed async function
const { deployments, getNamedAccounts } = hre
const { execute } = deployments
const { deployer } = await getNamedAccounts()