mining: add getMemoryLoad() using BlockTemplateManager#120
Closed
Sjors wants to merge 11 commits into
Closed
Conversation
This was referenced Jun 24, 2026
Draft
6b17dc3 to
1dd1c78
Compare
Add BlockTemplateManager as an encapsulation that wraps BlockAssembler::CreateNewBlock(). Add a simple unit test that verifies that block template can be created via the block template manager.
Pass the parsed mining args to BlockTemplateManager at construction and expose them via GetInitBlockCreateOptions(), so the manager owns the init-time block create options instead of NodeContext.
Move SubmitBlockStateCatcher and SubmitBlock from miner.cpp into BlockTemplateManager as a member function. This groups block submission with block creation in the same class. The function uses m_chainman directly instead of taking it as a parameter.
Move mining tip lookup and block-template waiting helpers into BlockTemplateManager so the manager owns the template waiting flow, including the notification wait helpers used by waitNext.
Route the Mining interface's createNewBlock() through BlockTemplateManager::CreateNewTemplate() instead of constructing a BlockAssembler directly.
Use BlockTemplateManager directly for in-process RPC and test block template creation instead of going through the IPC Mining interface. This keeps RPC-created templates untracked and prevents process-static RPC caches from owning BlockTemplateImpl objects whose destructor reaches back into NodeContext during shutdown.
Add a fuzz target that creates block templates through BlockTemplateManager under fuzzed mining options and asserts a template is always produced.
IPC clients can hold on to block templates indefinately, which has the same impact as when the node holds a shared pointer to the CBlockTemplate. Because each template in turn tracks CTransactionRefs, transactions that are removed from the mempool will not have their memory cleared. This commit adds bookkeeping to the block template constructor and destructor that will let us track the resulting memory footprint. Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
Calculate the non-mempool memory footprint for template transaction references. Add bench logging to collect data on whether caching or simplified heuristics are needed, such as not checking for mempool presence.
1dd1c78 to
1350116
Compare
Allow IPC clients to inspect the amount of memory consumed by non-mempool transactions in blocks. Returns a MemoryLoad struct which can later be expanded to e.g. include a limit. Expand the interface_ipc.py test to demonstrate the behavior and to illustrate how clients can call destroy() to reduce memory pressure.
1350116 to
1178895
Compare
Owner
Author
|
I'm going to use this in bitcoin#33922. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Alternative to:
Based on: