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

Upgrade path testing #80

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7e8ee44
updated the change log
gzukel Nov 14, 2023
83af01e
Merge pull request #78 from zeta-chain/v12.1.0-rc
gzukel Nov 14, 2023
0caa09b
updated links and version for upgrade path testing from google
gzukel Nov 20, 2023
d996498
updated links and version for upgrade path testing from google
gzukel Nov 20, 2023
698640d
updated links and version for upgrade path testing from google
gzukel Nov 20, 2023
8293959
updated links and version for upgrade path testing from google
gzukel Nov 20, 2023
40aa52e
updated links and version for upgrade path testing from google
gzukel Nov 20, 2023
e5aa839
updated links and version for upgrade path testing from google
gzukel Nov 20, 2023
624c8e3
updated links and version for upgrade path testing from google
gzukel Nov 20, 2023
9244382
updated links and version for upgrade path testing from google
gzukel Nov 20, 2023
66915ec
updated links and version for upgrade path testing from google
gzukel Nov 20, 2023
70761d2
updated links and version for upgrade path testing from google
gzukel Nov 20, 2023
c7cf739
updated links and version for upgrade path testing from google
gzukel Nov 20, 2023
9df4929
updated links and version for upgrade path testing from google
gzukel Nov 20, 2023
27eaaf4
updated links and version for upgrade path testing from google
gzukel Nov 20, 2023
8de7c5c
updated links and version for upgrade path testing from google
gzukel Nov 21, 2023
3d0362c
updated links and version for upgrade path testing from google
gzukel Nov 21, 2023
b6f6331
updated links and version for upgrade path testing from google
gzukel Nov 21, 2023
be42b85
updated links and version for upgrade path testing from google
gzukel Nov 21, 2023
2b64bab
updated links and version for upgrade path testing from google
gzukel Nov 21, 2023
22013f5
updated links and version for upgrade path testing from google
gzukel Nov 21, 2023
a32a115
updated links and version for upgrade path testing from google
gzukel Nov 21, 2023
7f7d74d
updated links and version for upgrade path testing from google
gzukel Nov 21, 2023
0f0e70e
updated links and version for upgrade path testing from google
gzukel Nov 21, 2023
e15a1b9
updated links and version for upgrade path testing from google
gzukel Nov 21, 2023
7ecd214
updated links and version for upgrade path testing from google
gzukel Nov 21, 2023
5b42cce
updated links and version for upgrade path testing from google
gzukel Nov 21, 2023
0ff266d
updated links and version for upgrade path testing from google
gzukel Nov 21, 2023
b66ec56
updated links and version for upgrade path testing from google
gzukel Nov 21, 2023
d932c6f
updated links and version for upgrade path testing from google
gzukel Nov 21, 2023
7deafd7
updated
gzukel Nov 21, 2023
aacb882
updated
gzukel Nov 21, 2023
3ae8716
updated
gzukel Nov 21, 2023
fc5bd0d
updated
gzukel Nov 21, 2023
96d6819
updated
gzukel Nov 21, 2023
af53da4
updated
gzukel Nov 22, 2023
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
106 changes: 54 additions & 52 deletions .github/actions/upgrade-testing/create_genesis.py
Original file line number Diff line number Diff line change
@@ -1,54 +1,56 @@
import json
import os

genesis = open(os.environ["NEW_GENESIS"], "r").read()
genesis_json_object = json.loads(genesis)

#cut this out for now because it fails to start when done in python with the exact same keys being replaced with same value. Will fix later.
# genesis_json_object["staking"]["params"]["bond_denom"] = "azeta"
# genesis_json_object["crisis"]["constant_fee"]["denom"] = "azeta"
# genesis_json_object["gov"]["deposit_params"]["min_deposit"][0]["denom"] = "azeta"
# genesis_json_object["mint"]["params"]["mint_denom"] = "azeta"
# genesis_json_object["evm"]["params"]["evm_denom"] = "azeta"
# genesis_json_object["block"]["max_gas"] = "10000000"
# genesis_json_object["gov"]["voting_params"]["voting_period"] = '60s'

