Downloading and running a binary makes most sane people nervous. Gitian introduces a level of trust for binary artifacts and is the distribution method chosen by IOV and other blockchains including Bitcoin and Cosmos. We'll use binaries built using gitian and systemd to drive the IOV Name Service blockchain.
This document is not for beginners. It assumes that you know how to setup a sentry node architecture for Tendermint nodes. It also assumes that basename
, curl
, grep
, jq
, sed
, sha256sum
, and wget
are installed on your system, and user $USER_IOV
exists.
Given that, you should be able to copy-and-paste the following commands into a terminal and end up with a running node. It has been tested on Centos8, Ubuntu 19, and Fedora 31. You'll have to do this procedure on at least two machines to implement a sentry node architecture.
sudo su # make life easier for the next ~100 lines​cd /etc/systemd/system​export USER_IOV=iov # "iov" is not recommendedexport SIGNER=dave # signer for the create-validator tx​# create an environment file for the IOV Name Service servicescat <<__EOF_IOVNS_ENV__ > starname.env# operator variablesCHAIN_ID=iovns-galaxynetMONIKER=$(hostname)SIGNER=${SIGNER}USER_IOV=${USER_IOV}​# directories (without spaces to ease pain)DIR_IOVNS=/opt/iovns/binDIR_WORK=/home/${USER_IOV}/galaxynet​# artifactsIOVNS=https://github.com/iov-one/iovns/releases/download/v0.9.7/iovns-0.9.7-linux-amd64.tar.gz__EOF_IOVNS_ENV__​chgrp ${USER_IOV} starname.envchmod g+r starname.env​set -o allexport ; source /etc/systemd/system/starname.env ; set +o allexport # pick-up env vars​# create starname.servicecat <<__EOF_STARNAME_SERVICE__ > starname.service[Unit]Description=IOV Name ServiceAfter=network-online.target#PartOf=iovnsapi.service​[Service]Type=simpleUser=$(id ${USER_IOV} -u -n)Group=$(id ${USER_IOV} -g -n)EnvironmentFile=/etc/systemd/system/starname.envExecStart=${DIR_IOVNS}/iovnsd.shLimitNOFILE=4096#Restart=on-failure#RestartSec=3StandardError=journalStandardOutput=journalSyslogIdentifier=iovnsd​[Install]WantedBy=multi-user.target__EOF_STARNAME_SERVICE__​systemctl daemon-reload​# download gitian built binaries; iovnsd is the IOV Name Service daemonmkdir -p ${DIR_IOVNS} && cd ${DIR_IOVNS}wget ${IOVNS} && sha256sum $(basename ${IOVNS}) | grep b06575a0254ad1dceeabdb56de09cca0451173d57d3de43f060ff8be67fdf053 && tar xvf $(basename ${IOVNS}) || echo 'BAD BINARY!'​# create iovnsd.sh, a wrapper for iovnsdcat <<__EOF_IOVNSD_SH__ > iovnsd.sh#!/bin/bash​exec $PWD/iovnsd start \\--home=${DIR_WORK} \\--minimum-gas-prices='1.0uvoi' \\--moniker='${MONIKER}' \\--p2p.laddr='tcp://0.0.0.0:46656' \\--p2p.persistent_peers='b69d5878ef8997e749a499f14cb050c5de6bcedc@64.227.40.19:46656' \\--rpc.laddr='tcp://127.0.0.1:46657' \\--rpc.unsafe=true \\​__EOF_IOVNSD_SH__​chgrp ${USER_IOV} iovnsd.shchmod a+x iovnsd.sh​# initialize the IOV Name Servicesu - ${USER_IOV}set -o allexport ; source /etc/systemd/system/starname.env ; set +o allexport # pick-up env vars​rm -rf ${DIR_WORK} && mkdir -p ${DIR_WORK} && cd ${DIR_WORK}​# initialize IOV Name Service (iovnsd)${DIR_IOVNS}/iovnsd init ${MONIKER} --chain-id ${CHAIN_ID} --home ${DIR_WORK} 2>&1 | jq -r .chain_id​curl --fail https://rpc.cluster-galaxynet.iov.one/genesis | jq -r .result.genesis > config/genesis.jsonsha256sum config/genesis.json | grep d41378b0d21dd4c3bc7e0e77325df4adc7d801d6c804879946a001361f24056d || echo 'BAD GENESIS FILE!'​exit # ${USER_IOV}​journalctl -f -u starname.service & # watch the chain syncsystemctl start starname.service​exit # root
At this point you're running a full-node that can be examined at http://localhost:46657/status
. Repeat the above procedure on as many sentry nodes as you have and once more on your validator node.
Now that you have sentry node(s) and a validator, they need to be made aware of their role and pointed at each other.
In the most rudimentary form, a sentry node is meant to gossip with other nodes but keep its associated validator hidden. Change ${DIR_IOVNS}/iovnsd.sh
so that the node gossips while keeping its validator hidden. Be mindful of --rpc.unsafe true
below, you might not want that. On the validator node, execute curl -s http://localhost:46657/status | jq -r .result.node_info.id
to get the value for VALIDATOR_ID
.
exec "$PWD/iovnsd start \...--moniker='sentry' \--p2p.laddr='tcp://0.0.0.0:46656' \--p2p.persistent_peers='b69d5878ef8997e749a499f14cb050c5de6bcedc@64.227.40.19:46656' \--rpc.laddr='tcp://127.0.0.1:46657' \--rpc.unsafe=true \"
There are a lot more tendermint configuration options available than those shown above. Customize them as you see fit and then execute sudo systemctl restart starname.service
.
As mentioned, it's ${DIR_IOVNS}/iovnsd.sh
that determines whether the node will act as a sentry or validator based on p2p.*
options and priv_validator_laddr
if you're using an HSM. Change ${DIR_IOVNS}/iovnsd.sh
so that the node gossips with its sentry node(s) only, ie set p2p.pex=false
and add an explicit list of p2p.persistent_peers
. Obtain the sentry node ids for p2p.persistent_peers
by executing curl -s http://localhost:46657/status | jq -r .result.node_info.id
on each sentry node. You know the IP and PORT of the nodes, so include them appropriately.
exec "$PWD/iovnsd start \...--moniker='validator' \--priv_validator_laddr='tcp://HSM_IP:HSM_PORT' \--p2p.persistent_peers='SENTRY_ID0@SENTRY_IP0:SENTRY_PORT0,SENTRY_ID1@SENTRY_IP1:SENTRY_PORT1' \--p2p.pex='false' \--rpc.unsafe='false' \"
Execute sudo systemctl restart starname.service
.
The IOV Name Service is based on tendermint v0.33.x
, which requires tmkms v0.8.0-rc0
or better.
Update your tmkms.toml
file after you customize ADDR_VALIDATOR
, FILE_SECRET
and FILE_TMKMS
in the following script:
sudo su # make life easier for the next 20 lines​export ADDR_VALIDATOR="tcp://id@example1.example.com:46658" # or addr = "unix:///path/to/socket"export FILE_SECRET=/path/to/kms-identity.keyexport FILE_TMKMS=/path/to/tmkms.toml​set -o allexport ; source /etc/systemd/system/starname.env ; set +o allexport # pick-up env vars​grep ${CHAIN_ID} ${FILE_TMKMS} || { cat <<__EOF_TMKMS_UPDATE__ >> ${FILE_TMKMS}[[chain]]id = "${CHAIN_ID}"key_format = { type = "bech32", account_key_prefix = "starpub", consensus_key_prefix = "starvalconspub" }state_file = "${DIR_WORK}/data/priv_validator_state.json"# state_hook = { cmd = ["/path/to/block/height_script", "--example-arg", "starname network"] }​[[validator]]addr = "${ADDR_VALIDATOR}"chain_id = "${CHAIN_ID}"secret_key = "${FILE_SECRET}"protocol_version = "v0.33"__EOF_TMKMS_UPDATE__​sed --in-place "s/\(chain_ids.*\)\"/\\1\", \"${CHAIN_ID}\"/" ${FILE_TMKMS}​systemctl restart tmkms.service}​exit # root
Once your sentry nodes and validator are sync'ed then the final step to becoming a validator is to execute the create-validator
command just like for any Cosmos-based chain. Get some tokens from our faucet with `curl https://faucet.cluster-galaxynet.iov.one/credit?address=${SIGNER}`. The testnet's token is denominated in uvoi
, so your create validator command will look something like
set -o allexport ; source /etc/systemd/system/starname.env ; set +o allexport # pick-up env vars​export PATH=${DIR_IOVNS}:$PATH​iovnscli tx staking create-validator \--moniker "${MONIKER}" \--amount 100000000uvoi \--commission-max-change-rate 0.01 \--commission-max-rate 0.2 \--commission-rate 0.1 \--min-self-delegation 1 \--from ${SIGNER} \--pubkey $(iovnsd tendermint show-validator --home ${DIR_WORK}) \--gas-prices 1.0uvoi \--node https://rpc.cluster-galaxynet.iov.one:443 \--chain-id ${CHAIN_ID}​
Happy validating!
​