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

feat: Kava Protonet Data Reset Chain CI #2025

Draft
wants to merge 57 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
902faae
feat: add base genesis file for kava-protonet validator
sesheffield Sep 18, 2024
fea13c0
feat: update KAVA.VERSION to current branch til merged into master
sesheffield Sep 18, 2024
b480988
add god committee to branch
luke-kava Sep 19, 2024
ae8df5d
add issuance params, bank info and dev-wallet (correct) to account
luke-kava Sep 20, 2024
01b38f0
add README.d
luke-kava Sep 20, 2024
c3faac1
feat: handle protonet flow with new ansible playbook for reset and di…
sesheffield Sep 20, 2024
44dc38c
update README
luke-kava Sep 20, 2024
e7da1ab
fix: remove node-types
sesheffield Sep 20, 2024
895f0a0
fix: add seed-chain-state
sesheffield Sep 20, 2024
e25fae7
fix: increase to 10 seconds
sesheffield Sep 20, 2024
91e7f28
fix: change evm_denom to ukava and london and below blocks to null
sesheffield Sep 20, 2024
6998fd0
fix: use shef-protonet-validator-network-ephemeral branch for infra
sesheffield Sep 23, 2024
92282e7
fix: use akava
sesheffield Sep 23, 2024
cf12137
fix: use kava_version_filepath
sesheffield Sep 23, 2024
d619f41
fix: add another loop to keep waiting til fully in standby, helps wit…
sesheffield Sep 23, 2024
d0ed836
fix: just run reset since reset will start chain too
sesheffield Sep 23, 2024
982a556
fix: add bring the chain online to reset
sesheffield Sep 23, 2024
129aa25
fix: start chain
sesheffield Sep 23, 2024
2b4f24d
fix: update genesis
sesheffield Sep 23, 2024
bebb594
fix: update exit
sesheffield Sep 23, 2024
ee51bfa
fix: update version
sesheffield Sep 23, 2024
ac56d13
fix: update members
sesheffield Sep 23, 2024
badce97
fix: put genesis back
sesheffield Sep 23, 2024
72a8aa4
fix: evm_denom set to akava
sesheffield Sep 23, 2024
b9ff55d
fix: force
sesheffield Sep 23, 2024
7b97d74
fix: add max_gas
sesheffield Sep 23, 2024
9124b4a
fix: force
sesheffield Sep 23, 2024
3ba904a
fix: force
sesheffield Sep 23, 2024
7853d63
fix: update genesis.json to match more internal testnet
sesheffield Sep 23, 2024
c85e39d
fix: do only validator for reset for now
sesheffield Sep 23, 2024
3689b2e
fix: add pricefeed for bnb:usd and swap claims
sesheffield Sep 23, 2024
df499b0
fix: no_base_fee true and other updates
sesheffield Sep 23, 2024
4a80b1f
fix: put back kava1jaw3g097lq9jdrnscchspr2233yhpsxdjky582 auth
sesheffield Sep 23, 2024
bf3ed1f
fix: add rest of genesis.json
sesheffield Sep 23, 2024
aa7263d
fix: update comments
sesheffield Sep 23, 2024
60765b7
fix: update comments
sesheffield Sep 23, 2024
2d42ed1
fix: add env for exit-standby-all-chain-nodes
sesheffield Sep 23, 2024
d204d47
fix: remove unneeded file
sesheffield Sep 23, 2024
70c7170
fix: put back to 6.5 secs between blocks
sesheffield Sep 23, 2024
fa15519
fix: put back to master and only run on merging into master
sesheffield Sep 23, 2024
230c398
update README for kava-protonet
luke-kava Sep 24, 2024
31dfe07
Merge branch 'master' into shef-protonet-validator-network-ci
luke-kava Sep 24, 2024
6c7459d
Merge branch 'shef-protonet-validator-network' into shef-protonet-val…
lbayas Sep 24, 2024
d6fab27
Merge branch 'master' into shef-protonet-validator-network
luke-kava Sep 24, 2024
95f4ed6
Merge branch 'shef-protonet-validator-network' into shef-protonet-val…
luke-kava Sep 24, 2024
01e6549
mimic what validate-internal-testnet-genesis in validate-protonet-gen…
luke-kava Sep 24, 2024
1e01e10
fix: remove dup
sesheffield Sep 24, 2024
24a4aab
fix: restart
sesheffield Sep 24, 2024
d3fe3a8
fix: kvtool?:
sesheffield Sep 25, 2024
8613af8
force
sesheffield Sep 25, 2024
18d1f27
fix: put back to running once merged into master
sesheffield Sep 25, 2024
064a252
feat: handle when kava-protonet files have changed for reset
sesheffield Sep 25, 2024
f1de797
fix: add needs changed_files for reset-chain-to-zero-state
sesheffield Sep 25, 2024
09bcd10
fix: use protonet
sesheffield Sep 25, 2024
5483433
fix: rename AWS_CHAIN_ID_TAG_NAME
sesheffield Sep 25, 2024
7c24a03
Merge branch 'master' into shef-protonet-validator-network-ci
sesheffield Sep 30, 2024
4012a57
fix: newline
sesheffield Sep 30, 2024
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
13 changes: 12 additions & 1 deletion .github/scripts/exit-standby-all-chain-nodes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -x

