-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create state-sync documentation (#199)
Co-authored-by: Denis Fadeev <[email protected]>
- Loading branch information
1 parent
0543eb6
commit c478980
Showing
2 changed files
with
109 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
--- | ||
sidebar_position: 4 | ||
sidebar_label: State-sync | ||
hide_title: false | ||
id: state-sync | ||
title: Syncing a node using state-sync | ||
--- | ||
|
||
# Syncing a node using state-sync | ||
|
||
Follow this guide to setup a RPC node using state-sync. | ||
This guide was created and tested in MacOS and may need to be modified slightly for your local system. | ||
|
||
## State-sync nodes | ||
### Testnet | ||
|
||
| Region | IP | | ||
| :-------------------------- | :------------- | | ||
| US | 35.224.160.108 | | ||
|
||
### Mainnet | ||
|
||
| Region | IP | | ||
| :-------------------------- | :-- | | ||
| | TBD | | ||
|
||
## Download binary | ||
Make sure you are downloading the same version as our network is using. | ||
You can find the available `zetacored` versions here: https://github.com/zeta-chain/node/tags | ||
|
||
1. Download the binary and give execution perms to the binary: | ||
|
||
```bash | ||
wget https://github.com/zeta-chain/node/releases/download/v10.1.0/zetacored_testnet-darwin-amd64 -O /usr/local/bin/zetacored | ||
chmod a+x /usr/local/bin/zetacored | ||
``` | ||
|
||
## Init base config | ||
|
||
1. Initialize the base folder and config with the following command: | ||
|
||
```bash | ||
MONIKER=$(hostname) | ||
zetacored init ${MONIKER} --chain-id athens_7001-1 | ||
``` | ||
|
||
## Download config files | ||
1. Download the genesis.json file and *.toml configuration files: | ||
|
||
```bash | ||
wget https://raw.githubusercontent.com/zeta-chain/network-athens3/main/network_files/config/genesis.json -O ~/.zetacored/config/genesis.json | ||
wget https://raw.githubusercontent.com/zeta-chain/network-athens3/main/network_files/config/config.toml -O ~/.zetacored/config/config.toml | ||
wget https://raw.githubusercontent.com/zeta-chain/network-athens3/main/network_files/config/app.toml -O ~/.zetacored/config/app.toml | ||
wget https://raw.githubusercontent.com/zeta-chain/network-athens3/main/network_files/config/client.toml -O ~/.zetacored/config/client.toml | ||
``` | ||
|
||
## State sync | ||
1. Fetch the height and hash from our state-sync servers (make sure to replace `<closest StateSync IP>` with the IP from our state-sync node): | ||
```bash | ||
STATE_SYNC_SERVER="[closest StateSync IP]:26657" | ||
TRUST_HEIGHT=$(curl -s http://${STATE_SYNC_SERVER}/block | jq -r '.result.block.header.height') | ||
HEIGHT=$((TRUST_HEIGHT-40000)) | ||
TRUST_HASH=$(curl -s "http://${STATE_SYNC_SERVER}/block?height=${HEIGHT}" | jq -r '.result.block_id.hash') | ||
``` | ||
|
||
NOTE: You need to sync from LATEST_HEIGHT - 40000 to make sure that the node will fetch an existing state-sync snapshot. | ||
|
||
## Replace config values | ||
1. Make sure to replace `[closest StateSync IP]` with the IP from our state-sync node and run this block of code: | ||
```bash | ||
RPC_STATE_SYNC_SERVERS="[closest StateSync IP]:26657,[closest StateSync IP]:26657" | ||
SEED="[email protected]:26656" | ||
EXTERNAL_IP=$(curl -4 icanhazip.com) | ||
sed -i "" -e "s/-=RPC_SERVERS=-/${RPC_STATE_SYNC_SERVERS}/g" ~/.zetacored/config/config.toml && | ||
sed -i "" -e "s/-=SYNC_HEIGHT=-/${HEIGHT}/g" ~/.zetacored/config/config.toml && | ||
sed -i "" -e "s/-=TRUST_HASH=-/${TRUST_HASH}/g" ~/.zetacored/config/config.toml && | ||
sed -i "" -e "s/-=MONIKER=-/${MONIKER}/g" ~/.zetacored/config/config.toml && | ||
sed -i "" -e "s/-=external_ip_address=-/${EXTERNAL_IP}/g" ~/.zetacored/config/config.toml | ||
sed -i "" -e "s/^seeds = .*/seeds = \"${SEED}\"/" ~/.zetacored/config/config.toml | ||
sed -i "" -e 's/^max_num_inbound_peers = .*/max_num_inbound_peers = 120/' ~/.zetacored/config/config.toml | ||
sed -i "" -e 's/^max_num_outbound_peers = .*/max_num_outbound_peers = 60/' ~/.zetacored/config/config.toml | ||
``` | ||
|
||
## Generate keys | ||
```bash | ||
zetacored keys add ${MONIKER} --keyring-backend test | ||
``` | ||
|
||
## Start node | ||
```bash | ||
zetacored start --home ~/.zetacored/ --log_level info --moniker ${MONIKER} --rpc.laddr tcp://0.0.0.0:26657 --minimum-gas-prices 1.0azeta "--grpc.enable=true" | ||
``` | ||
The node will fetch a snapshot and start applying chunks. Once it gets to the last chunk, it will take a few more minutes to finish the state-sync and start commiting new blocks. | ||
|
||
## Common errors | ||
### Port error | ||
```bash | ||
accept tcp [::]:26657: use of closed network connection | ||
``` | ||
|
||
1. Check if something is running on port 26657 | ||
```bash | ||
sudo lsof -i :26657 | ||
``` | ||
|
||
2. Kill any process running on that port | ||
```bash | ||
kill -9 PID | ||
``` |