lnrpc/chainrpc: surface re-org depth and Done over the chain notifier#10943
lnrpc/chainrpc: surface re-org depth and Done over the chain notifier#10943ellemouton wants to merge 3 commits into
Conversation
03d9901 to
a8baef0
Compare
🟠 PR Severity: HIGH
🟠 High (3 files)
🟢 Low (2 files)
AnalysisThe highest-severity files touched are under No bump conditions apply: only 4 non-generated files changed (well under the 20-file threshold), ~92 non-generated/non-doc lines changed (well under the 500-line threshold), and no critical packages (lnwallet, htlcswitch, contractcourt, sweep, etc.) are touched. Since this PR modifies a public RPC API surface (chainnotifier), it warrants review from someone familiar with the lnrpc API conventions and backward-compatibility concerns, consistent with HIGH severity. To override, add a |
a8baef0 to
188d227
Compare
Temporary replace onto the lnd branch that adds the reorg depth and Done events to the ChainNotifier proto (lightningnetwork/lnd#10943). Lands before the code change so each commit builds. Drop this once that lnd change is merged and tagged.
188d227 to
8b4da07
Compare
Temporary replace onto the lnd branch that adds the reorg depth and Done events to the ChainNotifier proto (lightningnetwork/lnd#10943). Lands before the code change so each commit builds. Drop this once that lnd change is merged and tagged.
|
@Roasbeef: review reminder |
42555ce to
d451363
Compare
Historical rescan matches that are already deeper than the reorg-safety limit never pass through the per-block finality sweep in ConnectTip. That sweep only signals Done for requests that mature at the connecting height, so callers waiting for finality can block forever. Signal Done while dispatching both confirmation and spend details when the event is already past the safety limit. Deliver Confirmed or Spend first to preserve event ordering.
The ChainNotifier confirmation and spend streams expose reorgs only as payload-less events and provide no terminal event when a request reaches the reorg-safety depth. Add a depth field to Reorg and a Done variant to both event oneofs. This is an additive protobuf change; the server begins emitting the new values in the following commit.
d451363 to
fd02a89
Compare
Forward confirmation reorg depth and explicit Done events through the ChainNotifier RPC streams. Spend reorg depth remains zero because the notifier does not track it internally. Historical registrations can make the primary confirmation or spend event ready at the same time as Done. Drain a ready primary event first so Done cannot overtake it across the separate buffered channels. Cover both RPC paths with ordering tests.
f4ef0e9 to
ed0a3dd
Compare
Summary
The
ChainNotifierconfirmation/spend gRPC streams currently drop two piecesof information that lnd already tracks internally:
ConfirmationEvent.NegativeConfcarries the depth as anint32, but the server discarded it and sent an emptyReorg{}.ConfirmationEvent.DoneandSpendEvent.Donefire once a watch reaches lnd's configured re-org-safetydepth, but the RPC server conveyed that only by closing the stream. A client
cannot distinguish normal completion from unrelated teardown that way.
This PR makes the notification lifecycle reversible and explicitly terminal:
Changes
already beyond the re-org-safety limit now receive
Doneimmediately aftertheir positive event. Without this, they can never be reached by the
per-block finality sweep and wait forever.
Reorg.depth, add a payload-lessDonemessage, and adddoneto theConfEventandSpendEventoneofs. These are additive wirechanges.
Donefor confirmation and spend streams. The server enforces positive-before-
Doneordering even if Go selects the terminal channel first when both areready.
and the complete positive/reorg/positive/Done lifecycle for both stream
types.
Semantics and compatibility
Donemeans the backend's configured re-org-safety boundary, not a claim ofconsensus-level finality.
0:SpendEvent.Reorgis currently a bareinternal signal and does not track depth.
clients can distinguish normal completion from stream failure.
Downstream adapter: lightninglabs/lndclient#283.
Validation
go test -tags=chainrpc ./lnrpc/chainrpc ./chainntnfsgo test -race -tags=chainrpc ./lnrpc/chainrpc ./chainntnfsmatrix on the pushed head.