Skip to content

Story Cosmovisor

Story banner
  • 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

Terminal window
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

Terminal window
#cosmovisor version 1.7
source $HOME/.bash_profile
go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@latest
banner
  • Check cosmovisor version:
Terminal window
cosmovisor version
banner

3. Init Cosmovisor

  • Set DAEMON_HOME:
Terminal window
export DAEMON_NAME=story
echo "export DAEMON_NAME=story" >> $HOME/.bash_profile
export DAEMON_HOME=$HOME/.story/story
echo "export DAEMON_HOME=$HOME/.story/story" >> $HOME/.bash_profile
banner
  • Initialize Cosmovisor with DAEMON_HOME:
Terminal window
cosmovisor init $(whereis -b story | awk '{print $2}')
banner
  • Create the backup directory: Now that DAEMON_HOME is defined, you can create the necessary directories.
Terminal window
mkdir -p $DAEMON_HOME/cosmovisor/backup
echo "export DAEMON_DATA_BACKUP_DIR=$DAEMON_HOME/cosmovisor/backup" >> $HOME/.bash_profile
echo "export DAEMON_ALLOW_DOWNLOAD_BINARIES=false" >> $HOME/.bash_profile

After setting up, reload your environment variables with:

Terminal window
source $HOME/.bash_profile

4. Create upgrades folder

Terminal window
mkdir -p $HOME/.story/story/cosmovisor/genesis/bin
mkdir -p $HOME/.story/story/cosmovisor/upgrades/v0.13.0/bin
  • Stop node
Terminal window
sudo systemctl stop story
  • Download Story binary v0.13.0
Terminal window
#download binay
cd $HOME
rm story-linux-amd64
wget https://github.com/piplabs/story/releases/download/v0.13.0/story-linux-amd64
chmod +x story-linux-amd64
  • Copy new binary to upgrades folder
Terminal window
# Copy new version binary to upgrade folder
sudo cp $HOME/story-linux-amd64 $HOME/.story/story/cosmovisor/upgrades/v0.13.0/bin/story
banner
  • Add Upgrade Information for new version
Terminal window
echo '{"name":"v0.13.0","time":"0001-01-01T00:00:00Z","height":858000}' > $HOME/.story/story/cosmovisor/upgrades/v0.13.0/upgrade-info.json

5. Verify the Setup

Terminal window
# Check current symlink
ls -l /root/.story/story/cosmovisor/current
Terminal window
# Check the story version in genesis folder. It should be old version is v0.12.1
$HOME/.story/story/cosmovisor/genesis/bin/story version
Terminal window
# Check the new binary version in upgrade folder. It should be new version v0.13.0
$HOME/.story/story/cosmovisor/upgrades/v0.13.0/bin/story version
Terminal window
# Check upgrade info
cat $HOME/.story/story/cosmovisor/upgrades/v0.13.0/upgrade-info.json
banner
  • Update service file:
Terminal window
sudo tee /etc/systemd/system/story.service > /dev/null <<EOF
[Unit]
Description=Story Consensus Client
After=network.target
[Service]
User=root
Environment="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 run
Restart=always
RestartSec=3
LimitNOFILE=4096
[Install]
WantedBy=multi-user.target
EOF
Terminal window
sudo systemctl daemon-reload
sudo systemctl start story && sudo systemctl status story
banner

5. Set schedule for upgrade:

Terminal window
source $HOME/.bash_profile
cosmovisor add-upgrade v0.13.0 $HOME/.story/story/cosmovisor/upgrades/v0.13.0/bin/story --force --upgrade-height 858000
banner