# get all the node's ec2 instance ids for the specified chain id
chain_node_instance_ids=$(aws ec2 describe-instances --filters "Name=tag:KavaChainId,Values=$CHAIN_ID" | jq -r '[.Reservations | .[] | .Instances | .[] | .InstanceId] | join(" ")')
chain_node_instance_ids=$(aws ec2 describe-instances --filters "Name=tag:$AWS_CHAIN_ID_TAG_NAME,Values=$CHAIN_ID" | jq -r '[.Reservations | .[] | .Instances | .[] | .InstanceId] | join(" ")')

for chain_node_instance_id in ${chain_node_instance_ids}
do
Expand All @@ -17,6 +17,17 @@ do
aws autoscaling exit-standby \
--instance-ids "$chain_node_instance_id" \
--auto-scaling-group-name "$autoscaling_group_name"

while true; do
autoscaling_group_state=$(aws autoscaling describe-auto-scaling-instances --instance-ids "$chain_node_instance_id" | jq -r '[.AutoScalingInstances | .[].LifecycleState] | join(" ")')
if [ "$autoscaling_group_state" == "InService" ]; then
echo "instance ($chain_node_instance_id) is now in inService state"
break
else
echo "instance ($chain_node_instance_id) not in standby state yet (current state: $autoscaling_group_state), waiting 10 seconds"
sleep 10
fi
done
;;
*)
echo "instance ($chain_node_instance_id) not in an elgible state ($autoscaling_group_state) for exiting standby, skipping"
Expand Down
15 changes: 13 additions & 2 deletions .github/scripts/put-all-chain-nodes-on-standby.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/bash
set -x

# get all the node's ec2 instance ids for the specified chain id
chain_node_instance_ids=$(aws ec2 describe-instances --filters "Name=tag:KavaChainId,Values=$CHAIN_ID" | jq -r '[.Reservations | .[] | .Instances | .[] | .InstanceId] | join(" ")')
# get all the node's ec2 instance ids for the specified chain id KavaChainId
chain_node_instance_ids=$(aws ec2 describe-instances --filters "Name=tag:$AWS_CHAIN_ID_TAG_NAME,Values=$CHAIN_ID" | jq -r '[.Reservations | .[] | .Instances | .[] | .InstanceId] | join(" ")')

for chain_node_instance_id in ${chain_node_instance_ids}
do
Expand All @@ -19,6 +19,17 @@ do
--instance-ids "$chain_node_instance_id" \
--auto-scaling-group-name "$autoscaling_group_name" \
--should-decrement-desired-capacity

while true; do
autoscaling_group_state=$(aws autoscaling describe-auto-scaling-instances --instance-ids "$chain_node_instance_id" | jq -r '[.AutoScalingInstances | .[].LifecycleState] | join(" ")')
if [ "$autoscaling_group_state" == "Standby" ]; then
echo "instance ($chain_node_instance_id) is now in standby state"
break
else
echo "instance ($chain_node_instance_id) not in standby state yet (current state: $autoscaling_group_state), waiting 10 seconds"
sleep 10
fi
done
;;
*)
echo "instance ($chain_node_instance_id) not in an elgible state ($autoscaling_group_state) for going on standby, skipping"
Expand Down
78 changes: 51 additions & 27 deletions .github/workflows/cd-protonet.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,64 @@
name: Continuous Deployment (Protonet)
## run after every successful CI job of new commits to the master branch
#on:
# workflow_run:
# workflows: [Continuous Integration (Kava Master)]
# types:
# - completed
# run after every successful CI job of new commits to the master branch
on:
workflow_run:
workflows: [Continuous Integration (Kava Master)]
types:
- completed

