Review report

core: PR #25665

๐ŸŸ  Major

Track the active union member (src/util/result.h:161, head)

A Result with no failure data is considered successful by operator bool(), but SuccessType is constructed later with placement new. If that construction throws, the Result base destructor runs and destroys an object whose lifetime never began. update() can also leave an invalid state after destroying an existing success value but before constructing its replacement. Track the active union member independently, or otherwise keep the object valid when construction or update throws.

๐ŸŸก Minor

Log the verification result on failure (src/kernel/bitcoinkernel.cpp:1147, head)

When VerifyLoadedChainstate fails or is interrupted, this branch logs ErrorString(load_result) instead of ErrorString(verify_result). Loading has already succeeded, so the load result does not contain the verification failure message. The kernel API therefore returns nullptr with a blank or unrelated diagnostic. Pass verify_result to ErrorString here.

Require an explicit error mapping during conversion (src/util/result.h:334, head)

When moving a failed result with ErrorType = void into a result with a typed ErrorType, this branch default-initializes the destination error. For example, converting a failed Result<int> to Result<int, FnError> yields FnError{}; in the test enum, that is ERR1, a specific error rather than a generic-failure sentinel. A caller branching on the typed error can therefore take a path unsupported by the source result. Require an explicit mapping or fallback, or define and enforce a generic-error sentinel contract for destination error types.

Require an rvalue for destructive Result conversion (src/util/result.h:216, head)

This constructor's constraint permits non-const lvalue Result sources, and its body unconditionally transfers their value and messages. Conversion between different Result specializations can therefore silently consume an lvalue source. For example, converting a Result holding unique_ptr<Derived> to one holding unique_ptr<Base> leaves the source moved-from. Constrain this conversion to rvalues so destructive transfer requires an explicit std::move.

Keep test setup assertions sensitive to interruption (src/test/util/setup_common.cpp:373, head)

LoadChainstate can return Interrupted as a successful InterruptResult payload, so Assert(load_result) passes even though loading did not complete. The same applies to verify_result. The helper can then set chainstateLoaded and continue setup with incomplete state, whereas the previous status == SUCCESS assertion rejected interruption. Assert that each successful result is also not interrupted.

๐Ÿ’ก Suggestion

Avoid copying message vectors when joining messages (src/util/messages.cpp:16, head)

The range expression creates initializer-list elements from messages.errors and messages.warnings by value, copying both vectors and their strings on each call. This adds avoidable work and allocations that grow with the accumulated messages. Iterate over the two vectors separately, or use references to them, to preserve the same errors-then-warnings output without copying.

Review coverage was incomplete. The adversarial review did not complete. The adversarial_glm review did not complete.