Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Decouple deploying contracts from compilation #253

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
---
name: Devenv - deploy contracts (on demand)
name: Deploy MOST L1 contracts to Testnet

on:
workflow_dispatch:
inputs:
deploy-contracts:
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 Testnet
type: boolean
required: false
default: false

concurrency:
group: "${{ github.ref }}-${{ github.workflow }}"
Expand All @@ -15,105 +27,57 @@ 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

- 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"
run: |
make eth-deps
cd eth
npx hardhat run --network sepolia scripts/get_latest_block.js

- name: Get latest azero block
- name: Compile solidity contracts
shell: bash
run: |
make azero-deps
cd azero
AZERO_ENV=testnet npm run get-latest-block
make compile-eth

- name: Deploy eth contracts
- 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 deploy-eth NETWORK=sepolia
make compile-azero-docker

- name: Deploy eth contracts (TransferLimit)
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-transfer-limit NETWORK=sepolia

- name: Deploy azero contracts
- name: Compile azero JS types 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

- 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
Expand Down Expand Up @@ -146,25 +110,30 @@ 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
path: azero
name: azero-compiled-contracts
path: azero/artifacts

- uses: actions/download-artifact@v4
with:
name: eth-deployed-contracts
path: eth
name: azero-compiled-contracts-types
path: azero/types

- uses: actions/download-artifact@v4
with:
name: eth-compiled-contracts
path: eth/artifacts

- name: Store artifact in S3 bucket
shell: bash
Expand All @@ -175,8 +144,135 @@ 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/artifacts

- uses: actions/download-artifact@v4
with:
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

- 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 eth contracts (TransferLimit)
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-transfer-limit

- name: Deploy azero contracts
shell: bash
env:
AZERO_ENV: "testnet"
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:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/on-master-branch-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,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:
Expand Down Expand Up @@ -70,4 +70,4 @@ jobs:
with:
notify-on: "failure"
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_DEV_ONDUTY }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_DEV_ONDUTY }}
Loading
Loading