Skip to content

single-shot, sender-side mpp via sendtoroute#3442

Merged
Roasbeef merged 11 commits into
lightningnetwork:masterfrom
cfromknecht:router-registry
Nov 5, 2019
Merged

single-shot, sender-side mpp via sendtoroute#3442
Roasbeef merged 11 commits into
lightningnetwork:masterfrom
cfromknecht:router-registry

Conversation

@cfromknecht
Copy link
Copy Markdown
Contributor

@cfromknecht cfromknecht commented Aug 30, 2019

This PR lays some more groundwork for our road to MPP payments in lnd. Here we add the ability to send MPP shards from the sender-side via SendToRoute, whose additional fields are properly encoded in the onion blob and delivered to the receiver.

Apart from verifying that mpp records are not received at intermediate hops, the receiver does not perform any additional validation of the actual fields contained within. The receiver side has been modified to deliver these values all the way down to the invoice registry, but they are not inspected. Thus, the receiver will process the payment as they would a traditional payment. The additional behavior to enforce the MPP fields will be added in #3415, at which point the behaviors will diverge.

For now, the integration tests have been expanded to cover the three send to route endpoints Lightning.SendToRoute, Lightning.SendToRouteSync, and RouterRPC.SendToRoute, as well as testing that each can properly pay with single MPP shards. Future changes will continue to expand the assertions as more pieces come into place.

Copy link
Copy Markdown
Contributor

@joostjager joostjager left a comment

Choose a reason for hiding this comment

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

I also experienced that the onion blob decryption code needs to be moved out of htlcswitch so that it can be used in cnct without a circular reference. Will we move that into htlcswitch/payload too?

Comment thread htlcswitch/payload/hop.go Outdated
Comment thread htlcswitch/payload/hop.go Outdated
@cfromknecht cfromknecht force-pushed the router-registry branch 7 times, most recently from d08300d to 0b70f6d Compare August 30, 2019 21:12
@cfromknecht
Copy link
Copy Markdown
Contributor Author

I also experienced that the onion blob decryption code needs to be moved out of htlcswitch so that it can be used in cnct without a circular reference. Will we move that into htlcswitch/payload too?

Discussed offline. Plan is to move decryption (HopIterator) into the hop package and replace with hop.Iterator

Comment thread lnrpc/routerrpc/router.proto Outdated
Comment thread htlcswitch/hop/payload.go
Comment thread htlcswitch/hop/payload.go
Comment thread record/mpp.go Outdated
@Roasbeef Roasbeef added enhancement Improvements to existing features / behaviour incomplete WIP PR, not fully finalized, but light review possible routing labels Sep 9, 2019
Comment thread lnrpc/routerrpc/router.proto 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.

This comment is a bit confusing, should say something like "the total amount in satoshis of the payment if this is a sub payment of smaller amount"? I don't know what the best way to put this..

Comment thread routing/route/route.go Outdated
@cfromknecht cfromknecht force-pushed the router-registry branch 2 times, most recently from a8001c5 to 28e9d02 Compare October 10, 2019 20:54
@cfromknecht cfromknecht force-pushed the router-registry branch 3 times, most recently from 2dcb941 to b94383e Compare October 15, 2019 07:42
@cfromknecht cfromknecht marked this pull request as ready for review October 15, 2019 09:13
@cfromknecht cfromknecht requested a review from Roasbeef as a code owner October 15, 2019 09:13
@cfromknecht cfromknecht changed the title mpp: rpc+router+htlcswitch single-shot sender-side mpp via sendtoroute Oct 31, 2019
@cfromknecht cfromknecht changed the title single-shot sender-side mpp via sendtoroute single-shot, sender-side mpp via sendtoroute Oct 31, 2019
@joostjager joostjager added this to the 0.9.0 milestone Oct 31, 2019
@cfromknecht
Copy link
Copy Markdown
Contributor Author

Also, PR desc is still empty.

@joostjager added

Copy link
Copy Markdown
Contributor

@joostjager joostjager left a comment

Choose a reason for hiding this comment

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

Ack on restructuring db to single tlv blob (also containing legacy payload fields) in a follow-up.

@halseth
Copy link
Copy Markdown
Contributor

halseth commented Nov 1, 2019

ACK on using single blob in follow-up. I still have opinions about not having the optional MPP record be its own field on the struct, but that we can discuss in the follow-up.

Copy link
Copy Markdown
Contributor

@halseth halseth left a comment

Choose a reason for hiding this comment

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

LGTM ✅

Comment thread lntest/itest/lnd_test.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.

Hm, when is the time to get rid of one of these RPCs?

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 wouldn't be opposed to deprecating the streaming version and telling people to switch to SendToRouteSync, or RouterRPC.SendToRoute if they don't mind dealing with breaking changes.

Comment thread lntest/itest/lnd_test.go Outdated
@Roasbeef
Copy link
Copy Markdown
Member

Roasbeef commented Nov 2, 2019

Needs a rebase! Then I think this is ready to land.

@cfromknecht
Copy link
Copy Markdown
Contributor Author

@Roasbeef rebased!

@cfromknecht cfromknecht force-pushed the router-registry branch 2 times, most recently from 3be2935 to 3b5185d Compare November 4, 2019 20:41
These encoders can be composed to create composite types without
incurring additional allocations that would be required to pass the
truncated types through the generic interface.
This commit also modifies the Router serialization to persist the MPP
struct when present, and properly restore it when loading from disk.
This commit add mpp_total_amt_msat and mpp_payment_addr to the Hop
message. Doing so enables users submitting mpp payments via rpc to
set these parameters for the destination. In addition, it will allow us
to display these fields in rpc responses.
This commit parses mpp_total_amt_msat and mpp_payment_addr from the
SendToRoute rpc and populates an MPP record on the internal hop
reprsentation. When the router goes to encode the onion packet, these
fields will be serialized for the destination. We also populate the mpp
fields when marshalling routes in rpc responses.
We already wait for all channels to open before creating the payment
requests.
In this commit, we refactor the testSingleHopSendToRoute test to support
table driven tests for various endpoints and payment types. Currently
only the main rpcserver's SendToRoute is tested, so we also add
support the SendToRouteSync and the routerrpc's SendToRoute.

The tests are also modified to have each endpoint perform a single-hop,
single-shot MPP payment. This asserts that the Hop messages are being
properly unmarshalled and that setting correctly yields a successful
payment. At the momemnt the receiver does not actually verify or use the
MPP fields presented in the onion, though this test will be expanded
later as those pieces are assembled.
@Roasbeef Roasbeef merged commit 7ecb713 into lightningnetwork:master Nov 5, 2019
@cfromknecht cfromknecht deleted the router-registry branch November 22, 2019 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

amp enhancement Improvements to existing features / behaviour routing spec

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants