State sync

State Sync’ feature was included in the recent release of the tendermint core v0.34 update. The feature allows users to look up information on the most recent credible block height instead of having to look up all block information from the past. The ‘state sync’ feature reduces the time required to synchronize the network to a matter of minutes.

State syncing a node

FirmaChain is structured to create a status sync snapshot of a portion of its nodes to allow a new node to join the network using the ‘State Sync’ feature. In order to join the network through ‘State Sync’ the following information must be retrieved in advance.

  • At least 2 available RPC servers.

  • A trusted height.

  • The block ID hash of the trusted height.

List of networks provided

Please refer to the genesis file, the seed and the github link according to your choice of network.

Initialize the firmachain

Initialize the node and designate the name of the moniker.

firmachaind init <moniker-name> --chain-id <chain-id>

Rename the moniker

Before activating the chain, you can modify the name of the node using the moniker field at ~/.firmachain/config/config.toml.

vim .firmachain/config/config.toml

# A custom human readable name for this node
moniker = "<moniker-name>"

Setup minimum gas prices

Modify minimum gas fee.

sed -i 's/minimum-gas-prices = "0stake"/minimum-gas-prices = "0.01ufct"/g' ~/.firmachain/config/app.toml

Set seeds

FirmaChain discloses information on seed nodes for the purpose of P2P connection.

# Mainnet
sed -i.bak -e "s/^seeds *=.*/seeds = \"f89dcc15241e30323ae6f491011779d53f9a5487@mainnet-seed1.firmachain.dev:26656,04cce0da4cf5ceb5ffc04d158faddfc5dc419154@mainnet-seed2.firmachain.dev:26656,940977bdc070422b3a62e4985f2fe79b7ee737f7@mainnet-seed3.firmachain.dev:26656\"/" ~/.firmachain/config/config.toml
# Testnet
sed -i.bak -e "s/^seeds *=.*/seeds = \"ddeaeb19dbe29558ac3f8569f99c0906adf7d8cf@testnet-seed1.firmachain.dev:26656,a195e07dad206431293ab141434331a8373221ab@testnet-seed2.firmachain.dev:26656\"/" ~/.firmachain/config/config.toml

Download genesis.json file

After downloading the genesis.json file of the network you are planning to join, please swap the file with ~/.firmachain/config/genesis.json.

# Mainnet genesis.json
wget https://raw.githubusercontent.com/FirmaChain/mainnet/main/colosseum-1/genesis.json -O ~/.firmachain/config/genesis.json
# Testnet genesis.json
wget https://raw.githubusercontent.com/FirmaChain/testnet/master/imperium-4/genesis.json -O ~/.firmachain/config/genesis.json

Set trust datas

If you do not have a jq package, please install the jq package.

sudo apt install jq -y

By running the command below, you will be able to retrieve data on the ‘trust height’ and ‘trust_hash’ via RPC.

# Mainnet
curl -s https://lcd-mainnet.firmachain.dev:26657/block | \
jq -r '.result.block.header.height + "\n" + .result.block_id.hash'

# Expected return data
5112101
07B4F8FE53D04AA5E34396FA12C6795967108C2A2D4336D3FE0F4CDE56350EF7
# Testnet
curl -s https://lcd-testnet.firmachain.dev:26657/block | \
jq -r '.result.block.header.height + "\n" + .result.block_id.hash'

# Expected return data
1337168
C826D099BD2F4E941597140115F4871067B293563A9019A9E788FF434EF3771B

Please set the chain to allow ‘State Sync’ feature and put in the retrieved data in the config.toml file.

# Mainnet
sed -i -e 's/enable = false/enable = true/g' ~/.firmachain/config/config.toml
sed -i -e 's/rpc_servers = ""/rpc_servers = "mainnet-seed1.firmachain.dev:26657,mainnet-seed2.firmachain.dev:26657"/g' ~/.firmachain/config/config.toml
sed -i -e 's/trust_height = 0/trust_height = 5112101/g' ~/.firmachain/config/config.toml
sed -i -e 's/trust_hash = ""/trust_hash = "07B4F8FE53D04AA5E34396FA12C6795967108C2A2D4336D3FE0F4CDE56350EF7"/g' ~/.firmachain/config/config.toml
sed -i -e 's/trust_period = "168h0m0s"/trust_period = "336h0m0s"/g' ~/.firmachain/config/config.toml
# Testnet
sed -i -e 's/enable = false/enable = true/g' ~/.firmachain/config/config.toml
sed -i -e 's/rpc_servers = ""/rpc_servers = "lcd-testnet.firmachain.dev:26657,testnet-seed2.firmachain.dev:26657"/g' ~/.firmachain/config/config.toml
sed -i -e 's/trust_height = 0/trust_height = 1337168/g' ~/.firmachain/config/config.toml
sed -i -e 's/trust_hash = ""/trust_hash = "C826D099BD2F4E941597140115F4871067B293563A9019A9E788FF434EF3771B"/g' ~/.firmachain/config/config.toml
sed -i -e 's/trust_period = "168h0m0s"/trust_period = "336h0m0s"/g' ~/.firmachain/config/config.toml

Now we are all set. Please start the chain. Once you start the chain, it will automatically search and restore the status sync snapshot from the network. (This process takes approximately 2 to 5 minutes.)

firmachaind start

Discovering snapshots for 15s
Discovered new snapshot        height=3000 format=1 hash=0F14A473
Discovered new snapshot        height=2000 format=1 hash=C6209AF7

Option

You can start firmachain using Cosmovisor or System Daemon.

Last updated