Pruning CometBFT blocks

Pruning CometBFT blocks

The size of the CometBFT directory will grow with validator signatures, transactions, etc.

The tool CometPrune (opens in a new tab) can prune old blocks from your CometBFT directory. It reduces only the CometBFT data in ${BASE_DIR}/${CHAIN_ID}/cometbft and does not affect Namada's storage data in ${BASE_DIR}/${CHAIN_ID}/db.

Install CometPrune

git clone [email protected]:ekhvalov/cometprune.git
cd cometprune
go install

Prune the blocks

  1. Stop the node

  2. Prune the blocks

cometprune --path ${BASE_DIR}/${CHAIN_ID}/cometbft/data --keep-blocks $BLOCKS_TO_KEEP

where the most recent $BLOCKS_TO_KEEP will be retained.

💡

Leaving the last one block (--keep-blocks 1) is enough to restart the node successfully. The tool will reject to delete all blocks, i.e. --keep-blocks 0 doesn't work.

  1. Restart the node