Installation

Setting up your validator node has never been so easy. Get your validator running in minutes by following step by step instructions.

Chain ID: mars-1 | Latest Version Tag: v1.0.0

Setup validator name

Replace YOUR_MONIKER_GOES_HERE with your validator name

MONIKER="YOUR_MONIKER_GOES_HERE"

Install dependencies

Update system and install build tools

sudo apt -q update
sudo apt -qy install curl git jq lz4 build-essential
sudo apt -qy upgrade

Install Go

sudo rm -rf /usr/local/go
curl -Ls https://go.dev/dl/go1.19.4.linux-amd64.tar.gz | sudo tar -xzf - -C /usr/local
eval $(echo 'export PATH=$PATH:/usr/local/go/bin' | sudo tee /etc/profile.d/golang.sh)
eval $(echo 'export PATH=$PATH:$HOME/go/bin' | tee -a $HOME/.profile)

Download and build binaries

# Clone project repository
cd $HOME
rm -rf hub
git clone https://github.com/mars-protocol/hub.git
cd hub
git checkout v1.0.0

# Build binaries
make build

# Prepare binaries for Cosmovisor
mkdir -p $HOME/.mars/cosmovisor/genesis/bin
mv target/dist/mars $HOME/.mars/cosmovisor/genesis/bin/
rm -rf build

# Create application symlinks
ln -s $HOME/.mars/cosmovisor/genesis $HOME/.mars/cosmovisor/current
sudo ln -s $HOME/.mars/cosmovisor/current/bin/mars /usr/local/bin/mars

Install Cosmovisor and create a service

# Download and install Cosmovisor
go install cosmossdk.io/tools/cosmovisor/cmd/[email protected]

# Create service
sudo tee /etc/systemd/system/marsd.service > /dev/null << EOF
[Unit]
Description=mars-main node service
After=network-online.target

[Service]
User=$USER
ExecStart=$(which cosmovisor) run start
Restart=on-failure
RestartSec=10
LimitNOFILE=65535
Environment="DAEMON_HOME=$HOME/.mars"
Environment="DAEMON_NAME=marsd"
Environment="UNSAFE_SKIP_BACKUP=true"

[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable marsd

Initialize the node

# Set node configuration
marsd config chain-id mars-1
marsd config keyring-backend test

# Initialize the node
marsd init $MONIKER --chain-id mars-1

# Download genesis and addrbook
curl -Ls https://snapshots.stakeandrelax.net/mars/genesis.json > $HOME/.mars/config/genesis.json
curl -Ls https://snapshots.stakeandrealx.net/mars/addrbook.json > $HOME/.mars/config/addrbook.json

# Remove the empty wasm folder if you have an empty one, just in case
rm -r ~/.mars/data/wasm

# Get our wasm folder
wget -O wasmonly.tar.lz4 https://snapshots.stakeandrealx.net/wasm/mars/wasmonly.tar.lz4 --inet4-only

# Extract the wasm folder into the right place
lz4 -c -d wasmonly.tar.lz4  | tar -x -C $HOME/.mars/data

# Clean up
rm wasmonly.tar.lz4

# Add seeds
sed -i -e "s|^seeds *=.*|seeds = \"9e7f28b8c0ac9d8d17bb17a390421d540a29eb3f@mars-rpc.stakeandrelax.net:18557\"|" $HOME/.mars/config/config.toml

# Set pruning
sed -i \
  -e 's|^pruning *=.*|pruning = "custom"|' \
  -e 's|^pruning-keep-recent *=.*|pruning-keep-recent = "100"|' \
  -e 's|^pruning-keep-every *=.*|pruning-keep-every = "0"|' \
  -e 's|^pruning-interval *=.*|pruning-interval = "19"|' \
  $HOME/.mars/config/app.toml

Download latest chain snapshot

curl -L https://snapshots.stakeandrelax.net/mars/snapshot_latest.tar.lz4 | tar -Ilz4 -xf - -C $HOME/.mars
[[ -f $HOME/.mars/data/upgrade-info.json ]] && cp $HOME/.mars/data/upgrade-info.json $HOME/.mars/cosmovisor/genesis/upgrade-info.json

Start service and check the logs

sudo systemctl start marsd && sudo journalctl -u marsd -f --no-hostname -o cat

Last updated