Skip to content

Commit a64fac3

Browse files
Add support for deployment on Goerli testnet
Görli became a recommended test network after Ropsten's deprecation notice (https://blog.ethereum.org/2022/06/21/testnet-deprecation/). We're modifying GitHub Actions workflow for deploying `random-beacon` and `ecdsa` contracts to support the deployment on Görli. We're also leaving the possibility of deployment on Ropsten (this will be removed once we have the Görli deployment battle-tested and Ropsten gets shut down). We're also adding some actions to the deployment flows, like Tenderly/Etherscan verification or triggering execution of other workflows in the CI flow. NOTE: We're temporarily using some testing configuration in the workflow, which needs to be removed before merge to `main`.
1 parent 3e93c29 commit a64fac3

10 files changed

+359
-18
lines changed

.github/workflows/contracts-ecdsa.yml

+100-6
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,43 @@ jobs:
181181
- name: Install dependencies
182182
run: yarn install --frozen-lockfile
183183

184-
# TODO: Configure tenderly
184+
- name: Get upstream packages versions
185+
uses: keep-network/ci/actions/upstream-builds-query@v1
186+
id: upstream-builds-query
187+
with:
188+
upstream-builds: ${{ github.event.inputs.upstream_builds }}
189+
query: |
190+
solidity-contracts-version = github.com/threshold-network/solidity-contracts#version
191+
random-beacon-version = github.com/keep-network/keep-core/solidity/random-beacon#version
185192
186-
- name: Deploy contracts
193+
- name: Resolve latest contracts
194+
run: |
195+
yarn upgrade \
196+
@threshold-network/solidity-contracts@${{ steps.upstream-builds-query.outputs.solidity-contracts-version }} \
197+
@keep-network/random-beacon@${{ steps.upstream-builds-query.outputs.random-beacon-version }} \
198+
@keep-network/sortition-pools
199+
200+
- name: Configure tenderly
201+
env:
202+
TENDERLY_TOKEN: ${{ secrets.TENDERLY_TOKEN }}
203+
run: ./config_tenderly.sh
204+
205+
# Ultimately, we want to get rid of steps deploying on Ropsten (as it will
206+
# be shut down in Q4 2022) and switch to deployment on Goerli. We're
207+
# leaving both deployment options for the transition period.
208+
209+
- name: Deploy contracts on Ropsten
210+
if: github.event.inputs.environment == 'ropsten'
211+
env:
212+
CHAIN_API_URL: ${{ secrets.ROPSTEN_ETH_HOSTNAME_HTTP }}
213+
CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: ${{ secrets.ROPSTEN_ETH_CONTRACT_OWNER_PRIVATE_KEY }}
214+
run: yarn deploy --network ${{ github.event.inputs.environment }}
215+
216+
- name: Deploy contracts on Goerli
217+
if: github.event.inputs.environment == 'goerli'
187218
env:
188-
CHAIN_API_URL: ${{ secrets.KEEP_TEST_ETH_HOSTNAME_HTTP }}
189-
CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: ${{ secrets.KEEP_TEST_ETH_CONTRACT_OWNER_PRIVATE_KEY }}
219+
CHAIN_API_URL: ${{ secrets.GOERLI_ETH_HOSTNAME_HTTP }}
220+
CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: ${{ secrets.GOERLI_ETH_CONTRACT_OWNER_PRIVATE_KEY }}
190221
run: yarn deploy --network ${{ github.event.inputs.environment }}
191222

192223
- name: Bump up package version
@@ -201,6 +232,69 @@ jobs:
201232
- name: Publish to npm
202233
env:
203234
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
204-
run: npm publish --access=public --tag ${{ github.event.inputs.environment }} --network=${{ github.event.inputs.environment }}
235+
# TODO: remove `--dry-run` before merge to main
236+
run: npm publish --access=public --tag ${{ github.event.inputs.environment }} --network=${{ github.event.inputs.environment }} --dry-run
205237

