However there's interdependency between them. Specifically, chanRouter depends on the current cc.chainViewinstance but calls to GetBlock might block indefinitely until the chainView is called to stop.
One situation where this is manifested is on the garbage_collect_link_nodes itest where a channel is opened between Alice and Dave and immediately after that Bob and Carol are restarted. It might be the case that Bob (or Carol) is in the middle of a GetBlock() call and on the remotewallet implementation that cashes out to a loop that is only returned from once the wallet is told to shutdown. But that only happens later in the server shutdown routine, so the wallet shutdown deadlocks.
Currently this is solved in the itest with a dummy Sleep call but ideally this should be solved either by performing subsystem shutdown in parallel (so that the wallet shutting down bubbles up an error to chanRouter) or by requiring the chainView methods to accept a context parameter, so that the caller itself can cancel them.
Sub-systems are shutdown concurrently: https://github.com/decred/dcrlnd/blob/29759788a0212a4777aac8a7bd0f4410a9a9b3a6/server.go#L1411
However there's interdependency between them. Specifically,
chanRouter
depends on the currentcc.chainView
instance but calls toGetBlock
might block indefinitely until thechainView
is called to stop.One situation where this is manifested is on the
garbage_collect_link_nodes
itest where a channel is opened between Alice and Dave and immediately after that Bob and Carol are restarted. It might be the case that Bob (or Carol) is in the middle of aGetBlock()
call and on theremotewallet
implementation that cashes out to a loop that is only returned from once the wallet is told to shutdown. But that only happens later in the server shutdown routine, so the wallet shutdown deadlocks.Currently this is solved in the itest with a dummy
Sleep
call but ideally this should be solved either by performing subsystem shutdown in parallel (so that the wallet shutting down bubbles up an error to chanRouter) or by requiring thechainView
methods to accept acontext
parameter, so that the caller itself can cancel them.