Skip to content

A State Sync Refresher usable in Tendermint or CometBFT-based protocols. This wipes the whole data folder and recalibrates the state-sync to a more recent height while making sure to backup and restore the priv_validator_state.json file.

License

Notifications You must be signed in to change notification settings

zenodeapp/restate-sync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Restate Sync

A State Sync Refresher usable in Tendermint or CometBFT-based protocols. This wipes the whole data folder and recalibrates the state-sync to a more recent height while making sure to backup and restore the priv_validator_state.json file.

This has been written by ZENODE and is licensed under the MIT-license (see LICENSE).

Overview

Running out of space happens to all of us, especially when you're running multiple nodes that grow day-by-day. When State Sync arrived, many got very enthusiastic to how quickly one could now join a network, without needing a ton of space.

But, even a state-synced node could eventually become too large in size. This small repository aims to solve this problem by providing a script that somewhat automates the steps required to recalibrate a state-sync to a more recent height.

Usage:   sh restate-sync.sh <binary_name> <node_dir_name> [height_interval] [rpc_server_1] [rpc_server_2]

Example: sh restate-sync.sh genesisd .genesis 1000 "https://26657.genesisl1.org:443"
         This will refresh the state sync using a trust height of latest_block - 1000 (rounded)
         and sets the RPC server addresses to https://26657.genesisl1.org:443

  <node_dir_name> should only be the name of the node directory, not a path (e.g. .gaia, .genesis, .cronos, .osmosisd etc.).
  [height_interval] is optional (default: 2000).
  [rpc_server_1] is optional (if none is given then the script will try to use the RPC SERVER url in your config.toml file).
  [rpc_server_2] is optional (default: [rpc_server_1]).

Data wipe

Caution

The node's data-folder will get wiped using <binary_name> tendermint unsafe-reset-all!

While it does try to stop the node service, create a backup of and restores the priv_validator_state.json file, we encourage you to stop it yourself and create a backup in case of the small chance your setup or chain differs from the norm. Though, rest assured, the script will tell you exactly what will happen before it does anything reckless.

Here follows an example warning message when one runs sh restate-sync.sh genesisd .genesis:

WARNING: - Service 'genesisd' will get halted using 'systemctl stop genesisd'.
         - A backup and restore of /root/.genesis/data/priv_validator_state.json will be performed.
         - State-syncing will wipe the /root/.genesis/data folder.

If any of this doesn't match your setup, make sure to halt and/or backup the node yourself before continuing!

Do you want to continue? (y/N): 

Breaking the two RPC server limit

Tip

If you want to add more than two RPCs, then manually configure the rpc_servers-field in your config.toml and leave [rpc_server_1] and [rpc_server_2] blank.

This script is limited to setting two RPC URIs in the rpc_servers-field of your config.toml file. If you want to add more, then manually add the RPC URIs in your config.toml file and do not call the script with either of the [rpc_server_1] or [rpc_server_2] arguments. This will let the script parse the first rpc server frm the rpc_servers-field, uses this to query the latest block height and leaves the field untouched.

Cronjob idea

Something for later down the line or something you could create is a cronjob that periodically checks the size of the node directory and runs the restate-sync.sh script whenever a certain threshold (in GBs) gets met.


— ZEN

Copyright (c) 2024 ZENODE

About

A State Sync Refresher usable in Tendermint or CometBFT-based protocols. This wipes the whole data folder and recalibrates the state-sync to a more recent height while making sure to backup and restore the priv_validator_state.json file.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages