Story Cosmovisor

- Check go version #requirement go version above v.1.22 if you have Go v.1.22 already. Please skip install Go step.
1. Install go
cd $HOME && \ver="1.22.0" && \wget "https://golang.org/dl/go$ver.linux-amd64.tar.gz" && \sudo rm -rf /usr/local/go && \sudo tar -C /usr/local -xzf "go$ver.linux-amd64.tar.gz" && \rm "go$ver.linux-amd64.tar.gz" && \[ ! -f ~/.bash_profile ] && touch ~/.bash_profile && \echo 'export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin' >> ~/.bash_profile && \source ~/.bash_profile && \go version
2. Install Cosmovisor
#cosmovisor version 1.7source $HOME/.bash_profilego install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@latest

- Check cosmovisor version:
cosmovisor version

3. Init Cosmovisor
- Set DAEMON_HOME:
export DAEMON_NAME=storyecho "export DAEMON_NAME=story" >> $HOME/.bash_profileexport DAEMON_HOME=$HOME/.story/storyecho "export DAEMON_HOME=$HOME/.story/story" >> $HOME/.bash_profile

- Initialize Cosmovisor with DAEMON_HOME:
cosmovisor init $(whereis -b story | awk '{print $2}')

- Create the backup directory: Now that DAEMON_HOME is defined, you can create the necessary directories.
mkdir -p $DAEMON_HOME/cosmovisor/backupecho "export DAEMON_DATA_BACKUP_DIR=$DAEMON_HOME/cosmovisor/backup" >> $HOME/.bash_profileecho "export DAEMON_ALLOW_DOWNLOAD_BINARIES=false" >> $HOME/.bash_profile
After setting up, reload your environment variables with:
source $HOME/.bash_profile
4. Create upgrades folder
mkdir -p $HOME/.story/story/cosmovisor/genesis/bin
- Stop node
sudo systemctl stop story
- Download Story binary v1.1.0
#download binaycd $HOMErm story-linux-amd64wget https://github.com/piplabs/story/releases/download/v1.1.0/story-linux-amd64chmod +x story-linux-amd64
- Copy new binary to upgrades folder
# Copy new version binary to upgrade foldersudo cp $HOME/story-linux-amd64 $HOME/.story/story/cosmovisor/upgrades/v1.1.0/bin/story
- Add Upgrade Information for new version
echo '{"name":"v1.1.0","time":"0001-01-01T00:00:00Z","height":677886}' > $HOME/.story/story/cosmovisor/upgrades/v1.1.0/upgrade-info.json
5. Verify the Setup
# Check current symlinkls -l /root/.story/story/cosmovisor/current
# Check the story version in genesis folder. It should be old version is v1.1.0$HOME/.story/story/cosmovisor/genesis/bin/story version
# Check the new binary version in upgrade folder. It should be new version v1.1.0$HOME/.story/story/cosmovisor/upgrades/v1.1.0/bin/story version
# Check upgrade infocat $HOME/.story/story/cosmovisor/upgrades/v1.1.0/upgrade-info.json
- Update service file:
sudo tee /etc/systemd/system/story.service > /dev/null <<EOF[Unit]Description=Story Consensus ClientAfter=network.target
[Service]User=rootEnvironment="DAEMON_NAME=story"Environment="DAEMON_HOME=/root/.story/story"Environment="DAEMON_ALLOW_DOWNLOAD_BINARIES=true"Environment="DAEMON_RESTART_AFTER_UPGRADE=true"Environment="DAEMON_DATA_BACKUP_DIR=/root/.story/story/data"Environment="UNSAFE_SKIP_BACKUP=true"ExecStart=/root/go/bin/cosmovisor run runRestart=alwaysRestartSec=3LimitNOFILE=65535
[Install]WantedBy=multi-user.targetEOF
sudo systemctl daemon-reloadsudo systemctl start story && sudo systemctl status story
5. Set schedule for upgrade:
source $HOME/.bash_profilecosmovisor add-upgrade v1.1.0 $HOME/.story/story/cosmovisor/upgrades/v1.1.0/bin/story --force --upgrade-height 677886
Output sample:
⚡ root@josephtran ~ source $HOME/.bash_profilecosmovisor add-upgrade v1.1.0 $HOME/.story/story/cosmovisor/upgrades/v1.1.0/bin/story --force --upgrade-height 6778868:16AM INF Using /root/.story/story/cosmovisor/upgrades/v1.1.0/bin/story for v1.1.0 upgrade module=cosmovisor8:16AM INF Upgrade binary located at /root/.story/story/cosmovisor/upgrades/v1.1.0/bin/story module=cosmovisor8:16AM INF /root/.story/story/data/upgrade-info.json created, v1.1.0 upgrade binary will switch at height 677886 module=cosmovisor