exported_genesis = open(os.environ["OLD_GENESIS"], "r").read()
exported_genesis_json_object = json.loads(exported_genesis)

crosschain = exported_genesis_json_object["app_state"]["crosschain"]
observer = exported_genesis_json_object["app_state"]["observer"]
emissions = exported_genesis_json_object["app_state"]["emissions"]
fungible = exported_genesis_json_object["app_state"]["fungible"]
evm = exported_genesis_json_object["app_state"]["evm"]
auth_accounts = exported_genesis_json_object["app_state"]["auth"]["accounts"]

genesis_json_object["app_state"]["auth"]["accounts"] = genesis_json_object["app_state"]["auth"]["accounts"] + auth_accounts
genesis_json_object["app_state"]["crosschain"] = crosschain
genesis_json_object["app_state"]["observer"] = observer
genesis_json_object["app_state"]["emissions"] = emissions
genesis_json_object["app_state"]["fungible"] = fungible

evm_accounts = []
for index, account in enumerate(evm["accounts"]):
if account["address"] == "0x0000000000000000000000000000000000000001":
print("pop account", account["address"])
elif account["address"] == "0x0000000000000000000000000000000000000006":
print("pop account", account["address"])
elif account["address"] == "0x0000000000000000000000000000000000000002":
print("pop account", account["address"])
elif account["address"] == "0x0000000000000000000000000000000000000002":
print("pop account", account["address"])
elif account["address"] == "0x0000000000000000000000000000000000000008":
print("pop account", account["address"])
else:
evm_accounts.append(account)

evm["accounts"] = evm_accounts
genesis_json_object["app_state"]["evm"] = evm

genesis = open("genesis-edited.json", "w")
genesis_string = json.dumps(genesis_json_object, indent=2)
dumped_genesis_object = genesis_string.replace("0x0000000000000000000000000000000000000001","0x387A12B28fe02DcAa467c6a1070D19B82F718Bb5")
genesis.write(genesis_string)
genesis.close()
from memory_profiler import profile


@profile
def genesis_modification():
genesis = open(os.environ["NEW_GENESIS"], "r").read()
genesis_json_object = json.loads(genesis)

exported_genesis = open(os.environ["OLD_GENESIS"], "r").read()
exported_genesis_json_object = json.loads(exported_genesis)

exported_genesis = None
genesis = None

print("APP_STATE:AUTH:ACCOUNTS")
genesis_json_object["app_state"]["auth"]["accounts"] = genesis_json_object["app_state"]["auth"]["accounts"] + \
exported_genesis_json_object["app_state"]["auth"]["accounts"]
print("APP_STATE:CROSSCHAIN")
genesis_json_object["app_state"]["crosschain"] = exported_genesis_json_object["app_state"]["crosschain"]
print("APP_STATE:OBSERVER")
genesis_json_object["app_state"]["observer"] = exported_genesis_json_object["app_state"]["observer"]
print("APP_STATE:EMISSIONS")
genesis_json_object["app_state"]["emissions"] = exported_genesis_json_object["app_state"]["emissions"]
print("APP_STATE:FUNGIBLE")
genesis_json_object["app_state"]["fungible"] = exported_genesis_json_object["app_state"]["fungible"]

print("EVM:ACCOUNTS")
evm_accounts = []
for index, account in enumerate(exported_genesis_json_object["app_state"]["evm"]["accounts"]):
if account["address"] == "0x0000000000000000000000000000000000000001":
print("pop account", account["address"])
elif account["address"] == "0x0000000000000000000000000000000000000006":
print("pop account", account["address"])
elif account["address"] == "0x0000000000000000000000000000000000000002":
print("pop account", account["address"])
elif account["address"] == "0x0000000000000000000000000000000000000002":
print("pop account", account["address"])
elif account["address"] == "0x0000000000000000000000000000000000000008":
print("pop account", account["address"])
else:
evm_accounts.append(account)

