Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support of block header pruning. #4788

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

shamil-gadelshin
Copy link
Contributor

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 and prune_displaced_branches methods of the sc-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) in try_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.

@shamil-gadelshin shamil-gadelshin marked this pull request as ready for review June 13, 2024 10:58
@shamil-gadelshin
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant