Add support of block header pruning. #4788
Open
+429
−66
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.
This PR follows #3962 and relates to #1570
The PR introduces
--prune-block-headers
flag to CLI that enables block header pruning along with block prunings when conditions (pruning mode, block finalization, etc) are met. The rationale behind the change is to reduce DB size by removing unnecessary data from the disk.The flag goes to
prune_blocks
andprune_displaced_branches
methods of thesc-client-db
crate and enables the gathering of the affected hashes to prune, the hash collection is iterated with block header pruning (both from DB and metadata cache) intry_commit_operation
as one of the final steps before the transaction commits. The initial implementation was simpler and pruned the block headers together with block pruning, however,try_commit_operation
refreshes the cache after the block header pruning and before the transaction commit and thus keeps the block header in memory.Tests cover regular block header pruning and block header pruning on forks and reorgs.