print("SET:EVM:ACCOUNTS")
exported_genesis_json_object["app_state"]["evm"]["accounts"] = evm_accounts
evm_accounts = None
print("UPDATE:EVM")
genesis_json_object["app_state"]["evm"] = exported_genesis_json_object["app_state"]["evm"]
exported_genesis_json_object = None
print("SAVE:EDITED:GENESIS")
with open("genesis-edited.json", "w") as genesis:
genesis.write(json.dumps(genesis_json_object))


genesis_modification()
75 changes: 56 additions & 19 deletions .github/workflows/upgrade_path_testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,24 @@ on:
version:
description: 'The new version of tag you are going to download the binary from..'
required: true
default: 'v10.1.0'
default: 'v12.1.0'
upgrade_name:
description: 'The version that is set in setup_handlers.go'
required: true
default: 'v10.1.0'
default: 'v12.1.0'
current_version:
description: 'The version that the network is currently on.'
required: true
default: 'v10.0.0'
default: 'v10.1.0'

jobs:
upgrade_path_test_state_export:
name: "UPGRADE_PATH_TEST_STATE_EXPORT"
runs-on: ["buildjet-8vcpu-ubuntu-2204"]
runs-on: ["buildjet-16vcpu-ubuntu-2204"]
timeout-minutes: 3000
env:
latest_state_export: "https://zetachain-external-files.s3.amazonaws.com/state-export/athens3/latest.json"
github_binary_version_link: "https://github.com/zeta-chain/node/releases/download/${{ github.event.inputs.version }}/zetacored_testnet-linux-amd64"
latest_state_export: "https://storage.googleapis.com/statesync-rpc-snapshots-zetachain-dev/latest.json"
github_binary_version_link: "https://github.com/zeta-chain/ci-testing-node/releases/download/${{ github.event.inputs.version }}/zetacored_testnet-linux-amd64"
downloaded_binary_name: "zetacored-testnet-linux-amd64"
VERSION: "${{ github.event.inputs.version }}"
aws_region: "us-east-1"
Expand All @@ -37,6 +38,7 @@ jobs:
DENOM: "azeta"
DAEMON_ALLOW_DOWNLOAD_BINARIES: "true"
DAEMON_RESTART_AFTER_UPGRADE: "true"
SLEEP_START_TIME: "800"
MONIKER: "zeta"
BLOCK_TIME_SECONDS: "6"
PROPOSAL_TIME_SECONDS: "60"
Expand All @@ -61,11 +63,6 @@ jobs:
steps:
- uses: actions/checkout@v1

- id: install-aws-cli
uses: unfor19/install-aws-cli-action@v1
with:
version: 2

- uses: actions/setup-go@v4
with:
check-latest: false
Expand Down Expand Up @@ -106,8 +103,13 @@ jobs:
wget -q ${latest_state_export}

echo "*********DOWNLOAD UPGRADE BINARY AND PUT IN ZETAVISOR UPGRADES FOLDER*********"
echo "*********DOWNLOADING: ${github_binary_version_link}*********"
wget -q ${github_binary_version_link} -O /home/runner/.zetacored/zetavisor/upgrades/${{ github.event.inputs.version }}/bin/zetacored

echo "GET CHECKSUME OF DOWNLOADED BINARY"
ZETACORED_CHECKSUM=$(shasum -b -a 256 /home/runner/.zetacored/zetavisor/upgrades/${{ github.event.inputs.version }}/bin/zetacored | cut -d ' ' -f 1)

echo "CHANGE PERMISSIONS"
sudo chmod a+x /home/runner/.zetacored/zetavisor/upgrades/${{ github.event.inputs.version }}/bin/zetacored

