Skip to content

Change block pruning#393

Merged
n8mgr merged 3 commits intomasterfrom
nate/pruning
Feb 4, 2026
Merged

Change block pruning#393
n8mgr merged 3 commits intomasterfrom
nate/pruning

Conversation

@n8mgr
Copy link
Member

@n8mgr n8mgr commented Feb 3, 2026

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.

@n8mgr n8mgr self-assigned this Feb 3, 2026
Copilot AI review requested due to automatic review settings February 3, 2026 19:35
@github-project-automation github-project-automation bot moved this to In Progress in Sia Feb 3, 2026
Copy link

Copilot AI left a 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 WithPruneTarget manager 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 sync command to manually call PruneBlocks after 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.

Copy link
Member

@peterjan peterjan left a 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!

@n8mgr n8mgr merged commit f6fb6cc into master Feb 4, 2026
13 checks passed
@n8mgr n8mgr deleted the nate/pruning branch February 4, 2026 16:23
@github-project-automation github-project-automation bot moved this from In Progress to Done in Sia Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants