From 212932f18bf8c900347816474d8d0f418e7e1a49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michalina=20Ciencia=C5=82a?= Date: Tue, 16 May 2023 09:20:01 +0200 Subject: [PATCH] Don't include stub contracts in NPM packages If `hardhat deploy` is run with `TEST_USE_STUBS_ECDSA` environment variable set to `true`, the deployment will include deployment of stub contracts, which are needed for testing purposes (execution of unit tests). So far we've been running `hardhat deploy TEST_USE_STUBS_ECDSA=true` together with `USE_EXTERNAL_DEPLOY=true` in `ecdsa` in the `deploy:test` script. The `USE_EXTERNAL_DEPLOY` variable specifies how the contracts of the dependencies should be deployed - whether to deploy them from scratch (`true`) or reuse the already deployed artifacts (`false`). We were using the `deploy:test` script in `ecdsa` in two places - when running `contracts-deployment-dry-run` job (test of deployment on `hardhat` local network) and in `npm-compile-publish-contracts` job (publishing of `development`-tagged NPM package). This second use proved to be problematic, as the `development`-tagged package is used to generate the client bindings when running `make all`, resulting in the presence of unneeded (and unwanted) functionalities (like `forceAddWallet` and `getDkgData` from `WalletRegistryStub`). The first use is not causing such problems, but it should still be modified, as it's better to run the dry-run of deploy on the real contracts and not on the stubs. What we decided to do is to replace ``` "deploy:test": "USE_EXTERNAL_DEPLOY=true TEST_USE_STUBS_ECDSA=true hardhat deploy", ``` with ``` "deploy:local": "USE_EXTERNAL_DEPLOY=true hardhat deploy", ``` and use the new `deploy:local` script in both jobs that previously used `deploy:test`. This way we'll no longer include stub functionalities in NPM packages (and hence in the clinet bindings) and we'll execute dry-run of the unmodified contracts. Scripts in `random-beacon` also got updated to follow the new naming. --- .github/workflows/contracts-ecdsa.yml | 2 +- .github/workflows/contracts-random-beacon.yml | 2 +- .github/workflows/npm-ecdsa.yml | 4 ++-- .github/workflows/npm-random-beacon.yml | 4 ++-- solidity/ecdsa/package.json | 2 +- solidity/random-beacon/package.json | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/contracts-ecdsa.yml b/.github/workflows/contracts-ecdsa.yml index 4e20dc64c9..65438be546 100644 --- a/.github/workflows/contracts-ecdsa.yml +++ b/.github/workflows/contracts-ecdsa.yml @@ -175,7 +175,7 @@ jobs: run: yarn install --frozen-lockfile - name: Deploy contracts - run: yarn deploy:test + run: yarn deploy:local - name: Build Docker Image uses: ./.github/actions/docker-build-push diff --git a/.github/workflows/contracts-random-beacon.yml b/.github/workflows/contracts-random-beacon.yml index 2c6fd00a02..ae3fa1f751 100644 --- a/.github/workflows/contracts-random-beacon.yml +++ b/.github/workflows/contracts-random-beacon.yml @@ -173,7 +173,7 @@ jobs: run: yarn install --network-concurrency 1 --frozen-lockfile - name: Deploy contracts - run: yarn deploy:test + run: yarn deploy:local - name: Build Docker Image uses: ./.github/actions/docker-build-push diff --git a/.github/workflows/npm-ecdsa.yml b/.github/workflows/npm-ecdsa.yml index 058b2a194c..b27b1cd4b3 100644 --- a/.github/workflows/npm-ecdsa.yml +++ b/.github/workflows/npm-ecdsa.yml @@ -38,9 +38,9 @@ jobs: @threshold-network/solidity-contracts # Deploy contracts to a local network to generate deployment artifacts that - # are required by dashboard and client compilation. + # are required by client compilation. - name: Deploy contracts - run: yarn deploy:test --network hardhat --write true + run: yarn deploy:local --network hardhat --write true - name: Bump up package version id: npm-version-bump diff --git a/.github/workflows/npm-random-beacon.yml b/.github/workflows/npm-random-beacon.yml index d046520aad..36a84a52f8 100644 --- a/.github/workflows/npm-random-beacon.yml +++ b/.github/workflows/npm-random-beacon.yml @@ -37,9 +37,9 @@ jobs: @threshold-network/solidity-contracts # Deploy contracts to a local network to generate deployment artifacts that - # are required by dashboard and client compilation. + # are required by client compilation. - name: Deploy contracts - run: yarn deploy:test --network hardhat --write true + run: yarn deploy:local --network hardhat --write true - name: Bump up package version id: npm-version-bump diff --git a/solidity/ecdsa/package.json b/solidity/ecdsa/package.json index f5880a5384..1751db51de 100644 --- a/solidity/ecdsa/package.json +++ b/solidity/ecdsa/package.json @@ -29,7 +29,7 @@ "build": "hardhat compile", "test": "USE_EXTERNAL_DEPLOY=true TEST_USE_STUBS_ECDSA=true hardhat test", "deploy": "hardhat deploy --export export.json", - "deploy:test": "USE_EXTERNAL_DEPLOY=true TEST_USE_STUBS_ECDSA=true hardhat deploy", + "deploy:local": "USE_EXTERNAL_DEPLOY=true hardhat deploy", "prepack": "tsc -p tsconfig.export.json && hardhat export-artifacts --including-no-public-functions export/artifacts", "prepublishOnly": "hardhat prepare-artifacts --network $npm_config_network" }, diff --git a/solidity/random-beacon/package.json b/solidity/random-beacon/package.json index f99d432039..644de1f4ae 100644 --- a/solidity/random-beacon/package.json +++ b/solidity/random-beacon/package.json @@ -18,7 +18,7 @@ "build": "hardhat compile", "test": "hardhat check-accounts-count && USE_EXTERNAL_DEPLOY=true TEST_USE_STUBS_BEACON=true hardhat test", "deploy": "hardhat deploy --export export.json", - "deploy:test": "USE_EXTERNAL_DEPLOY=true hardhat deploy", + "deploy:local": "USE_EXTERNAL_DEPLOY=true hardhat deploy", "format": "npm run lint", "format:fix": "npm run lint:fix", "lint": "npm run lint:eslint && npm run lint:sol && npm run lint:config",