Cosmovisor is a new process manager for cosmos blockchains. It can make low-downtime upgrades smoother, as validators don't have to manually upgrade binaries during the upgrade, and instead can pre-install new binaries, and Cosmovisor will automatically update them based on on-chain SoftwareUpgrade proposals.
# Get the Cosmovisor binarywget-O-"https://github.com/cosmos/cosmos-sdk/releases/download/cosmovisor%2Fv1.1.0/cosmovisor-v1.1.0-linux-amd64.tar.gz"|sudotar-xz-C/bincosmovisorsudochmod+x/bin/cosmovisor# Make the necessary directory structure for secretd v1.2mkdir-p~/.secretd/cosmovisor/genesis/bin# Setup environment variables for every future bash session# This will make sure to setup cosmovisor on you shell in# in case you'll want to run the cosmovisor command manuallyecho"# Setup Secret & Cosmovisorexport SCRT_ENCLAVE_DIR="${HOME}/.secretd/cosmovisor/current/bin"export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${HOME}/.secretd/cosmovisor/current/bin"export PATH="${PATH}:${HOME}/.secretd/cosmovisor/current/bin"export DAEMON_NAME=secretdexport DAEMON_HOME="${HOME}/.secretd"export DAEMON_ALLOW_DOWNLOAD_BINARIES=falseexport DAEMON_LOG_BUFFER_SIZE=512export DAEMON_RESTART_AFTER_UPGRADE=trueexport DAEMON_DATA_BACKUP_DIR="${HOME}"export UNSAFE_SKIP_BACKUP=true">>~/.profilesource~/.profile# Setup a systemd serviceecho"[Unit]Description=Cosmovisor Secret Network NodeAfter=network.target[Service]Type=simpleWorkingDirectory=${HOME}ExecStart=/bin/cosmovisor run startUser=${USER}Restart=on-failureStartLimitInterval=0RestartSec=3LimitNOFILE=65535LimitMEMLOCK=209715200Environment=SCRT_ENCLAVE_DIR=${HOME}/.secretd/cosmovisor/current/binEnvironment=LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${HOME}/.secretd/cosmovisor/current/binEnvironment=DAEMON_NAME=secretdEnvironment=DAEMON_HOME=${HOME}/.secretdEnvironment=DAEMON_ALLOW_DOWNLOAD_BINARIES=falseEnvironment=DAEMON_LOG_BUFFER_SIZE=512Environment=DAEMON_RESTART_AFTER_UPGRADE=trueEnvironment=DAEMON_DATA_BACKUP_DIR=${HOME}Environment=UNSAFE_SKIP_BACKUP=true[Install]WantedBy=multi-user.target"|sudotee/etc/systemd/system/cosmovisor.service>/dev/nullsudosystemctldaemon-reloadsudosystemctlenablecosmovisor
Set Up A New v1.2 Node
# Make the necessary directory structure for v1.2mkdir-p~/.secretd/cosmovisor/genesis/bin# Get v1.2 binarieswget-P/tmp/"https://github.com/scrtlabs/SecretNetwork/releases/download/v1.2.2/secretnetwork_v1.2.2_mainnet_amd64.deb"# Verify v1.2 binaries checksumecho"1a51d3d9324979ef9a1f56023e458023488b4583bf4587abeed2d1f389aea947 /tmp/secretnetwork_v1.2.2_mainnet_amd64.deb"|sha256sum--check# Extract v1.2 from archivedpkg-deb-R/tmp/secretnetwork_v1.2.2_mainnet_amd64.deb/tmp/secretnetwork_v1.2.2_mainnet_amd64.deb.extracted# Move v1.2 binaries to Cosmovisor's directorymv/tmp/secretnetwork_v1.2.2_mainnet_amd64.deb.extracted/usr/{local/bin/*,lib/*}~/.secretd/cosmovisor/genesis/bin
Now the Cosmovisor directory structure should look like this:
After making the proper configurations to your new node, launch it using sudo systemctl start cosmovisor. You should now see blocks executing in the logs (journalctl -fu cosmovisor).
Migrate A Running v1.2 Node
# Make the necessary directory structure for v1.2mkdir-p~/.secretd/cosmovisor/genesis/bin# Disable the old secret-node systemd servicesudosystemctlstopsecret-nodesudosystemctldisablesecret-node# Move v1.2 binaries to Cosmovisor's directorysudomv/usr/local/bin/secretd/usr/lib/{libgo_cosmwasm.so,librust_cosmwasm_enclave.signed.so}~/.secretd/cosmovisor/genesis/bin# For a query node also move the query enclavesudomv/usr/lib/librust_cosmwasm_query_enclave.signed.so~/.secretd/cosmovisor/genesis/bin# Launch the Cosmovisor servicesudosystemctlstartcosmovisor
Now the Cosmovisor directory structure should look like this:
To relaunch your node, use sudo systemctl start cosmovisor. You should now see blocks executing in the logs (journalctl -fu cosmovisor).
Prepare A v1.3 Node Upgrade (Shockwave Alpha)
The "Shockwave Alpha" upgrade is anticipated to be on Wednesday April 27th, 2022 at 2:00PM UTC. Below are instructions to prepare Cosmovisor for automatically upgrading your node to v1.3.
# Make the necessary directory structure for v1.3mkdir-p~/.secretd/cosmovisor/upgrades/v1.3/bin# Get & verify v1.3 binaries# Uncomment goleveldb or rocksdb:# wget -P /tmp/ "https://github.com/scrtlabs/SecretNetwork/releases/download/v1.3.0/secretnetwork_1.3.0_mainnet_goleveldb_amd64.deb"# echo "b5a4387fd3af477f1d7d0c8ab13debc9b9ad9abccb59c82b1a35cc8a90db902b /tmp/secretnetwork_1.3.0_mainnet_goleveldb_amd64.deb" | sha256sum --check# or rocksdb#wget -P /tmp/ "https://github.com/scrtlabs/SecretNetwork/releases/download/v1.3.0/secretnetwork_1.3.0_mainnet_rocksdb_amd64.deb"#echo "a1fc48003b3b563aae216901fc5821bb11164746c61b86507bc813cb49bd85cb /tmp/secretnetwork_1.3.0_mainnet_rocksdb_amd64.deb" | sha256sum --check# Extract v1.3 from archivedpkg-deb-R/tmp/secretnetwork_1.3.0_mainnet_*_amd64.deb/tmp/secretnetwork_1.3.0_mainnet_amd64.deb.extracted# Move v1.3 binaries to Cosmovisor's directorymv/tmp/secretnetwork_1.3.0_mainnet_amd64.deb.extracted/usr/{local/bin/secretd,lib/librust_cosmwasm_enclave.signed.so,librust_cosmwasm_query_enclave.signed.so,lib/libgo_cosmwasm.so}~/.secretd/cosmovisor/upgrades/v1.3/bin
Now the Cosmovisor directory structure should look like this: