cosmos-sdk: [Bug]: [Cosmovisor] Upgrade is applied immediately when using the --upgrade-height flag
Is there an existing issue for this?
- I have searched the existing issues
What happened?
Cosmovisor restarts with the new binary immediately after running add-upgrade with the --upgrade-height flag.
Cosmos SDK Version
Cosmovisor v1.5.0
How to reproduce?
- Start a Gaia v13 chain with Cosmovisor v1.5.0
- Download a Gaia v14 binary to
gaiad - Run
cosmovisor add-upgrade v14 gaiad --upgrade-height 300at any point before reaching block 300. - The node will start right away with the downloaded binary.
I used this script to run steps 2 and 3:
#!/bin/bash
export DAEMON_NAME=gaiad
export DAEMON_HOME=/home/gaia/.gaia
export DAEMON_DATA_BACKUP_DIR=/home/gaia/backup
height=$(curl -s http://localhost:26657/abci_info | jq -r '.result.response.last_block_height')
version=$(curl -s http://localhost:26657/abci_info | jq -r '.result.response.version')
echo "The node is running $version at height $height."
wget https://github.com/cosmos/gaia/releases/download/v14.0.0-rc0/gaiad-v14.0.0-rc0-linux-amd64 -q -O gaiad
chmod +x gaiad
command="cosmovisor add-upgrade v14 gaiad --upgrade-height 300"
echo "$command"
$command
echo "Waiting ten seconds..."
sleep 10
height=$(curl -s http://localhost:26657/abci_info | jq -r '.result.response.last_block_height')
version=$(curl -s http://localhost:26657/abci_info | jq -r '.result.response.version')
echo "The node is running $version at height $height."
Upgrade info:
cat ~/.gaia/cosmovisor/upgrades/v14/upgrade-info.json
{"name":"v14","time":"0001-01-01T00:00:00Z","height":300}
Pre-upgrade cosmos_sdk_version: v0.45.16 (Gaia v13.0.2)
Post-upgrade cosmos_sdk_version: v0.45.16 (Gaia v14.0.0-rc0)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 19 (10 by maintainers)
š I am re-prioritizing cosmovisor work. Iāll re-investigate this.
@julienrbrt I see a potential problem here, in scanner.go
Avoid launching the node binary like that as much as possible, especially without any command-line options. A more thorough way to get data from the running node is to parse config/config.toml once, find its current RPC endpoint, and send an RPC request each time you need to get the current block height. E.g. some of my shell code:
This is significantly faster because it avoids launching another executable, even if for a moment (Iām still doing that but you can use something like a mandatory DAEMON_RPC_ENDPOINT variable instead). It is compatible with nodes that run the RPC server on a different port, which
gaiad statuswonāt pick up by itself without--node. If there are multiple nodes on one machine, this code can end up requesting the status of the node that runs on the default RPC port and using that value oflatest_block_heightto check if the upgrade should be applied immediately to a different node. It also avoids possible side effects related to outputs and exit codes of thestatuscommand. For example, in some earlier versions of CosmosSDK I noticed that this command was printing its output tostderr, notstdout, as did the main logger. Finally, it could resolve your TODO problem related to test binaries š Of course, I donāt know if either of these situations is the culprit behind this specific problem, but refactoring this part of the code to use an RPC call is a good idea anyway and will aid in any further debugging.Hey, now: https://github.com/cosmos/cosmos-sdk/releases/tag/tools%2Fcosmovisor%2Fv1.6.0
Looking at this again right now!
I also got bitten by that issue!
cosmovisor version: v1.6.0cosmovisor add-upgrade v4.2.1 ~/go/bin/neutrond --force --upgrade-height 13711950EDIT: Scratch that @julienrbrt I see where i messed up. While i did upgrade cosmovisor I didnāt restart the process before running the
add-upgradecommand so I was still actually on v1.5.0 when running the command. I have just tested again with a fake upgrade using the same binaries and it did indeed stop the node at the correct height to apply the upgrade.Thank you.
experiencing the same issue on current theta and provider testnet.
I faced this yesterday on Neutron emergency upgrade on 2 nodes. Might be because I used --force flag as there was already an upgrade-info.json file there.
@julienrbrt can we get this prioritised please? as this is quite dangerous
I have encountered this issue with the Warden testnet as well. command used:
After executing
cosmovisor add-upgrade, the node immediately restarts and uses the new binary, resulting in a crash.I am observing the same behaviour with dydxv4 cosmos scheduled for Jul 25th 2024, 07:50:07+00:00 UTC (in 10 hours) Anyone happened to know if downgrade is an option?
Weird, then it should be parsed properly: https://github.com/cosmos/cosmos-sdk/blob/main/tools/cosmovisor/scanner.go#167
@julienrbrt Upgrade info:
Pre-upgrade
cosmos_sdk_version: v0.45.16(Gaia v13.0.2) Post-upgradecosmos_sdk_version: v0.45.16(Gaia v14.0.0-rc0)