From a9fda9c82cd3290fdb1eb50323164d012babef68 Mon Sep 17 00:00:00 2001 From: Marcin Date: Tue, 1 Oct 2024 10:15:25 +0200 Subject: [PATCH 01/17] Fixed on push to main commit --- ...contracts-compile-and-deploy-to-devenv.yml | 23 ++++--------------- .github/workflows/on-master-branch-commit.yml | 11 ++++++++- Makefile | 3 ++- 3 files changed, 16 insertions(+), 21 deletions(-) diff --git a/.github/workflows/contracts-compile-and-deploy-to-devenv.yml b/.github/workflows/contracts-compile-and-deploy-to-devenv.yml index 50822d24..d6ba0965 100644 --- a/.github/workflows/contracts-compile-and-deploy-to-devenv.yml +++ b/.github/workflows/contracts-compile-and-deploy-to-devenv.yml @@ -15,18 +15,10 @@ jobs: uses: ./.github/workflows/_check-vars-and-secrets.yml secrets: inherit - test-azero-contracts: - needs: [check-vars-and-secrets] - uses: ./.github/workflows/test-azero-contracts.yml - - test-eth-contracts: - needs: [check-vars-and-secrets] - uses: ./.github/workflows/test-eth-contracts.yml - deploy-contracts: name: Deploy and setup contracts runs-on: [self-hosted, Linux, X64, large] - needs: [test-eth-contracts, test-azero-contracts] + needs: [check-vars-and-secrets] outputs: artifact-matrix-json: ${{ steps.get-artifact-matrix.outputs.artifact-matrix }} @@ -37,14 +29,6 @@ jobs: - name: Setup node uses: asdf-vm/actions/install@v3 - - name: Create token config - shell: bash - run: | - cat cfg/tokens_testnet_example.json > cfg/tokens_testnet.json - # Commented out for now, in case contracts should be marked as not deployed - #jq '.eth[0].deployed = false' | jq '.aleph[0].deployed = false' - #jq 'del(.eth[0].address)' | jq 'del(.aleph[0].address)' - - name: Create azero env file shell: bash env: @@ -53,9 +37,10 @@ jobs: AZERO3: ${{ secrets.DEVENV_TESTNET_AZERO3_ACCOUNT_NUMBER }} AZERO1_SEED: ${{ secrets.DEVENV_TESTNET_AZERO1_KEY }} run: | - cat azero/env/testnet.json.example | \ + cat azero/env/testnet.json | \ jq '.relayers = ["${{ env.AZERO1 }}", "${{ env.AZERO2 }}", "${{ env.AZERO3 }}"]' | \ - jq '.deployer_seed = "${{ env.AZERO1_SEED }}"' | jq '.dev = true' > azero/env/testnet.json + jq '.deployer_seed = "${{ env.AZERO1_SEED }}"' | jq '.dev = true' > azero/env/testnet.json.tmp + mv azero/env/testnet.json.tmp azero/env/testnet.json - name: Get latest eth block shell: bash diff --git a/.github/workflows/on-master-branch-commit.yml b/.github/workflows/on-master-branch-commit.yml index b218492e..ce3f9180 100644 --- a/.github/workflows/on-master-branch-commit.yml +++ b/.github/workflows/on-master-branch-commit.yml @@ -5,6 +5,7 @@ on: push: branches: - master + - MOST-192 jobs: check-vars-and-secrets: @@ -12,8 +13,16 @@ jobs: uses: ./.github/workflows/_check-vars-and-secrets.yml secrets: inherit +# test-azero-contracts: +# needs: [check-vars-and-secrets] +# uses: ./.github/workflows/test-azero-contracts.yml +# +# test-eth-contracts: +# needs: [check-vars-and-secrets] +# uses: ./.github/workflows/test-eth-contracts.yml + compile-contracts-and-deploy-to-devenv: - needs: [check-vars-and-secrets] + #needs: [test-azero-contracts, test-eth-contracts] name: Compile contracts and deploy to devenv uses: ./.github/workflows/contracts-compile-and-deploy-to-devenv.yml secrets: inherit diff --git a/Makefile b/Makefile index 97d21095..84cccde0 100644 --- a/Makefile +++ b/Makefile @@ -99,7 +99,8 @@ compile-eth: eth-deps deploy-eth: # Deploy eth contracts deploy-eth: compile-eth cd eth && \ - npx hardhat run --network $(NETWORK) scripts/0_deploy_bridge_contracts.js + npx hardhat run --network $(NETWORK) scripts/0_deploy_bridge_contracts.js \ + && npx hardhat run --network $(NETWORK) scripts/deploy_transfer_limit.js .PHONY: upload-eth upload-eth: # Upload the MOST contract to a live ethereum network (testnet or mainnet) for an upgrade From 7cea9e1fb4c9be2eee58467dbffd44fd3c0a45fc Mon Sep 17 00:00:00 2001 From: Marcin Date: Wed, 2 Oct 2024 09:00:35 +0200 Subject: [PATCH 02/17] Make deploy to dev env contracts on demand --- ...contracts-compile-and-deploy-to-devenv.yml | 3 +-- .github/workflows/on-master-branch-commit.yml | 23 +++++++------------ 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/.github/workflows/contracts-compile-and-deploy-to-devenv.yml b/.github/workflows/contracts-compile-and-deploy-to-devenv.yml index d6ba0965..5fd1347c 100644 --- a/.github/workflows/contracts-compile-and-deploy-to-devenv.yml +++ b/.github/workflows/contracts-compile-and-deploy-to-devenv.yml @@ -1,8 +1,7 @@ --- -name: Devenv - deploy contracts +name: Devenv - deploy contracts (on demand) on: - workflow_call: workflow_dispatch: concurrency: diff --git a/.github/workflows/on-master-branch-commit.yml b/.github/workflows/on-master-branch-commit.yml index ce3f9180..90e78a8c 100644 --- a/.github/workflows/on-master-branch-commit.yml +++ b/.github/workflows/on-master-branch-commit.yml @@ -5,7 +5,6 @@ on: push: branches: - master - - MOST-192 jobs: check-vars-and-secrets: @@ -13,28 +12,22 @@ jobs: uses: ./.github/workflows/_check-vars-and-secrets.yml secrets: inherit -# test-azero-contracts: -# needs: [check-vars-and-secrets] -# uses: ./.github/workflows/test-azero-contracts.yml -# -# test-eth-contracts: -# needs: [check-vars-and-secrets] -# uses: ./.github/workflows/test-eth-contracts.yml + test-azero-contracts: + needs: [check-vars-and-secrets] + uses: ./.github/workflows/test-azero-contracts.yml - compile-contracts-and-deploy-to-devenv: - #needs: [test-azero-contracts, test-eth-contracts] - name: Compile contracts and deploy to devenv - uses: ./.github/workflows/contracts-compile-and-deploy-to-devenv.yml - secrets: inherit + test-eth-contracts: + needs: [check-vars-and-secrets] + uses: ./.github/workflows/test-eth-contracts.yml build-l1-relayer: - needs: [compile-contracts-and-deploy-to-devenv] + needs: [test-eth-contracts, test-azero-contracts] name: Build L1 relayer uses: ./.github/workflows/l1-relayer-build.yml secrets: inherit build-l2-relayer: - needs: [compile-contracts-and-deploy-to-devenv] + needs: [test-eth-contracts, test-azero-contracts] name: Build L2 relayer uses: ./.github/workflows/l2-relayer-build.yml secrets: inherit From c303ba6d300763aee53de66ffe4da1dcc2ecfa0f Mon Sep 17 00:00:00 2001 From: Marcin Date: Wed, 2 Oct 2024 09:17:36 +0200 Subject: [PATCH 03/17] Fixed test-transfers.yml --- eth/hardhat.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/eth/hardhat.config.js b/eth/hardhat.config.js index b82c061b..429a19ee 100644 --- a/eth/hardhat.config.js +++ b/eth/hardhat.config.js @@ -44,6 +44,7 @@ var config = { }, gas: 25e6, // Gas limit gasPrice: 20e9, + dev: true, deploymentConfig: { guardianIds: [ "0x05501355922a6529670DB49158676D98D6c34245", From 1f289606f6515bde3c8c8d9d1b89e14b6d29a020 Mon Sep 17 00:00:00 2001 From: Marcin Date: Wed, 2 Oct 2024 09:54:06 +0200 Subject: [PATCH 04/17] Another fix --- .github/workflows/_relayer-build-and-push.yml | 6 ++++++ .github/workflows/on-master-branch-commit.yml | 19 ++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/workflows/_relayer-build-and-push.yml b/.github/workflows/_relayer-build-and-push.yml index 476ea653..5b3f359d 100644 --- a/.github/workflows/_relayer-build-and-push.yml +++ b/.github/workflows/_relayer-build-and-push.yml @@ -7,6 +7,10 @@ on: description: Relayer to build - L1 or L2 type: string required: true + download-contracts: + description: Whether to download contracts from S3 + type: boolean + default: false outputs: docker-tag: description: Docker image tag @@ -47,6 +51,8 @@ jobs: uses: Cardinal-Cryptography/github-actions/get-ref-properties@v6 - name: Download artifacts from S3 bucket + # disable this step + if: ${{ inputs.download-contracts }} env: AWS_ACCESS_KEY_ID: ${{ secrets.CONTRACTS_MOST_ARTIFACTS_RO_AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.CONTRACTS_MOST_ARTIFACTS_RO_AWS_SECRET_ACCESS_KEY }} diff --git a/.github/workflows/on-master-branch-commit.yml b/.github/workflows/on-master-branch-commit.yml index 90e78a8c..150ff104 100644 --- a/.github/workflows/on-master-branch-commit.yml +++ b/.github/workflows/on-master-branch-commit.yml @@ -5,6 +5,7 @@ on: push: branches: - master + - MOST-192 jobs: check-vars-and-secrets: @@ -12,22 +13,22 @@ jobs: uses: ./.github/workflows/_check-vars-and-secrets.yml secrets: inherit - test-azero-contracts: - needs: [check-vars-and-secrets] - uses: ./.github/workflows/test-azero-contracts.yml - - test-eth-contracts: - needs: [check-vars-and-secrets] - uses: ./.github/workflows/test-eth-contracts.yml +# test-azero-contracts: +# needs: [check-vars-and-secrets] +# uses: ./.github/workflows/test-azero-contracts.yml +# +# test-eth-contracts: +# needs: [check-vars-and-secrets] +# uses: ./.github/workflows/test-eth-contracts.yml build-l1-relayer: - needs: [test-eth-contracts, test-azero-contracts] +# needs: [test-eth-contracts, test-azero-contracts] name: Build L1 relayer uses: ./.github/workflows/l1-relayer-build.yml secrets: inherit build-l2-relayer: - needs: [test-eth-contracts, test-azero-contracts] +# needs: [test-eth-contracts, test-azero-contracts] name: Build L2 relayer uses: ./.github/workflows/l2-relayer-build.yml secrets: inherit From d83f5b51f3de4acca1c307efa4308ec3860d2ca5 Mon Sep 17 00:00:00 2001 From: Marcin Date: Wed, 2 Oct 2024 10:05:01 +0200 Subject: [PATCH 05/17] WIP : try to fix master CI --- .github/workflows/_relayer-build-and-push.yml | 6 ----- ...contracts-compile-and-deploy-to-devenv.yml | 1 + .github/workflows/on-master-branch-commit.yml | 25 +++++++++++-------- Makefile | 3 +-- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/.github/workflows/_relayer-build-and-push.yml b/.github/workflows/_relayer-build-and-push.yml index 5b3f359d..476ea653 100644 --- a/.github/workflows/_relayer-build-and-push.yml +++ b/.github/workflows/_relayer-build-and-push.yml @@ -7,10 +7,6 @@ on: description: Relayer to build - L1 or L2 type: string required: true - download-contracts: - description: Whether to download contracts from S3 - type: boolean - default: false outputs: docker-tag: description: Docker image tag @@ -51,8 +47,6 @@ jobs: uses: Cardinal-Cryptography/github-actions/get-ref-properties@v6 - name: Download artifacts from S3 bucket - # disable this step - if: ${{ inputs.download-contracts }} env: AWS_ACCESS_KEY_ID: ${{ secrets.CONTRACTS_MOST_ARTIFACTS_RO_AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.CONTRACTS_MOST_ARTIFACTS_RO_AWS_SECRET_ACCESS_KEY }} diff --git a/.github/workflows/contracts-compile-and-deploy-to-devenv.yml b/.github/workflows/contracts-compile-and-deploy-to-devenv.yml index 5fd1347c..372e636b 100644 --- a/.github/workflows/contracts-compile-and-deploy-to-devenv.yml +++ b/.github/workflows/contracts-compile-and-deploy-to-devenv.yml @@ -3,6 +3,7 @@ name: Devenv - deploy contracts (on demand) on: workflow_dispatch: + workflow_call: concurrency: group: "${{ github.ref }}-${{ github.workflow }}" diff --git a/.github/workflows/on-master-branch-commit.yml b/.github/workflows/on-master-branch-commit.yml index 150ff104..08bbbda8 100644 --- a/.github/workflows/on-master-branch-commit.yml +++ b/.github/workflows/on-master-branch-commit.yml @@ -5,7 +5,6 @@ on: push: branches: - master - - MOST-192 jobs: check-vars-and-secrets: @@ -13,22 +12,28 @@ jobs: uses: ./.github/workflows/_check-vars-and-secrets.yml secrets: inherit -# test-azero-contracts: -# needs: [check-vars-and-secrets] -# uses: ./.github/workflows/test-azero-contracts.yml -# -# test-eth-contracts: -# needs: [check-vars-and-secrets] -# uses: ./.github/workflows/test-eth-contracts.yml + compile-contracts-and-deploy-to-devenv: + needs: [check-vars-and-secrets] + name: Compile contracts and deploy to devenv + uses: ./.github/workflows/contracts-compile-and-deploy-to-devenv.yml + secrets: inherit + + test-azero-contracts: + needs: [check-vars-and-secrets] + uses: ./.github/workflows/test-azero-contracts.yml + + test-eth-contracts: + needs: [check-vars-and-secrets] + uses: ./.github/workflows/test-eth-contracts.yml build-l1-relayer: -# needs: [test-eth-contracts, test-azero-contracts] + needs: [test-eth-contracts, test-azero-contracts, compile-contracts-and-deploy-to-devenv] name: Build L1 relayer uses: ./.github/workflows/l1-relayer-build.yml secrets: inherit build-l2-relayer: -# needs: [test-eth-contracts, test-azero-contracts] + needs: [test-eth-contracts, test-azero-contracts, compile-contracts-and-deploy-to-devenv] name: Build L2 relayer uses: ./.github/workflows/l2-relayer-build.yml secrets: inherit diff --git a/Makefile b/Makefile index 84cccde0..97d21095 100644 --- a/Makefile +++ b/Makefile @@ -99,8 +99,7 @@ compile-eth: eth-deps deploy-eth: # Deploy eth contracts deploy-eth: compile-eth cd eth && \ - npx hardhat run --network $(NETWORK) scripts/0_deploy_bridge_contracts.js \ - && npx hardhat run --network $(NETWORK) scripts/deploy_transfer_limit.js + npx hardhat run --network $(NETWORK) scripts/0_deploy_bridge_contracts.js .PHONY: upload-eth upload-eth: # Upload the MOST contract to a live ethereum network (testnet or mainnet) for an upgrade From f02b2b175f056c4660cdeb3fe1fcd72222b799d2 Mon Sep 17 00:00:00 2001 From: Marcin Date: Wed, 9 Oct 2024 15:32:12 +0200 Subject: [PATCH 06/17] [WIP] --- ...contracts-compile-and-deploy-to-devenv.yml | 205 ++++++++++++------ Makefile | 30 ++- azero/env/testnet.json | 2 +- eth/hardhat.config.js | 3 + 4 files changed, 173 insertions(+), 67 deletions(-) diff --git a/.github/workflows/contracts-compile-and-deploy-to-devenv.yml b/.github/workflows/contracts-compile-and-deploy-to-devenv.yml index 372e636b..e9887356 100644 --- a/.github/workflows/contracts-compile-and-deploy-to-devenv.yml +++ b/.github/workflows/contracts-compile-and-deploy-to-devenv.yml @@ -1,9 +1,21 @@ --- -name: Devenv - deploy contracts (on demand) +name: Devenv - deploy MOST L1 contracts (on demand) on: workflow_dispatch: + inputs: + deploy-contracts: + description: Set to true to deploy contracts to Devenv + type: boolean + required: false + default: false workflow_call: + inputs: + deploy-contracts: + description: Set to true to deploy contracts to Devenv + type: boolean + required: false + default: false concurrency: group: "${{ github.ref }}-${{ github.workflow }}" @@ -15,13 +27,12 @@ jobs: uses: ./.github/workflows/_check-vars-and-secrets.yml secrets: inherit - deploy-contracts: - name: Deploy and setup contracts - runs-on: [self-hosted, Linux, X64, large] + compile-contracts: + name: Compile ink and solidity contracts + runs-on: ubuntu-latest needs: [check-vars-and-secrets] outputs: artifact-matrix-json: ${{ steps.get-artifact-matrix.outputs.artifact-matrix }} - steps: - name: Checkout code uses: actions/checkout@v4 @@ -29,82 +40,37 @@ jobs: - name: Setup node uses: asdf-vm/actions/install@v3 - - name: Create azero env file + - name: Compile solidity contracts shell: bash - env: - AZERO1: ${{ secrets.DEVENV_TESTNET_AZERO1_ACCOUNT_NUMBER }} - AZERO2: ${{ secrets.DEVENV_TESTNET_AZERO2_ACCOUNT_NUMBER }} - AZERO3: ${{ secrets.DEVENV_TESTNET_AZERO3_ACCOUNT_NUMBER }} - AZERO1_SEED: ${{ secrets.DEVENV_TESTNET_AZERO1_KEY }} run: | - cat azero/env/testnet.json | \ - jq '.relayers = ["${{ env.AZERO1 }}", "${{ env.AZERO2 }}", "${{ env.AZERO3 }}"]' | \ - jq '.deployer_seed = "${{ env.AZERO1_SEED }}"' | jq '.dev = true' > azero/env/testnet.json.tmp - mv azero/env/testnet.json.tmp azero/env/testnet.json + make compile-eth - - name: Get latest eth block + - name: Compile ink! contracts shell: bash - env: - SEPOLIA_MNEMONIC: ${{ secrets.DEVENV_TESTNET_SEPOLIA_KEY }} - SEPOLIA_ACCOUNT_NUMBER: ${{ secrets.DEVENV_TESTNET_SEPOLIA_ACCOUNT_NUMBER }} - SEPOLIA_TOKEN_CONFIG_PATH: "../cfg/tokens_testnet.json" run: | - make eth-deps - cd eth - npx hardhat run --network sepolia scripts/get_latest_block.js + make compile-azero-docker - - name: Get latest azero block + - name: Compile azero JS types contracts shell: bash run: | - make azero-deps - cd azero - AZERO_ENV=testnet npm run get-latest-block - - - name: Deploy eth contracts - shell: bash - env: - SEPOLIA_MNEMONIC: ${{ secrets.DEVENV_TESTNET_SEPOLIA_KEY }} - SEPOLIA_ACCOUNT_NUMBER: ${{ secrets.DEVENV_TESTNET_SEPOLIA_ACCOUNT_NUMBER }} - SEPOLIA_TOKEN_CONFIG_PATH: "../cfg/tokens_testnet.json" - run: | - make deploy-eth NETWORK=sepolia - - - name: Deploy azero contracts - shell: bash - run: | - AZERO_ENV=testnet make deploy-azero-docker - - - name: Setup eth contracts - shell: bash - env: - SEPOLIA_MNEMONIC: ${{ secrets.DEVENV_TESTNET_SEPOLIA_KEY }} - SEPOLIA_ACCOUNT_NUMBER: ${{ secrets.DEVENV_TESTNET_SEPOLIA_ACCOUNT_NUMBER }} - SEPOLIA_TOKEN_CONFIG_PATH: "../cfg/tokens_testnet.json" - run: make setup-eth NETWORK=sepolia - - - name: Setup azero contracts - shell: bash - run: AZERO_ENV=testnet make setup-azero-docker + make typechain-azero - uses: actions/upload-artifact@v4 with: - name: eth-deployed-contracts + name: eth-compiled-contracts if-no-files-found: error retention-days: 1 path: | eth/artifacts - eth/addresses.json - eth/block_latest.json - uses: actions/upload-artifact@v4 with: - name: azero-deployed-contracts + name: azero-compiled-contracts if-no-files-found: error retention-days: 1 path: | azero/artifacts - azero/addresses.json - azero/block_latest.json + azero/types - name: Get list of contract artifacts shell: bash @@ -137,24 +103,24 @@ jobs: echo "artifact-matrix=$(cat tmp-artifacts-matrix.json)" >> $GITHUB_OUTPUT - upload-contract-artifacts: + upload-contract-artifacts-to-s3: name: Upload contract artifacts to S3 runs-on: [self-hosted, Linux, X64, small] - needs: [deploy-contracts] + needs: [compile-contracts] strategy: - matrix: ${{ fromJson(needs.deploy-contracts.outputs.artifact-matrix-json) }} + matrix: ${{ fromJson(needs.compile-contracts.outputs.artifact-matrix-json) }} steps: - name: Checkout code uses: actions/checkout@v4 - uses: actions/download-artifact@v4 with: - name: azero-deployed-contracts + name: azero-compiled-contracts path: azero - uses: actions/download-artifact@v4 with: - name: eth-deployed-contracts + name: eth-compiled-contracts path: eth - name: Store artifact in S3 bucket @@ -166,8 +132,119 @@ jobs: run: | aws s3 cp ${{ matrix.from }} s3://${{ secrets.CONTRACTS_S3BUCKET_NAME }}/most/artifacts/${{ github.sha }}/${{ matrix.to }}/ + deploy-contracts: + name: Deploy and setup contracts + if: ${{ inputs.deploy-contracts }} + runs-on: [self-hosted, Linux, X64, large] + needs: [compile-contracts] + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - uses: actions/download-artifact@v4 + with: + name: azero-compiled-contracts + path: azero + + - uses: actions/download-artifact@v4 + with: + name: eth-compiled-contracts + path: eth + + - name: Setup node + uses: asdf-vm/actions/install@v3 + + - name: Create azero env file + shell: bash + env: + AZERO1: ${{ secrets.DEVENV_TESTNET_AZERO1_ACCOUNT_NUMBER }} + AZERO2: ${{ secrets.DEVENV_TESTNET_AZERO2_ACCOUNT_NUMBER }} + AZERO3: ${{ secrets.DEVENV_TESTNET_AZERO3_ACCOUNT_NUMBER }} + AZERO1_SEED: ${{ secrets.DEVENV_TESTNET_AZERO1_KEY }} + run: | + cat azero/env/testnet.json | \ + jq '.relayers = ["${{ env.AZERO1 }}", "${{ env.AZERO2 }}", "${{ env.AZERO3 }}"]' | \ + jq '.deployer_seed = "${{ env.AZERO1_SEED }}"' | jq '.dev = true' > azero/env/testnet.json.tmp + mv azero/env/testnet.json.tmp azero/env/testnet.json + + - name: Get latest eth block + shell: bash + env: + SEPOLIA_MNEMONIC: ${{ secrets.DEVENV_TESTNET_SEPOLIA_KEY }} + SEPOLIA_ACCOUNT_NUMBER: ${{ secrets.DEVENV_TESTNET_SEPOLIA_ACCOUNT_NUMBER }} + SEPOLIA_TOKEN_CONFIG_PATH: "../cfg/tokens_testnet.json" + NETWORK: "sepolia" + run: | + make get-latest-eth-block + + - name: Get latest azero block + shell: bash + env: + AZERO_ENV: "testnet" + run: | + make get-latest-azero-block + + - name: Deploy eth contracts + shell: bash + env: + SEPOLIA_MNEMONIC: ${{ secrets.DEVENV_TESTNET_SEPOLIA_KEY }} + SEPOLIA_ACCOUNT_NUMBER: ${{ secrets.DEVENV_TESTNET_SEPOLIA_ACCOUNT_NUMBER }} + SEPOLIA_TOKEN_CONFIG_PATH: "../cfg/tokens_testnet.json" + NETWORK: "sepolia" + COMPILE_ETH_CONTRACTS_WHEN_DEPLOYING: "no-compile" + run: | + make deploy-eth + + - name: Deploy azero contracts + shell: bash + env: + NETWORK: "sepolia" + COMPILE_AZERO_CONTRACTS_WHEN_DEPLOYING: "no-compile" + run: | + make deploy-azero-docker + + - name: Setup eth contracts + shell: bash + env: + SEPOLIA_MNEMONIC: ${{ secrets.DEVENV_TESTNET_SEPOLIA_KEY }} + SEPOLIA_ACCOUNT_NUMBER: ${{ secrets.DEVENV_TESTNET_SEPOLIA_ACCOUNT_NUMBER }} + SEPOLIA_TOKEN_CONFIG_PATH: "../cfg/tokens_testnet.json" + NETWORK: "sepolia" + COMPILE_ETH_CONTRACTS_WHEN_SETUP: "no-compile" + run: | + make setup-eth + + - name: Setup azero contracts + shell: bash + env: + AZERO_ENV: "testnet" + COMPILE_AZERO_CONTRACTS_WHEN_SETUP: "no-compile" + run: | + make setup-azero-docker + + - uses: actions/upload-artifact@v4 + with: + name: eth-deployed-contracts + if-no-files-found: error + retention-days: 1 + path: | + eth/addresses.json + eth/block_latest.json + + - uses: actions/upload-artifact@v4 + with: + name: azero-deployed-contracts + if-no-files-found: error + retention-days: 1 + path: | + azero/addresses.json + azero/block_latest.json + + upload-contract-addresses: name: Upload contract addresses to S3 + if: ${{ inputs.deploy-contracts }} runs-on: [self-hosted, Linux, X64, small] needs: [deploy-contracts] steps: diff --git a/Makefile b/Makefile index 97d21095..b2b92256 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,10 @@ AZERO_ENV ?= dev DOCKER_RELAYER_NAME ?= most-relayer DOCKER_RELAYER_COPY_ADDRESSES ?= copy DOCKER_RELAYER_COMPILE_CONTRACTS ?= compile +COMPILE_ETH_CONTRACTS_WHEN_DEPLOYING ?= compile +COMPILE_AZERO_CONTRACTS_WHEN_DEPLOYING ?= compile +COMPILE_ETH_CONTRACTS_WHEN_SETUP ?= compile +COMPILE_AZERO_CONTRACTS_WHEN_SETUP ?= compile DOCKER_SIGNER_NAME ?= most-signer L2 ?= false @@ -97,7 +101,9 @@ compile-eth: eth-deps .PHONY: deploy-eth deploy-eth: # Deploy eth contracts +ifeq ($(COMPILE_ETH_CONTRACTS_WHEN_DEPLOYING),compile) deploy-eth: compile-eth +endif cd eth && \ npx hardhat run --network $(NETWORK) scripts/0_deploy_bridge_contracts.js @@ -119,7 +125,9 @@ verify-eth: .PHONY: setup-eth setup-eth: # Setup eth contracts +ifeq ($(COMPILE_ETH_CONTRACTS_WHEN_SETUP),compile) setup-eth: compile-eth +endif cd eth && \ npx hardhat run --network $(NETWORK) scripts/1_setup_bridge_contracts.js @@ -159,12 +167,16 @@ print-azero-codehashes: compile-azero-docker .PHONY: deploy-azero-docker deploy-azero-docker: # Deploy azero contracts compiling in docker +ifeq ($(COMPILE_AZERO_CONTRACTS_WHEN_DEPLOYING),compile) deploy-azero-docker: azero-deps compile-azero-docker typechain-azero +endif cd azero && AZERO_ENV=$(AZERO_ENV) npm run deploy .PHONY: setup-azero-docker setup-azero-docker: # Setup azero contracts compiling in docker +ifeq ($(COMPILE_AZERO_CONTRACTS_WHEN_SETUP),compile) setup-azero-docker: azero-deps compile-azero-docker +endif cd azero && AZERO_ENV=$(AZERO_ENV) npm run setup .PHONY: azero-deps @@ -194,16 +206,18 @@ compile-azero: azero-deps make compile-azero-single-contract CONTRACT_DIR=gas-price-oracle/contract CONTRACT_NAME=oracle cd azero && cp external_artifacts/wrapped_azero.contract artifacts/ cd azero && cp external_artifacts/wrapped_azero.json artifacts/ - cd azero && cp external_artifacts/wrapped_azero.wasm artifacts/ + cd azero && cp external_artifacts/wrapped_azero.wasm artifacts/14 .PHONY: typechain-azero typechain-azero: # Generate typechain typings for azero contracts -typechain-azero: +typechain-azero: azero-deps compile-azero cd azero && npm run typechain .PHONY: deploy-azero deploy-azero: # Deploy azero contracts +ifeq ($(COMPILE_AZERO_CONTRACTS_WHEN_DEPLOYING),compile) deploy-azero: compile-azero typechain-azero +endif cd azero && AZERO_ENV=$(AZERO_ENV) npm run deploy .PHONY: upload-azero @@ -213,7 +227,9 @@ upload-azero: compile-azero-docker typechain-azero .PHONY: setup-azero setup-azero: # Setup azero contracts +ifeq ($(COMPILE_AZERO_CONTRACTS_WHEN_SETUP),compile) setup-azero: compile-azero typechain-azero +endif cd azero && AZERO_ENV=$(AZERO_ENV) npm run setup .PHONY: deploy @@ -451,3 +467,13 @@ build-docker-signer: cd relayer && cargo build -p signer --release cp relayer/target/release/signer relayer/signer_docker cd relayer/signer_docker && docker build -t $(DOCKER_SIGNER_NAME) . + +.PHONY: get-latest-eth-block +get-latest-eth-block: # Get latest eth block +get-latest-eth-block: eth-deps + cd eth && npx hardhat run --network $(NETWORK) scripts/get_latest_block.js + +.PHONY: get-latest-azero-block +get-latest-azero-block: # Get latest eth block +get-latest-azero-block: azero-deps + cd azerpo && AZERO_ENV=$(AZERO_ENV) npm run get-latest-block \ No newline at end of file diff --git a/azero/env/testnet.json b/azero/env/testnet.json index d4920e03..011fc198 100644 --- a/azero/env/testnet.json +++ b/azero/env/testnet.json @@ -3,7 +3,7 @@ "relayers": [ ">" ], - "deployer_seed": ">", + "deployer_seed": "", "signature_threshold": 1, "pocket_money": 1000000000000, "min_gas_price": 60000000, diff --git a/eth/hardhat.config.js b/eth/hardhat.config.js index 429a19ee..0d4b0a7f 100644 --- a/eth/hardhat.config.js +++ b/eth/hardhat.config.js @@ -106,6 +106,9 @@ if (SEPOLIA_MNEMONIC || SEPOLIA_PRIVATE_KEY) { mnemonic: SEPOLIA_MNEMONIC, } : [SEPOLIA_PRIVATE_KEY], + gasPrice: 20e9, // 20 Gwei + timeout: 20000, // 20s; if gas prices are higher than 20 Gwei, any tx would likely + // stuck in the mempool, hence we need a timeout deploymentConfig: { guardianIds: [ typeof SEPOLIA_ACCOUNT_NUMBER == "undefined" || From d4bc37da8d9b4916f746847f829b1cb946aad77e Mon Sep 17 00:00:00 2001 From: Marcin Date: Thu, 10 Oct 2024 08:34:43 +0200 Subject: [PATCH 07/17] WIP 2nd --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index b2b92256..38c99eef 100644 --- a/Makefile +++ b/Makefile @@ -210,7 +210,7 @@ compile-azero: azero-deps .PHONY: typechain-azero typechain-azero: # Generate typechain typings for azero contracts -typechain-azero: azero-deps compile-azero +typechain-azero: cd azero && npm run typechain .PHONY: deploy-azero From 9da0c643ee9b3cadab7a8a49aabe3df2f27f834d Mon Sep 17 00:00:00 2001 From: Marcin Date: Thu, 10 Oct 2024 09:32:27 +0200 Subject: [PATCH 08/17] For sake of testing, do not build docker & cargo contracts --- .github/workflows/contracts-compile-and-deploy-to-devenv.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/contracts-compile-and-deploy-to-devenv.yml b/.github/workflows/contracts-compile-and-deploy-to-devenv.yml index e9887356..d5a93483 100644 --- a/.github/workflows/contracts-compile-and-deploy-to-devenv.yml +++ b/.github/workflows/contracts-compile-and-deploy-to-devenv.yml @@ -48,7 +48,7 @@ jobs: - name: Compile ink! contracts shell: bash run: | - make compile-azero-docker + make compile-azero - name: Compile azero JS types contracts shell: bash From caa8fa79bdee96cf60f084573e3ccfaa8eedb034 Mon Sep 17 00:00:00 2001 From: Marcin Date: Thu, 10 Oct 2024 09:37:46 +0200 Subject: [PATCH 09/17] Try again with the docker --- .github/workflows/contracts-compile-and-deploy-to-devenv.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/contracts-compile-and-deploy-to-devenv.yml b/.github/workflows/contracts-compile-and-deploy-to-devenv.yml index d5a93483..e9887356 100644 --- a/.github/workflows/contracts-compile-and-deploy-to-devenv.yml +++ b/.github/workflows/contracts-compile-and-deploy-to-devenv.yml @@ -48,7 +48,7 @@ jobs: - name: Compile ink! contracts shell: bash run: | - make compile-azero + make compile-azero-docker - name: Compile azero JS types contracts shell: bash From 495759a74e744e477b5b5beda0ea63766a001f59 Mon Sep 17 00:00:00 2001 From: Marcin Date: Thu, 10 Oct 2024 10:26:58 +0200 Subject: [PATCH 10/17] Upload whole folders --- .github/workflows/contracts-compile-and-deploy-to-devenv.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/contracts-compile-and-deploy-to-devenv.yml b/.github/workflows/contracts-compile-and-deploy-to-devenv.yml index e9887356..36e97084 100644 --- a/.github/workflows/contracts-compile-and-deploy-to-devenv.yml +++ b/.github/workflows/contracts-compile-and-deploy-to-devenv.yml @@ -61,7 +61,7 @@ jobs: if-no-files-found: error retention-days: 1 path: | - eth/artifacts + eth - uses: actions/upload-artifact@v4 with: @@ -69,8 +69,7 @@ jobs: if-no-files-found: error retention-days: 1 path: | - azero/artifacts - azero/types + azero - name: Get list of contract artifacts shell: bash From f3cff8ea840b4cbfd747824d889d07c9deadfde1 Mon Sep 17 00:00:00 2001 From: Marcin Date: Mon, 28 Oct 2024 12:46:52 +0100 Subject: [PATCH 11/17] Do not upload everything --- .../workflows/contracts-compile-and-deploy-to-devenv.yml | 8 ++++---- Makefile | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/contracts-compile-and-deploy-to-devenv.yml b/.github/workflows/contracts-compile-and-deploy-to-devenv.yml index 99c2d4a9..363e3654 100644 --- a/.github/workflows/contracts-compile-and-deploy-to-devenv.yml +++ b/.github/workflows/contracts-compile-and-deploy-to-devenv.yml @@ -61,7 +61,7 @@ jobs: if-no-files-found: error retention-days: 1 path: | - eth + eth/artifacts - uses: actions/upload-artifact@v4 with: @@ -69,7 +69,7 @@ jobs: if-no-files-found: error retention-days: 1 path: | - azero + azero/artifacts - name: Get list of contract artifacts shell: bash @@ -115,12 +115,12 @@ jobs: - uses: actions/download-artifact@v4 with: name: azero-compiled-contracts - path: azero + path: azero/artifacts - uses: actions/download-artifact@v4 with: name: eth-compiled-contracts - path: eth + path: eth/artifacts - name: Store artifact in S3 bucket shell: bash diff --git a/Makefile b/Makefile index 1535e2f5..640953bb 100644 --- a/Makefile +++ b/Makefile @@ -482,4 +482,4 @@ get-latest-eth-block: eth-deps .PHONY: get-latest-azero-block get-latest-azero-block: # Get latest eth block get-latest-azero-block: azero-deps - cd azerpo && AZERO_ENV=$(AZERO_ENV) npm run get-latest-block \ No newline at end of file + cd azero && AZERO_ENV=$(AZERO_ENV) npm run get-latest-block \ No newline at end of file From a3eb129207b02dbe7ce87f133d58885ef4e8bc5b Mon Sep 17 00:00:00 2001 From: Marcin Date: Mon, 28 Oct 2024 13:08:56 +0100 Subject: [PATCH 12/17] Fixed download path --- .github/workflows/contracts-compile-and-deploy-to-devenv.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/contracts-compile-and-deploy-to-devenv.yml b/.github/workflows/contracts-compile-and-deploy-to-devenv.yml index 363e3654..ab999078 100644 --- a/.github/workflows/contracts-compile-and-deploy-to-devenv.yml +++ b/.github/workflows/contracts-compile-and-deploy-to-devenv.yml @@ -144,12 +144,12 @@ jobs: - uses: actions/download-artifact@v4 with: name: azero-compiled-contracts - path: azero + path: azero/artifacts - uses: actions/download-artifact@v4 with: name: eth-compiled-contracts - path: eth + path: eth/artifacts - name: Setup node uses: asdf-vm/actions/install@v3 From 18b5b2d0724a2daf4734a9adc680d60f8b463221 Mon Sep 17 00:00:00 2001 From: Marcin Date: Mon, 28 Oct 2024 13:33:45 +0100 Subject: [PATCH 13/17] Fixes --- .../workflows/contracts-compile-and-deploy-to-devenv.yml | 6 ++++-- Makefile | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/contracts-compile-and-deploy-to-devenv.yml b/.github/workflows/contracts-compile-and-deploy-to-devenv.yml index ab999078..b36f3595 100644 --- a/.github/workflows/contracts-compile-and-deploy-to-devenv.yml +++ b/.github/workflows/contracts-compile-and-deploy-to-devenv.yml @@ -201,13 +201,15 @@ jobs: SEPOLIA_MNEMONIC: ${{ secrets.DEVENV_TESTNET_SEPOLIA_KEY }} SEPOLIA_ACCOUNT_NUMBER: ${{ secrets.DEVENV_TESTNET_SEPOLIA_ACCOUNT_NUMBER }} SEPOLIA_TOKEN_CONFIG_PATH: "../cfg/tokens_testnet.json" + NETWORK: "sepolia" + COMPILE_ETH_CONTRACTS_WHEN_DEPLOYING: "no-compile" run: | - make deploy-eth-transfer-limit NETWORK=sepolia + make deploy-eth-transfer-limit - name: Deploy azero contracts shell: bash env: - NETWORK: "sepolia" + AZERO_ENV: "testnet" COMPILE_AZERO_CONTRACTS_WHEN_DEPLOYING: "no-compile" run: | make deploy-azero-docker diff --git a/Makefile b/Makefile index 640953bb..9cb605e4 100644 --- a/Makefile +++ b/Makefile @@ -109,7 +109,9 @@ endif .PHONY: deploy-eth-transfer-limit deploy-eth-transfer-limit: # Deploy TransferLimit eth contract +ifeq ($(COMPILE_ETH_CONTRACTS_WHEN_DEPLOYING),compile) deploy-eth-transfer-limit: compile-eth +endif cd eth && \ npx hardhat run --network $(NETWORK) scripts/deploy_transfer_limit.js From 25e59066d1c28efd64471ce9b60f4234a1dffcb4 Mon Sep 17 00:00:00 2001 From: Marcin Date: Mon, 28 Oct 2024 15:17:40 +0100 Subject: [PATCH 14/17] Upload typechain --- .../contracts-compile-and-deploy-to-devenv.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/contracts-compile-and-deploy-to-devenv.yml b/.github/workflows/contracts-compile-and-deploy-to-devenv.yml index b36f3595..971251e9 100644 --- a/.github/workflows/contracts-compile-and-deploy-to-devenv.yml +++ b/.github/workflows/contracts-compile-and-deploy-to-devenv.yml @@ -71,6 +71,14 @@ jobs: path: | azero/artifacts + - uses: actions/upload-artifact@v4 + with: + name: azero-compiled-contracts-types + if-no-files-found: error + retention-days: 1 + path: | + azero/types + - name: Get list of contract artifacts shell: bash id: get-artifact-matrix @@ -117,6 +125,11 @@ jobs: name: azero-compiled-contracts path: azero/artifacts + - uses: actions/download-artifact@v4 + with: + name: azero-compiled-contracts-types + path: azero/types + - uses: actions/download-artifact@v4 with: name: eth-compiled-contracts From 70f329c43fbe91a8552c044378c6e39e42bc82de Mon Sep 17 00:00:00 2001 From: Marcin Date: Tue, 29 Oct 2024 13:13:31 +0100 Subject: [PATCH 15/17] Actually download the types --- .github/workflows/contracts-compile-and-deploy-to-devenv.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/contracts-compile-and-deploy-to-devenv.yml b/.github/workflows/contracts-compile-and-deploy-to-devenv.yml index 971251e9..e8b6f8d1 100644 --- a/.github/workflows/contracts-compile-and-deploy-to-devenv.yml +++ b/.github/workflows/contracts-compile-and-deploy-to-devenv.yml @@ -164,6 +164,11 @@ jobs: name: eth-compiled-contracts path: eth/artifacts + - uses: actions/download-artifact@v4 + with: + name: azero-compiled-contracts-types + path: azero/types + - name: Setup node uses: asdf-vm/actions/install@v3 From 94cc22e2180732130d6f033f61d5fa61cbca23b5 Mon Sep 17 00:00:00 2001 From: Marcin Date: Tue, 29 Oct 2024 15:29:26 +0100 Subject: [PATCH 16/17] Testing --- ...venv.yml => contracts-compile-and-deploy-to-testnet.yml} | 6 +++--- .github/workflows/on-master-branch-commit.yml | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) rename .github/workflows/{contracts-compile-and-deploy-to-devenv.yml => contracts-compile-and-deploy-to-testnet.yml} (98%) diff --git a/.github/workflows/contracts-compile-and-deploy-to-devenv.yml b/.github/workflows/contracts-compile-and-deploy-to-testnet.yml similarity index 98% rename from .github/workflows/contracts-compile-and-deploy-to-devenv.yml rename to .github/workflows/contracts-compile-and-deploy-to-testnet.yml index e8b6f8d1..76a0985e 100644 --- a/.github/workflows/contracts-compile-and-deploy-to-devenv.yml +++ b/.github/workflows/contracts-compile-and-deploy-to-testnet.yml @@ -1,18 +1,18 @@ --- -name: Devenv - deploy MOST L1 contracts (on demand) +name: Deploy MOST L1 contracts to Testnet on: workflow_dispatch: inputs: deploy-contracts: - description: Set to true to deploy contracts to Devenv + description: Set to true to deploy contracts to Testnet type: boolean required: false default: false workflow_call: inputs: deploy-contracts: - description: Set to true to deploy contracts to Devenv + description: Set to true to deploy contracts to Testnet type: boolean required: false default: false diff --git a/.github/workflows/on-master-branch-commit.yml b/.github/workflows/on-master-branch-commit.yml index 2eb76262..fdd803ac 100644 --- a/.github/workflows/on-master-branch-commit.yml +++ b/.github/workflows/on-master-branch-commit.yml @@ -5,6 +5,7 @@ on: push: branches: - master + - MOST-192 jobs: check-vars-and-secrets: @@ -15,7 +16,7 @@ jobs: compile-contracts-and-deploy-to-devenv: needs: [check-vars-and-secrets] name: Compile contracts and deploy to devenv - uses: ./.github/workflows/contracts-compile-and-deploy-to-devenv.yml + uses: ./.github/workflows/contracts-compile-and-deploy-to-testnet.yml secrets: inherit test-azero-contracts: From c44c17c061ef5838bef2e8d520d74591e2804f8e Mon Sep 17 00:00:00 2001 From: Marcin Date: Wed, 30 Oct 2024 09:21:38 +0100 Subject: [PATCH 17/17] Revmoed testing code, and formatting --- .github/workflows/on-master-branch-commit.yml | 1 - eth/hardhat.config.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/on-master-branch-commit.yml b/.github/workflows/on-master-branch-commit.yml index fdd803ac..2fd9a5ac 100644 --- a/.github/workflows/on-master-branch-commit.yml +++ b/.github/workflows/on-master-branch-commit.yml @@ -5,7 +5,6 @@ on: push: branches: - master - - MOST-192 jobs: check-vars-and-secrets: diff --git a/eth/hardhat.config.js b/eth/hardhat.config.js index 7f9c8c65..4fc31563 100644 --- a/eth/hardhat.config.js +++ b/eth/hardhat.config.js @@ -108,7 +108,7 @@ if (SEPOLIA_MNEMONIC || SEPOLIA_PRIVATE_KEY) { : [SEPOLIA_PRIVATE_KEY], gasPrice: 20e9, // 20 Gwei timeout: 20000, // 20s; if gas prices are higher than 20 Gwei, any tx would likely - // stuck in the mempool, hence we need a timeout + // stuck in the mempool, hence we need a timeout deploymentConfig: { guardianIds: [ typeof SEPOLIA_ACCOUNT_NUMBER == "undefined" ||