-
Notifications
You must be signed in to change notification settings - Fork 715
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
Test: automate upgrade test in ci #2692
Merged
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
30e19a3
feat: automate upgrade test
cead278
test: update upgrade workflow
32e3480
test: update upgrade workflow again
3f68759
test: update update upgrade scripts
101174f
test: update binary copying
01854db
test: update upgrade dir
a0a804c
test: update upgrade dir path
9691202
fix: binary copying
f15a211
fix: update dir path
261c632
debug
771ddb7
fix: upgrade version number
fdce9b8
fix: version comparision
1583e17
fix: version comparision in run_upgrade_commands.sh
ab4590b
fix: use pre-release tag first, then use latest release tag for old b…
c385062
fix: continue-on-error
81fc1ae
checkout current pr branch
b12d9d5
remove checkout -
f10c943
release checkout
f333b69
Merge branch 'main' into upgrade-test-automation
yaruwangway 1185d45
typo
d30d32e
move gaiad binary to GITHUB_WORKSPACE
2ce1957
debug
c68801c
debug: update checkout verison
53e074d
fix test.yml
661acea
debug: binary share between steps
b5c2b0e
debug: checkout present pr branch before run scripts
9e0842d
query proposals
dc3e249
fix cosmovisor dir
7614b8e
fix the upgrade version
fa8c5f0
formatting
2635fff
formatting
4ff33c2
formatting
5bb6ce0
debug yml format
8ae2fa3
typo correction
b8ae848
Merge branch 'main' into upgrade-test-automation
yaruwangway 4a81307
make old gaiad version hardcoded
bb996ac
Merge branch 'main' into upgrade-test-automation
yaruwangway ecf8f3d
chore: add comments
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#!/bin/sh | ||
|
||
set -o errexit -o nounset | ||
|
||
# find the highest upgrade version number($UPGRADE_VERSION_NUMBER) within the 'app/upgrades' dir. | ||
# the highest upgrade version is used to propose upgrade and create /cosmovisor/upgrades/$UPGRADE_VERSION/bin dir. | ||
UPGRADES_DIR=$(realpath ./app/upgrades) | ||
UPGRADE_VERSION_NUMBER=0 | ||
|
||
for dir in "$UPGRADES_DIR"/*; do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. might be worth adding a comment in the script what this loop does |
||
if [ -d "$dir" ]; then | ||
DIR_NAME=$(basename "$dir") | ||
VERSION_NUMBER="${DIR_NAME#v}" | ||
if [ "$VERSION_NUMBER" -gt "$UPGRADE_VERSION_NUMBER" ]; then | ||
UPGRADE_VERSION_NUMBER=$VERSION_NUMBER | ||
fi | ||
fi | ||
done | ||
|
||
if [ -n "$UPGRADE_VERSION_NUMBER" ]; then | ||
echo "Upgrade to version: $UPGRADE_VERSION_NUMBER" | ||
else | ||
echo "No upgrade version found in app/upgrades." | ||
fi | ||
|
||
UPGRADE_VERSION=v$UPGRADE_VERSION_NUMBER | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here upgrade version is configured from the latest upgrade in |
||
NODE_HOME=$(realpath ./build/.gaia) | ||
echo "NODE_HOME = ${NODE_HOME}" | ||
BINARY=$NODE_HOME/cosmovisor/genesis/bin/gaiad | ||
echo "BINARY = ${BINARY}" | ||
CHAINID=cosmoshub-4 | ||
|
||
USER_MNEMONIC="abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon art" | ||
|
||
if ! test -f "./build/gaiadold"; then | ||
echo "old gaiad binary does not exist" | ||
exit | ||
fi | ||
|
||
rm -rf ./build/.gaia | ||
|
||
mkdir -p "$NODE_HOME"/cosmovisor/genesis/bin | ||
cp ./build/gaiadold "$NODE_HOME"/cosmovisor/genesis/bin/gaiad | ||
$BINARY init upgrader --chain-id $CHAINID --home "$NODE_HOME" | ||
|
||
if ! test -f "./build/gaiadnew"; then | ||
echo "new gaiad binary does not exist" | ||
exit | ||
fi | ||
|
||
mkdir -p "$NODE_HOME"/cosmovisor/upgrades/$UPGRADE_VERSION/bin | ||
cp ./build/gaiadnew "$NODE_HOME"/cosmovisor/upgrades/$UPGRADE_VERSION/bin/gaiad | ||
|
||
GOPATH=$(go env GOPATH) | ||
|
||
export DAEMON_NAME=gaiad | ||
export DAEMON_HOME=$NODE_HOME | ||
COSMOVISOR=$GOPATH/bin/cosmovisor | ||
|
||
$BINARY config chain-id $CHAINID --home $NODE_HOME | ||
$BINARY config keyring-backend test --home $NODE_HOME | ||
tmp=$(mktemp) | ||
|
||
# add bank part of genesis | ||
jq --argjson foo "$(jq -c '.' contrib/denom.json)" '.app_state.bank.denom_metadata = $foo' $NODE_HOME/config/genesis.json >"$tmp" && mv "$tmp" $NODE_HOME/config/genesis.json | ||
|
||
# replace default stake token with uatom | ||
sed -i -e 's/stake/uatom/g' $NODE_HOME/config/genesis.json | ||
# min deposition amount (this one isn't working) | ||
sed -i -e 's%"amount": "10000000",%"amount": "1",%g' $NODE_HOME/config/genesis.json | ||
# min voting power that a proposal requires in order to be a valid proposal | ||
sed -i -e 's%"quorum": "0.334000000000000000",%"quorum": "0.000000000000000001",%g' $NODE_HOME/config/genesis.json | ||
# the minimum proportion of "yes" votes requires for the proposal to pass | ||
sed -i -e 's%"threshold": "0.500000000000000000",%"threshold": "0.000000000000000001",%g' $NODE_HOME/config/genesis.json | ||
# voting period to 30s | ||
sed -i -e 's%"voting_period": "172800s"%"voting_period": "30s"%g' $NODE_HOME/config/genesis.json | ||
|
||
echo $USER_MNEMONIC | $BINARY --home $NODE_HOME keys add val --recover --keyring-backend=test | ||
$BINARY add-genesis-account val 10000000000000000000000000uatom --home $NODE_HOME --keyring-backend test | ||
$BINARY gentx val 1000000000uatom --home $NODE_HOME --chain-id $CHAINID | ||
$BINARY collect-gentxs --home $NODE_HOME | ||
|
||
sed -i.bak'' 's/minimum-gas-prices = ""/minimum-gas-prices = "0uatom"/' $NODE_HOME/config/app.toml | ||
|
||
perl -i~ -0777 -pe 's/# Enable defines if the API server should be enabled. | ||
enable = false/# Enable defines if the API server should be enabled. | ||
enable = true/g' $NODE_HOME/config/app.toml | ||
|
||
pwd | ||
ls $NODE_HOME | ||
|
||
$COSMOVISOR run start --home $NODE_HOME --x-crisis-skip-assert-invariants >log.out 2>&1 & |
96 changes: 96 additions & 0 deletions
96
contrib/scripts/upgrade_test_scripts/run_upgrade_commands.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/bin/sh | ||
|
||
set -o errexit -o nounset | ||
|
||
UPGRADES_DIR=$(realpath ./app/upgrades) | ||
UPGRADE_VERSION_NUMBER=0 | ||
|
||
for dir in "$UPGRADES_DIR"/*; do | ||
if [ -d "$dir" ]; then | ||
DIR_NAME=$(basename "$dir") | ||
VERSION_NUMBER="${DIR_NAME#v}" | ||
if [ "$VERSION_NUMBER" -gt "$UPGRADE_VERSION_NUMBER" ]; then | ||
UPGRADE_VERSION_NUMBER=$VERSION_NUMBER | ||
fi | ||
fi | ||
done | ||
|
||
if [ -n "$UPGRADE_VERSION_NUMBER" ]; then | ||
echo "Upgrade to version: $UPGRADE_VERSION_NUMBER" | ||
else | ||
echo "No upgrade version found in app/upgrades." | ||
fi | ||
|
||
UPGRADE_VERSION=v$UPGRADE_VERSION_NUMBER | ||
UPGRADE_HEIGHT=$1 | ||
|
||
if [ -z "$1" ]; then | ||
echo "Need to add an upgrade height" | ||
exit 1 | ||
fi | ||
|
||
NODE_HOME=$(realpath ./build/.gaia) | ||
|
||
echo "NODE_HOME = ${NODE_HOME}" | ||
|
||
BINARY=$NODE_HOME/cosmovisor/genesis/bin/gaiad | ||
echo "BINARY = ${BINARY}" | ||
|
||
$BINARY version | ||
|
||
USER_MNEMONIC="abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon art" | ||
CHAINID=cosmoshub-4 | ||
|
||
if test -f "$BINARY"; then | ||
|
||
echo "wait 10 seconds for blockchain to start" | ||
sleep 10 | ||
|
||
$BINARY config chain-id $CHAINID --home $NODE_HOME | ||
$BINARY config output json --home $NODE_HOME | ||
$BINARY config keyring-backend test --home $NODE_HOME | ||
$BINARY config --home $NODE_HOME | ||
|
||
key=$($BINARY keys show val --home $NODE_HOME) | ||
if [ -z "$key" ]; then | ||
echo $USER_MNEMONIC | $BINARY --home $NODE_HOME keys add val --recover --keyring-backend=test | ||
fi | ||
|
||
echo "\n" | ||
echo "Submitting proposal... \n" | ||
$BINARY tx gov submit-proposal software-upgrade $UPGRADE_VERSION \ | ||
--title $UPGRADE_VERSION \ | ||
--deposit 10000000uatom \ | ||
--upgrade-height $UPGRADE_HEIGHT \ | ||
--upgrade-info "upgrade" \ | ||
--description "upgrade" \ | ||
--fees 400uatom \ | ||
--from val \ | ||
--keyring-backend test \ | ||
--chain-id $CHAINID \ | ||
--home $NODE_HOME \ | ||
--node tcp://localhost:26657 \ | ||
--yes | ||
echo "Done \n" | ||
|
||
sleep 6 | ||
echo "Casting vote... \n" | ||
|
||
$BINARY tx gov vote 1 yes \ | ||
--from val \ | ||
--keyring-backend test \ | ||
--chain-id $CHAINID \ | ||
--home $NODE_HOME \ | ||
--fees 400uatom \ | ||
--node tcp://localhost:26657 \ | ||
--yes | ||
|
||
echo "Done \n" | ||
|
||
$BINARY q gov proposals \ | ||
--home $NODE_HOME \ | ||
--node tcp://localhost:26657 | ||
|
||
else | ||
echo "Please build old gaia binary and move to ./build/gaiadold" | ||
fi |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yaruwangway Could you please fix the indentation to avoid having the entire file modified (hard to see the diff)?