Skip to main content

Automated Upgrades

We strongly advise validators to run their nodes with Cosmovisor. As a result, low-downtime upgrades will go more smoothly since validators won't need to manually upgrade binaries while the upgrade is taking place. Instead, users can pre-install fresh binaries, and Cosmovisor will update them automatically depending on suggestions for on-chain Software Upgrade proposal.

A simple process manager called cosmovisor watches the governance module for incoming chain upgrade proposals in Cosmos SDK application binaries. Cosmovisor can automatically download the new binary, stop the existing binary, switch from the old binary to the new one, and then restart the node with the new binary if it notices a proposal that is accepted.

Prerequisites

1. Setup Cosmovisor

Configure the environment variables for Cosmovisor. We advise setting these in your .profile so that they are pre-configured for each session.

echo "# Setup Cosmovisor" >> ~/.profile
echo "export DAEMON_NAME=humansd" >> ~/.profile
echo "export DAEMON_HOME=$HOME/.humansd" >> ~/.profile
source ~/.profile

After that, you must create the required cosmosvisor folders in your DAEMON_HOME directory (/.humansd), then copy the existing binaries there.

mkdir -p ~/.humansd/cosmovisor
mkdir -p ~/.humansd/cosmovisor/genesis
mkdir -p ~/.humansd/cosmovisor/genesis/bin
mkdir -p ~/.humansd/cosmovisor/upgrades

cp $GOPATH/bin/humansd ~/.humansd/cosmovisor/genesis/bin

To check that you followed the instructions successfully, make sure your copies of cosmovisor and humansd are identical:

cosmovisor run version
humansd version

2. Download the Humans.ai release

Manual Download

The $DAEMON_HOME/data/upgrade-info.json file will be checked by Cosmovisor frequently for fresh upgrade instructions. When a release is made, node operators must:

  1. Download the updated release's binaries (DO NOT INSTALL).
  2. Put it in the $DAEMON_HOME/cosmovisor/upgrades/name>/bin directory, where <name> is the upgrade's URI-encoded name as listed in the Software Upgrade Plan.

Example: for a Plan with name v1.0.1 with the following upgrade-info.json:

{
"binaries": {
"darwin/arm64": "https://github.com/humansdotai/humans/releases/tag/v1.0.0/humans_1.0.0_Darwin_arm64.tar.gz",
"darwin/x86_64": "https://github.com/humansdotai/humans/releases/tag/v1.0.0/humans_1.0.0_Darwin_x86_64.tar.gz",
"linux/arm64": "https://github.com/humansdotai/humans/releases/tag/v1.0.0/humans_1.0.0_Linux_arm64.tar.gz",
"linux/amd64": "https://github.com/humansdotai/humans/releases/tag/v1.0.0/humans_1.0.0_Linux_amd64.tar.gz",
"windows/x86_64": "https://github.com/humansdotai/humans/releases/tag/v1.0.0/humans_1.0.0_Windows_x86_64.zip"
}
}

The structure of your cosmovisor/ directory should be as follows:

cosmovisor/
├── current/ # either genesis or upgrades/<name>
├── genesis
│ └── bin
│ └── humansd
└── upgrades
└── v1.0.0
├── bin
│ └── humansd
└── upgrade-info.json

Automatic Download

danger

NOTE: Auto-download doesn't check to see if a binary is accessible beforehand. Cosmovisor will stop and not restart the chain (which could bring it to a halt) if there is a problem downloading a binary.

It is possible to have Cosmovisor automatically download the new binary. Validators can use the automatic download option to prevent unnecessary downtime during the upgrade process. This option will automatically restart the chain with the upgrade binary once the chain has halted at the proposed upgrade-height. The major benefit of this option is that validators can prepare the upgrade binary in advance and then relax at the time of the upgrade.

Set the following environment variable to enable auto-downloading:

echo "export DAEMON_ALLOW_DOWNLOAD_BINARIES=true" >> ~/.profile

3. Start your node

You can start your node now that everything is set up and ready to go.

cosmovisor run start

You will require a method to keep the process active at all times. You can accomplish this by setting up a service if you use Linux.

sudo tee /etc/systemd/system/humansd.service > /dev/null <<EOF
[Unit]
Description=Humans Daemon
After=network-online.target

[Service]
User=$USER
ExecStart=$(which cosmovisor) start
Restart=always
RestartSec=3
LimitNOFILE=infinity

Environment="DAEMON_HOME=$HOME/.humansd"
Environment="DAEMON_NAME=humansd"
Environment="DAEMON_ALLOW_DOWNLOAD_BINARIES=false"
Environment="DAEMON_RESTART_AFTER_UPGRADE=true"

[Install]
WantedBy=multi-user.target
EOF

Then update and start the node

sudo -S systemctl daemon-reload
sudo -S systemctl enable humansd
sudo -S systemctl start humansd

You can check the status with:

systemctl status humansd