What to Review
Plan
Introduce the Block Template Manager (#35675)
This PR introduces
node::BlockTemplateManagerand moves block template creation, submission, and mining wait helpers behind it.Block template requests from node components, along with other block-template-related operations, are now handled through this manager. Instead of keeping template state and helper functions spread across
NodeContext,miner.cpp, the mining interface, RPC, and tests, the manager owns the node's init-time mining options and exposes the methods callers need.This also avoids some redundant copies that previously happened when callers used the mining interface to create a block template and then retrieve the template data.
This keeps the IPC mining interface focused on IPC-facing mining objects, while RPC and tests use the block template manager directly.
Mempool: asynchronous mempool fee-rate diagram updates via validation interface (#34803)
This PR adds a validation signal for mempool mutations. The signal reports the old and new fee-rate diagrams for the clusters affected by each mutation.
Node: add block template manager and track
waitNextfee inflow (#35581)This PR includes the commits from the PRs above, plus a commit that enables fee-inflow detection for block templates using propagated mempool fee-rate diagram mutations.
This lets
WaitAndCreateNewBlockdetect mempool fee inflow more efficiently, without rebuilding a full block template every second. Another possible approach would be to query the mempool and txgraph directly, as discussed here:https://delvingbitcoin.org/t/determining-blocktemplate-fee-increase-using-fee-rate-diagram/2052/2
TODO
Remove remaining global states.
- https://github.com/bitcoin/bitcoin/blob/292ea0eb8982faef460c210bd4215d603f487463/src/rpc/mining.cpp#L776
- https://github.com/bitcoin/bitcoin/blob/292ea0eb8982faef460c210bd4215d603f487463/src/rpc/mining.cpp#L859-L861
- https://github.com/bitcoin/bitcoin/blob/292ea0eb8982faef460c210bd4215d603f487463/src/node/miner.h#L186-L189