-
Notifications
You must be signed in to change notification settings - Fork 6
Change block pruning #393
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
Change block pruning #393
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR refactors block pruning from an automatic passive operation (via WithPruneTarget option) to an active manual operation (via PruneBlocks method). The change aims to fix a race condition where blocks were pruned before chain subscribers could index them, by giving integrators explicit control over when pruning occurs.
Changes:
- Removed
WithPruneTargetmanager option and automatic pruning logic from the chain manager - Added new
PruneBlocks(height)method that allows manual pruning of blocks below a specified height - Updated
synccommand to manually callPruneBlocksafter each reorg event - Added test coverage for the new pruning functionality
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| chain/options.go | Removes the WithPruneTarget option function |
| chain/manager.go | Removes automatic pruning from applyTip and adds new PruneBlocks method for manual pruning |
| internal/cmd/sync/main.go | Updates reorg channel to pass ChainIndex and calls PruneBlocks manually after each reorg |
| internal/cmd/calcswaps/main.go | Removes usage of WithPruneTarget option |
| chain/db_test.go | Adds test for the new PruneBlocks functionality |
| .changeset/*.md | Documents the breaking change with appropriate version bump |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
peterjan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
This fixes a race condition on some nodes when chain subscribers are slow where blocks would be removed from the store before they could be indexed.