1 minor finding · 1 suggestion
Findings
[minor] · The new height exception leaves failed wallet loads subscribed
A height decrease during wallet attachment can return a load error while retaining the wallet's database lock until restart, and callbacks can advance its rescan checkpoint past unscanned blocks.
Location: src/node/interfaces.cpp:601 (head).
Details and suggested fix
AttachChain registers notifications before reading the tip height and hash under separate cs_main acquisitions. A concurrent authenticated invalidateblock RPC, or a reorg to a lower-height chain with more work, can invalidate that saved height despite cs_wallet being held. The new std::runtime_error bypasses LoadExisting and CreateNew's false-return cleanup; LoadWalletInternal catches it before AddWallet. The proxy and wallet retain each other through the handler, leaving the SQLite database open. unloadwallet cannot find the failed wallet, and retrying loadwallet cannot reopen its database until restart. The queued blockDisconnected callback also writes a best-block locator at the lowered tip. If historical scanning was needed, the next successful load can consequently skip that range unless the user runs rescanblockchain. Disconnect notifications on exceptional exits from both attachment callers, then rethrow. Do this after AttachChain releases cs_wallet, because disconnection waits for callbacks. Add a deterministic wallet test that throws after registration and checks that reloading succeeds. This interleaving has not been reproduced, and its production frequency is unconfirmed.
Optional improvements
[suggestion] · Notification tests do not enforce the selective exception policy
All throwing callbacks use ipc::Exception, so broadening Notify to catch std::runtime_error or std::exception would leave these assertions passing.
Location: src/test/interfaces_tests.cpp:207 (head).
Details and suggested fix
throwingNotifications checks that IPC failures are swallowed and delivery continues, but never requires a non-IPC exception to escape as Notify intends. Add a synchronous negative case using a local NodeContext whose own ValidationSignals uses util::ImmediateTaskRunner, then construct a chain with interfaces::MakeChain. Register a subscriber whose chainStateFlushed throws an ordinary std::runtime_error, and use BOOST_CHECK_THROW around ValidationSignals::ChainStateFlushed. The immediate runner invokes the proxy inline, so the test can enforce the selective catch without terminating the fixture's scheduler thread.