Cosmovisor
Automated chain upgrade setup using Cosmovisor
What is Cosmovisor?
Cosmovisor is a process manager that automatically handles binary upgrades for Cosmos SDK-based chains. When a chain upgrade is approved through governance, it automatically swaps binaries to minimize downtime.
To minimize validator downtime, using Cosmovisor is strongly recommended.
Installation
go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@latestOr download from GitHub Releases.
Directory Structure
Cosmovisor uses the following directory structure:
~/.lumiwave-protocol/
└── cosmovisor/
├── genesis/
│ └── bin/
│ └── lumiwave-protocold # Initial binary
├── upgrades/
│ └── <upgrade-name>/
│ └── bin/
│ └── lumiwave-protocold # Upgrade binary
└── current -> genesis or upgrades/<latest>Initial Setup
1. Create Directories and Place Binary
# Create directories
mkdir -p ~/.lumiwave-protocol/cosmovisor/genesis/bin
mkdir -p ~/.lumiwave-protocol/cosmovisor/upgrades
# Copy binary
cp $(which lumiwave-protocold) ~/.lumiwave-protocol/cosmovisor/genesis/bin/
chmod +x ~/.lumiwave-protocol/cosmovisor/genesis/bin/lumiwave-protocold
# Symbolic link (for CLI usage)
sudo ln -sf ~/.lumiwave-protocol/cosmovisor/genesis/bin/lumiwave-protocold /usr/local/bin/lumiwave-protocold2. Set Environment Variables
# Add to ~/.bashrc or ~/.profile
export DAEMON_NAME=lumiwave-protocold
export DAEMON_HOME=$HOME/.lumiwave-protocol
export DAEMON_ALLOW_DOWNLOAD_BINARIES=false
export DAEMON_RESTART_AFTER_UPGRADE=true
export DAEMON_LOG_BUFFER_SIZE=512
export UNSAFE_SKIP_BACKUP=false| Environment Variable | Value | Description |
|---|---|---|
DAEMON_NAME | lumiwave-protocold | Binary name |
DAEMON_HOME | ~/.lumiwave-protocol | Home directory |
DAEMON_ALLOW_DOWNLOAD_BINARIES | false | Disable automatic downloads (security) |
DAEMON_RESTART_AFTER_UPGRADE | true | Auto-restart after upgrade |
UNSAFE_SKIP_BACKUP | false | Perform backup before upgrade |
In production environments, DAEMON_ALLOW_DOWNLOAD_BINARIES must be set to false. Unverified binaries could be automatically executed otherwise.
systemd Service Configuration
sudo tee /etc/systemd/system/cosmovisor.service > /dev/null <<EOF
[Unit]
Description=LumiWave Cosmovisor
After=network-online.target
[Service]
User=$USER
ExecStart=$(which cosmovisor) run start
Restart=on-failure
RestartSec=3
LimitNOFILE=65535
Environment="DAEMON_NAME=lumiwave-protocold"
Environment="DAEMON_HOME=$HOME/.lumiwave-protocol"
Environment="DAEMON_ALLOW_DOWNLOAD_BINARIES=false"
Environment="DAEMON_RESTART_AFTER_UPGRADE=true"
Environment="DAEMON_LOG_BUFFER_SIZE=512"
Environment="UNSAFE_SKIP_BACKUP=false"
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable cosmovisor
sudo systemctl start cosmovisorService Management
# Check status
sudo systemctl status cosmovisor
# View logs
journalctl -u cosmovisor -f --no-hostname
# Restart
sudo systemctl restart cosmovisor
# Stop
sudo systemctl stop cosmovisorUpgrade Procedure
Automatic Upgrade (Governance Proposal)
When a SoftwareUpgrade proposal passes through governance:
- Place the upgrade binary in advance:
# Create upgrade directory
mkdir -p ~/.lumiwave-protocol/cosmovisor/upgrades/<UPGRADE_NAME>/bin
# Place the new binary
cp lumiwave-protocold-new ~/.lumiwave-protocol/cosmovisor/upgrades/<UPGRADE_NAME>/bin/lumiwave-protocold
chmod +x ~/.lumiwave-protocol/cosmovisor/upgrades/<UPGRADE_NAME>/bin/lumiwave-protocold- When the upgrade height is reached, automatically:
- Stop the existing binary
- Back up data (when
UNSAFE_SKIP_BACKUP=false) - Swap to the new binary
- Auto-restart
Manual Upgrade
When manually replacing the binary without a governance proposal:
# 1. Stop the node
sudo systemctl stop cosmovisor
# 2. Copy the new binary
cp lumiwave-protocold-new ~/.lumiwave-protocol/cosmovisor/genesis/bin/lumiwave-protocold
# 3. Restart the node
sudo systemctl start cosmovisorVerify Upgrade Status
# Current binary version
cosmovisor version
# Active binary path
ls -la ~/.lumiwave-protocol/cosmovisor/current
# Available upgrades
ls ~/.lumiwave-protocol/cosmovisor/upgrades/Troubleshooting
Cosmovisor Fails to Start
# Check environment variables
echo $DAEMON_NAME
echo $DAEMON_HOME
# Verify binary exists
ls -la ~/.lumiwave-protocol/cosmovisor/genesis/bin/lumiwave-protocold
# Check execution permissions
chmod +x ~/.lumiwave-protocol/cosmovisor/genesis/bin/lumiwave-protocoldStartup Failure After Upgrade
# Check logs for errors
journalctl -u cosmovisor -n 100 --no-hostname
# Verify binary compatibility
~/.lumiwave-protocol/cosmovisor/upgrades/<UPGRADE_NAME>/bin/lumiwave-protocold versionRelated Documents
- Join Mainnet — Mainnet node deployment
- Join Testnet — Testnet node deployment
- Become a Validator — Validator creation
- Governance Process — Upgrade proposals