Skip to content

Commit

Permalink
Add New Node Flow fixes (#1712)
Browse files Browse the repository at this point in the history
* Add New Node Flow fixes

* fixes

* node_id

* update gas values

* updating gas prices

* expand ports

* bump gas

* bump gas

* add geth checks

* sleep between first batches

* nits

* .

* weird get tx count handling

* add logs around port reuse

* fix lb + test

* adding more details to the deploy scheme

* comment out the load balancer change
  • Loading branch information
otherview authored Dec 28, 2023
1 parent b6444cf commit 06d02fb
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 60 deletions.
114 changes: 60 additions & 54 deletions .github/workflows/manual-deploy-testnet-validator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@
# This script uses GitHub Environments for variables (vars) and secrets - these are configured on GitHub and
# the environments match the input.testnet_type options
#
# # # # README # # # #
#
# 1 - Fetch the Management, Msg Bus Contract addresses and L1 Start Hash from:
# curl -X POST erpc.dev-testnet.obscu.ro:80 -H 'Content-Type: application/json' \
# -d '{"jsonrpc":"2.0","method":"obscuro_config","params":[],"id":1}'
#
# 2 - Update the secrets in Github
# ADD_NEW_NODE_L1_WS_URL -> l1 WS url
# ADD_NEW_NODE_PRIVATE_KEY -> L1 and L2 Private Key
# Note: L1 PK Must have funds in it
#
# 3 - Trigger the flow and supply data from Step 1.
# Node Id: is the node number
# Node Account Address: is the Account Address of the ADD_NEW_NODE_PRIVATE_KEY
#

name: '[M] Deploy Testnet Validator'
run-name: '[M] Deploy Testnet Validator ( ${{ github.event.inputs.testnet_type }} )'
Expand All @@ -23,18 +38,14 @@ on:
required: true
default: 3
type: number
node_private_key:
description: 'Node Private Key'
node_id:
description: 'Node id'
required: true
type: string
node_account_address:
description: 'Node Account Address'
required: true
type: string
node_l1_ws_url:
description: 'Node L1 Connection String'
required: true
type: string
MGMT_CONTRACT_ADDR:
description: 'Management Contract Addr'
required: true
Expand All @@ -47,14 +58,7 @@ on:
description: 'L1 Starting Hash'
required: true
type: string
HOC_ERC20_ADDR:
description: 'HOC ERC20 Contract Addr'
required: true
type: string
POC_ERC20_ADDR:
description: 'POC ERC20 Contract Addr'
required: true
type: string


jobs:
build:
Expand Down Expand Up @@ -115,34 +119,34 @@ jobs:
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: 'Create VM for Obscuro node-${{ matrix.host_id }} on Azure'
- name: 'Create VM for Obscuro node-${{ github.event.inputs.node_id }} on Azure'
uses: azure/CLI@v1
with:
inlineScript: |
az vm create -g Testnet -n "${{ vars.AZURE_RESOURCE_PREFIX }}-${{ matrix.host_id }}-${{ GITHUB.RUN_NUMBER }}" \
az vm create -g Testnet -n "${{ vars.AZURE_RESOURCE_PREFIX }}-${{ github.event.inputs.node_id }}-${{ GITHUB.RUN_NUMBER }}" \
--admin-username obscurouser --admin-password "${{ secrets.OBSCURO_NODE_VM_PWD }}" \
--public-ip-address-dns-name "obscuronode-${{ matrix.host_id }}-${{ github.event.inputs.testnet_type }}-${{ GITHUB.RUN_NUMBER }}" \
--public-ip-address-dns-name "obscuronode-${{ github.event.inputs.node_id }}-${{ github.event.inputs.testnet_type }}-${{ GITHUB.RUN_NUMBER }}" \
--tags deploygroup=ObscuroNode-${{ github.event.inputs.testnet_type }}-${{ GITHUB.RUN_NUMBER }} ${{ vars.AZURE_DEPLOY_GROUP_L2 }}=true \
--vnet-name ${{ github.event.inputs.testnet_type }}-virtual-network --subnet ${{ github.event.inputs.testnet_type }}-sub-network \
--size Standard_DC8_v2 --storage-sku StandardSSD_LRS --image ObscuroConfUbuntu \
--public-ip-sku Standard --authentication-type password
- name: 'Open Obscuro node-${{ matrix.host_id }} ports on Azure'
- name: 'Open Obscuro node-${{ github.event.inputs.host_id }} ports on Azure'
uses: azure/CLI@v1
with:
inlineScript: |
az vm open-port -g Testnet -n "${{ vars.AZURE_RESOURCE_PREFIX }}-${{ matrix.host_id }}-${{ GITHUB.RUN_NUMBER }}" --port 80,81,6060,6061,10000
az vm open-port -g Testnet -n "${{ vars.AZURE_RESOURCE_PREFIX }}-${{ github.event.inputs.node_id }}-${{ GITHUB.RUN_NUMBER }}" --port 80,81,6060,6061,10000
# To overcome issues with critical VM resources being unavailable, we need to wait for the VM to be ready
- name: 'Allow time for VM initialization'
shell: bash
run: sleep 60

- name: 'Start Obscuro node-${{ matrix.host_id }} on Azure'
- name: 'Start Obscuro node-${{ github.event.inputs.node_id }} on Azure'
uses: azure/CLI@v1
with:
inlineScript: |
az vm run-command invoke -g Testnet -n "${{ vars.AZURE_RESOURCE_PREFIX }}-${{ matrix.host_id }}-${{ GITHUB.RUN_NUMBER }}" \
az vm run-command invoke -g Testnet -n "${{ vars.AZURE_RESOURCE_PREFIX }}-${{ github.event.inputs.node_id }}-${{ GITHUB.RUN_NUMBER }}" \
--command-id RunShellScript \
--scripts 'mkdir -p /home/obscuro \
&& git clone --depth 1 -b ${{ env.BRANCH_NAME }} https://github.com/ten-protocol/go-ten.git /home/obscuro/go-obscuro \
Expand All @@ -166,13 +170,13 @@ jobs:
-node_type=validator \
-is_sgx_enabled=true \
-host_id=${{ github.event.inputs.node_account_address }} \
-l1_ws_url=${{ github.event.inputs.node_l1_ws_url }} \
-l1_ws_url=${{ secrets.ADD_NEW_NODE_L1_WS_URL }} \
-management_contract_addr=${{ github.event.inputs.MGMT_CONTRACT_ADDR }} \
-message_bus_contract_addr=${{ github.event.inputs.MSG_BUS_CONTRACT_ADDR }} \
-l1_start=${{ github.event.inputs.L1_START_HASH }} \
-private_key=${{ github.event.inputs.node_private_key }} \
-private_key=${{ secrets.ADD_NEW_NODE_PRIVATE_KEY }} \
-sequencer_id=${{ vars.ACCOUNT_ADDR_NODE_0 }} \
-host_public_p2p_addr=obscuronode-${{ matrix.host_id }}-${{ github.event.inputs.testnet_type }}-${{ GITHUB.RUN_NUMBER }}.uksouth.cloudapp.azure.com:10000 \
-host_public_p2p_addr=obscuronode-${{ github.event.inputs.node_id }}-${{ github.event.inputs.testnet_type }}-${{ GITHUB.RUN_NUMBER }}.uksouth.cloudapp.azure.com:10000 \
-host_p2p_port=10000 \
-enclave_docker_image=${{ vars.L2_ENCLAVE_DOCKER_BUILD_TAG }} \
-host_docker_image=${{ vars.L2_HOST_DOCKER_BUILD_TAG }} \
Expand All @@ -185,34 +189,37 @@ jobs:
start'
update-loadbalancer:
needs:
- build
- deploy
runs-on: ubuntu-latest
environment:
name: ${{ github.event.inputs.testnet_type }}
steps:
- uses: actions/checkout@v3

- name: 'Login via Azure CLI'
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: 'Remove existing backend nodes from the load balancer'
run: ./.github/workflows/runner-scripts/testnet-clear-loadbalancer.sh ${{ github.event.inputs.testnet_type }}

- name: 'Add load balancer address pool to the IP configuration'
uses: azure/CLI@v1
with:
inlineScript: |
az network nic ip-config address-pool add \
--address-pool ${{ github.event.inputs.testnet_type }}-backend-pool \
--ip-config-name ipconfig${{ vars.AZURE_RESOURCE_PREFIX }}-1-${{ GITHUB.RUN_NUMBER }} \
--nic-name ${{ vars.AZURE_RESOURCE_PREFIX }}-1-${{ GITHUB.RUN_NUMBER }}VMNic \
--resource-group Testnet \
--lb-name ${{ github.event.inputs.testnet_type }}-loadbalancer
#
# Load Balancer can't be updated until the L1 and L2 is bootstrapped
#
# update-loadbalancer:
# needs:
# - build
# - deploy
# runs-on: ubuntu-latest
# environment:
# name: ${{ github.event.inputs.testnet_type }}
# steps:
# - uses: actions/checkout@v3
#
# - name: 'Login via Azure CLI'
# uses: azure/login@v1
# with:
# creds: ${{ secrets.AZURE_CREDENTIALS }}
#
# - name: 'Remove existing backend nodes from the load balancer'
# run: ./.github/workflows/runner-scripts/testnet-clear-loadbalancer.sh ${{ github.event.inputs.testnet_type }}
#
# - name: 'Add load balancer address pool to the IP configuration'
# uses: azure/CLI@v1
# with:
# inlineScript: |
# az network nic ip-config address-pool add \
# --address-pool ${{ github.event.inputs.testnet_type }}-backend-pool \
# --ip-config-name ipconfig${{ vars.AZURE_RESOURCE_PREFIX }}-${{ github.event.inputs.node_id }}-${{ GITHUB.RUN_NUMBER }} \
# --nic-name ${{ vars.AZURE_RESOURCE_PREFIX }}-${{ github.event.inputs.node_id }}-${{ GITHUB.RUN_NUMBER }}VMNic \
# --resource-group Testnet \
# --lb-name ${{ github.event.inputs.testnet_type }}-loadbalancer

check-obscuro-is-healthy:
needs:
Expand All @@ -227,5 +234,4 @@ jobs:
- name: "Wait until obscuro node is healthy"
shell: bash
run: |
./.github/workflows/runner-scripts/wait-node-healthy.sh --host=obscuronode-0-${{ github.event.inputs.testnet_type }}-${{ GITHUB.RUN_NUMBER }}.uksouth.cloudapp.azure.com
./.github/workflows/runner-scripts/wait-node-healthy.sh --host=obscuronode-1-${{ github.event.inputs.testnet_type }}-${{ GITHUB.RUN_NUMBER }}.uksouth.cloudapp.azure.com
./.github/workflows/runner-scripts/wait-node-healthy.sh --host=obscuronode-${{ github.event.inputs.node_id }}-${{ github.event.inputs.testnet_type }}-${{ GITHUB.RUN_NUMBER }}.uksouth.cloudapp.azure.com
12 changes: 6 additions & 6 deletions .github/workflows/runner-scripts/testnet-clear-loadbalancer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ if [[ -z "${ipconfig_id}" ]]; then
exit 0
fi

az network nic ip-config address-pool remove \
--address-pool ${pool} \
--ip-config-name "${ipconfig_id}" \
--nic-name "${nic_id}" \
--resource-group Testnet \
--lb-name ${lb} \
#az network nic ip-config address-pool remove \
# --address-pool ${pool} \
# --ip-config-name "${ipconfig_id}" \
# --nic-name "${nic_id}" \
# --resource-group Testnet \
# --lb-name ${lb} \


echo 'Load balancer removed successfully'

0 comments on commit 06d02fb

Please sign in to comment.