Skip to content

multi: implement latest variable sized EOB proposal#38

Merged
Roasbeef merged 18 commits intolightningnetwork:masterfrom
Roasbeef:variable-eob
Aug 8, 2019
Merged

multi: implement latest variable sized EOB proposal#38
Roasbeef merged 18 commits intolightningnetwork:masterfrom
Roasbeef:variable-eob

Conversation

@Roasbeef
Copy link
Member

@Roasbeef Roasbeef commented Jul 4, 2019

This picks up where #31, #33, and #36 left off. It implements the latest version of lightning/bolts#619. The only thing wrong with this PR atm is that it fails the EOB JSON test included in the latest spec PR, while passing end-to-end tests within the same implementation.

@Roasbeef
Copy link
Member Author

Fixed some issues mapping the JSON test vectors, we now match up with the spec's test vectors!

@Roasbeef
Copy link
Member Author

Roasbeef commented Aug 6, 2019

PTAL @cfromknecht

(won't build until the TLV PR in lnd is merged)

@Roasbeef
Copy link
Member Author

Roasbeef commented Aug 7, 2019

Rebased now to the latest version of lnd that has the tlv package merged.

Copy link
Contributor

@cfromknecht cfromknecht left a comment

Choose a reason for hiding this comment

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

pretty straight forward, overall diff is much smaller than i anticipated!

cdecker and others added 17 commits August 8, 2019 15:03
We'll be encoding to and decoding from a variable length byte-slice
once we complete the multi-hop proposal.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
…frames

Since we want to use multiple former per-hop-payloads as a single
payload, we want to differentiate the notion of a frame from a
payload, since the latter can be now be made up of multiple frames.

Signed-off-by: Christian Decker <@cdecker>
HopPayload represents the raw, unparsed payload, from which the
HopData can be parsed. The sphinx code internally only handles
HopPayload, and the `HopData()` method can be used to parse and return
the HopData. This completes the transition to HopPayload.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This is the central commit in this whole series, it modifies the
right- and left- shifts to account for multi-frame payloads and it
modifies the filler generation code to generate multi-frame fillers if
the payload requires it.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This is a simple test that create a 5 hop onion, and the third hop
gets a payload that spans 2 frames.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This should make testing a lot easier, since we can just have a bunch of these
sitting in the repo and test them.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
In this commit, we move the HopData struct back into path.go. Along the
way, we remove its old HMAC field (since it's now in the hop payload),
and also restore its Decode method for later use.
In this commit, we add a new constructor to abstract away the details of
the hop payload framing from the caller. This new function accepts the
hop data, as well as optional EOB bytes. We'll then map these two pieces
of data into a single hop payload by appending the EOB bytes to the
serialized hop data.
Rather than mutate the underlying realm byte, we'll now expose two
methods to the caller: one for the "external" realm, and one of the
realm that we'll encode in the payload.
In this commit, we remove the HopData field from the OnionHop struct as
it's no longer needed since we can obtain the HopData via the HopData()
method of the HopPayload struct. Additinoally, we also now return the
set of unused payload bytes after the HopData encoding, we call these
the EOB or extra onion blobs.

With this distinction we now provide the caller of ProcessOnionPacket
with the forwarding instructions, then the left over EOB bytes. These
EOB bytes will then be interpreted using a TLV format or any other
arbitrary framing system.
In this commit, we make the jump from the prior fixed sized frame
payloads, to the latest variable sized format. The main change is that
now we no longer need to pack all the payloads into a fixed frame size,
adding padding. Instead, for the new TLV format, we'll now use a var-int
to signal the length of the payload.

In the process, we lift the Realm field from the HopPayload struct into
the HopData struct. We do this as the new TLV payload has no realm
field, and it's instead used to signal the existence of the legacy
payload format.
We no longer have the concept of frames, so the old test no longer applies.
@Roasbeef
Copy link
Member Author

Roasbeef commented Aug 8, 2019

PTAL @cfromknecht

Copy link
Contributor

@cfromknecht cfromknecht left a comment

Choose a reason for hiding this comment

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

LGTM 🥓

@Roasbeef Roasbeef merged commit 0c0c9db into lightningnetwork:master Aug 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants