Join the network using StateSync
Learn how to join the Paxeer network quickly using state sync, including clean-up steps, script setup, and troubleshooting common errors.
Follow this guide to join the Paxeer network through statesync. To quickly spin up a fresh full node and join the network, it's recommended to sync through state sync.
State Sync
State sync allows a new node to join a network by fetching a snapshot of the application state at a recent height instead of fetching and replaying all historical blocks. This can reduce the time needed to sync with the network from days to minutes.
Clean Up
If you are not starting a node from fresh, then you need to do some backups and clean ups.
Assuming your Paxeer home directory is $HOME/.paxeer, back up priv_validator_key.json and priv_validator_state.json:
cp $HOME/.paxeer/data/priv_validator_state.json $HOME/priv_validator_state.json
cp $HOME/.paxeer/config/priv_validator_key.json $HOME/priv_validator_key.json
Reset the state:
paxd tendermint unsafe-reset-all --home $HOME/.paxeer
Finally, remove the existing data folders and restore the priv_validator_state.json:
rm -rf $HOME/.paxeer/data/*
cp $HOME/priv_validator_state.json $HOME/.paxeer/data/priv_validator_state.json
Statesync script
Set up the RPC servers for primary and secondary endpoints.
For STATE_SYNC_RPC, use the Paxeer RPC endpoint.
The seed peer for the network is:
e9c56cbadc4a96b67f69dcaaa7b4691851e945ca@31.220.74.140:26656
The script sets up trust_height and trust_hash automatically. Each statesync snapshot is created at a certain block height. The script uses the best practice here and sets the trust height to be earlier than the latest snapshot block height to avoid backward verifications.
Script that you can use:
#!/bin/bash
# Prompt for the State Sync RPC Endpoint and store it in STATE_SYNC_RPC
echo -n State Sync RPC Endpoint:
read STATE_SYNC_RPC
echo
# Prompt for the State Sync Peer and store it in STATE_SYNC_PEER
echo -n State Sync Peer:
read STATE_SYNC_PEER
echo
# Create a backup directory for keys
mkdir -p $HOME/key_backup
# Backup the validator key and state files
cp $HOME/.paxeer/config/priv_validator_key.json $HOME/key_backup
cp $HOME/.paxeer/data/priv_validator_state.json $HOME/key_backup
# Create a backup directory for the entire .paxeer configuration
mkdir -p $HOME/.paxeer_backup
# Copy existing config and data directories to the backup directory
cp -r $HOME/.paxeer/config $HOME/.paxeer_backup/
cp -r $HOME/.paxeer/data $HOME/.paxeer_backup/
# Create a temp directory on the main disk and set the path in config.toml
mkdir -p /home/ubuntu/statesync-temp
sed -i 's|temp-dir = ""|temp-dir = "/home/ubuntu/statesync-temp"|' ~/.paxeer/config/config.toml
# Fetch the latest block height from the State Sync RPC endpoint
LATEST_HEIGHT=$(curl -s $STATE_SYNC_RPC/block | jq -r .block.header.height)
# Calculate the trust height (rounded down to the nearest 100,000)
BLOCK_HEIGHT=$(( (LATEST_HEIGHT / 100000) * 100000 ))
# Fetch the block hash at the trust height
TRUST_HASH=$(curl -s "$STATE_SYNC_RPC/block?height=$BLOCK_HEIGHT" | jq -r .block_id.hash)
# Update the config.toml file to enable state sync with the appropriate settings
sed -i.bak -E "s|^(enable[[:space:]]+=[[:space:]]+).*$|\1true| ; \
s|^(rpc-servers[[:space:]]+=[[:space:]]+).*$|\1\"$STATE_SYNC_RPC,$STATE_SYNC_RPC\"| ; \
s|^(trust-height[[:space:]]+=[[:space:]]+).*$|\1$BLOCK_HEIGHT| ; \
s|^(trust-hash[[:space:]]+=[[:space:]]+).*$|\1\"$TRUST_HASH\"|" $HOME/.paxeer/config/config.toml
# Set the persistent peers in the config.toml file
sed -i.bak -e "s|^persistent-peers *=.*|persistent-peers = \"$STATE_SYNC_PEER\"|" \
$HOME/.paxeer/config/config.tomlFinally start the daemon:
sudo systemctl start paxd
Troubleshooting statesync
Q: I can't connect to the state sync url.
A: Try another statesync url in that case.
Q: The statesync finishes, but immediately get AppHash errors upon regular block syncing:
A: Make sure that you use the latest version of the chain node when you state-sync.
Q: The statesync randomly stops.
A: State-sync can be flaky at times, just try again. Please give it around 4-5 tries.