Full guide chạy full node + validator Cosmos Hub (cosmoshub-4)
Bao gồm: cài đặt, sync nhanh (snapshot / statesync), tạo validator
CPU: 4 cores
RAM: 8 GB
Disk: 200 GB SSD
CPU: 8 cores
RAM: 32 GB
Disk: 500 GB NVMe
Uptime: ≥ 99.9%
sudo apt update && sudo apt upgrade -y
sudo apt install curl git wget htop tmux build-essential jq make lz4 gcc unzip -y
cd $HOME
wget https://go.dev/dl/go1.23.6.linux-amd64.tar.gz
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf go1.23.6.linux-amd64.tar.gz
echo "export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin" >> ~/.bash_profile
source ~/.bash_profile
cd $HOME
git clone https://github.com/cosmos/gaia
cd gaia
git checkout v26.0.0
make install
Check:
gaiad version
gaiad init YOUR_MONIKER --chain-id cosmoshub-4
wget -O $HOME/.gaia/config/genesis.json.gz https://raw.githubusercontent.com/cosmos/mainnet/master/genesis/genesis.cosmoshub-4.json.gz
gunzip -f $HOME/.gaia/config/genesis.json.gz
curl -L https://ss.cosmos.nodestake.org/addrbook.json -o $HOME/.gaia/config/addrbook.json
SEEDS="00bf1f9d3c65137dc99c40cd03864384ce0ef7c3@cosmoshub-mainnet-seed.itrocket.net:34656"
sed -i -e "s/^seeds *=.*/seeds = \"$SEEDS\"/" $HOME/.gaia/config/config.toml
sed -i 's/^minimum-gas-prices *=.*/minimum-gas-prices = "0.005uatom"/' $HOME/.gaia/config/app.toml
sudo systemctl stop gaiad
cp $HOME/.gaia/data/priv_validator_state.json $HOME/.gaia/priv_validator_state.json.backup 2>/dev/null || true
rm -rf $HOME/.gaia/data
rm -rf $HOME/.gaia/wasm
gaiad tendermint unsafe-reset-all --home ~/.gaia --keep-addr-book
SNAP_NAME=$(curl -s https://ss.cosmos.nodestake.org/ | egrep -o ">20.*\.tar.lz4" | tr -d ">")
curl -L https://ss.cosmos.nodestake.org/${SNAP_NAME} | lz4 -dc - | tar -xf - -C $HOME/.gaia
mv $HOME/.gaia/priv_validator_state.json.backup $HOME/.gaia/data/priv_validator_state.json 2>/dev/null || true
SNAP_RPC="https://rpc.cosmoshub.strange.love:443"
LATEST_HEIGHT=$(curl -s $SNAP_RPC/block | jq -r .result.block.header.height)
TRUST_HEIGHT=$((LATEST_HEIGHT - 2000))
TRUST_HASH=$(curl -s "$SNAP_RPC/block?height=$TRUST_HEIGHT" | jq -r .result.block_id.hash)
sed -i -e "s/^enable *=.*/enable = true/" $HOME/.gaia/config/config.toml
sed -i -e "s/^rpc_servers *=.*/rpc_servers = \"$SNAP_RPC,$SNAP_RPC\"/" $HOME/.gaia/config/config.toml
sed -i -e "s/^trust_height *=.*/trust_height = $TRUST_HEIGHT/" $HOME/.gaia/config/config.toml
sed -i -e "s/^trust_hash *=.*/trust_hash = \"$TRUST_HASH\"/" $HOME/.gaia/config/config.toml
sudo tee /etc/systemd/system/gaiad.service > /dev/null <<EOF
[Unit]
Description=Cosmos Gaia Node
After=network-online.target
[Service]
User=root
ExecStart=$(which gaiad) start --home /root/.gaia
Restart=always
RestartSec=3
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable gaiad
sudo systemctl start gaiad
journalctl -u gaiad -f
curl -s localhost:26657/status | jq .result.sync_info
curl -s localhost:26657/net_info | jq .result.n_peers
gaiad keys add your-wallet
gaiad keys show your-wallet -a
gaiad tx staking create-validator \
--amount=200000000uatom \
--pubkey=$(gaiad tendermint show-validator) \
--moniker="your-moniker" \
--chain-id=cosmoshub-4 \
--commission-rate=0.05 \
--commission-max-rate=0.20 \
--commission-max-change-rate=0.01 \
--min-self-delegation=1 \
--from=your-wallet \
--gas auto --gas-adjustment 2 --gas-prices 0.005uatom \
-y
gaiad tx staking delegate \
$(gaiad keys show your-moniker--bech val -a) \
100000000uatom \
--from=your-wallet\
--gas auto --gas-adjustment 2 --gas-prices 0.005uatom \
--chain-id cosmoshub-4 \
-y
gaiad tx distribution withdraw-rewards \
$(gaiad keys show your-moniker --bech val -a) \
--from your-wallet\
--commission \
--gas auto --gas-adjustment 2 --gas-prices 0.005uatom \
-y