jobs:
changed_files:
runs-on: ubuntu-latest
# define output for first job forwarding output of changedProtonetConfig job
outputs:
changedProtonetConfig: ${{ steps.changed-protonet-config.outputs.any_changed }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # OR "2" -> To retrieve the preceding commit.
- name: Get all changed protonet files
id: hanged-protonet-config
uses: tj-actions/changed-files@v42
with:
# Avoid using single or double quotes for multiline patterns
files: |
ci/env/kava-protonet/**

# in order:
# enter standby (prevents autoscaling group from killing node during deploy)
# stop kava
# take ebs + zfs snapshots
# stop doctor and kava
# download updated binary and genesis
# reset application database state (only done on internal testnet)
# reset application database state
# restart all once all have been reset
# start kava and doctor
# enter inService
reset-chain-to-zero-state:
# only start cd pipeline if last ci run was successful
if: ${{ github.event.workflow_run.conclusion == 'success' }}
uses: ./.github/workflows/cd-reset-internal-testnet.yml
if: ${{ github.event.workflow_run.conclusion == 'success' && needs.changed_files.outputs.changedProtonetConfig == 'true' }}
uses: ./.github/workflows/cd-reset-protonet.yml
with:
aws-region: us-east-1
aws-chain-id-tag-name: ChainId
chain-id: proto_2221-17000
ssm-document-name: kava-testnet-internal-node-update
playbook-name: reset-protonet-playbook.yml
auto_scaling_group_names: kava-protonet-iavl-v1-validator-api-node,kava-protonet-iavl-v1-rpc-api-node
ssm-document-name: kava-protonet-iavl-v1-instance-update
playbook-name: reset-chain.yml
playbook-infrastructure-branch: master
secrets: inherit
needs: [changed_files]

# start kava with new binary and genesis state on api, peer and seed nodes, place nodes in service once they start and are synched to live
start-chain-api:
uses: ./.github/workflows/cd-start-chain.yml
with:
aws-region: us-east-1
chain-id: proto_2221-17000
ssm-document-name: kava-testnet-internal-node-update
playbook-name: start-chain-api-playbook.yml
playbook-infrastructure-branch: master
secrets: inherit
needs: [reset-chain-to-zero-state]
restart-chain:
uses: ./.github/workflows/cd-restart-protonet.yml
with:
aws-region: us-east-1
aws-chain-id-tag-name: ChainId
chain-id: proto_2221-17000
auto_scaling_group_names: kava-protonet-iavl-v1-validator-api-node,kava-protonet-iavl-v1-rpc-api-node
ssm-document-name: kava-protonet-iavl-v1-instance-update
playbook-name: restart-chain.yml
playbook-infrastructure-branch: master
secrets: inherit
needs: [ reset-chain-to-zero-state ]

# setup test and development accounts and balances, deploy contracts by calling the chain's api
seed-chain-state:
Expand All @@ -45,16 +68,17 @@ jobs:
chain-id: proto_2221-17000
seed-script-filename: seed-protonet.sh
erc20-deployer-network-name: protonet
genesis_validator_addresses: "kavavaloper14w4avgdvqrlpww6l5dhgj4egfn6ln7gmtp7r2m"
genesis_validator_addresses: "kavavaloper1jaw3g097lq9jdrnscchspr2233yhpsxdlq7ula"
kava_version_filepath: ./ci/env/kava-protonet/KAVA.VERSION
secrets: inherit
needs: [start-chain-api]
needs: [restart-chain]

post-pipeline-metrics:
uses: ./.github/workflows/metric-pipeline.yml
if: always() # always run so we metric failures and successes
with:
aws-region: us-east-1
metric-name: kava.deploys.testnet.proto
metric-name: kava.deploys.protonet.proto
namespace: Kava/ContinuousDeployment
secrets: inherit
needs: [seed-chain-state]
1 change: 1 addition & 0 deletions .github/workflows/cd-reset-internal-testnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:
- name: take the chain offline
run: bash ${GITHUB_WORKSPACE}/.github/scripts/put-all-chain-nodes-on-standby.sh
env:
AWS_CHAIN_ID_TAG_NAME: ${{ inputs.aws-chain-id-tag-name }}
CHAIN_ID: ${{ inputs.chain-id }}
AWS_REGION: ${{ inputs.aws-region }}
AWS_ACCESS_KEY_ID: ${{ secrets.CI_AWS_KEY_ID }}
Expand Down
94 changes: 94 additions & 0 deletions .github/workflows/cd-reset-protonet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Reset Protonet

on:
workflow_call:
inputs:
auto_scaling_group_names:
required: true
type: string
description: 'Comma-separated list of auto-scaling group names'
aws-chain-id-tag-name:
required: false
type: string
default: 'KavaChainId'
chain-id:
required: true
type: string
aws-region:
required: true
type: string
ssm-document-name:
required: true
type: string
playbook-name:
required: true
type: string
playbook-infrastructure-branch:
required: true
type: string
secrets:
CI_AWS_KEY_ID:
required: true
CI_AWS_KEY_SECRET:
required: true
KAVA_PRIVATE_GITHUB_ACCESS_TOKEN:
required: true

# in order:
# enter standby (prevents autoscaling group from killing node during deploy)
# stop doctor and kava
# download updated binary and genesis
# reset application database state
# start kava and doctor
# enter inService
jobs:
place-chain-nodes-on-standby:
runs-on: ubuntu-latest
steps:
- name: checkout repo from current commit
uses: actions/checkout@v4
- name: take the chain offline
run: bash ${GITHUB_WORKSPACE}/.github/scripts/put-all-chain-nodes-on-standby.sh
env:
AWS_CHAIN_ID_TAG_NAME: ${{ inputs.aws-chain-id-tag-name }}
CHAIN_ID: ${{ inputs.chain-id }}
AWS_REGION: ${{ inputs.aws-region }}
AWS_ACCESS_KEY_ID: ${{ secrets.CI_AWS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_AWS_KEY_SECRET }}
- name: checkout infrastructure repo
uses: actions/checkout@v4
with:
repository: Kava-Labs/infrastructure
token: ${{ secrets.KAVA_PRIVATE_GITHUB_ACCESS_TOKEN }}
path: infrastructure
ref: master
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: build kava node updater
run: cd infrastructure/cli/kava-node-updater && make install && cd ../../../
- name: run reset playbook on all chain nodes
run: |
IFS=',' read -r -a auto_scaling_group_names <<< "$AUTO_SCALING_GROUP_NAMES"
for auto_scaling_group_name in "${auto_scaling_group_names[@]}"; do
kava-node-updater \
--debug \
--max-retries=2 \
--aws-ssm-document-name="$SSM_DOCUMENT_NAME" \
--infrastructure-git-pointer="$PLAYBOOK_INFRASTRUCTURE_BRANCH" \
--update-playbook-filename="$PLAYBOOK_NAME" \
--autoscaling-group-name="$auto_scaling_group_name" \
--max-upgrade-batch-size=0 \
--node-types="" \
--wait-for-node-sync-after-upgrade=true
done
env:
SSM_DOCUMENT_NAME: ${{ inputs.ssm-document-name }}
PLAYBOOK_NAME: ${{ inputs.playbook-name }}
AUTO_SCALING_GROUP_NAMES: ${{ inputs.auto_scaling_group_names }}
AWS_REGION: ${{ inputs.aws-region }}
AWS_ACCESS_KEY_ID: ${{ secrets.CI_AWS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_AWS_KEY_SECRET }}
AWS_SDK_LOAD_CONFIG: 1
PLAYBOOK_INFRASTRUCTURE_BRANCH: ${{ inputs.playbook-infrastructure-branch }}
102 changes: 102 additions & 0 deletions .github/workflows/cd-restart-protonet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Restart Protonet

on:
workflow_call:
inputs:
auto_scaling_group_names:
required: true
type: string
description: 'Comma-separated list of auto-scaling group names'
aws-chain-id-tag-name:
required: false
type: string
default: 'KavaChainId'
chain-id:
required: true
type: string
aws-region:
required: true
type: string
ssm-document-name:
required: true
type: string
playbook-name:
required: true
type: string
playbook-infrastructure-branch:
required: true
type: string
secrets:
CI_AWS_KEY_ID:
required: true
CI_AWS_KEY_SECRET:
required: true
KAVA_PRIVATE_GITHUB_ACCESS_TOKEN:
required: true

# in order:
# enter standby (prevents autoscaling group from killing node during deploy)
# stop doctor and kava
# download updated binary and genesis
# reset application database state
# start kava and doctor
# enter inService
jobs:
restart-traffic:
runs-on: ubuntu-latest
steps:
- name: checkout repo from current commit
uses: actions/checkout@v4
- name: take the chain offline
run: bash ${GITHUB_WORKSPACE}/.github/scripts/put-all-chain-nodes-on-standby.sh
env:
AWS_CHAIN_ID_TAG_NAME: ${{ inputs.aws-chain-id-tag-name }}
CHAIN_ID: ${{ inputs.chain-id }}
AWS_REGION: ${{ inputs.aws-region }}
AWS_ACCESS_KEY_ID: ${{ secrets.CI_AWS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_AWS_KEY_SECRET }}
- name: checkout infrastructure repo
uses: actions/checkout@v4
with:
repository: Kava-Labs/infrastructure
token: ${{ secrets.KAVA_PRIVATE_GITHUB_ACCESS_TOKEN }}
path: infrastructure
ref: master
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: build kava node updater
run: cd infrastructure/cli/kava-node-updater && make install && cd ../../../
- name: run reset playbook on all chain nodes
run: |
IFS=',' read -r -a auto_scaling_group_names <<< "$AUTO_SCALING_GROUP_NAMES"
for auto_scaling_group_name in "${auto_scaling_group_names[@]}"; do
kava-node-updater \
--debug \
--max-retries=2 \
--aws-ssm-document-name="$SSM_DOCUMENT_NAME" \
--infrastructure-git-pointer="$PLAYBOOK_INFRASTRUCTURE_BRANCH" \
--update-playbook-filename="$PLAYBOOK_NAME" \
--autoscaling-group-name="$auto_scaling_group_name" \
--max-upgrade-batch-size=0 \
--node-types="" \
--wait-for-node-sync-after-upgrade=true
done
env:
SSM_DOCUMENT_NAME: ${{ inputs.ssm-document-name }}
PLAYBOOK_NAME: ${{ inputs.playbook-name }}
AUTO_SCALING_GROUP_NAMES: ${{ inputs.auto_scaling_group_names }}
AWS_REGION: ${{ inputs.aws-region }}
AWS_ACCESS_KEY_ID: ${{ secrets.CI_AWS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_AWS_KEY_SECRET }}
AWS_SDK_LOAD_CONFIG: 1
PLAYBOOK_INFRASTRUCTURE_BRANCH: ${{ inputs.playbook-infrastructure-branch }}
- name: bring the chain online
run: bash ${GITHUB_WORKSPACE}/.github/scripts/exit-standby-all-chain-nodes.sh
env:
AWS_CHAIN_ID_TAG_NAME: ${{ inputs.aws-chain-id-tag-name }}
CHAIN_ID: ${{ inputs.chain-id }}
AWS_REGION: ${{ inputs.aws-region }}
AWS_ACCESS_KEY_ID: ${{ secrets.CI_AWS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.CI_AWS_KEY_SECRET }}
4 changes: 3 additions & 1 deletion .github/workflows/cd-seed-chain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ jobs:
- name: get desired version of network
id: kava-version
run: |
echo "KAVA_VERSION=$(cat ./ci/env/kava-internal-testnet/KAVA.VERSION)" >> $GITHUB_OUTPUT
KAVA_VERSION=$(cat ${{ inputs.kava_version_filepath }})
echo "KAVA_VERSION=$KAVA_VERSION" >> $GITHUB_OUTPUT
echo "Kava Version: $KAVA_VERSION"
env:
KAVA_VERSION_FILEPATH: ${{ inputs.kava_version_filepath }}
- name: checkout version of kava used by network
Expand Down
Loading
Loading