-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[htlcnotifier 4/4]: lnrpc: Add HTLC Event Subscription #3848
[htlcnotifier 4/4]: lnrpc: Add HTLC Event Subscription #3848
Conversation
aff9bb4
to
a8cdea4
Compare
5edad82
to
680aaae
Compare
62ea380
to
8988ee8
Compare
54b1e9b
to
4403e4c
Compare
a89412e
to
b7f9e46
Compare
Rebased to address some merge conflicts, ready for a look @cfromknecht @joostjager :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only a few questions about quitting left.
Tested using https://github.com/carlaKC/lndwrap to monitor a three node network. Looks good 👍
lnrpc/routerrpc/router_server.go
Outdated
@@ -167,6 +170,7 @@ func (s *Server) Start() error { | |||
// | |||
// NOTE: This is part of the lnrpc.SubServer interface. | |||
func (s *Server) Stop() error { | |||
close(s.quit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need a waitgroup too, to wait for completion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Offline discussion about this, no reason for subscriptions not to be wait grouped (I thought there could be some grpc magic in the background). Added wait group for routerrpc subserver + trackPayment
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want to add sync.Once
here? o/w calling Stop()
multiple times will panic
b7f9e46
to
f6b5b32
Compare
lnrpc/routerrpc/router_server.go
Outdated
@@ -449,6 +454,9 @@ func (s *Server) trackPayment(paymentHash lntypes.Hash, | |||
} | |||
} | |||
|
|||
s.wg.Add(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still this feels a bit strange. Normally we add to the waitgroup right before we start the goroutine. In this case, grpc started the goroutine already, so are we too late here? I don't know the answer really, but maybe it doesn't make sense after all to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the router server level, adding this wait group means that we don't consider the server to be stopped before all the subscriptions have received the quit signal. So I think that adds something, although all the other subservers are shutting down fine without it, so also unsure.
|
||
// The amount of the outgoing htlc. | ||
uint64 outgoing_amt_msat = 4; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a reason for not exposing payment hash? perhaps i'm just forgetting something that was already decided on this front
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we discussed it in the previous notifier PRs, wanted to force people towards identifying htlcs by incoming/outgoing circuit keys rather than payment hash, since it's not a unique identifier. If it's there, chances are people with use it as a uuid. It's specifically a concern here since forwards need to be matched with settles/fails, and doing so with payment hash could go very wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense, i think that's a reasonable assumption 👍
lnrpc/routerrpc/router_server.go
Outdated
@@ -167,6 +170,7 @@ func (s *Server) Start() error { | |||
// | |||
// NOTE: This is part of the lnrpc.SubServer interface. | |||
func (s *Server) Stop() error { | |||
close(s.quit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want to add sync.Once
here? o/w calling Stop()
multiple times will panic
Add SubscribeHtlcEvents to RouterBackend in preparation for the addition of a HtlcNotifier stream.
f6b5b32
to
891a9fd
Compare
891a9fd
to
0a5b918
Compare
@joostjager re-requesting to make sure approval still stands. Removed wait group (see comment) and converted timestamps to ns. |
Yes approval still stands. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🏄♂️
|
||
// The amount of the outgoing htlc. | ||
uint64 outgoing_amt_msat = 4; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense, i think that's a reasonable assumption 👍
Last push build, so must have missed the travis build check merge in some werid order. Fixed in #4105. |
This PR is change 4 of 4 proposed to add a htlc event notifier to lnd.
1:
#38432:
#38443:
#37814: This PR
This PR adds a
htlcnotifier
subscription torouterrpc
:Fixes #3420