Skip to content

channeldb+rpcserver: expose legacy payments as multi-path payments - #3499

Merged
Roasbeef merged 9 commits into
lightningnetwork:masterfrom
cfromknecht:mpp-payments-rpc
Nov 22, 2019
Merged

channeldb+rpcserver: expose legacy payments as multi-path payments#3499
Roasbeef merged 9 commits into
lightningnetwork:masterfrom
cfromknecht:mpp-payments-rpc

Conversation

@cfromknecht

@cfromknecht cfromknecht commented Sep 12, 2019

Copy link
Copy Markdown
Contributor

Builds on #3442

This PR extends the ListPayments, RouterRPC.SendPayment, and RouterRPC.TrackPayment to include an experimental field for displaying HTLC attempts for a given payment. This will us to display multiple HTLCs when MPP is fully integrated. Legacy payments will have at most one attempt, and we simply convert them into a more generic MPPayment struct after loading from disk.

In the future we will perform a migration to convert the legacy on-disk format into real MPP payments on disk, but this allows us to fleshing out the API before the internal work is completed.

Comment thread channeldb/payments.go Outdated
Comment thread channeldb/payments.go Outdated
Comment thread rpcserver.go Outdated
Comment thread channeldb/mp_payment.go Outdated
Comment thread channeldb/mp_payment.go Outdated
Comment thread lnrpc/rpc.proto Outdated
Comment thread channeldb/mp_payment.go Outdated
Comment thread channeldb/payments.go Outdated
Comment thread lnrpc/rpc.proto Outdated
Comment thread lnrpc/rpc.proto Outdated
@cfromknecht
cfromknecht force-pushed the mpp-payments-rpc branch 3 times, most recently from 24852d6 to 0369eb7 Compare September 16, 2019 18:54

@halseth halseth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I really like the limited scope of this PR! Makes it easy to review, and it is a great first step :)

Gave it a high level look, looks more or less good to me, but will need to see it in tandem with upcoming MPP PRs to make sure things fit 👍

Comment thread channeldb/payments.go Outdated
Comment thread lnrpc/rpc.proto Outdated
@Roasbeef Roasbeef added routing database Related to the database/storage of LND P2 should be fixed if one has time rpc Related to the RPC interface amp and removed routing labels Oct 3, 2019
Comment thread channeldb/mp_payment.go Outdated
Comment thread channeldb/mp_payment.go Outdated

@Roasbeef Roasbeef left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solid base groundwork towards multi-pathing all the things 👍

Comment thread lnrpc/rpc.proto Outdated
Comment thread lnrpc/rpc.proto Outdated
Comment thread cmd/lncli/types.go Outdated

@Roasbeef Roasbeef left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about the PaymentStatus call in the router sub-server?

@cfromknecht cfromknecht added this to the 0.9.0 milestone Nov 2, 2019
@cfromknecht
cfromknecht force-pushed the mpp-payments-rpc branch 2 times, most recently from 5ce2ebc to b1db05a Compare November 2, 2019 03:09
@cfromknecht

cfromknecht commented Nov 2, 2019

Copy link
Copy Markdown
Contributor Author

What about the PaymentStatus call in the router sub-server?

Last few commits now add the HTLC attempts to PaymentStatus

I rebased everything over #3442, which also allowed me test that the MPP record is being set properly in the new sendtoroute itests. This actually pointed out a bug in the test where we would send before receiving the node ann, causing us to downgrade to legacy payments for some of the htlcs. That bug has been fixed in #3442, and here we extend the itest with additional checks on the listpayments rpc.

@cfromknecht
cfromknecht force-pushed the mpp-payments-rpc branch 2 times, most recently from 6b01397 to 36798d3 Compare November 2, 2019 21:17

@joostjager joostjager left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice approach to change internal data structures, but not yet the db.

Main question is the payment-level FailureReason enum on the htlc level.

Comment thread .golangci.yml Outdated
Comment thread channeldb/mp_payment.go Outdated
Comment thread channeldb/payments.go Outdated
Comment thread rpcserver.go Outdated
Comment thread lnrpc/rpc.proto Outdated
Comment thread routing/control_tower.go Outdated
Comment thread channeldb/payments.go Outdated
Comment thread channeldb/mp_payment.go Outdated
Comment thread lnrpc/routerrpc/router_backend.go Outdated
@joostjager joostjager changed the title channeldb+rcpserver: expose legacy payments as mutli-path payments channeldb+rpcserver: expose legacy payments as mutli-path payments Nov 6, 2019
@joostjager joostjager changed the title channeldb+rpcserver: expose legacy payments as mutli-path payments channeldb+rpcserver: expose legacy payments as multi-path payments Nov 6, 2019

@halseth halseth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is very close, no major comments :)

Comment thread channeldb/mp_payment.go Outdated
Comment thread channeldb/mp_payment.go Outdated
Comment thread channeldb/payments.go Outdated
Comment thread lnrpc/rpc.proto Outdated
Comment thread rpcserver.go Outdated
Comment thread routing/control_tower.go Outdated
Comment thread routing/control_tower.go Outdated

@halseth halseth left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 😱

Comment thread channeldb/mp_payment.go Outdated
Comment thread channeldb/payments.go Outdated
Comment thread channeldb/payments.go Outdated
Comment thread channeldb/payment_control.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: would be nice if these channeldb changes could get their own commit

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i attempted to do so originally, but it ended up causing more code shuffling than it was worth. the extraction code ends up being duplicated and move around, the tests end up double testing various aspects, etc over 4 commits. so i squashed it all into one since it's i found it easier to just look at the whole change

Comment thread lnrpc/routerrpc/router_server.go Outdated
Comment thread lnrpc/routerrpc/router_server.go Outdated
Comment thread channeldb/mp_payment.go Outdated
Comment thread channeldb/mp_payment.go Outdated
Comment thread channeldb/payments.go Outdated
Comment thread lnrpc/rpc.proto Outdated
Comment thread lnrpc/routerrpc/router_backend.go Outdated
Comment thread routing/control_tower_test.go Outdated
Preliminary step to exposing PaymentPreimage() as a method that can be
shared between legacy payments and mutli-path payments.
This commit modifies the FetchPayment method to return MPPayment structs
converted from the legacy on-disk format. This allows us to attach the
HTLCs to the events given to clients subscribing to the outcome of an
HTLC.

This commit also bubbles up to the routerrpc/router_server, by
populating HTLCAttempts in the response and extracting the legacy route
field from the HTLCAttempts.

@joostjager joostjager left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Only wondering how relevant this change is now that we aim for single shot mpp first?

case htlc.Failure != nil && result.FailureReason ==
channeldb.FailureReasonPaymentDetails:

legacyRoute = &htlc.Route

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this better than just an if statement? Or at least use fallthrough?

Comment thread channeldb/mp_payment.go
Route route.Route

// AttemptTime is the time at which this HTLC was attempted.
AttemptTime time.Time

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field doesn't seem to be set at all in this pr. Remove and introduce in the follow up?

@joostjager joostjager left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed offline, proceeding in parallel with single shot mpp

@Roasbeef
Roasbeef merged commit 6f9fcfa into lightningnetwork:master Nov 22, 2019
@cfromknecht
cfromknecht deleted the mpp-payments-rpc branch November 22, 2019 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

amp database Related to the database/storage of LND P2 should be fixed if one has time rpc Related to the RPC interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants