mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:50:37 +00:00
WIP: kernel: add prune locks and target pruning #36857
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36857
Loading…
Reference in a new issue
No description provided.
Delete branch "kernel-prune-locks-and-target"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This adds more of the pruning API discussed in #35627:
btck_block_manager_update_prune_lockandbtck_block_manager_delete_prune_lockkeep blocks at and above a height until the application deletes the lock. Like the node's prune locks, they are held in memory, so an application sets them again after a restart before it prunes.btck_block_manager_prune_to_targetdeletes the oldest block files until usage, with room for the next allocation, is below a target. It keeps the same blocks asbtck_block_manager_prune_up_to_height. Unlike-prune, the target has no minimum, and pruning doesn't wait for the chain to reach a minimum height.Target pruning uses
BeginManualPrune.BeginTargetPruneonly proceeds after a new block file is allocated, and the periodic flush during block processing already consumes that, so it would never prune.Names the buffer
FindFilesToPrunekeeps below a target. The kernel uses it to tell whether a flush would help.Based on #36856. Draft until it is merged.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
A summary of reviews will appear here.
LLM Linter (✨ experimental)
Possible places where comparison-specific test macros should replace generic comparisons:
src/test/kernel/test_kernel.cpp:BOOST_CHECK_THROW(BlockManagerOptions(context, data_dir, blocks_dir), std::runtime_error)→ PreferBOOST_CHECK_EXCEPTIONwith aHasReasonpredicate checking the expected message.src/test/kernel/test_kernel.cpp:BOOST_CHECK_THROW(ChainstateManagerOptions(context, ""), std::runtime_error)andBOOST_CHECK_THROW(ChainstateManagerOptions(context, {nullptr, 0}), std::runtime_error)→ PreferBOOST_CHECK_EXCEPTIONwith predicates checking the expected messages.src/test/kernel/test_kernel.cpp:BOOST_CHECK_THROW(ChainMan(context, chainman_opts, blockman), std::runtime_error)(context mismatch and reused block manager) → PreferBOOST_CHECK_EXCEPTIONwith predicates checking the respective expected messages.src/test/kernel/test_kernel.cpp:BOOST_CHECK_THROW(blockman.ReadBlockSpentOutputs(chain.GetByHeight(1)), std::runtime_error)(both occurrences) → PreferBOOST_CHECK_EXCEPTIONwith a predicate checking the expected message.src/test/kernel/test_kernel.cpp:BOOST_CHECK_THROW(create_chainman(...), std::runtime_error)→ PreferBOOST_CHECK_EXCEPTIONwith a predicate checking the expected message.src/test/kernel/test_kernel.cpp:BOOST_CHECK_THROW(blockman.ReadBlockSpentOutputs(tip), std::runtime_error)→ PreferBOOST_CHECK_EXCEPTIONwith a predicate checking the expected message.2026-11-13 15:38:38
🟠 Minor · Kernel pruning lets storage exceptions escape the C API
Local database-write or filesystem-query failures can bypass the documented error returns from both kernel prune functions and may terminate an FFI caller, depending on its runtime.
Location:
src/kernel/bitcoinkernel.cpp:1354(head).🟠 Minor · Locks at height 0 or 1 still permit pruning those blocks
The new lock API can delete protected low-height blocks in test-only fast-prune layouts; the clamp is inherited, and production impact with normal block files is unconfirmed.
Location:
src/kernel/bitcoinkernel.cpp:1382(head).🔵 Suggestion · Target-pruning test misses stopping at the requested size
The kernel test's 16 MiB requests cannot reach their target because the buffer alone is 17 MiB, leaving target-based stopping untested.
Location:
src/test/kernel/test_kernel.cpp:1496(head).Review coverage was incomplete.
Reviewed:
3a95f31c1ee2· Review report · Previous reportspermalink