-
Notifications
You must be signed in to change notification settings - Fork 586
Feature request: ability to prune the old ancient blockchain data #718
Copy link
Copy link
Closed
Labels
Description
Rationale
I'm running a new snap-sync node, downloading a fresh snapshot from https://snapshots.matic.today, after the syncing progress, found the local chaindata consuming 1.1/1.6TB are the ancient data, used toooomuch disk:
$ du --max-depth=1 -h bor/chaindata/
1.1T bor/chaindata/ancient
1.6T bor/chaindata/The old ancient data is useless in most cases, so if we support the ancient data pruning, we can use fewer disks.
Implementation
Seems the binance smartchain has supported this feature(merged in #543) maybe we can backport this feature into go-ethereum.
$ ./bin/bsc snapshot prune-block --help
prune-block [command options]
geth offline prune-block for block data in ancientdb.
The amount of blocks expected for remaining after prune can be specified via block-amount-reserved in this command,
will prune and only remain the specified amount of old block data in ancientdb.
the brief workflow is to backup the the number of this specified amount blocks backward in original ancientdb
into new ancient_backup, then delete the original ancientdb dir and rename the ancient_backup to original one for replacement,
finally assemble the statedb and new ancientDb together.
The purpose of doing it is because the block data will be moved into the ancient store when it
becomes old enough(exceed the Threshold 90000), the disk usage will be very large over time, and is occupied mainly by ancientDb,
so it's very necessary to do block data prune, this feature will handle it.
ETHEREUM OPTIONS:
--datadir value Data directory for the databases and keystore (default: "/home/amber/.ethereum")
--datadir.ancient value Data directory for ancient chain segments (default = inside chaindata, '${datadir}/geth/chaindata/ancient/')
--block-amount-reserved value Sets the expected remained amount of blocks for offline block prune (default: 0)
--triesInMemory value The layer of tries trees that keep in memory (default: 128)
--check-snapshot-with-mpt Enable checking between snapshot and MPTReactions are currently unavailable