206-
# TODO: Notify CI about completion of the workflow
238+
# TODO: restore commented out `uses` config before merge to `main``
239+
- name: Notify CI about completion of the workflow
240+
# uses: keep-network/ci/actions/notify-workflow-completed@v1
241+
uses: keep-network/ci/actions/notify-workflow-completed@ci-goerli
242+
env:
243+
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
244+
with:
245+
module: "github.com/keep-network/keep-core/solidity/ecdsa"
246+
url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
247+
environment: ${{ github.event.inputs.environment }}
248+
upstream_builds: ${{ github.event.inputs.upstream_builds }}
249+
upstream_ref: ${{ github.event.inputs.upstream_ref }}
250+
version: ${{ steps.npm-version-bump.outputs.version }}
251+
252+
- name: Upload files needed for etherscan verification
253+
uses: actions/upload-artifact@v2
254+
with:
255+
name: Artifacts for etherscan verifcation
256+
path: |
257+
./solidity/ecdsa/deployments
258+
./solidity/ecdsa/package.json
259+
./solidity/ecdsa/yarn.lock
260+
261+
contracts-etherscan-verification:
262+
needs: [contracts-deployment-testnet]
263+
runs-on: ubuntu-latest
264+
defaults:
265+
run:
266+
working-directory: ./solidity/ecdsa
267+
steps:
268+
- uses: actions/checkout@v2
269+
270+
- name: Download files needed for etherscan verification
271+
uses: actions/download-artifact@v2
272+
with:
273+
name: Artifacts for etherscan verifcation
274+
275+
- uses: actions/setup-node@v2
276+
with:
277+
node-version: "14.x"
278+
cache: "yarn"
279+
cache-dependency-path: solidity/ecdsa/yarn.lock
280+
281+
- name: Install needed dependencies
282+
run: yarn install --frozen-lockfile
283+
284+
# If we don't remove the `keep-core` contracts from `node-modules`, the
285+
# `etherscan-verify` plugins tries to verify them, which is not desired.
286+
- name: Prepare for verification on Etherscan
287+
run: |
288+
rm -rf ./node_modules/@keep-network/keep-core
289+
rm -rf ./node_modules/@keep-network/random-beacon
290+
rm -rf ./node_modules/@keep-network/sortition-pools
291+
rm -rf ./node_modules/@threshold-network/solidity-contracts
292+
rm -rf ./external/npm
293+
294+
- name: Verify contracts on Etherscan
295+
env:
296+
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
297+
CHAIN_API_URL: ${{ secrets.ROPSTEN_ETH_HOSTNAME_HTTP }}
298+
run: |
299+
yarn run hardhat --network ${{ github.event.inputs.environment }} \
300+
etherscan-verify --license GPL-3.0 --force-license

.github/workflows/contracts-random-beacon.yml

+97-6
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,41 @@ jobs:
179179
- name: Install dependencies
180180
run: yarn install --network-concurrency 1 --frozen-lockfile
181181

182-
# TODO: Configure tenderly
182+
- name: Get upstream packages versions
183+
uses: keep-network/ci/actions/upstream-builds-query@v1
184+
id: upstream-builds-query
185+
with:
186+
upstream-builds: ${{ github.event.inputs.upstream_builds }}
187+
query: |
188+
solidity-contracts-version = github.com/threshold-network/solidity-contracts#version
183189
184-
- name: Deploy contracts
190+
- name: Resolve latest contracts
191+
run: |
192+
yarn upgrade \
193+
@threshold-network/solidity-contracts@${{ steps.upstream-builds-query.outputs.solidity-contracts-version }} \
194+
@keep-network/sortition-pools
195+
196+
- name: Configure tenderly
197+
env:
198+
TENDERLY_TOKEN: ${{ secrets.TENDERLY_TOKEN }}
199+
run: ./config_tenderly.sh
200+
201+
# Ultimately, we want to get rid of steps deploying on Ropsten (as it will
202+
# be shut down in Q4 2022) and switch to deployment on Goerli. We're
203+
# leaving both deployment options for the transition period.
204+
205+
- name: Deploy contracts on Ropsten
206+
if: github.event.inputs.environment == 'ropsten'
207+
env:
208+
CHAIN_API_URL: ${{ secrets.ROPSTEN_ETH_HOSTNAME_HTTP }}
209+
CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: ${{ secrets.ROPSTEN_ETH_CONTRACT_OWNER_PRIVATE_KEY }}
210+
run: yarn deploy --network ${{ github.event.inputs.environment }}
211+
212+
- name: Deploy contracts on Goerli
213+
if: github.event.inputs.environment == 'goerli'
185214
env:
186-
CHAIN_API_URL: ${{ secrets.KEEP_TEST_ETH_HOSTNAME_HTTP }}
187-
CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: ${{ secrets.KEEP_TEST_ETH_CONTRACT_OWNER_PRIVATE_KEY }}
215+
CHAIN_API_URL: ${{ secrets.GOERLI_ETH_HOSTNAME_HTTP }}
216+
CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: ${{ secrets.GOERLI_ETH_CONTRACT_OWNER_PRIVATE_KEY }}
188217
run: yarn deploy --network ${{ github.event.inputs.environment }}
189218

