-
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
Changes from 36 commits
30e19a3
cead278
32e3480
3f68759
101174f
01854db
a0a804c
9691202
f15a211
261c632
771ddb7
fdce9b8
1583e17
ab4590b
c385062
81fc1ae
b12d9d5
f10c943
f333b69
1185d45
d30d32e
2ce1957
c68801c
53e074d
661acea
b5c2b0e
9e0842d
dc3e249
7614b8e
fa8c5f0
2635fff
4ff33c2
5bb6ce0
8ae2fa3
b8ae848
4a81307
bb996ac
ecf8f3d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,33 +146,34 @@ jobs: | |
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: 1.20.x | ||
- name: Install GaiaV11 | ||
- name: Install Old Gaiad | ||
run: | | ||
git checkout v11.0.0 | ||
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. Does the hardcoded 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. yes, here need to be changed every time when we release a new major release, I can add a comment here. presently this test only runs on PR trying to merge to main. This means the test is targeting at upgrading from last major release to present PR branch binary version. I also tried:
|
||
make build | ||
cp ./build/gaiad ./build/gaiad11 | ||
cp ./build/gaiad ./build/gaiadold | ||
go clean -modcache | ||
if: env.GIT_DIFF | ||
- name: Install GaiaV12 | ||
# if: env.GIT_DIFF | ||
- name: Install New Gaiad | ||
run: | | ||
git checkout - | ||
make build | ||
cp ./build/gaiad ./build/gaiad12 | ||
if: env.GIT_DIFF | ||
cp ./build/gaiad ./build/gaiadnew | ||
go clean -modcache | ||
# if: env.GIT_DIFF | ||
- name: Install Cosmovisor | ||
run: | | ||
go install github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor@latest | ||
if: env.GIT_DIFF | ||
- name: Start GaiaV11 | ||
# if: env.GIT_DIFF | ||
- name: Start Old Gaiad Binary | ||
run: | | ||
go env GOPATH | ||
./contrib/scripts/upgrade_test_scripts/v12/run_gaia_v11.sh | ||
if: env.GIT_DIFF | ||
./contrib/scripts/upgrade_test_scripts/run_gaia.sh | ||
# if: env.GIT_DIFF | ||
- name: Submit Upgrade Commands | ||
run: | | ||
./contrib/scripts/upgrade_test_scripts/v12/run_upgrade_commands_v12.sh 15 | ||
if: env.GIT_DIFF | ||
./contrib/scripts/upgrade_test_scripts/run_upgrade_commands.sh 15 | ||
# if: env.GIT_DIFF | ||
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.
|
||
- name: Check for successful upgrade | ||
run: | | ||
./contrib/scripts/upgrade_test_scripts/test_upgrade.sh 20 5 16 localhost | ||
if: env.GIT_DIFF | ||
# if: env.GIT_DIFF |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#!/bin/sh | ||
|
||
set -o errexit -o nounset | ||
set -x | ||
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 & |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/bin/sh | ||
|
||
set -o errexit -o nounset | ||
set -x | ||
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 |
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)?