Ноды
September 23, 2022
Установка ноды DWS
Установка необходимых пакетов:
sudo apt update && sudo apt upgrade -y && \sudo apt install curl chrony tar wget clang pkg-config libssl-dev libleveldb-dev jq build-essential bsdmainutils git make ncdu htop screen unzip bc htop mc -y
cd $HOME && \ ver="1.18.5" && \ wget "https://golang.org/dl/go$ver.linux-amd64.tar.gz" && \ sudo rm -rf /usr/local/go && \ sudo tar -C /usr/local -xzf "go$ver.linux-amd64.tar.gz" && \ rm "go$ver.linux-amd64.tar.gz" && \ echo "export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin" >> $HOME/.bash_profile && \ source $HOME/.bash_profile && \ go version
Начало установки ноды:
# Set variables # Input your data # Set number of Cosmos nodes on your server (0, if it's first) # Example: NODES_NUM="0" NODES_NUM="0" MONIKER="moniker" WALLET="moniker_wallet" WEBSITE="https://starnodes.ru" IDENTITY="" DETAILS="https://t.me/starnodes_ru" SECURITY_CONTACT="" TIKER=dewebd && \ CHAIN=deweb-testnet-sirius && \ TOKEN=udws && \ PROJECT=deweb && \ CONFIG=.deweb && \ DENOM=1000000 && \ PROJECT_REPOSITORY_PATH="https://github.com/deweb-services/deweb" && \ BRANCH="v0.3.1" && \ NODE="http://localhost:$((NODES_NUM+26))657"
echo "export MONIKER=$MONIKER" >> $HOME/.bash_profile && \ echo "export WALLET=$WALLET" >> $HOME/.bash_profile && \ echo "export WEBSITE=$WEBSITE" >> $HOME/.bash_profile && \ echo "export IDENTITY=$IDENTITY" >> $HOME/.bash_profile && \ echo "export DETAILS=$DETAILS" >> $HOME/.bash_profile && \ echo "export SECURITY_CONTACT=$SECURITY_CONTACT" >> $HOME/.bash_profile && \ echo "export NODES_NUM=$NODES_NUM" >> $HOME/.bash_profile && \ echo "export TIKER=$TIKER" >> $HOME/.bash_profile && \ echo "export CHAIN=$CHAIN" >> $HOME/.bash_profile && \ echo "export TOKEN=$TOKEN" >> $HOME/.bash_profile && \ echo "export PROJECT=$PROJECT" >> $HOME/.bash_profile && \ echo "export CONFIG=$CONFIG" >> $HOME/.bash_profile && \ echo "export PROJECT_REPOSITORY_PATH=$PROJECT_REPOSITORY_PATH" >> $HOME/.bash_profile && \ echo "export BRANCH=$BRANCH" >> $HOME/.bash_profile && \ echo "export NODE=$NODE" >> $HOME/.bash_profile && \ source $HOME/.bash_profile
git clone $PROJECT_REPOSITORY_PATH $PROJECT && \ cd $PROJECT && \ git checkout $BRANCH && \ make install && \ $TIKER version --long | head # version: 0.3.1 # commit: 05a3111414ae9b510672925166b727371b669246
$TIKER init $MONIKER --chain-id $CHAIN && \ $TIKER config chain-id $CHAIN && \ $TIKER config keyring-backend test && \ $TIKER config node $NODE
# Add wallet $TIKER keys add $WALLET # Or recover $TIKER keys add $WALLET --recover
VALOPER=$($TIKER keys show $WALLET --bech val -a) && \ ADDRESS=$($TIKER keys show $WALLET --address) && \ echo "export VALOPER=$VALOPER" >> $HOME/.bash_profile && \ echo "export ADDRESS=$ADDRESS" >> $HOME/.bash_profile && \ source $HOME/.bash_profile
PEERS="c5b45045b0555c439d94f4d81a5ec4d1a578f98c@dws-testnet.nodejumper.io:27656" SEEDS="[email protected]:26656" sed -i.bak -e "s/^persistent_peers *=.*/persistent_peers = \"$PEERS\"/; s/^seeds *=.*/seeds = \"$SEEDS\"/" $HOME/$CONFIG/config/config.toml
external_address=$(wget -qO- eth0.me) sed -i.bak -e "s/^external_address *=.*/external_address = \"$external_address:26656\"/" $HOME/$CONFIG/config/config.toml
Настраиваем минимальную цену за газ в app.toml:
min_gas=0.0001 sed -i.bak -e "s/^minimum-gas-prices *=.*/minimum-gas-prices = \"$min_gas$TOKEN\"/;" $HOME/$CONFIG/config/app.toml
wget -O $HOME/$CONFIG/config/genesis.json https://raw.githubusercontent.com/deweb-services/deweb/main/genesis.json
sha256sum $HOME/$CONFIG/config/genesis.json # 5316dc5abf1bc46813b673e920cb6faac06850c4996da28d343120ee0d713ab9
https://gist.github.com/Danil00524/70038a9ef2c1d64ad0767f0bf71c7ecf # Memory optimization. Removes unused data from the database. | ONE COMMAND 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\"/" $HOME/$CONFIG/config/config.toml && \ sed -i.bak -e "s/^snapshot-interval *=.*/snapshot-interval = \"$snapshot_interval\"/" $HOME/$CONFIG/config/app.toml && \ sed -i.bak -e "s/^pruning *=.*/pruning = \"$pruning\"/" $HOME/$CONFIG/config/app.toml && \ sed -i.bak -e "s/^pruning-keep-recent *=.*/pruning-keep-recent = \"$pruning_keep_recent\"/" $HOME/$CONFIG/config/app.toml && \ sed -i.bak -e "s/^pruning-keep-every *=.*/pruning-keep-every = \"$pruning_keep_every\"/" $HOME/$CONFIG/config/app.toml && \ sed -i.bak -e "s/^pruning-interval *=.*/pruning-interval = \"$pruning_interval\"/" $HOME/$CONFIG/config/app.toml
Создание службы и запуск ноды:
# Create service | ONE COMMAND sudo tee /etc/systemd/system/$TIKER.service > /dev/null <<EOF [Unit] Description=$PROJECT Node After=network.target [Service] User=$USER Type=simple ExecStart=$(which $TIKER) start Restart=on-failure LimitNOFILE=65535 [Install] WantedBy=multi-user.target EOF
SNAP_RPC="https://dws-testnet.nodejumper.io:443" LATEST_HEIGHT=$(curl -s $SNAP_RPC/block | jq -r .result.block.header.height); \ BLOCK_HEIGHT=$((LATEST_HEIGHT - 2000)); \ 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 -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\"|" $HOME/$CONFIG/config/config.toml
sudo systemctl daemon-reload && \ sudo systemctl enable $TIKER && \ sudo systemctl restart $TIKER && \ sudo journalctl -u $TIKER -f -o cat
Дождитесь пока нода синхронизируется, ответ команды ниже должен быть false:
curl -s $NODE/status | jq .result.sync_info.catching_up
Создание валидатора:
Запросите тестовые токены в дискорде проекта в ветке #faucet
$request адрес_кошелька sirius
Адрес можно посмотреть командой echo $ADDRESS
Посмотрите в кошельке, что токены дошли:
$TIKER q bank balances $ADDRESS
$TIKER tx staking create-validator \ --amount=99000000$TOKEN \ --pubkey=$($TIKER tendermint show-validator) \ --moniker=$MONIKER \ --chain-id=$CHAIN \ --commission-rate="0.10" \ --commission-max-rate="0.20" \ --commission-max-change-rate="0.05" \ --min-self-delegation=1 \ --fees=5000$TOKEN \ --from=$WALLET \ --identity=$IDENTITY \ --website=$WEBSITE \ --details=$DETAILS \ --security-contact=$SECURITY_CONTACT \ -y
Сделайте бэкап ключа валидатора:
mkdir -p /home/$PROJECT/ cp $HOME/$CONFIG/config/priv_validator_key.json /home/$PROJECT/
Скорее всего вы будете в инактиве, запрашивайте токены в дискорде и делегируйте их валидатору командой ниже, пока не наберете токены для активного сета:
$TIKER tx staking delegate $VALOPER <TOKENS_COUNT>$TOKEN --from $WALLET --fees 500$TOKEN -y
Посмотреть валидатора в Explorer.
Обновить ноду:
TAG_NAME=v0.3.1 BRANCH_NAME=v0.3.1 sudo systemctl stop $TIKER && \ cd $PROJECT && \ git pull; \ git checkout tags/$TAG_NAME -b $BRANCH_NAME && \ make clean; \ make install && \ sudo systemctl restart $TIKER && \ journalctl -u $TIKER -f -o cat
Полезные команды:
Статус ноды
# Service logs journalctl -u $TIKER -f -o cat # Service control systemctl status $TIKER systemctl stop $TIKER systemctl start $TIKER systemctl restart $TIKER # Check node status curl -s $NODE/status # Check synchronization of your node, if the result is false, the node is synchronized curl -s $NODE/status | jq .result.sync_info.catching_up # Check consensus (AFTER START) curl -s $NODE/consensus_state | jq '.result.round_state.height_vote_set[0].prevotes_bit_array' # Connected peers curl -s $NODE/net_info | jq -r '.result.peers[] | "\(.node_info.id)@\(.remote_ip):\(.node_info.listen_addr | split(":")[2])"' | wc -l # Jail, tombstoned, start_height, index_offset $TIKER q slashing signing-info $($TIKER tendermint show-validator) # Get peer (e.g. [email protected]:26656 echo "$($TIKER tendermint show-node-id)@$(curl ifconfig.me):$(curl -s $NODE/status | jq -r '.result.node_info.listen_addr' | cut -d':' -f3)"
Кошельки
# Get wallet address echo $ADDRESS # Get eth wallet private key $TIKER keys unsafe-export-eth-key $WALLET # Get balance $TIKER q bank balances $ADDRESS # Send tokens. 1 token = 1000000 (Cosmos) $TIKER tx bank send $WALLET <ADDRESS_TO> <TOKENS_COUNT>$TOKEN --fees 500$TOKEN
Голосование
# Vote $TIKER tx gov vote <PROPOSAL_ID> <yes|no> --from $WALLET --fees 5000$TOKEN -y # Check all voted proposals $TIKER q gov proposals --voter $ADDRESS
Действия с валидатором
# Get validator address (valoper) echo $VALOPER # Edit validator $TIKER tx staking edit-validator --website="<YOUR_WEBSITE>" --details="<YOUR_DESCRIPTION>" --moniker="<YOUR_NEW_MONIKER>" --from=$WALLET --fees 500$TOKEN # Unjail $TIKER tx slashing unjail --from $WALLET --fees 500$TOKEN # Bond more tokens (if you want increase your validator stake you should bond more to your valoper address): $TIKER tx staking delegate $VALOPER <TOKENS_COUNT>$TOKEN --from $WALLET --fees 500$TOKEN -y # Undelegate $TIKER tx staking unbond $VALOPER <TOKENS_COUNT>$TOKEN --from $WALLET --fees 500$TOKEN -y # собрать реварды со всех валидаторов, которым делегировали (без комиссии) # Take rewards from all walidators without commission $TIKER tx distribution withdraw-all-rewards --from $WALLET --fees 500$TOKEN -y # собрать реварды + комиссию со своего валидатора # Take rewards and commission from your validator $TIKER tx distribution withdraw-rewards $VALOPER --from $WALLET --fees 500$TOKEN --commission -y # Reset private validator file to genesis state and delete addrbook.json $TIKER tendermint unsafe-reset-all --home $HOME/$CONFIG ## All validators info # List of all active validators | ONE COMMAND $TIKER q staking validators -o json --limit=1000 \ | jq '.validators[] | select(.status=="BOND_STATUS_BONDED")' \ | jq -r '.tokens + " - " + .description.moniker' \ | sort -gr | nl # List of all inactive validators | ONE COMMAND $TIKER q staking validators -o json --limit=1000 \ | jq '.validators[] | select(.status=="BOND_STATUS_UNBONDED")' \ | jq -r '.tokens + " - " + .description.moniker' \ | sort -gr | nl # параметры сети # Network options $TIKER q staking params $TIKER q slashing params
@starnodes_ru - наш канал в Telegram с новостями и гайдами по тестнетам.
@starnodes_chat - канал, куда можно обратиться за помощью.