3. State Synchronization

Before a node can actively participate in a blockchain network, it must undergo a process called state synchronization. This essential step involves downloading and verifying the entire history of the blockchain, from its inception (the genesis block) to the most recent block.

By synchronizing its state, a node ensures it has a complete and accurate record of all transactions and events that have occurred on the network. This comprehensive understanding is vital for several reasons:

  • Validating Transactions: Nodes must verify the authenticity of new transactions and ensure they adhere to network rules.

  • Consensus Participation: To contribute to the consensus mechanism and secure the network, a node needs a complete view of the blockchain's history.

  • Processing Queries: Nodes often handle requests for information about past transactions or account balances, requiring access to historical data.

In essence, state synchronization is the foundational step that equips a node to become a fully functional and trusted participant in the blockchain ecosystem.

3.1 Query for the Latest Block

To ensure your node has the most up-to-date information, you'll need to retrieve the latest block height and hash from a trusted node. This information will be used to configure your node for state synchronization.

Use the following command to retrieve the trust height and trust hash of the latest block on a trusted node:

$ curl -s http:/34.128.114.243:26657/commit | jq "{height: .result.signed_header.header.height, hash: .result.signed_header.commit.block_id.hash}"

This command will display a JSON response with the height and hash of the latest block.

{
  "height": "264382",
  "hash": "DB8E5522FDA2B4A9BBE488FE46CF2BEF14CC36938A1A60BE4B48BAF4F74827FB"
}

3.2 Configure State Synchronization

Once you have the latest block height and hash, you'll need to update your node's configuration file to enable state synchronization.

  • Locate the config.toml file in your Cifer node's configuration directory (typically .cifer/config).

  • Enable state sync by setting the enable in[statesync] section to true.

  • Replace trust_height and trust_hash with the values obtained in "3.1 Query for the Latest Block":

config.toml
[statesync]
enable = true
rpc_servers = "<RPC_server_1>, <RPC_server_2>" # Replace with at least 2 validator RPC server addresses
trust_height = 264382 # Replace with the height from step 1
trust_hash = "DB8E5522FDA2B4A9BBE488FE46CF2BEF14CC36938A1A60BE4B48BAF4F74827FB"
trust_period = "" # Should be significantly smaller than the unbonding period

3.3 Restart your Node

To apply the configuration changes and initiate state synchronization, restart your Cifer node.

Stop the currently running Cifer Chain instance by pressing q in the terminal window.

Press the 'q' key to stop serve

💿 Genesis state saved in /root/.ignite/local-chains/cifer/exported_genesis.json

𝓲 Stopped

Restart the blockchain using the following command:

$ ignite chain serve --reset-once

Your node will now begin the state synchronization process, downloading and verifying the blockchain data from the trust height up to the latest block. This process may take some time depending on the size of the blockchain.

Note: Ensure you have sufficient disk space to accommodate the entire blockchain data.

Last updated