From d1a880d4503854bb1db2c36cee5bc5d990b1de88 Mon Sep 17 00:00:00 2001 From: Michalina Date: Tue, 5 Sep 2023 16:18:30 +0200 Subject: [PATCH] Support deployment on Sepolia MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Görli testnet currently used by Threshold/Keep for development purposes is planned to become deprecated with the end of year 2023. The testnet that is planned to replace it is called [Holešky](https://github.com/eth-clients/holesky), however it's not yet available - it's planned it will become widely accessible on Oct 1, 2023 ([source](https://everstake.one/blog/new-ethereum-testnet-holesky-all-you-need-to-know-now)). Switching our infrastructure to support new testnet is quite time consuming, so moving directly from Görli to Holešky may be quite risky, especially if there would be some delays in the date of Holešky genesis (not meeting the planned timelines is not a rare occurrence in the Ethereum space). 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. --- .github/workflows/contracts.yml | 49 ++++++++++++++++---- deploy/00_resolve_nucypher_staking_escrow.ts | 2 +- deploy/00_resolve_nucypher_token.ts | 2 +- deploy/07_deploy_token_staking.ts | 2 +- hardhat.config.ts | 17 +++---- 5 files changed, 50 insertions(+), 22 deletions(-) diff --git a/.github/workflows/contracts.yml b/.github/workflows/contracts.yml index 7054c4ef..9c2286bb 100644 --- a/.github/workflows/contracts.yml +++ b/.github/workflows/contracts.yml @@ -24,7 +24,7 @@ on: workflow_dispatch: inputs: environment: - description: "Environment (network) for workflow execution, e.g. `goerli`" + description: "Environment (network) for workflow execution, e.g. `sepolia`" required: false upstream_builds: description: "Upstream builds" @@ -153,9 +153,22 @@ jobs: - name: Deploy contracts env: - CHAIN_API_URL: ${{ secrets.GOERLI_ETH_HOSTNAME_HTTP }} - CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: ${{ secrets.GOERLI_ETH_CONTRACT_OWNER_PRIVATE_KEY }} - KEEP_CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: ${{ secrets.GOERLI_KEEP_ETH_CONTRACT_OWNER_PRIVATE_KEY }} + # Use fake ternary expressions to decide which credentials to use, + # depending on chosen environment. Note: if `GOERLI...` credentials + # are empty, the expressions will be evaluated to the `SEPOLIA...` + # ones. + CHAIN_API_URL: | + ${{ inputs.github.event.inputs.environment == 'goerli' + && secrets.GOERLI_ETH_HOSTNAME_HTTP + || secrets.SEPOLIA_ETH_HOSTNAME_HTTP }} + CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: | + ${{ inputs.github.event.inputs.environment == 'goerli' + && secrets.GOERLI_ETH_CONTRACT_OWNER_PRIVATE_KEY + || secrets.SEPOLIA_ETH_CONTRACT_OWNER_PRIVATE_KEY }} + KEEP_CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: | + ${{ inputs.github.event.inputs.environment == 'goerli' + && secrets.GOERLI_KEEP_ETH_CONTRACT_OWNER_PRIVATE_KEY + || secrets.SEPOLIA_KEEP_ETH_CONTRACT_OWNER_PRIVATE_KEY }} run: yarn deploy --network ${{ github.event.inputs.environment }} - name: Bump up package version @@ -224,7 +237,14 @@ jobs: - name: Verify contracts on Etherscan env: ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }} - CHAIN_API_URL: ${{ secrets.GOERLI_ETH_HOSTNAME_HTTP }} + # Use fake ternary expression to decide which credentials to use, + # depending on chosen environment. Note: if `GOERLI...` credential + # is empty, the expressions will be evaluated to the `SEPOLIA...` + # one. + CHAIN_API_URL: | + ${{ inputs.github.event.inputs.environment == 'goerli' + && secrets.GOERLI_ETH_HOSTNAME_HTTP + || secrets.SEPOLIA_ETH_HOSTNAME_HTTP }} run: | yarn run hardhat --network ${{ github.event.inputs.environment }} \ etherscan-verify --license GPL-3.0 --force-license @@ -259,9 +279,22 @@ jobs: - name: Deploy contracts env: - CHAIN_API_URL: ${{ secrets.GOERLI_ETH_HOSTNAME_HTTP }} - CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: ${{ secrets.DAPP_DEV_GOERLI_ETH_CONTRACT_OWNER_PRIVATE_KEY }} - KEEP_CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: ${{ secrets.GOERLI_KEEP_ETH_CONTRACT_OWNER_PRIVATE_KEY }} + # Use fake ternary expressions to decide which credentials to use, + # depending on chosen environment. Note: if `GOERLI...` credentials + # are empty, the expressions will be evaluated to the `SEPOLIA...` + # ones. + CHAIN_API_URL: | + ${{ inputs.github.event.inputs.environment == 'goerli' + && secrets.GOERLI_ETH_HOSTNAME_HTTP + || secrets.SEPOLIA_ETH_HOSTNAME_HTTP }} + CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: | + ${{ inputs.github.event.inputs.environment == 'goerli' + && secrets.DAPP_DEV_GOERLI_ETH_CONTRACT_OWNER_PRIVATE_KEY + || secrets.DAPP_DEV_SEPOLIA_ETH_CONTRACT_OWNER_PRIVATE_KEY }} + KEEP_CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: | + ${{ inputs.github.event.inputs.environment == 'goerli' + && secrets.GOERLI_KEEP_ETH_CONTRACT_OWNER_PRIVATE_KEY + || secrets.SEPOLIA_KEEP_ETH_CONTRACT_OWNER_PRIVATE_KEY }} run: yarn deploy --network ${{ github.event.inputs.environment }} - name: Bump up package version diff --git a/deploy/00_resolve_nucypher_staking_escrow.ts b/deploy/00_resolve_nucypher_staking_escrow.ts index 53188089..509c90d8 100644 --- a/deploy/00_resolve_nucypher_staking_escrow.ts +++ b/deploy/00_resolve_nucypher_staking_escrow.ts @@ -26,7 +26,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { } else if ( // TODO: For testnets currently we deploy a stub contract. We should consider // switching to an actual contract. - hre.network.name !== "ropsten" && + hre.network.name !== "sepolia" && hre.network.name !== "goerli" && (!hre.network.tags.allowStubs || (hre.network.config as HardhatNetworkConfig)?.forking?.enabled) diff --git a/deploy/00_resolve_nucypher_token.ts b/deploy/00_resolve_nucypher_token.ts index cc35e53f..58383398 100644 --- a/deploy/00_resolve_nucypher_token.ts +++ b/deploy/00_resolve_nucypher_token.ts @@ -21,7 +21,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { } else if ( // TODO: For testnets currently we deploy a stub contract. We should consider // switching to an actual contract. - hre.network.name !== "ropsten" && + hre.network.name !== "sepolia" && hre.network.name !== "goerli" && (!hre.network.tags.allowStubs || (hre.network.config as HardhatNetworkConfig)?.forking?.enabled) diff --git a/deploy/07_deploy_token_staking.ts b/deploy/07_deploy_token_staking.ts index 0f0c084a..f8db19a9 100644 --- a/deploy/07_deploy_token_staking.ts +++ b/deploy/07_deploy_token_staking.ts @@ -25,7 +25,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { ] const tokenStakingInitializerArgs = [] - // TODO: Consider upgradable deployment also for goerli. + // TODO: Consider upgradable deployment also for goerli/sepolia. let tokenStakingAddress if (hre.network.name == "mainnet") { const TokenStaking = await ethers.getContractFactory("TokenStaking") diff --git a/hardhat.config.ts b/hardhat.config.ts index 17bcfabb..d2b5c358 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -57,21 +57,13 @@ const config: HardhatUserConfig = { : undefined, tags: ["tenderly"], }, - rinkeby: { + sepolia: { url: process.env.CHAIN_API_URL || "", - chainId: 4, - accounts: process.env.CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY - ? [process.env.CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY] - : undefined, - tags: ["tenderly"], - }, - ropsten: { - url: process.env.CHAIN_API_URL || "", - chainId: 3, + chainId: 11155111, accounts: process.env.CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY ? [ process.env.CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY, - process.env.KEEP_CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY, + process.env.KEEP_CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY, // TODO: verify if we have different owner here or can we remove this ] : undefined, tags: ["tenderly"], @@ -100,6 +92,7 @@ const config: HardhatUserConfig = { // to the contract artifacts. hardhat: process.env.FORKING_URL ? ["./external/mainnet"] : [], goerli: ["./external/goerli"], + sepolia: ["./external/sepolia"], mainnet: ["./external/mainnet"], }, }, @@ -107,6 +100,7 @@ const config: HardhatUserConfig = { deployer: { default: 1, // take the first account as deployer goerli: 0, + sepolia: 0, // mainnet: "0x123694886DBf5Ac94DDA07135349534536D14cAf", }, thresholdCouncil: { @@ -116,6 +110,7 @@ const config: HardhatUserConfig = { default: 1, // same as the deployer ropsten: "0x923C5Dbf353e99394A21Aa7B67F3327Ca111C67D", goerli: "0x68ad60CC5e8f3B7cC53beaB321cf0e6036962dBc", + // sepolia: "", TODO: Fill with the address of the deployer }, }, mocha: {