echo "UPGRADE_INFO=${UPGRADE_INFO}" >> ${GITHUB_ENV}
Expand Down Expand Up @@ -141,8 +143,9 @@ jobs:
sudo chmod a+x /home/runner/.zetacored/zetavisor/genesis/bin/zetacored
echo "PATH=/home/runner/.zetacored/zetavisor/genesis/bin:$PATH" >> ${GITHUB_ENV}

- name: "START_TESTING_NETWORK"
- name: "SETUP:GENESIS"
run: |
pip install memory_profiler
zetacored config keyring-backend $KEYRING --home ${DAEMON_HOME}

zetacored config chain-id $CHAINID --home ${DAEMON_HOME}
Expand Down Expand Up @@ -198,26 +201,59 @@ jobs:
zetacored validate-genesis

cp $DAEMON_HOME/config/genesis.json ./genesis.json
echo "enable swap"
sudo fallocate -l 30G ./swapfile
sudo chmod 600 ./swapfile
sudo mkswap ./swapfile
sudo swapon ./swapfile
sudo swapon --show

echo "Do Genesis Manipulation"
export OLD_GENESIS=./latest.json
export NEW_GENESIS=./genesis.json
python .github/actions/upgrade-testing/scripts/create_genesis.py
nohup /usr/bin/time -v python .github/actions/upgrade-testing/scripts/create_genesis.py &
PYTHON_PID=$!

# Loop while the Python process is running
while ps -p $PYTHON_PID > /dev/null 2>&1; do
free
sleep 1 # Pause for 1 second before the next check
done

echo "Move Manipulated Genesis"
cp ./genesis-edited.json $DAEMON_HOME/config/genesis.json

cat $DAEMON_HOME/config/genesis.json | grep -A 10 -B 10 out_tx_tracker

echo "DAEMON HOME: $DAEMON_HOME"
ls -lah $DAEMON_HOME/config/
echo "Zetavisor Version"
zetavisor version || echo "zetavisor not found"
zetacored version || echo "zetcored not found"

echo "BEFORE CHANGE CONFIG DB"
cat $DAEMON_HOME/config/config.toml
echo "***************************"

echo "fix db"
sed -i 's/db_backend = "goleveldb"/db_backend = "pebbledb"/g' $DAEMON_HOME/config/config.toml

echo "AFTER CHANGE CONFIG DB"
cat $DAEMON_HOME/config/config.toml
echo "***************************"

- name: "START_TESTING_NETWORK"
run: |
sudo swapoff ./swapfile
sudo rm ./swapfile

echo "Start Network"
nohup zetavisor start --rpc.laddr tcp://0.0.0.0:26657 --minimum-gas-prices ${GAS_PRICES} "--grpc.enable=true" > cosmovisor.log 2>&1 &

sleep ${UPGRADES_SLEEP_TIME}
duration=10
start_time=$SECONDS
while [ $(($SECONDS - start_time)) -lt ${SLEEP_START_TIME} ]; do
free
echo "Looping..."
sleep 1
done
cat cosmovisor.log

- name: "DETERMINE_UPGRADE_TYPE"
Expand Down Expand Up @@ -251,6 +287,7 @@ jobs:
- name: "NON_CONSENSUS_BREAKING_UPGRADE"
if: env.UPGRADE_TYPE == 'NONCON'
run: |
cat cosmovisor.log
echo ${UPGRADE_TYPE}
echo "*********CHECK VERSION BEFORE BINARY SWITCH*********"
zetavisor version
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/validate-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
fetch-depth: 0

- name: Check for CHANGELOG.md changes
if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-changelog') }}
run: |
git fetch origin ${{ github.base_ref }}
CHANGELOG_DIFF=$(git diff origin/${{ github.base_ref }} origin/${{ github.head_ref }} -- changelog.md)
Expand Down
1 change: 0 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@
* fix: begin blocker for mock mainnet by @kingpinXD in https://github.com/zeta-chain/node/pull/1308



Loading