Enable State Pruning

Guidance about state pruning

State Pruning

State pruning is a feature we implemented in harmony node to prune redundant state node from the state DB before it was written to DB. State pruning will reduce the blockchain size from current 80+G (as of Feb/25/2020) to <2G. Validators should be able to reduce the disk size significantly to save the cloud cost.

If you are currently running a validator node, you may create a new node using existing blskey and with state pruning enabled to make sure your account can keep earning block rewards. You should backup your blskey and transport it to the new node.

State pruning requires additional CPU power to process the pruning work. Please make sure your CPU has enough power to handle it, i.e, AWS m5a.large, c5.large or better instances should have sufficient CPU power.

Download the latest node.sh

curl -LO https://harmony.one/node.sh
chmod +x node.sh

Use rclone to clone the DB snapshot

Please refer to the rclone document for more details. Replace <ShardID> with your shard id.

rclone sync mainnet:pub.harmony.one/mainnet.min/harmony_db_<ShardID> harmony_db_<ShardID>

state pruning is enabled by default using the latest node.sh. So you just need to start the node.sh as normal to enjoy the new

You need to make sure the new node is fully sync'ed and generating BINGO before you can terminate the old validator node.

Use the following command to get the latest sync'ed block on your node and compare it to the block explorer to determine your node is fully sync'ed.

sudo tac latest/zerolog*.log | grep -m 1 blockShard.:[1-3] | grep -oE blockNumber.:[0-9]+

Upgrade existing node

You may also reuse existing node, but you may have to stop the node for a few minutes. The process is like,

  1. stop current harmony node process

  2. remove harmony_db_<ShardID> directory, and harmony_db_0 directory

  3. use rclone to sync the state pruned snapshot, both your own shard and shard 0

  4. restart the harmony node process