Skip to content

Commit a7959a6

Browse files
committed
chain_bridge: use GetBestBlock instead of GetInfo
Because GetInfo now (lnd 0.19) waits for all subsystems to be synced to the latest block, we might get into a deadlock situation if we call GetInfo downstream of an aux component call (which might happen in case of a force closure): Observed deadlock case: force closure of custom channel -> lnd detects force closure during block beat -> calls into aux component to resolve -> resolution involves registering a transfer in the chain porter -> chain porter gets CurrentHeight from chain bridge -> chain bridge calls into lnd's GetInfo -> GetInfo is blocked because the block beat sync is still waiting for the resolution of the aux channel. By diverting the call to the chain backend directly, we resolve this circular dependency.
1 parent c134b75 commit a7959a6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

chain_bridge.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,12 @@ func (l *LndRpcChainBridge) VerifyBlock(ctx context.Context,
184184

185185
// CurrentHeight return the current height of the main chain.
186186
func (l *LndRpcChainBridge) CurrentHeight(ctx context.Context) (uint32, error) {
187-
info, err := l.lnd.Client.GetInfo(ctx)
187+
_, bestHeight, err := l.lnd.ChainKit.GetBestBlock(ctx)
188188
if err != nil {
189189
return 0, fmt.Errorf("unable to grab block height: %w", err)
190190
}
191191

192-
return info.BlockHeight, nil
192+
return uint32(bestHeight), nil
193193
}
194194

195195
// GetBlockTimestamp returns the timestamp of the block at the given height.

0 commit comments

Comments
 (0)