mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:50:37 +00:00
WIP: kernel: let callers create the block manager #36854
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!36854
Loading…
Reference in a new issue
No description provided.
Delete branch "kernel-create-block-manager"
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?
The kernel creates its block storage inside
btck_chainstate_manager_create, configures it through the chainstate manager's options and reads blocks through the chainstate manager. Pruning (#35627) needs block storage that the caller can configure, keep and prune directly.This adds
btck_BlockManagerOptionsandbtck_BlockManager.btck_chainstate_manager_createtakes a block manager and keeps a shared reference to it, so either handle can be destroyed first. A block manager can be passed to only one chainstate manager, and a failed creation still uses it up unless the contexts differ.btck_block_readandbtck_block_spent_outputs_readtake the block manager, and block tree entries are valid for its lifetime, which can be longer than the chainstate manager's.Changes for callers:
btck_chainstate_manager_options_createno longer takes a blocks directory.btck_chainstate_manager_options_set_wipe_dbsis replaced bybtck_block_manager_options_update_wipe_block_tree_dbandbtck_chainstate_manager_options_update_wipe_chainstate_db. The block tree db is wiped when the block manager is created, and wiping it also wipes the chainstate db, which the old function required anyway.btck_chainstate_manager_options_update_block_tree_db_in_memorymoves to the block manager options.Based on #36739. Draft until it is merged. Feedback on the API is welcome in the meantime.
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.
Conflicts
Reviewers, this pull request conflicts with the following ones:
-Wunusedby fanquake)If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
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 that checks the failure message.src/test/kernel/test_kernel.cpp:BOOST_CHECK_THROW(ChainstateManagerOptions(context, ""), std::runtime_error)and the null-path equivalent → PreferBOOST_CHECK_EXCEPTIONwith aHasReasonpredicate.src/test/kernel/test_kernel.cpp:BOOST_CHECK_THROW(ChainMan(context, chainman_opts, blockman), std::runtime_error)for the context mismatch and already-used block manager → PreferBOOST_CHECK_EXCEPTIONwith aHasReasonpredicate.src/test/kernel/test_kernel.cpp:BOOST_CHECK_THROW(blockman.ReadBlockSpentOutputs(tip), std::runtime_error)→ PreferBOOST_CHECK_EXCEPTIONwith aHasReasonpredicate.2026-11-13 15:09:15
🟠 Minor · Discarding a wiping block manager loses the pending chainstate wipe
Discarding a disk-backed wiping block manager before attachment makes a populated datadir fail to reopen with defaults; no current in-tree caller producing this sequence was found.
Location:
src/kernel/bitcoinkernel.cpp:1361(head).🔵 Suggestion · One-use tests can pass through unrelated DB-lock failures
The new lifecycle assertions do not distinguish the documented consumption rules from context rejection or a live coins-database lock.
Location:
src/test/kernel/test_kernel.cpp:912(head).🔵 Suggestion · Independent data directories lack a persisted-state compatibility contract
The split options permit incompatible index and chainstate pairings without documenting the requirement; no current in-tree caller was found doing this, and the loader's unchecked snapshot assumption predates this PR.
Location:
src/kernel/bitcoinkernel.h:1392(head).🔵 Suggestion · Independent cache setters do not enforce a shared total
Setting only the chainstate total to 4 MiB leaves 5.5 MiB of combined configured caches, despite the header describing shares of the same total.
Location:
src/kernel/bitcoinkernel.cpp:1256(head).🔵 Suggestion · Lifetime reads retain an extra context owner
Neither lifetime test leaves BlockMan as the sole context owner, so the new post-chainstate read coverage does not isolate BlockMan's context ownership.
Location:
src/test/kernel/test_kernel.cpp:1246(head).🔵 Suggestion · Pruning restarts do not cover rejection with pruning disabled
The rewritten prune-mode guard retains a pre-existing coverage gap: pruning tests restart with pruning enabled, so they do not verify rejection of a pruned datadir reopened without pruning.
Location:
src/node/chainstate.cpp:57(head).Review coverage was incomplete.
Reviewed:
d26ba9d2e242· Review report · Previous reportspermalink