From 5b11755dae801f3ef24aa9a1384e65474fac7859 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Mon, 11 Jul 2022 11:33:25 +0200 Subject: [PATCH 01/11] Add support for deployment on Goerli testnet MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 `tbtc-v2` 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 have the Görli deployment battle-tested and Ropsten gets shut down). NOTE: We're temporarily using some testing configuration in the workflow, which needs to be removed before merge to `main`. --- .github/workflows/contracts.yml | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/.github/workflows/contracts.yml b/.github/workflows/contracts.yml index ae6f0e07b..66d1f024e 100644 --- a/.github/workflows/contracts.yml +++ b/.github/workflows/contracts.yml @@ -146,21 +146,34 @@ jobs: id: upstream-builds-query with: upstream-builds: ${{ github.event.inputs.upstream_builds }} - query: tbtc-contracts-version = github.com/keep-network/tbtc/solidity#version + query: | + random-beacon-contracts-version = github.com/keep-network/keep-core/solidity/random-beacon#version + ecdsa-contracts-version = github.com/keep-network/keep-core/solidity/ecdsa#version - name: Resolve latest contracts - run: yarn upgrade @keep-network/tbtc@${{ steps.upstream-builds-query.outputs.tbtc-contracts-version }} + run: | + yarn upgrade \ + @keep-network/random-beacon@${{ steps.upstream-builds-query.outputs.random-beacon-contracts-version }} \ + @keep-network/ecdsa@${{ steps.upstream-builds-query.outputs.ecdsa-contracts-version }} + @keep-network/tbtc@1.1.2-goerli.0 - name: Configure tenderly - if: github.event.inputs.environment == 'ropsten' env: TENDERLY_TOKEN: ${{ secrets.TENDERLY_TOKEN }} run: ./config_tenderly.sh - - name: Deploy contracts + - name: Deploy contracts on Ropsten + if: github.event.inputs.environment == 'ropsten' env: - CHAIN_API_URL: ${{ secrets.KEEP_TEST_ETH_HOSTNAME_HTTP }} - CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: ${{ secrets.KEEP_TEST_ETH_CONTRACT_OWNER_PRIVATE_KEY }} + CHAIN_API_URL: ${{ secrets.ROPSTEN_ETH_HOSTNAME_HTTP }} + CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: ${{ secrets.ROPSTEN_ETH_CONTRACT_OWNER_PRIVATE_KEY }} + run: yarn deploy --network ${{ github.event.inputs.environment }} + + - name: Deploy contracts on Goerli + if: github.event.inputs.environment == 'goerli' + env: + CHAIN_API_URL: ${{ secrets.GOERLI_ETH_HOSTNAME_HTTP }} + CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: ${{ secrets.GOERLI_ETH_CONTRACT_OWNER_PRIVATE_KEY }} run: yarn deploy --network ${{ github.event.inputs.environment }} - name: Bump up package version @@ -175,10 +188,13 @@ jobs: - name: Publish to npm env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - run: npm publish --access=public --tag ${{ github.event.inputs.environment }} --network=${{ github.event.inputs.environment }} + # TODO: remove `--dry-run` before merge to main + run: npm publish --access=public --tag ${{ github.event.inputs.environment }} --network=${{ github.event.inputs.environment }} --dry-run + # TODO: restore commented out `uses` config before merge to `main`` - name: Notify CI about completion of the workflow - uses: keep-network/ci/actions/notify-workflow-completed@v1 + # uses: keep-network/ci/actions/notify-workflow-completed@v1 + uses: keep-network/ci/actions/notify-workflow-completed@ci-goerli env: GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} with: From 9f10e2e4035aa2c66a8652197732318f4392841e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Wed, 13 Jul 2022 12:21:02 +0200 Subject: [PATCH 02/11] Remove Ropsten-related config from deployment job As the Ropsten testnet becomes deprecated in the near future, we are switching to deployment on Goerli. If deployment on Ropsten will be needed in the interm period, we will do it manually, not via GH Actions. --- .github/workflows/contracts.yml | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/.github/workflows/contracts.yml b/.github/workflows/contracts.yml index 66d1f024e..a0e9f7df8 100644 --- a/.github/workflows/contracts.yml +++ b/.github/workflows/contracts.yml @@ -113,7 +113,9 @@ jobs: contracts-deployment-testnet: needs: [contracts-detect-changes, contracts-build-and-test] - if: github.event_name == 'workflow_dispatch' + if: | + github.event_name == 'workflow_dispatch' + && github.event.inputs.environment == 'goerli' runs-on: ubuntu-latest defaults: run: @@ -162,15 +164,7 @@ jobs: TENDERLY_TOKEN: ${{ secrets.TENDERLY_TOKEN }} run: ./config_tenderly.sh - - name: Deploy contracts on Ropsten - if: github.event.inputs.environment == 'ropsten' - env: - CHAIN_API_URL: ${{ secrets.ROPSTEN_ETH_HOSTNAME_HTTP }} - CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: ${{ secrets.ROPSTEN_ETH_CONTRACT_OWNER_PRIVATE_KEY }} - run: yarn deploy --network ${{ github.event.inputs.environment }} - - - name: Deploy contracts on Goerli - if: github.event.inputs.environment == 'goerli' + - name: Deploy contract env: CHAIN_API_URL: ${{ secrets.GOERLI_ETH_HOSTNAME_HTTP }} CONTRACT_OWNER_ACCOUNT_PRIVATE_KEY: ${{ secrets.GOERLI_ETH_CONTRACT_OWNER_PRIVATE_KEY }} @@ -258,7 +252,7 @@ jobs: - name: Verify contracts on Etherscan env: ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }} - CHAIN_API_URL: ${{ secrets.KEEP_TEST_ETH_HOSTNAME_HTTP }} + CHAIN_API_URL: ${{ secrets.GOERLI_ETH_HOSTNAME_HTTP }} run: yarn run hardhat --network ${{ github.event.inputs.environment }} etherscan-verify --license MIT contracts-format: From 08c0311905722a02e98f67d42fefbf397037d0f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Fri, 15 Jul 2022 12:24:08 +0200 Subject: [PATCH 03/11] Bump version of custom CI actions to v2 We are bumping the version of used custom GH actions from `v1` to `v2`, as `v2` uses the new order of modules execution. --- .github/workflows/contracts.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/contracts.yml b/.github/workflows/contracts.yml index a0e9f7df8..f9577c0ea 100644 --- a/.github/workflows/contracts.yml +++ b/.github/workflows/contracts.yml @@ -144,7 +144,7 @@ jobs: run: yarn install --frozen-lockfile - name: Get upstream packages versions - uses: keep-network/ci/actions/upstream-builds-query@v1 + uses: keep-network/ci/actions/upstream-builds-query@v2 id: upstream-builds-query with: upstream-builds: ${{ github.event.inputs.upstream_builds }} @@ -185,10 +185,8 @@ jobs: # TODO: remove `--dry-run` before merge to main run: npm publish --access=public --tag ${{ github.event.inputs.environment }} --network=${{ github.event.inputs.environment }} --dry-run - # TODO: restore commented out `uses` config before merge to `main`` - name: Notify CI about completion of the workflow - # uses: keep-network/ci/actions/notify-workflow-completed@v1 - uses: keep-network/ci/actions/notify-workflow-completed@ci-goerli + uses: keep-network/ci/actions/notify-workflow-completed@v2 env: GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} with: From edb2660f280f008e8de65b6a45a28a4170ddecc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Tue, 2 Aug 2022 08:42:45 +0200 Subject: [PATCH 04/11] Use tag when resolving `tbtc` contracts We tag the latest `@keep-network/tbtc` package containing contracts migrated on some environment with tag that is a name of that environment. We can use that tag instead of the explicit version when resolving contracts of dependent projects. --- .github/workflows/contracts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/contracts.yml b/.github/workflows/contracts.yml index f9577c0ea..71365fe9d 100644 --- a/.github/workflows/contracts.yml +++ b/.github/workflows/contracts.yml @@ -157,7 +157,7 @@ jobs: yarn upgrade \ @keep-network/random-beacon@${{ steps.upstream-builds-query.outputs.random-beacon-contracts-version }} \ @keep-network/ecdsa@${{ steps.upstream-builds-query.outputs.ecdsa-contracts-version }} - @keep-network/tbtc@1.1.2-goerli.0 + @keep-network/tbtc@${{ github.event.inputs.environment }} - name: Configure tenderly env: From 0912bad52bbb443cf8fd191f12d77609860bbbd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Tue, 2 Aug 2022 17:38:38 +0200 Subject: [PATCH 05/11] Remove check of `environment` in deployment job Right now we only support `goerli` network and we expect that the workflow (when triggered manually) is always dispatched with this `environment`. Previously we introduced `github.event.inputs.environment == 'goerli'` condition to not run the deploy job if workflow gets accidentally run on a different environment. But even without this condition we don't risk publishing of a package with some invalid contracts - deploy will fail either due to unsupported `environment` or due to incorrect account being used. Actually, returning error instead of cleanly exiting the workflow may be a better idea in case wrong `environment` is provided - this will alarm the scheduler that something went wrong with the deployment. --- .github/workflows/contracts.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/contracts.yml b/.github/workflows/contracts.yml index 71365fe9d..c6be64b2c 100644 --- a/.github/workflows/contracts.yml +++ b/.github/workflows/contracts.yml @@ -113,9 +113,7 @@ jobs: contracts-deployment-testnet: needs: [contracts-detect-changes, contracts-build-and-test] - if: | - github.event_name == 'workflow_dispatch' - && github.event.inputs.environment == 'goerli' + if: github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest defaults: run: From b15f9e9d411969a0ba1c9788bd24a14aa4253bdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Wed, 3 Aug 2022 11:18:24 +0200 Subject: [PATCH 06/11] Add missing linebreak in the command for resolving contracts --- .github/workflows/contracts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/contracts.yml b/.github/workflows/contracts.yml index c6be64b2c..b7ab1bfdb 100644 --- a/.github/workflows/contracts.yml +++ b/.github/workflows/contracts.yml @@ -154,7 +154,7 @@ jobs: run: | yarn upgrade \ @keep-network/random-beacon@${{ steps.upstream-builds-query.outputs.random-beacon-contracts-version }} \ - @keep-network/ecdsa@${{ steps.upstream-builds-query.outputs.ecdsa-contracts-version }} + @keep-network/ecdsa@${{ steps.upstream-builds-query.outputs.ecdsa-contracts-version }} \ @keep-network/tbtc@${{ github.event.inputs.environment }} - name: Configure tenderly From 9b1d0590121a69b1675b47f4c7af225667e4ab96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Fri, 5 Aug 2022 11:53:27 +0200 Subject: [PATCH 07/11] Update names of the CI modules We're changing the name of the CI modules (in order for the CI flow to execute jobs one after another the modules names can't consist of more than 4 slash-separated parts). --- .github/workflows/contracts.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/contracts.yml b/.github/workflows/contracts.yml index b7ab1bfdb..d261670e3 100644 --- a/.github/workflows/contracts.yml +++ b/.github/workflows/contracts.yml @@ -147,8 +147,8 @@ jobs: with: upstream-builds: ${{ github.event.inputs.upstream_builds }} query: | - random-beacon-contracts-version = github.com/keep-network/keep-core/solidity/random-beacon#version - ecdsa-contracts-version = github.com/keep-network/keep-core/solidity/ecdsa#version + random-beacon-contracts-version = github.com/keep-network/keep-core/random-beacon#version + ecdsa-contracts-version = github.com/keep-network/keep-core/ecdsa#version - name: Resolve latest contracts run: | @@ -188,7 +188,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }} with: - module: "github.com/keep-network/tbtc-v2/solidity" + module: "github.com/keep-network/tbtc-v2" url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} environment: ${{ github.event.inputs.environment }} upstream_builds: ${{ github.event.inputs.upstream_builds }} From c5a15f4a2557ad8406d78c1ef2bbdbcb88afd97c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Tue, 9 Aug 2022 10:53:53 +0200 Subject: [PATCH 08/11] Don't specify the licence when running etherscan-verify --- .github/workflows/contracts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/contracts.yml b/.github/workflows/contracts.yml index d261670e3..6e445d5f3 100644 --- a/.github/workflows/contracts.yml +++ b/.github/workflows/contracts.yml @@ -249,7 +249,7 @@ jobs: env: ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }} CHAIN_API_URL: ${{ secrets.GOERLI_ETH_HOSTNAME_HTTP }} - run: yarn run hardhat --network ${{ github.event.inputs.environment }} etherscan-verify --license MIT + run: yarn run hardhat --network ${{ github.event.inputs.environment }} etherscan-verify contracts-format: needs: contracts-detect-changes From 36b52913aebe97453855833c2054e7fa2319537d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Tue, 9 Aug 2022 11:15:57 +0200 Subject: [PATCH 09/11] Remove unwanted artifacts before verifying contracts on Etherscan We can be more precise when deleting unwanted artifacts. Also we need to get rid of the `random-beacon` artifacts. Otherwise the `random-beacon` contracts get picked by the `etherscan-verify` action. --- .github/workflows/contracts.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/contracts.yml b/.github/workflows/contracts.yml index 6e445d5f3..37fe305c4 100644 --- a/.github/workflows/contracts.yml +++ b/.github/workflows/contracts.yml @@ -237,13 +237,13 @@ jobs: - name: Install needed dependencies run: yarn install --frozen-lockfile - # If we don't remove the `ecdsa` and `tbtc` contracts from `node-modules`, - # the `etherscan-verify` plugins tries to verify them, which is not - # desired. + # If we don't remove the contracts from `node-modules`, the + # `etherscan-verify` plugins tries to verify them, which is not desired. - name: Prepare for verification on Etherscan run: | - rm -rf ./node_modules/@keep-network/ecdsa - rm -rf ./node_modules/@keep-network/tbtc + rm -rf ./node_modules/@keep-network/random-beacon/artifacts + rm -rf ./node_modules/@keep-network/ecdsa/artifacts + rm -rf ./node_modules/@keep-network/tbtc/artifacts - name: Verify contracts on Etherscan env: From 07435ee5a3ed6de34d3b0786a5ae152dd5b16305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Tue, 9 Aug 2022 15:55:22 +0200 Subject: [PATCH 10/11] Use deploy:test script in npm jobs The script has to be used in order to get dependency contracts working. --- .github/workflows/npm-contracts.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/npm-contracts.yml b/.github/workflows/npm-contracts.yml index 8f33a1cbf..8f28eca7d 100644 --- a/.github/workflows/npm-contracts.yml +++ b/.github/workflows/npm-contracts.yml @@ -43,7 +43,7 @@ jobs: # Deploy contracts to a local network to generate deployment artifacts that # are required by dashboard compilation. - name: Deploy contracts - run: yarn deploy --network hardhat --write true + run: yarn deploy:test --network hardhat --write true - name: Bump up package version id: npm-version-bump From d94c87c3ba4f6cff4f69ff40788e7fe7de9af96d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Tue, 9 Aug 2022 16:13:05 +0200 Subject: [PATCH 11/11] Remove testing configuration --- .github/workflows/contracts.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/contracts.yml b/.github/workflows/contracts.yml index 37fe305c4..56b869331 100644 --- a/.github/workflows/contracts.yml +++ b/.github/workflows/contracts.yml @@ -180,8 +180,7 @@ jobs: - name: Publish to npm env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - # TODO: remove `--dry-run` before merge to main - run: npm publish --access=public --tag ${{ github.event.inputs.environment }} --network=${{ github.event.inputs.environment }} --dry-run + run: npm publish --access=public --tag ${{ github.event.inputs.environment }} --network=${{ github.event.inputs.environment }} - name: Notify CI about completion of the workflow uses: keep-network/ci/actions/notify-workflow-completed@v2