190219
- name: Bump up package version
@@ -199,6 +228,68 @@ jobs:
199228
- name: Publish to npm
200229
env:
201230
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
202-
run: npm publish --access=public --tag ${{ github.event.inputs.environment }} --network=${{ github.event.inputs.environment }}
231+
# TODO: remove `--dry-run` before merge to main
232+
run: npm publish --access=public --tag ${{ github.event.inputs.environment }} --network=${{ github.event.inputs.environment }} --dry-run
233+
234+
# TODO: restore commented out `uses` config before merge to `main``
235+
- name: Notify CI about completion of the workflow
236+
# uses: keep-network/ci/actions/notify-workflow-completed@v1
237+
uses: keep-network/ci/actions/notify-workflow-completed@ci-goerli
238+
env:
239+
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
240+
with:
241+
module: "github.com/keep-network/keep-core/solidity/random-beacon"
242+
url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
243+
environment: ${{ github.event.inputs.environment }}
244+
upstream_builds: ${{ github.event.inputs.upstream_builds }}
245+
upstream_ref: ${{ github.event.inputs.upstream_ref }}
246+
version: ${{ steps.npm-version-bump.outputs.version }}
247+
248+
- name: Upload files needed for etherscan verification
249+
uses: actions/upload-artifact@v2
250+
with:
251+
name: Artifacts for etherscan verifcation
252+
path: |
253+
./solidity/random-beacon/deployments
254+
./solidity/random-beacon/package.json
255+
./solidity/random-beacon/yarn.lock
256+
257+
contracts-etherscan-verification:
258+
needs: [contracts-deployment-testnet]
259+
runs-on: ubuntu-latest
260+
defaults:
261+
run:
262+
working-directory: ./solidity/random-beacon
263+
steps:
264+
- uses: actions/checkout@v2
203265

204-
# TODO: Notify CI about completion of the workflow
266+
- name: Download files needed for etherscan verification
267+
uses: actions/download-artifact@v2
268+
with:
269+
name: Artifacts for etherscan verifcation
270+
271+
- uses: actions/setup-node@v2
272+
with:
273+
node-version: "14.x"
274+
cache: "yarn"
275+
cache-dependency-path: solidity/random-beacon/yarn.lock
276+
277+
- name: Install needed dependencies
278+
run: yarn install --frozen-lockfile
279+
280+
# If we don't remove the `keep-core` contracts from `node-modules`, the
281+
# `etherscan-verify` plugins tries to verify them, which is not desired.
282+
- name: Prepare for verification on Etherscan
283+
run: |
284+
rm -rf ./node_modules/@keep-network/keep-core
285+
rm -rf ./node_modules/@keep-network/sortition-pools
286+
rm -rf ./node_modules/@threshold-network/solidity-contracts
287+
rm -rf ./external/npm
288+
289+
- name: Verify contracts on Etherscan
290+
env:
291+
ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }}
292+
CHAIN_API_URL: ${{ secrets.ROPSTEN_ETH_HOSTNAME_HTTP }}
293+
run: |
294+
yarn run hardhat --network ${{ github.event.inputs.environment }} \
295+
etherscan-verify --license GPL-3.0 --force-license

solidity/ecdsa/config_tenderly.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
LOG_START='\n\e[1;36m' # new line + bold + color
6+
LOG_END='\n\e[0m' # new line + reset color
7+
8+
printf "${LOG_START}Configuring Tenderly...${LOG_END}"
9+
10+
mkdir $HOME/.tenderly && touch $HOME/.tenderly/config.yaml
11+
12+
echo access_key: ${TENDERLY_TOKEN} > $HOME/.tenderly/config.yaml

solidity/ecdsa/hardhat.config.ts

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import "@keep-network/hardhat-local-networks-config"
33
import "@nomiclabs/hardhat-waffle"
44
import "@typechain/hardhat"
55
import "hardhat-deploy"
6+
import "@nomiclabs/hardhat-etherscan"
67
import "@tenderly/hardhat-tenderly"
78
import "hardhat-contract-sizer"
89
import "hardhat-dependency-compiler"
@@ -116,6 +117,9 @@ const config: HardhatUserConfig = {
116117
username: "thesis",
117118
project: "",
118119
},
120+
etherscan: {
121+
apiKey: process.env.ETHERSCAN_API_KEY,
122+
},
119123
namedAccounts: {
120124
deployer: {
121125
default: 1, // take the second account

solidity/ecdsa/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"@keep-network/hardhat-helpers": "^0.6.0-pre.8",
3838
"@keep-network/hardhat-local-networks-config": "^0.1.0-pre.4",
3939
"@nomiclabs/hardhat-ethers": "^2.0.6",
40+
"@nomiclabs/hardhat-etherscan": "^3.1.0",
4041
"@nomiclabs/hardhat-waffle": "^2.0.2",
4142
"@openzeppelin/hardhat-upgrades": "^1.17.0",
4243
"@tenderly/hardhat-tenderly": "^1.0.13",

0 commit comments

Comments
 (0)