refactor: remove outdated prune-block/pruneancient tool, implement it by tail-deletion
Description
This PR will remove prune-block/pruneancient tool, it can be replaced by tail-deletion, which is more easy & efficient for managing block history.
The PR will auto-detect the legacy offset metadata from db, and reset the tail metadata of freezer tables. So it's safe to run --history.blocks with the old pruneancient/prune-block feature.
Changes
Notable changes:
- misc: remove outdated prune-block tools
- chain: support new online prune block tool;
- freezer: remove prunedfreezer;
- freezer: support online prune by block history;
validator which has used tool pruneBlock still can run their nodes?
it would disable the prune-block tool, to avoid impacting the current users, better to be delivered in a separate maintenance release after Pascal hardfork.
Good Job!
Just FYI: https://github.com/bnb-chain/bsc/issues/2923
I would like to ask one more question, we now have 3 flags (history.state, history.transactions, history.blocks) to clear historical data, what data do we still have that is not cleared and if so, is it possible to reduce that too?
And I'd like to point out that we must avoid a situation where history.transactions > history.blocks. In such a case we will not be able to do indexTransactions/unindexTransactions, because there will be an error when getting the transaction hashes of the block. So TxIndexTail must be less than or equal to an existing block
https://github.com/bnb-chain/bsc/blob/87e622e51fab01204f6d57712f9d86192e7a9ac5/core/rawdb/chain_iterator.go#L150-L162
I would like to ask one more question, we now have 3 flags (history.state, history.transactions, history.blocks) to clear historical data, what data do we still have that is not cleared and if so, is it possible to reduce that too?
Hi @klim0v , You can refer to the inspected data from 2024 bnbchain storage report. https://www.bnbchain.org/en/blog/bnb-smart-chain-annual-storage-report-2024
The most burden is state history, chain history, and Index data. These data has a way to prune now. There also has some proposal for live state expiry, but it's more difficult.
And if you have good suggestions, it's greate to create an issue/proposal or discuss it in forum/discord.
And I'd like to point out that we must avoid a situation where history.transactions > history.blocks. In such a case we will not be able to do indexTransactions/unindexTransactions, because there will be an error when getting the transaction hashes of the block. So TxIndexTail must be less than or equal to an existing block
https://github.com/bnb-chain/bsc/blob/87e622e51fab01204f6d57712f9d86192e7a9ac5/core/rawdb/chain_iterator.go#L150-L162
Yeah, accepted, there is a corner case, when un-indexing & indexing again in node. Because the index and ancient data are saved in different ways, so they cannot generate or prune together. But it can be handled well to avoid bad behavior.
The following tools will be removed after this PR:
./bsc snapshot prune-state --datadir <datadir> --triesInMemory <size>
./bsc snapshot prune-block --datadir <datadir> --datadir.ancient <ancientdir> --block-amount-reserved <reserveNum>
--pruneancient will be deprecated, it is replaced by --history.blocks 360000