August 31, 2023

Archway (validator setup guide and network monitoring system)

Archway is a Cosmos-native incentivised smart contract chain that enables developers to easily deploy high-performance dapps that capture the value they create for the network. As developers build and launch impactful dapps, they receive a proportional share of network fees, inflation, and premiums. This shared revenue model enables dapps to access recurring value generation and participate in the upside of the underlying protocol.

----------------------------------------------------------------------------------------

Update packages

sudo apt update && sudo apt upgrade -y

Install dependencies

sudo apt install curl tar wget clang pkg-config libssl-dev libleveldb-dev jq build-essential bsdmainutils git make ncdu htop screen unzip bc fail2ban htop -y

Install Go

wget https://golang.org/dl/go1.20.linux-amd64.tar.gz 
sudo tar -C /usr/local -xzf go1.20.linux-amd64.tar.gz
cat <<EOF >> ~/.profile
export GOROOT=/usr/local/go 
export GOPATH=$HOME/go 
export GO111MODULE=on 
export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin 
EOF 
source ~/.profile 
go version

The output should be:go version go1.20 linux/amd64

Download binary for work

cd $HOME
git clone https://github.com/archway-network/archway.git
cd archway
git checkout v4.0.2
make install

Specify variables, for ease of work:

ARCHWAY_MONIKER="YourValidatorName"  
ARCHWAY_WALLET="YourWalletName"
echo 'export ARCHWAY_MONIKER='${ARCHWAY_MONIKER} >> $HOME/.profile 
echo 'export ARCHWAY_WALLET='${ARCHWAY_WALLET} >> $HOME/.profile 
source $HOME/.profile

Initialize the node:

archwayd init $ARCHWAY_MONIKER --chain-id archway-1

Set the settings:

archwayd config chain-id archway-1 && \
peers="" && \
sed -i.bak -e "s/^persistent_peers *=.*/persistent_peers = \"$peers\"/" $HOME/.archway/config/config.toml && \
seeds="[email protected]:10214" && \
sed -i.bak -e "s/^seeds =.*/seeds = \"$seeds\"/" $HOME/.archway/config/config.toml

Create wallet:

archwayd keys add $ARCHWAY_WALLET

Save the wallet.

Or restore if there is a mnemonic:

archwayd keys add $ARCHWAY_WALLET --recover

Download Genesis:

wget -O genesis.json https://snapshots.stakeup.tech/archway/genesis.json --inet4-only
mv genesis.json ~/.archway/config

Optional Settings:

  • Memory optimization
cd $HOME/.archway/config && \
indexer="null" && \
snapshot_interval="0" && \
pruning="custom" && \
pruning_keep_recent="100" && \
pruning_keep_every="0" && \
pruning_interval="10" && \
sed -i.bak -e "s/^indexer *=.*/indexer = \"$indexer\"/" config.toml && \
sed -i.bak -e "s/^snapshot-interval *=.*/snapshot-interval = \"$snapshot_interval\"/" app.toml && \
sed -i.bak -e "s/^pruning *=.*/pruning = \"$pruning\"/" app.toml && \
sed -i.bak -e "s/^pruning-keep-recent *=.*/pruning-keep-recent = \"$pruning_keep_recent\"/" app.toml && \
sed -i.bak -e "s/^pruning-keep-every *=.*/pruning-keep-every = \"$pruning_keep_every\"/" app.toml && \
sed -i.bak -e "s/^pruning-interval *=.*/pruning-interval = \"$pruning_interval\"/" app.toml
  • Change port
cd $HOME/.archway/config && \
sed -i.bak -e "s%^proxy_app = \"tcp://127.0.0.1:26658\"%proxy_app = \"tcp://127.0.0.1:26653\"%; s%^laddr = \"tcp://127.0.0.1:26657\"%laddr = \"tcp://127.0.0.1:26652\"%; s%^pprof_laddr = \"localhost:6060\"%pprof_laddr = \"localhost:6061\"%; s%^laddr = \"tcp://0.0.0.0:26656\"%laddr = \"tcp://0.0.0.0:26651\"%; s%^prometheus_listen_addr = \":26660\"%prometheus_listen_addr = \":26655\"%" config.toml && \
sed -i.bak -e "s%^address = \"0.0.0.0:9090\"%address = \"0.0.0.0:9092\"%; s%^address = \"0.0.0.0:9091\"%address = \"0.0.0.0:9093\"%" app.toml && \
echo 'export NODE=http://localhost:26652' >> $HOME/.bash_profile && \
source $HOME/.bash_profile && \
archwayd config node $NODE

