oasis-core
oasis-core copied to clipboard
Pruning strategy keep_n fails to reduce database size during client genesis sync
The pruning strategy keep_n doesn't work when syncing a client from genesis. The consensus block store located in data/consensus/data/blockstore.badger.db is never pruned, resulting in the database occupying more than 100GB of space during a mainnet sync.
One would expect this code to prune blocks, but this only occurs when a commit is finalized, not when a client processes older blocks. Restarting the client does not prune either.
Configuration:
consensus:
prune:
strategy: keep_n
num_kept: 10
checkpointer:
disabled: true
How to prune blocks manually:
import (
cmtstore "github.com/cometbft/cometbft/store"
tmBadger "github.com/oasisprotocol/oasis-core/go/consensus/cometbft/db/badger"
)
func main() {
n := 10
tmDb, _ := tmBadger.New("data/consensus/data/blockstore.badger.db", true)
tmBlkStore := cmtstore.NewBlockStore(tmDb)
tmBlkStore.PruneBlocks(tmBlkStore.Height() - n)
}