logo

0G Node State-Sync

Instruction

Create a reusable shell script such as state_sync.sh with the following code. The code will fetch important state-sync information (such as block height and trust hash) from our server and update your config.toml file accordingly.
shell
#!/bin/bash SNAP_RPC="https://0g-rpc.murphynode.net: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) 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\"|" $HOME/.0gchain/config/config.toml
Grant user the privilege to execute script and then run the script:
shell
chmod 700 state_sync.sh ./state_sync.sh
Stop the node:
shell
sudo systemctl stop 0gchaind
Reset the node:
shell
# On some tendermint chains 0gchaind unsafe-reset-all # On other tendermint chains 0gchaind tendermint unsafe-reset-all --home $HOME/.0gchain --keep-addr-book
Restart the node:
shell
sudo systemctl start 0gchaind

Powered by Notaku