Review report

bitcoin/bitcoin: PR #36451

3 suggestions

Earlier concerns neither republished nor resolved: 1 suggestion. See the Run archive for their assessments.

Optional improvements

Link

[suggestion] · getblocktemplate retains a dead post-creation null check

The NotNull conversion leaves getblocktemplate's pre-existing, always-passing template null check in place while removing equivalent checks from the other mining RPCs.

Location: src/node/block_template_manager.h:51 (head).

Details and suggested fix

In src/rpc/mining.cpp:907-908, CreateNewTemplate supplies the assembler's fresh NotNullUniquePtr, and its rvalue conversion moves the non-null pointer into the cached std::unique_ptr. Remove the following CHECK_NONFATAL(block_template), as this PR does for generateBlocks and generateblock. The cache can remain nullable: its initial state forces creation through !pindexPrev, and pindexPrev is cleared before creation and set only after success, so failures force a retry. Keep CHECK_NONFATAL(pindexPrev) on the cache-use path. This is consistency cleanup, not a behavior fix.


Link

[suggestion] · waitNext reconstructs a NotNull guarantee discarded by the manager

Successful templates lose their NotNull type at WaitAndCreateNewBlock's return boundary, so waitNext reconstructs the guarantee with an asserting wrapper.

Location: src/node/interfaces.cpp:928 (head).

Details and suggested fix

WaitAndCreateNewBlock obtains a NotNullUniquePtr from CreateNewTemplate, but both successful returns convert it to std::unique_ptr; waitNext then wraps it in util::NotNull again. Return std::optional<util::NotNullUniquePtr<CBlockTemplate>> internally, use std::nullopt for interruption, shutdown, and timeout, and move *new_template into BlockTemplateImpl after the presence check. Update the manager's return-value comment accordingly. This preserves the interrupt reset and tip/fee conditions and leaves the IPC-facing waitNext result unchanged. The current code is correct; this trades a new, more verbose optional/NotNull pattern for preserving the success invariant across one internal call.


Link

[suggestion] · Pimpl conversions leave redundant <memory> includes

Four converted pimpl headers no longer use a <memory> facility directly, but still include it in addition to util/not_null.h.

Location: src/addrman.h:113 (head).

Details and suggested fix

The pimpl members were the last direct <memory> uses in src/addrman.h, src/node/txreconciliation.h, src/txrequest.h, and src/test/fuzz/util/check_globals.h. Remove those headers' direct #include <memory> lines. They now use util::NotNullUniquePtr, and util/not_null.h includes <memory> for that alias, so the definitions remain available. Keep <memory> in dbwrapper.h, whose iterator constructor still names std::unique_ptr, and in node/txdownloadman.h, which names std::shared_ptr. This is optional include cleanup; IWYU was not run.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.