Sei
Search
⌃K

Join a Network

Follow this guide to join an existing network through statesync
To quickly stand up a fresh full node and join in the network, it's recommended to sync through state sync or db sync.
If you want to run a local instance of Sei, see Local Sei Cluster

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.

Configurations

  1. 1.
    Set up rpc servers for primary and secondary endpoints. You can use one of the RPC endpoint as primary and secondary in Resources page
# Example: Set polkachu rpc as rpc-servers
PRIMARY_ENDPOINT=https://sei-testnet-rpc.polkachu.com:443
sed -i.bak -e "s|^rpc-servers *=.*|rpc-servers = \"$PRIMARY_ENDPOINT,$PRIMARY_ENDPOINT\"|" ~/.sei/config/config.toml
  1. 2.
    Set up trust height and trust hash. Each snapshot is created at a certain block height, and best practice here is to set the trust height to be earlier than the latest snapshot block height to avoid backward verifications.
# Example: set trust height and hash to be the block height 10,000 earlier
PRIMARY_ENDPOINT=https://sei-testnet-rpc.polkachu.com:443
TRUST_HEIGHT_DELTA=10000
LATEST_HEIGHT=$(curl -s "$PRIMARY_ENDPOINT"/block | jq -r ".block.header.height")
if [[ "$LATEST_HEIGHT" -gt "$TRUST_HEIGHT_DELTA" ]]; then
SYNC_BLOCK_HEIGHT=$(($LATEST_HEIGHT - $TRUST_HEIGHT_DELTA))
else
SYNC_BLOCK_HEIGHT=$LATEST_HEIGHT
fi
# Get trust hash
SYNC_BLOCK_HASH=$(curl -s "$PRIMARY_ENDPOINT/block?height=$SYNC_BLOCK_HEIGHT" | jq -r ".block_id.hash")
# Override configs
sed -i.bak -e "s|^trust-height *=.*|trust-height = $SYNC_BLOCK_HEIGHT|" ~/.sei/config/config.toml
sed -i.bak -e "s|^trust-hash *=.*|trust-hash = \"$SYNC_BLOCK_HASH\"|" ~/.sei/config/config.toml
  1. 3.
    Set up persistent peers. If you need additional bootstrap-peer or persistent-peer (used for known good peers) in ~/.sei/config/config.toml.See Configure General Settings for more info about each peer field.
# Example: Get the peers from polkachu rpc server
PRIMARY_ENDPOINT=https://sei-testnet-rpc.polkachu.com:443
curl "$PRIMARY_ENDPOINT"/net_info |jq -r '.peers[] | .url' |sed -e 's#mconn://##' > PEERS
ERSISTENT_PEERS=$(paste -s -d ',' PEERS)
sed -i.bak -e "s|^persistent-peers *=.*|persistent-peers = \"$PERSISTENT_PEERS\"|" ~/.sei/config/config.toml
  1. 4.
    Enable state sync and disable db sync. Note, you can only enable either state sync or db sync at a time.
# Enable state sync
sed -i.bak -e "s|^enable *=.*|enable = true|" ~/.sei/config/config.toml
sed -i.bak -e "s|^db-sync-enable *=.*|db-sync-enable = false|" ~/.sei/config/config.toml

DB Sync

DB sync, similar to state sync allows a new node to be able to quickly join the network. The difference here is that instead of fetching a snapshot of the application state at a recent height, DB sync downloads the database db files directly from a remote peer and start the node with the downloaded application data.

Configuration

  1. 1.
    This is similar to state sync. For DB Sync, You can use one of the RPC endpoint as primary and secondary in DB Sync page
# Example: Set polkachu rpc as rpc-servers
PRIMARY_ENDPOINT=https://sei-testnet-rpc.polkachu.com:443
sed -i.bak -e "s|^rpc-servers *=.*|rpc-servers = \"$PRIMARY_ENDPOINT,$PRIMARY_ENDPOINT\"|" ~/.sei/config/config.toml
  1. 2.
    Similar to state sync, you want to find the trust height and hash from some rpc endpoint.
# Example: set trust height and hash to be the block height 10,000 earlier
PRIMARY_ENDPOINT=https://sei-testnet-rpc.polkachu.com:443
TRUST_HEIGHT_DELTA=10000
LATEST_HEIGHT=$(curl -s "$PRIMARY_ENDPOINT"/block | jq -r ".block.header.height")
if [[ "$LATEST_HEIGHT" -gt "$TRUST_HEIGHT_DELTA" ]]; then
SYNC_BLOCK_HEIGHT=$(($LATEST_HEIGHT - $TRUST_HEIGHT_DELTA))
else
SYNC_BLOCK_HEIGHT=$LATEST_HEIGHT
fi
# Get trust hash
SYNC_BLOCK_HASH=$(curl -s "$PRIMARY_ENDPOINT/block?height=$SYNC_BLOCK_HEIGHT" | jq -r ".block_id.hash")
# Override configs
sed -i.bak -e "s|^trust-height *=.*|trust-height = $SYNC_BLOCK_HEIGHT|" ~/.sei/config/config.toml
sed -i.bak -e "s|^trust-hash *=.*|trust-hash = \"$SYNC_BLOCK_HASH\"|" ~/.sei/config/config.toml
  1. 3.
    Set up persistent peers. It is recommended that you set persistent-peers to the node which provide db-sync snapshots specifically.
# Example: use sei internal db-sync node
CHAIN_ID=atlantic-2
NODE_ID=$(curl -s "http://db-sync.$CHAIN_ID.seinetwork.io:26657/status" | jq ".node_info.id" | tr -d '"')
echo "$NODE_ID@db-sync.$CHAIN_ID.seinetwork.io:26656" > PEERS
PERSISTENT_PEERS=$(paste -s -d ',' PEERS)
sed -i.bak -e "s|^persistent-peers *=.*|persistent-peers = \"$PERSISTENT_PEERS\"|" ~/.sei/config/config.toml
  1. 4.
    Enable db sync and disable state sync. Note, you can only enable either state sync or db sync at a time.
# Enable db sync
sed -i.bak -e "s|^enable *=.*|enable = false|" ~/.sei/config/config.toml
sed -i.bak -e "s|^db-sync-enable *=.*|db-sync-enable = true|" ~/.sei/config/config.toml