HomePhabricator

blockstorage: Add prune locks to BlockManager

Description

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

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D16096

Details

Provenance
Fabian Jahr <fjahr@protonmail.com>Authored on May 13 2021, 17:13
PiRKCommitted on Fri, May 3, 08:34
PiRKPushed on Fri, May 3, 08:34
Reviewer
Restricted Project
Differential Revision
D16096: blockstorage: Add prune locks to BlockManager
Parents
rABC7d2f38d2cad8: [ecash-agora] Add `AgoraOneshot`
Branches
Unknown
Tags
Unknown