Skip to content
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

htlcswitch+invoices: allow settling invoices via multi-path payments #3415

Merged
merged 4 commits into from Dec 11, 2019

Conversation

@joostjager
Copy link
Collaborator

joostjager commented Aug 19, 2019

Before this PR, MPP fields in the payload were parsed but not processed. This PR adds processing of those fields in the invoice registry. This means that it is now possible to settle an invoice using multiple partial payments.

@joostjager joostjager requested review from cfromknecht and Roasbeef as code owners Aug 19, 2019
@joostjager joostjager changed the title htlcswitch+invoices: multi-path payments [wip] [no review] htlcswitch+invoices: multi-path payments [wip] [don't review] Aug 23, 2019
@joostjager joostjager removed request for Roasbeef and cfromknecht Aug 23, 2019
@joostjager joostjager force-pushed the joostjager:mpp branch from 564776e to 6455de2 Aug 23, 2019
@joostjager joostjager force-pushed the joostjager:mpp branch 3 times, most recently from 5f1966a to 45a27a3 Aug 30, 2019
@joostjager joostjager force-pushed the joostjager:mpp branch 2 times, most recently from 9e0b20f to a4b9fa2 Oct 11, 2019
@joostjager joostjager added this to WIP in v0.9.0-beta via automation Oct 23, 2019
@joostjager joostjager self-assigned this Oct 23, 2019
Copy link
Collaborator

cfromknecht left a comment

just did a quick pass to refresh my memory of this pr. i know you said don't review, but just leaving some initial comments tho i'm sure the underlying pr has changed a bit

invoices/invoiceregistry.go Outdated Show resolved Hide resolved
invoices/invoiceregistry.go Outdated Show resolved Hide resolved
invoices/invoiceregistry.go Outdated Show resolved Hide resolved
cmd/lncli/commands.go Outdated Show resolved Hide resolved
cmd/lncli/commands.go Outdated Show resolved Hide resolved
cmd/lncli/commands.go Outdated Show resolved Hide resolved
lnrpc/rpc.proto Outdated Show resolved Hide resolved
@joostjager joostjager force-pushed the joostjager:mpp branch from a4b9fa2 to 442fd44 Nov 5, 2019
@joostjager joostjager changed the title htlcswitch+invoices: multi-path payments [wip] [don't review] htlcswitch+invoices: allow settling invoices via multi-path payments Nov 5, 2019
@joostjager joostjager force-pushed the joostjager:mpp branch from 442fd44 to 009bf64 Nov 5, 2019
@joostjager joostjager added this to the 0.9.0 milestone Nov 5, 2019
@joostjager joostjager added the v0.9.0 label Nov 5, 2019
@joostjager joostjager force-pushed the joostjager:mpp branch 3 times, most recently from 9c81a17 to c03862c Nov 6, 2019
Copy link
Collaborator

cfromknecht left a comment

so far so good, changes coming together :) should be pretty close to being able to do a full e2e!

invoices/invoiceregistry.go Outdated Show resolved Hide resolved
invoices/invoiceregistry.go Outdated Show resolved Hide resolved
invoices/invoiceregistry.go Outdated Show resolved Hide resolved
invoices/invoiceregistry.go Outdated Show resolved Hide resolved
invoices/invoiceregistry.go Outdated Show resolved Hide resolved
@halseth halseth self-requested a review Nov 7, 2019
@joostjager joostjager force-pushed the joostjager:mpp branch 2 times, most recently from 833c532 to 9a8df74 Nov 12, 2019
@joostjager joostjager force-pushed the joostjager:mpp branch from 158eafb to e0295d5 Dec 10, 2019
Copy link
Collaborator

cfromknecht left a comment

did another pass, just one minor nit. is it time to remove debug commits?

invoices/invoiceregistry.go Outdated Show resolved Hide resolved
@joostjager joostjager force-pushed the joostjager:mpp branch 3 times, most recently from c77e8ed to 894850a Dec 10, 2019
@joostjager

This comment has been minimized.

Copy link
Collaborator Author

joostjager commented Dec 10, 2019

debug commits removed

@joostjager joostjager force-pushed the joostjager:mpp branch 2 times, most recently from a68de27 to a96f9a4 Dec 10, 2019
Copy link
Collaborator

cfromknecht left a comment

LGTM 🍾

@joostjager joostjager force-pushed the joostjager:mpp branch from a96f9a4 to a378a51 Dec 11, 2019
@joostjager

This comment has been minimized.

Copy link
Collaborator Author

joostjager commented Dec 11, 2019

@cfromknecht brought up the mpp timeout failure. Will address that in a follow up in coordination with @carlaKC.

Without this error returned, senders that actually support sending multiple shards and interpret this new failure will not function optimally. But seems acceptable for where we are right now.

Copy link
Collaborator

halseth left a comment

All aboard the mpptrain! 🚂 LGTM

queue/priority_queue.go Show resolved Hide resolved
invoices/invoiceregistry_test.go Show resolved Hide resolved
@joostjager joostjager moved this from Needs Review to Approved in v0.9.0-beta Dec 11, 2019
@joostjager joostjager force-pushed the joostjager:mpp branch from a378a51 to 24814be Dec 11, 2019
queue/priority_queue.go Show resolved Hide resolved
invoices/clock_test.go Outdated Show resolved Hide resolved
invoices/clock_test.go Outdated Show resolved Hide resolved
invoices/clock_test.go Outdated Show resolved Hide resolved
invoices/clock_test.go Show resolved Hide resolved
invoices/invoiceregistry.go Show resolved Hide resolved
invoices/invoiceregistry.go Show resolved Hide resolved
@@ -196,6 +259,29 @@ func (i *InvoiceRegistry) invoiceEventNotifier() {
i.singleNotificationClients[e.id] = e
}

// A new htlc came in for auto-release.
case event := <-i.htlcAutoReleaseChan:
log.Debugf("Scheduling auto-release for htlc: "+

This comment has been minimized.

Copy link
@bhandras

bhandras Dec 11, 2019

Collaborator

Shouldn't we use either signed or unsigned types for block height everywhere?

This comment has been minimized.

Copy link
@joostjager

joostjager Dec 11, 2019

Author Collaborator

Yes, that is inconsistent at the moment. But if you start changing, you will expand into many different areas and also replace one case by the other sometimes.

"time"
)

// testClock can be used in tests to mock time.

This comment has been minimized.

Copy link
@bhandras

bhandras Dec 11, 2019

Collaborator

Really nice! May I suggest you to extend clock.Clock interface and use that as a common ground instead? Maybe also move this test clock in that package such that others can use it?

This comment has been minimized.

Copy link
@joostjager

joostjager Dec 11, 2019

Author Collaborator

I don't want to delay this PR with a discussion on where to put that package/file. Given the time those took in past prs I'd rather avoid it (reference class forecasting).

invoices/invoiceregistry_test.go Show resolved Hide resolved
v0.9.0-beta automation moved this from Approved to Needs Review Dec 11, 2019
@@ -674,3 +693,85 @@ func (p *mockPayload) MultiPath() *record.MPP {
func (p *mockPayload) CustomRecords() hop.CustomRecordSet {
return make(hop.CustomRecordSet)
}

// TestSettleMpp tests settling of an invoice with multiple partial payments.
func TestSettleMpp(t *testing.T) {

This comment has been minimized.

Copy link
@bhandras

bhandras Dec 11, 2019

Collaborator

Looks like the file changed during review. The above comment meant to be here: "I think it's important to test cases where settlement may fail".

This comment has been minimized.

Copy link
@joostjager

joostjager Dec 11, 2019

Author Collaborator

There is a case where the partial payment times out. Which other cases do you mean? Of course the total number of possible test cases is large, but I tried to cover at least the ones that usually occur.

// resolution.
htlc, ok := invoice.Htlcs[key]
if !ok {
return fmt.Errorf("htlc %v not found", key)

This comment has been minimized.

Copy link
@bhandras

bhandras Dec 11, 2019

Collaborator

Can this ever happen though?

This comment has been minimized.

Copy link
@joostjager

joostjager Dec 11, 2019

Author Collaborator

I don't think so. Perhaps we will do invoice cleanup in the future?

bhandras and others added 3 commits Nov 22, 2019
This commit introduces PriorityQueue, which is a general, heap
based priority queue, and PriorityQueueItem which is an interface
that concrete priority queue items must implement.
This implementation is encapsulated, users do not need to use any
other package for full functionality.
PriorityQueue exports the usual public methids: Push, Pop, Top,
Empty and Len. For full documentaton consult the priority_queue.go,
for usage: priority_queue_test.go
@joostjager joostjager force-pushed the joostjager:mpp branch from 24814be to 4ee65ac Dec 11, 2019
@joostjager joostjager force-pushed the joostjager:mpp branch from 4ee65ac to b2f4385 Dec 11, 2019
@joostjager joostjager requested a review from bhandras Dec 11, 2019
Copy link
Collaborator

bhandras left a comment

LGTM

v0.9.0-beta automation moved this from Needs Review to Approved Dec 11, 2019
@joostjager joostjager merged commit 62dadff into lightningnetwork:master Dec 11, 2019
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.03%) to 62.215%
Details
v0.9.0-beta automation moved this from Approved to Done Dec 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.