BEP-453: Optional Ancient Block Pruning Mechanism #453
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
BEP-453: Optional Ancient Block Pruning Mechanism
1. Summary
This BEP tries to solve the burden of redundant and infinitely growing ancient blocks on the entire network. It proposes an optional pruning mechanism for ancient blocks so that most nodes only need to maintain a bounded storage size for it.
2. Status
Draft
3. Motivation
The ancient blocks are useless for executing the latest blocks. The table below shows the data growth from December 2022 to December 2023:
The ancient blocks of Dec-2023 account for 61% of all chain data and increased by 42.6% compared to Dec-2022 in the BNB Smart Chain Annual Storage Report 2024.
This BEP introduces a hardcoded minimum retention bounded ancient range while satisfying most scenarios of ancient block requirements and reducing storage costs.
Meanwhile, the ancient blocks can be maintained by some archive node or Greenfield, users rely on other decentralized protocols or centralized organizations to fetch ancient blocks.
4. Specification
This BEP is an optional ancient block pruning mechanism that aims to reduce node operating costs. It does not affect any consensus rules and may affect the behavior of P2P Protocol and RPC Protocol. By default, the node keeps all ancient blocks.
4.1 Prune
By default, the node will keep all ancient blocks. If pruning is enabled, only the data within the range of ReserveAncientBlocks+ExtraReserveAncientBlocks will be retained. The deleted data includes:
The client recommends using the online pruning method. From the last storage report, it can save 57.3% of storage space for the node. There is no need to worry about the pruned data, which will continue to be maintained by the decentralized community and various centralized organizations.
The client should also support restoring ancient blocks from node snapshot.
4.2 P2P Protocol
For nodes that enable ancient block pruning, messages involving pruned data need to return empty data.
This BEP modifies the subprotocol BSC/1 and the HandShake message’s extra field to exchange the range of ancient blocks when connecting to a remote peer.
Specific message modifications:
The Extra field needs to be encoded by RLP as below:
After the msg exchanges, nodes can request the correct node with the corresponding ancient blocks as needed.
4.3 RPC Protocol
For nodes that enable the ancient block pruning, the RPC interface involving the pruned data needs to return empty data.
Also, a new interface should be added to provide the ancient block range supported by this node.
4.4 Chain Sync
The general workflow of node syncing is as below:
If the node is behind by less than 90 days, node can easily download blocks from the P2P network to complete the synchronization. If the node syncs from Genesis or falls behind for more than 90 days, it may need to find a peer with the required ancient blocks from the network.
5. Rationale
5.1 Parameters
For the parameters of ReserveAncientBlocks, referring to the blob DA time of the current BSC, the blob is guaranteed to be active in the entire network for ~18 days, the ancient block will keep longer, 90 days, and the size will be kept at ~110GB.
5.2 User experience
This BEP has a certain impact on scenarios that rely on ancient blocks for more than 90 days.
At the same time, various solutions provided by decentralized communities and centralized organizations can meet most needs:
6. Forward Compatibility
6.1 Portal Network
A Portal network is a hot topic to solve the storage pressure, once it is ready, it is possible that a portal network can keep the pruned ancient blocks too.
7. Backward Compatibility
7.1 Archive Node
If you run an archive node, you can just keep all the ancient blocks, with no impact on its business.
8. License
The content is licensed under CC0.