Skip to content

migrate to tlv for invoice body#3693

Merged
Roasbeef merged 8 commits intolightningnetwork:masterfrom
cfromknecht:tlv-invoice
Nov 26, 2019
Merged

migrate to tlv for invoice body#3693
Roasbeef merged 8 commits intolightningnetwork:masterfrom
cfromknecht:tlv-invoice

Conversation

@cfromknecht
Copy link
Contributor

@cfromknecht cfromknecht commented Nov 8, 2019

Builds on #3685

This PR migrates our invoices to use TLV for their bodies. In the process we add feature vectors and payment addrs to make way for our mpp series. The unused receipt field is ultimately dropped from the db and the rpc calls. Finally, invoices are now populated with an empty set of features, which will not appear on payment requests until a non-zero number of bits are initially set.

@wpaulino wpaulino removed their request for review November 8, 2019 22:13
@Roasbeef Roasbeef added database Related to the database/storage of LND enhancement Improvements to existing features / behaviour migration P2 should be fixed if one has time payments Related to invoices/payments labels Nov 9, 2019
Copy link
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.

First pass

@cfromknecht cfromknecht force-pushed the tlv-invoice branch 3 times, most recently from 59bec21 to c685d51 Compare November 13, 2019 00:45
@joostjager
Copy link
Contributor

Build generates a diff in go.mod

Copy link
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.

Tested upgrading from 0.8.0-beta to this branch. This is the ListInvoices diff. Seems not ok

image

@cfromknecht
Copy link
Contributor Author

This is the ListInvoices diff.

Looked into this, the channeldb.Invoice struct was still using invoice.Terms.State for encode decode. Fixed in latest commit by pointing it to i.State and removing the old field.

Build generates a diff in go.mod

also fixed, a log.Error in migtest caused it to import the prometheus log. it has not been replaced with t.Fatalf

@cfromknecht cfromknecht force-pushed the tlv-invoice branch 3 times, most recently from 0ebc88e to 2ba8cc3 Compare November 20, 2019 02:18
@cfromknecht
Copy link
Contributor Author

@joostjager @Roasbeef @halseth reverted to prior pr and touched up for another review. ended up using joost's suggestion of passing through the htlc bytes directly, which shaved 200+ lines off the diff

Copy link
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.

Looking better with htlc pass through.

Copy link
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.

LGTM

Copy link
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 📴

@cfromknecht cfromknecht force-pushed the tlv-invoice branch 3 times, most recently from ecdf974 to 1cd1a93 Compare November 21, 2019 22:34
These will allow us to serialize invoice features bits without double
encoding the length.
Instead of allocating a byte slice to read in each htlc's raw TLV
stream, use a LimitReader to truncate the stream to the proper length.
This commit restructures an invoice's ContractTerms to better encompass
the restrictions placed on settling. For instance, the final ctlv delta
and invoice expiry are moved from the main invoice body (where
additional metadata is stored). Additionally, it moves the State field
outside of the terms since it is rather metadata about the invoice
instead of any terms offered to the sender in the payment request.
Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

LGTM 📯

Latest diff on my node just shows the reciept field being removed between versions (diff'ing calls to ListInvoices) 👍

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 enhancement Improvements to existing features / behaviour migration P2 should be fixed if one has time payments Related to invoices/payments

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants