🧊0G

The First Decentralized AI Operating System

https://twitter.com/0G_labs https://discord.gg/0glabs

Auto-Install Node 0G

wget https://raw.githubusercontent.com/ValidatorVN/GuideNode/main/0G/0g && chmod +x 0g && ./0g

Public Endpoints

https://0g-rpc.validatorvn.com https://0g-api.validatorvn.com https://0g-rpc-evm01.validatorvn.com

Explorer

https://explorer.validatorvn.com/0g-Newton-V2

Snapshot

sudo systemctl stop 0gchaind
cp $HOME/.0gchain/data/priv_validator_state.json $HOME/.0gchain/priv_validator_state.json.backup
rm -rf $HOME/.0gchain/data
0gchaind tendermint unsafe-reset-all --home ~/.0gchain/ --keep-addr-book
curl https://snapshot.validatorvn.com/0g/data.tar.lz4 | lz4 -dc - | tar -xf - -C $HOME/.0gchain
mv $HOME/.0gchain/priv_validator_state.json.backup $HOME/.0gchain/data/priv_validator_state.json
sudo systemctl restart 0gchaind && sudo journalctl -u 0gchaind -f -o cat

State-sync

sudo systemctl stop 0gchaind
cp $HOME/.0gchain/data/priv_validator_state.json $HOME/.0gchain/priv_validator_state.json.backup
0gchaind tendermint unsafe-reset-all --home ~/.0gchain/ --keep-addr-book
SNAP_RPC="https://0g-rpc.validatorvn.com: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.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\"|" ~/.0gchain/config/config.toml
more ~/.0gchain/config/config.toml | grep 'rpc_servers'
more ~/.0gchain/config/config.toml | grep 'trust_height'
more ~/.0gchain/config/config.toml | grep 'trust_hash'

sudo mv $HOME/.0gchain/priv_validator_state.json.backup $HOME/.0gchain/data/priv_validator_state.json

sudo systemctl restart 0gchaind && journalctl -u 0gchaind -f -o cat

Seeds & Peers

URL="https://0g-rpc.validatorvn.com/net_info"
# Fetch data from the endpoint
response=$(curl -s $URL)
# Parse JSON and construct PEERS string using jq
PEERS=$(echo $response | jq -r '.result.peers[] | "\(.node_info.id)@\(.remote_ip):" + (.node_info.listen_addr | capture("(?<ip>.+):(?<port>[0-9]+)$").port)' | paste -sd "," -)
# Display the PEERS string
echo "PEERS=\"$PEERS\""
# Set the peers
sed -i 's|^persistent_peers *=.*|persistent_peers = "'$PEERS'"|' $HOME/.0gchain/config/config.toml

Addrbook

curl -L https://snapshot.validatorvn.com/og/addrbook.json > $HOME/.0gchain/config/addrbook.json

0g-storage-node snapshot

cd $HOME
sudo systemctl stop zgs && rm -r $HOME/0g-storage-node/run/db && rm -r $HOME/0g-storage-node/run/log && rm -r $HOME/0g-storage-node/run/network
curl -L https://snapshot.validatorvn.com/0g/storage_0gchain_snapshot.lz4 | lz4 -dc - | tar -xf - -C $HOME/0g-storage-node/run
sudo systemctl restart zgs
tail -f ~/0g-storage-node/run/log/zgs.log.$(TZ=UTC date +%Y-%m-%d)

Last updated