Page MenuHomePhabricator

blockstorage: Add prune locks to BlockManager
ClosedPublic

Authored by PiRK on May 2 2024, 12:20.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC792ecf617ce3: blockstorage: Add prune locks to BlockManager
Summary

PR rationale:

The main motivation of this change and only behavior change noticeable by user is to allow running coinstatsindex on pruned nodes.
coinstatsindex on pruned nodes can be enabled in a much simpler than it is done here but it comes with downside. The ability to run blockfilterindexon pruned nodes was added in #15946 but it also added the blockfilterindex as a dependency to validation and it introduced two new circular dependencies. Enabling coinstatsindex on pruned nodes in a similar way would add it as a dependency as well and introduce another circular dependency.

Instead, this PR introduces a m_prune_blockers map to BlockManager as a flexible approach to block pruning. Entities like blockfilterindex, for example, can add a key and a height to block pruning over that height. These entities need to update that value to allow more pruning when they are ready.

This change also introduces an aditional buffer of 10 blocks (PRUNE_LOCK_BUFFER) that will not be pruned before the best block.

Co-authored-by: Luke Dashjr <luke-jr+git@utopios.org>

This is a partial backport of core#21726
https://github.com/bitcoin/bitcoin/pull/21726/commits/2561823531c25e1510c107eb41de944b00444ce0

Test Plan

ninja all check-all

Event Timeline

PiRK requested review of this revision.May 2 2024, 12:20
Fabien requested changes to this revision.May 2 2024, 19:49
Fabien added a subscriber: Fabien.
Fabien added inline comments.
src/node/blockstorage.h
243 ↗(On Diff #47573)

it's never called ?

This revision now requires changes to proceed.May 2 2024, 19:49

move unused updateprunelock function to the next diff

This revision is now accepted and ready to land.May 3 2024, 08:07