Skip to content

Instantly share code, notes, and snippets.

@whonion
Created January 18, 2023 06:49
Show Gist options
  • Save whonion/1b605597f10691dbf231d1fc777e9af3 to your computer and use it in GitHub Desktop.
Save whonion/1b605597f10691dbf231d1fc777e9af3 to your computer and use it in GitHub Desktop.
#!/bin/bash
NODE_MONIKER="whonion"
cd || return
rm -rf hub
git clone https://github.com/mars-protocol/hub
cd hub || return
git checkout v1.0.0-rc7
make install
marsd version # 1.0.0-rc7
marsd config keyring-backend test
marsd config chain-id ares-1
marsd init "$NODE_MONIKER" --chain-id ares-1
curl -s https://raw.githubusercontent.com/mars-protocol/networks/main/ares-1/genesis.json > $HOME/.mars/config/genesis.json
curl -s https://snapshots1-testnet.nodejumper.io/mars-testnet/addrbook.json > $HOME/.mars/config/addrbook.json
SEEDS=""
PEERS=""
sed -i 's|^seeds *=.*|seeds = "'$SEEDS'"|; s|^persistent_peers *=.*|persistent_peers = "'$PEERS'"|' $HOME/.mars/config/config.toml
PRUNING_INTERVAL=$(shuf -n1 -e 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97)
sed -i 's|^pruning *=.*|pruning = "custom"|g' $HOME/.mars/config/app.toml
sed -i 's|^pruning-keep-recent *=.*|pruning-keep-recent = "100"|g' $HOME/.mars/config/app.toml
sed -i 's|^pruning-interval *=.*|pruning-interval = "'$PRUNING_INTERVAL'"|g' $HOME/.mars/config/app.toml
sed -i 's|^snapshot-interval *=.*|snapshot-interval = 2000|g' $HOME/.mars/config/app.toml
NODE_FOLDER=.mars
V_PORT=10
sed -i 's|^minimum-gas-prices *=.*|minimum-gas-prices = "0.0001umars"|g' $HOME/.mars/config/app.toml
sed -i 's|^prometheus *=.*|prometheus = true|' $HOME/.mars/config/config.toml
sed -i.bak -e "s%^proxy_app = \"tcp://127.0.0.1:26658\"%proxy_app = \"tcp://127.0.0.1:${V_PORT}658\"%; s%^laddr = \"tcp://127.0.0.1:26657\"%laddr = \"tcp://127.0.0.1:${V_PORT}657\"%; s%^pprof_laddr = \"localhost:6060\"%pprof_laddr = \"localhost:${V_PORT}060\"%; s%^laddr = \"tcp://0.0.0.0:26656\"%laddr = \"tcp://0.0.0.0:${V_PORT}656\"%; s%^prometheus_listen_addr = \":26660\"%prometheus_listen_addr = \":${V_PORT}660\"%" $HOME/$NODE_FOLDER/config/config.toml
sed -i.bak -e "s%^address = \"tcp://0.0.0.0:1317\"%address = \"tcp://0.0.0.0:${V_PORT}317\"%; s%^address = \":8080\"%address = \":${V_PORT}080\"%; s%^address = \"0.0.0.0:9090\"%address = \"0.0.0.0:${V_PORT}090\"%; s%^address = \"0.0.0.0:9091\"%address = \"0.0.0.0:${V_PORT}091\"%" $HOME/$NODE_FOLDER/config/app.toml
sed -i.bak -e "s%^node = \"tcp://localhost:26657\"%node = \"tcp://localhost:${V_PORT}657\"%" $HOME/$NODE_FOLDER/config/client.toml
sudo tee /etc/systemd/system/marsd.service > /dev/null << EOF
[Unit]
Description=Mars Node
After=network-online.target
[Service]
User=$USER
ExecStart=$(which marsd) start
Restart=on-failure
RestartSec=10
LimitNOFILE=10000
[Install]
WantedBy=multi-user.target
EOF
marsd tendermint unsafe-reset-all --home $HOME/.mars --keep-addr-book
SNAP_NAME=$(curl -s https://snapshots1-testnet.nodejumper.io/mars-testnet/ | egrep -o ">ares-1.*\.tar.lz4" | tr -d ">")
curl https://snapshots1-testnet.nodejumper.io/mars-testnet/${SNAP_NAME} | lz4 -dc - | tar -xf - -C $HOME/.mars
sudo systemctl daemon-reload
sudo systemctl enable marsd
sudo systemctl start marsd
sudo journalctl -u marsd -f --no-hostname -o cat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment