Installation
Install with one line script
bash <(curl -s https://raw.githubusercontent.com/staketown/cosmos/master/0g/test_install.sh)
Manual installation
sudo apt update
sudo apt install -y curl git jq lz4 build-essential unzip
bash <(curl -s "https://raw.githubusercontent.com/staketown/cosmos/master/utils/go_install.sh")
source .bash_profile
cd $HOME || return
rm -rf $HOME/0g-chain
git clone https://github.com/0glabs/0g-chain.git
cd $HOME/0g-chain || return
git checkout v0.3.1.alpha.0
make install
0gchaind config keyring-backend os
0gchaind config chain-id zgtendermint_16600-2
0gchaind init "Your Moniker" --chain-id zgtendermint_16600-2
# Download genesis and addrbook
curl -Ls https://snapshots-testnet.stake-town.com/0g/genesis.json > $HOME/.0gchain/config/genesis.json
curl -Ls https://snapshots-testnet.stake-town.com/0g/addrbook.json > $HOME/.0gchain/config/addrbook.json
APP_TOML="~/.0gchain/config/app.toml"
sed -i 's|^pruning *=.*|pruning = "custom"|g' $APP_TOML
sed -i 's|^pruning-keep-recent *=.*|pruning-keep-recent = "100"|g' $APP_TOML
sed -i 's|^pruning-keep-every *=.*|pruning-keep-every = "0"|g' $APP_TOML
sed -i 's|^pruning-interval *=.*|pruning-interval = 19|g' $APP_TOML
CONFIG_TOML="~/.0gchain/config/config.toml"
SEEDS=""
PEERS="e4a0123b9af65d36ef3f65af18a1cb05381b1ef5@65.108.124.43:48656"
sed -i.bak -e "s/^persistent_peers *=.*/persistent_peers = \"$PEERS\"/" $CONFIG_TOML
sed -i.bak -e "s/^seeds =.*/seeds = \"$SEEDS\"/" $CONFIG_TOML
external_address=$(wget -qO- eth0.me)
sed -i.bak -e "s/^external_address *=.*/external_address = \"$external_address:26656\"/" $CONFIG_TOML
sed -i 's|^minimum-gas-prices *=.*|minimum-gas-prices = "0.0025ua0gi"|g' $CONFIG_TOML
sed -i 's|^prometheus *=.*|prometheus = true|' $CONFIG_TOML
sed -i -e "s/^filter_peers *=.*/filter_peers = \"true\"/" $CONFIG_TOML
# Install cosmovisor
go install cosmossdk.io/tools/cosmovisor/cmd/cosmovisor@v1.4.0
mkdir -p ~/.0gchain/cosmovisor/genesis/bin
mkdir -p ~/.0gchain/cosmovisor/upgrades
cp ~/go/bin/0gchaind ~/.0gchain/cosmovisor/genesis/bin
sudo tee /etc/systemd/system/0gchaind.service > /dev/null << EOF
[Unit]
Description=0G Node
After=network-online.target
[Service]
User=$USER
ExecStart=$(which cosmovisor) run start
Restart=on-failure
RestartSec=3
LimitNOFILE=10000
Environment="DAEMON_NAME=0gchaind"
Environment="DAEMON_HOME=$HOME/.0gchain"
Environment="DAEMON_ALLOW_DOWNLOAD_BINARIES=false"
Environment="DAEMON_RESTART_AFTER_UPGRADE=true"
Environment="UNSAFE_SKIP_BACKUP=true"
[Install]
WantedBy=multi-user.target
EOF
# Snapshots
0gchaind tendermint unsafe-reset-all --home $HOME/.0gchain --keep-addr-book
URL=https://snapshots-testnet.stake-town.com/0g/zgtendermint_16600-2_latest.tar.lz4
curl -L $URL | lz4 -dc - | tar -xf - -C $HOME/.0gchain
[[ -f $HOME/.0gchain/data/upgrade-info.json ]] && cp $HOME/.0gchain/data/upgrade-info.json $HOME/.0gchain/cosmovisor/genesis/upgrade-info.json
(Optional) Configure timeouts for processing blocks
CONFIG_TOML="~/.0gchain/config/config.toml"
sed -i 's/timeout_propose =.*/timeout_propose = "100ms"/g' $CONFIG_TOML
sed -i 's/timeout_propose_delta =.*/timeout_propose_delta = "500ms"/g' $CONFIG_TOML
sed -i 's/timeout_prevote =.*/timeout_prevote = "100ms"/g' $CONFIG_TOML
sed -i 's/timeout_prevote_delta =.*/timeout_prevote_delta = "500ms"/g' $CONFIG_TOML
sed -i 's/timeout_precommit =.*/timeout_precommit = "100ms"/g' $CONFIG_TOML
sed -i 's/timeout_precommit_delta =.*/timeout_precommit_delta = "500ms"/g' $CONFIG_TOML
sed -i 's/timeout_commit =.*/timeout_commit = "1s"/g' $CONFIG_TOML
sed -i 's/skip_timeout_commit =.*/skip_timeout_commit = false/g' $CONFIG_TOML
Enable and start service
sudo systemctl daemon-reload
sudo systemctl enable 0gchaind
sudo systemctl start 0gchaind
sudo journalctl -u 0gchaind -f -o cat
After successful synchronisation we recommend to turn off snapshot_interval and state sync, this will save space on your hardware.
snapshot_interval=0
sed -i.bak -e "s/^snapshot-interval *=.*/snapshot-interval = \"$snapshot_interval\"/" ~/.0gchain/config/app.toml
sed -i 's|^enable *=.*|enable = false|' $HOME/.0gchain/config/config.toml
sudo systemctl restart 0gchaind && sudo journalctl -u 0gchaind -f -o cat
Wallet creation
Create wallet
⚠️ store seed phrase, important during recovering
0gchaind keys add <YOUR_WALLET_NAME> --eth
Recover wallet
⚠️ store seed phrase, important during recovering
0gchaind keys add <YOUR_WALLET_NAME> --eth --recover
Validator creation
After successful synchronisation we can proceed with validation creation.
Create validator
0gchaind tx staking create-validator \
--amount=1000000ua0gi \
--pubkey=$(0gchaind tendermint show-validator) \
--moniker="<Your moniker>" \
--identity=<Your identity> \
--details="<Your details>" \
--chain-id=zgtendermint_16600-2 \
--commission-rate=0.05 \
--commission-max-rate=0.20 \
--commission-max-change-rate=0.1 \
--min-self-delegation=1 \
--from=<YOUR_WALLET> \
--fees=1000ua0gi \
-y
Last updated