Review report

core: PR #36520

1 minor finding · 1 suggestion

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

Findings

Link

[minor] · std::out_of_range from getBlockHash bypasses wallet-load cleanup

A tip-height drop during in-process wallet loading can bypass cleanup, leaving the wallet marked as loading and retained by notification registration until restart.

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

Details and suggested fix

CWallet::AttachChain registers notifications before calling getHeight() and getBlockHash() under separate cs_main acquisitions. A concurrent authenticated invalidateblock can shorten the chain between those reads. The new std::out_of_range derives from std::logic_error, so LoadWalletInternal's std::runtime_error catch misses it. The RPC converts it to RPC_MISC_ERROR, but unwinding skips g_loading_wallet_set.erase, so retries report "Wallet already loading." LoadExisting also disconnects notifications only when AttachChain returns false. The proxy, wallet, and handler ownership therefore retains the failed wallet and its database without adding it to context.wallets. Use a std::runtime_error-derived exception so the existing load-error handling runs, and add unwind cleanup that disconnects notifications after releasing cs_wallet, since disconnection waits for the notification queue. Changing the exception type alone would still leave the registration retained. This race previously aborted the node; the incomplete recovery is new, and its occurrence in production remains unconfirmed.


Optional improvements

Link

[suggestion] · throwingNotifications covers only two of the six wrapped callbacks

throwingNotifications would miss a regression restoring direct calls in four forwarding methods because their inherited notification handlers never throw.

Location: src/test/interfaces_tests.cpp:208 (head).

Details and suggested fix

The two overrides exercise the shared Notify catch, but transactionAddedToMempool, transactionRemovedFromMempool, blockDisconnected, and chainStateFlushed retain the empty defaults from Chain::Notifications. Restoring a direct m_notifications->... call in any corresponding forwarder would therefore leave this test passing. Override the remaining four callbacks with counters that throw ipc::Exception, emit their events through m_node.validation_signals using valid fixture transaction, block, index, and locator payloads, then drain the queue and assert each counter. This covers each forwarder's use of Notify while preserving the intentional policy of catching only IPC exceptions.


Coverage details

Earlier concerns

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