-
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
htlcswitch+invoices: allow settling invoices via multi-path payments #3415
Conversation
5f1966a
to
45a27a3
Compare
9e0b20f
to
a4b9fa2
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.
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
9c81a17
to
c03862c
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.
so far so good, changes coming together :) should be pretty close to being able to do a full e2e!
833c532
to
9a8df74
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.
did another pass, just one minor nit. is it time to remove debug commits?
c77e8ed
to
894850a
Compare
debug commits removed |
a68de27
to
a96f9a4
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 🍾
@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. |
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.
All aboard the mpptrain! 🚂 LGTM
@@ -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: "+ |
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.
Shouldn't we use either signed or unsigned types for block height everywhere?
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.
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. |
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.
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?
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 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).
@@ -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) { |
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 the file changed during review. The above comment meant to be here: "I think it's important to test cases where settlement may fail".
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.
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) |
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.
Can this ever happen though?
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 don't think so. Perhaps we will do invoice cleanup in the future?
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
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
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.