December 23, 2022

Okp4 (validator setup guide)

OKP4 is a domain-specific layer-1 dedicated to trust-minimized data sharing.
The blockchain orchestrates assets shared by participants into the Dataverse: data, algorithms, software, storage and computation to enable a new generation of applications.
Any contributor earns rewards thanks to these new value chains.

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

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.18.linux-amd64.tar.gz 
sudo tar -C /usr/local -xzf go1.18.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.8 linux/amd64

Install binary for work

curl https://i.jpillora.com/okp4/[email protected]! | bash

Specify variables, for ease of work:

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

You can check the output:

echo $OKP4_MONIKER 
echo $OKP4_WALLET

Initialize the node:

okp4d init $OKP4_MONIKER --chain-id okp4-nemeton-1

Set the settings:

okp4d config chain-id okp4-nemeton-1 && \
peers="[email protected]:42656","[email protected]:61356","[email protected]:12656","[email protected]:43656","[email protected]:12233","[email protected]:36656","8d8fdad759361a57121903632adbd66ad072b1ab@okp4-testnet.nodejumper.io:29656","[email protected]:26656","[email protected]:36656","[email protected]:34656","a7f1dcf7441761b0e0e1f8c6fdc79d3904c22c01@[2a02:c206:2093:4875::1]:36656","[email protected]:36656","[email protected]:28656","[email protected]:26656","[email protected]:26616","[email protected]:26106","[email protected]:26656","[email protected]:28656","[email protected]:26656","[email protected]:21656","[email protected]:26157","[email protected]:26656","[email protected]:26646","[email protected]:17656","[email protected]:26656" && \
sed -i.bak -e "s/^persistent_peers *=.*/persistent_peers = \"$peers\"/" $HOME/.okp4d/config/config.toml && \
seeds="" && \
sed -i.bak -e "s/^seeds =.*/seeds = \"$seeds\"/" $HOME/.okp4d/config/config.toml

Create wallet:

okp4d keys add $OKP4_WALLET

Save the wallet.

Or restore if there is a mnemonic:

okp4d keys add $OKP4_WALLET --recover

Download Genesis:

wget -O ~/.okp4d/config/genesis.json https://raw.githubusercontent.com/okp4/networks/main/chains/nemeton-1/genesis.json

Optional Settings:

  • Memory optimization
cd $HOME/.okp4/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/.okp4/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 && \ 
okp4d config node $NODE

Create a service file

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

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

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

Running a node from a state sync (optional)

sudo systemctl stop okp4d && \
okp4d tendermint unsafe-reset-all --home /root/.okp4d --keep-addr-book
peers="[email protected]:38656 && \
sed -i.bak -e  "s/^persistent_peers *=.*/persistent_peers = \"$peers\"/" ~/.okp4d/config/config.toml && \
SNAP_RPC=213.239.207.175:38657 && \
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/.okp4d/config/config.toml && \
sudo systemctl restart okp4d && journalctl -u okp4d -f -o cat

After full synchronization, you can request tokens and create your own validator.

Create a validator

okp4d tx staking create-validator \
--amount=1000000uknow \
--pubkey=$(sourced tendermint show-validator) \
--moniker=$OKP4_MONIKER  \
--chain-id=okp4-nemeton-1 \
--commission-rate="0.10" \
--commission-max-rate="0.20" \
--commission-max-change-rate="0.1" \
--min-self-delegation="1" \
--fees 200uknow \
--from=$OKP4_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/cyberomanov/status/main/tendermint/node_status/cosmos.sh && \
wget https://raw.githubusercontent.com/cyberomanov/status/main/tendermint/node_status/cosmos.conf && \
wget https://raw.githubusercontent.com/cyberomanov/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 okp4.conf && \
sed -i 's,# CURL=,CURL=, g' $HOME/status/okp4.conf && \
sed -i "s/^SERVER *=.*/SERVER = \"Okp4_test\"/" $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/okp4.conf && \
sed -i 's,https://api-cosmos.cosmostation.io/v1/status/,https://okp4.api.explorers.guru/api/v1/blocks/latest, g' $HOME/status/okp4.conf && \
sed -i "s/^DELEGATOR_ADDRESS *=.*/DELEGATOR_ADDRESS = \"$DELEGATOR_ADDRESS\"/" $HOME/status/okp4.conf && \
sed -i "s/^VALIDATOR_ADDRESS *=.*/VALIDATOR_ADDRESS = \"$VALIDATOR_ADDRESS\"/" $HOME/status/okp4.conf && \
sed -i "s/^TOKEN *=.*/TOKEN = \"uKNOW\"/" $HOME/status/okp4.conf && \
sed -i "s/^DENOM *=.*/DENOM = \"1000000\"/" $HOME/status/okp4.conf && \
sed -i "s/^PROJECT *=.*/PROJECT = \"okp4-testnet\"/" $HOME/status/okp4.conf && \
sed -i 's,/root/go/bin/cosmosd,/root/go/bin/okp4d, g' $HOME/status/okp4.conf && \
sed -i 's,/root/.cosmos/config/,/root/.okp4d/config/, g' $HOME/status/okp4.conf && \
sed -i "s/^CHAT_ID_ALARM *=.*/CHAT_ID_ALARM = \"$CHAT_ID_ALARM\"/" $HOME/status/okp4.conf && \
sed -i "s/^CHAT_ID_STATUS *=.*/CHAT_ID_STATUS = \"$CHAT_ID_STATUS\"/" $HOME/status/okp4.conf && \
sed -i "s/^BOT_TOKEN *=.*/BOT_TOKEN = \"$BOT_TOKEN\"/" $HOME/status/okp4.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://okp4.network/

Discord - https://discord.com/invite/okp4

Twitter - https://twitter.com/OKP4_Protocol

Github - https://github.com/okp4

Medium - https://blog.okp4.network/