Create a service file

sudo tee /etc/systemd/system/archwayd.service > /dev/null <<EOF
[Unit]
Description=archway
After=network-online.target 

[Service]
User=$USER
ExecStart=$(which archwayd) start
Restart=on-failure
RestartSec=3
LimitNOFILE=65535 

[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload &&
sudo systemctl enable archwayd &&
sudo systemctl restart archwayd && sudo journalctl -u archwayd -f -o cat

Running a node from a state sync (optional)

sudo systemctl stop archwayd && \
archwayd tendermint unsafe-reset-all --home /root/.archway --keep-addr-book
rm -rf ~/.archway/wasm; \
mkdir -p ~/.archway/wasm; \
cd ~/.archway/wasm; \
wget http://snapshots.stakeup.tech/archway/wasm.tar; \
tar -xf wasm.tar -C $HOME/.archway/wasm/
peers="6ccbd12710c67de8642cf1a7f545537b6e3e5e66@rpc.archway.stakeup.tech:29656" && \
sed -i.bak -e  "s/^persistent_peers *=.*/persistent_peers = \"$peers\"/" ~/.archway/config/config.toml && \
SNAP_RPC="https://rpc.archway.stakeup.tech:443" && \
LATEST_HEIGHT=$(curl -s $SNAP_RPC/block | jq -r .result.block.header.height); \
BLOCK_HEIGHT=$((LATEST_HEIGHT - 1000)); \
TRUST_HASH=$(curl -s "$SNAP_RPC/block?height=$BLOCK_HEIGHT" | jq -r .result.block_id.hash) && \
echo $LATEST_HEIGHT $BLOCK_HEIGHT $TRUST_HASH && \
sed -i.bak -E "s|^(enable[[:space:]]+=[[:space:]]+).*$|\1true| ; \
s|^(rpc_servers[[:space:]]+=[[:space:]]+).*$|\1\"$SNAP_RPC,$SNAP_RPC\"| ; \
s|^(trust_height[[:space:]]+=[[:space:]]+).*$|\1$BLOCK_HEIGHT| ; \
s|^(trust_hash[[:space:]]+=[[:space:]]+).*$|\1\"$TRUST_HASH\"| ; \
s|^(seeds[[:space:]]+=[[:space:]]+).*$|\1\"\"|" $HOME/.archway/config/config.toml
sudo systemctl restart archwayd && journalctl -u archwayd -f -o cat

Running a node from a snapshot (optional)

Stop quicksilver service

sudo systemctl stop archwayd.service

Backup priv_validator_state.json

cp $HOME/.archway/data/priv_validator_state.json $HOME/priv_validator_state.json

Remove old data in directory ~/.archway/data and wasm

rm -rf ~/.archway/data; \
rm -rf ~/.archway/wasm

Download snapshot

mkdir -p ~/.archway/data; \
cd ~/.archway/data; \
wget https://snapshots.stakeup.tech/archway/archway-1_latest.tar; \
tar -xf archway-1_latest.tar -C $HOME/.archway/data/; \

Download wasm

mkdir -p ~/.archway/wasm; \
cd ~/.archway/wasm; \
wget https://snapshots.stakeup.tech/archway/wasm.tar; \
tar -xf wasm.tar -C $HOME/.archway/wasm/

Return your priv_validator_state.json

mv $HOME/priv_validator_state.json $HOME/.archway/data/priv_validator_state.json

Download addrbook

wget -O $HOME/.archway/config/addrbook.json "https://snapshots.stakeup.tech/archway/addrbook.json"

Start service and check logs

sudo systemctl restart archwayd && journalctl -u archwayd -f -o cat

After full synchronization, you can create own validator. Create a validator

archwayd tx staking create-validator \
--amount=1000000000000000000aarch \
--pubkey=$(archwayd tendermint show-validator) \
--moniker=$ARCHWAY_MONIKER  \
--chain-id=archway-1 \
--commission-rate="0.10" \
--commission-max-rate="0.20" \
--commission-max-change-rate="0.1" \
--min-self-delegation="1" \
--fees 180000000000000000aarch \
--from=$ARCHWAY_WALLET \
--identity="" \
--website="" \
--details="" \
-y

Network monitoring system (optional)

Install dependencies

sudo apt-get install jq sysstat bc smartmontools fdisk -y

Create a working directory

mkdir status && \
cd status

Download the script and settings

wget https://raw.githubusercontent.com/landerosua/status/main/tendermint/node_status/cosmos.sh && \
wget https://raw.githubusercontent.com/landerosua/status/main/tendermint/node_status/cosmos.conf && \
wget https://raw.githubusercontent.com/landerosua/status/main/tendermint/node_status/name.conf

Setting up access rights

chmod +x cosmos.sh

Customizing Your Options

CHAT_ID_ALARM="you_id_chat_for_alarm_messages(telegram)"
CHAT_ID_STATUS="you_id_chat_for_log_messages(telegram)"
BOT_TOKEN="you_bot_token(telegram bot)"
VALIDATOR_ADDRESS="you_valoper_address"
DELEGATOR_ADDRESS="you_wallet"
MONIKER="you_validator_moniker"

Updating and configuring settings in files

mv name.conf ARCHWAY.conf && \
sed -i 's,# CURL=,CURL=, g' $HOME/status/ARCHWAY.conf && \
sed -i "s/^SERVER *=.*/SERVER = \"ARCHWAY\"/" $HOME/status/cosmos.conf && \
sed -i "s/^CHAT_ID_ALARM *=.*/CHAT_ID_ALARM = \"$CHAT_ID_ALARM\"/" $HOME/status/cosmos.conf && \
sed -i "s/^BOT_TOKEN *=.*/BOT_TOKEN = \"$BOT_TOKEN\"/" $HOME/status/cosmos.conf && \
sed -i "s/^MONIKER *=.*/MONIKER = \"$MONIKER\"/" $HOME/status/ARCHWAY.conf && \
sed -i 's,https://api-cosmos.cosmostation.io/v1/status/,https://api.archway.nodestake.top/cosmos/base/tendermint/v1beta1/blocks/latest, g' $HOME/status/ARCHWAY.conf && \
sed -i "s/^DELEGATOR_ADDRESS *=.*/DELEGATOR_ADDRESS = \"$DELEGATOR_ADDRESS\"/" $HOME/status/ARCHWAY.conf && \
sed -i "s/^VALIDATOR_ADDRESS *=.*/VALIDATOR_ADDRESS = \"$VALIDATOR_ADDRESS\"/" $HOME/status/ARCHWAY.conf && \
sed -i "s/^TOKEN *=.*/TOKEN = \"arch\"/" $HOME/status/ARCHWAY.conf && \
sed -i "s/^DENOM *=.*/DENOM = \"1000000000000000000\"/" $HOME/status/ARCHWAY.conf && \
sed -i "s/^PROJECT *=.*/PROJECT = \"archway-mainnet\"/" $HOME/status/ARCHWAY.conf && \
sed -i 's,/root/go/bin/cosmosd,/root/go/bin/archwayd, g' $HOME/status/ARCHWAY.conf && \
sed -i 's,/root/.cosmos/config/,/root/.archway/config/, g' $HOME/status/ARCHWAY.conf && \
sed -i "s/^CHAT_ID_ALARM *=.*/CHAT_ID_ALARM = \"$CHAT_ID_ALARM\"/" $HOME/status/ARCHWAY.conf && \
sed -i "s/^CHAT_ID_STATUS *=.*/CHAT_ID_STATUS = \"$CHAT_ID_STATUS\"/" $HOME/status/ARCHWAY.conf && \
sed -i "s/^BOT_TOKEN *=.*/BOT_TOKEN = \"$BOT_TOKEN\"/" $HOME/status/ARCHWAY.conf

Setting up a crontab

crontab -e
Adding a line
1,11,21,31,41,51 * * * * bash $HOME/status/cosmos.sh >> $HOME/status/cosmos.log 2>&1

Done.

At work, the logs look like this

Useful links

Website - https://archway.io/

Discord - https://discord.gg/archwayhq

Twitter - https://twitter.com/archwayhq

Github - https://github.com/archway-network

Reddit - https://www.reddit.com/r/Archway/