-
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
routerrpc: async payment rpc #2973
routerrpc: async payment rpc #2973
Conversation
3aee088
to
25bc701
Compare
Shouldn't this be branched off of #2761? |
Yes, this is still wip. Should have added |
ecfdf21
to
17a98d4
Compare
Can be rebased now that #2761 is in. |
ed4fd68
to
3a60e31
Compare
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.
Awesome to see the latest changes! It was right to move subscription handling into routing
by moving the ControlTower
interface there; the separation is clean 👍
I also like the new APIs, they are easy to reason about.
routing/control_tower.go
Outdated
// succeeded, new subscriber is registered and will immediately receive | ||
// the succeeded status, this function sends out the succeeded | ||
// notification again to the same subscriber. | ||
p.hashMutex.Lock(string(paymentHash[:])) |
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.
looks like lock can acquired after DB transaction is over.
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.
The reason the lock needs to be acquired before the db transaction is to prevent a new subscription happening after the db transaction, but before notifyFinalEvent
, as is described in the comment above. Maybe I misunderstand you suggestion?
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.
From reading the comment that sounds alright though?
Payment status is updated to succeeded, new subscriber comes in and (acquire lock) retrieves succeed status and sends notification (release lock), this function (acquire lock) finds no one to send notification to (release lock).
Or is there another order of actions that require us to hold it while we update the DB?
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.
Updated code to only use a global lock. It indeed seems to be sufficient.
9d8603b
to
88dca29
Compare
@halseth ptal |
d9745ed
to
9e51fac
Compare
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 after removal pf last commit 👍
lnrpc/routerrpc/router_server.go
Outdated
if err != nil { | ||
log.Debugf("SendPayment async result for hash %x: %v", |
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.
Errorf
?
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.
Fixed using different log level for expected and unexpected errors.
71f1c03
to
74e4574
Compare
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 🔥
@@ -187,9 +192,12 @@ func (p *PaymentControl) RegisterAttempt(paymentHash lntypes.Hash, | |||
// duplicate payments to the same payment hash. The provided preimage is | |||
// atomically saved to the DB for record keeping. | |||
func (p *PaymentControl) Success(paymentHash lntypes.Hash, | |||
preimage lntypes.Preimage) error { | |||
preimage lntypes.Preimage) (*route.Route, error) { |
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.
To avoid having to do this change, one could instead provinde the route as a param to the Success
method in the routing ControlTower
.
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.
I am not sure if that is better. It puts a new requirement on the caller of ControlTower
.
p.subscribers[paymentHash], c, | ||
) | ||
|
||
return true, c, nil |
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.
Ok, this is much better now that we don't have to return this from the DB.
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.
It isn't new, I just restored code that I had previously. Do you mean it is better because the bool isn't set in the db tx?
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 💯not blocking, but we have been trying to remove all go-errors imports, and just use the std errors package. sometimes editors will mistakenly add that as the import automatically, since it is used in the integration tests to wrap errors.
74e4574
to
0f86c71
Compare
This commit lifts default setting up to the rpc server level, in line with other payment defaults.
Add missing parameters to routerrpc version of SendPayment.
This commit creates an empty shall for control tower in the routing package. It is a preparation for adding event notification.
Allows other sub-systems to subscribe to payment success and fail events.
Modify the routerrpc SendPayment api to asynchronous. This allows callers to pick up a payment after the rpc connection was lost or lnd was restarted.
This commit prepares lncli for moving over to routerrpc payment calls.
0f86c71
to
220c2be
Compare
This PR adds a new
SendPayment
payment call to therouterrpc
sub server. Notable changes:Configurable payment timeout (this is not to "cancel" htlcs in flight, which is impossible, but controls what the point is after which a new payment attempt isn't started anymore)
Fee limit can only be specified as an absolute value. There is no default anymore. Specifying a value of zero means that no fees may be paid. In that case, only a payment to a direct peer would succeed.
Only payment level failures are reported. This is currently limited to
timeout
andno_routes
, but will be extended in a follow up pr routerrpc: add more failure reasons and route hints #3156. The goal is to report terminal failures likepayment_hash_unknown
, but not to expose the result of the last payment attempt anymore.In addition to that, a new rpc call
TrackPayment
is added. UsingTrackPayment
an in-flight payment can be picked up after the rpc connection was lost on SendPayment. When #2762 is merged, this also allows picking up payments after a restart oflnd
.