-
Notifications
You must be signed in to change notification settings - Fork 339
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
Large final onion payload fixes #2752
Large final onion payload fixes #2752
Conversation
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #2752 +/- ##
=======================================
Coverage 88.53% 88.54%
=======================================
Files 115 115
Lines 91011 91094 +83
Branches 91011 91094 +83
=======================================
+ Hits 80580 80659 +79
- Misses 8004 8013 +9
+ Partials 2427 2422 -5 ☔ View full report in Codecov by Sentry. |
d907b9a
to
020eb9a
Compare
020eb9a
to
6b8735b
Compare
610e876
to
5494ddd
Compare
Rebased to fix CI. |
lightning/src/ln/onion_utils.rs
Outdated
@@ -322,7 +322,15 @@ fn construct_onion_packet_with_init_noise<HD: Writeable, P: Packet>( | |||
let mut res = Vec::with_capacity(ONION_HOP_DATA_LEN * (payloads.len() - 1)); | |||
|
|||
let mut pos = 0; | |||
let mut packet_len_without_filler = 0; |
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.
This variable can be elided entirely, just use (or rename) pos
.
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.
Removed the extra var. It means we'll unnecessarily seek
in chacha on the final payload, though.
5494ddd
to
ca25ca6
Compare
We previously assumed that the final node's payload would be ~93 bytes, and had code to ensure that the filler encoded after that payload is not all 0s. Now with custom TLVs and metadata supported, the final node's payload may take up the entire onion packet, so we can't assume that there are 64 bytes of filler to check.
Ensure that if we call construct_onion_packet and friends where payloads are too large for the allotted packet length, we'll fail to construct. Previously, senders would happily construct invalid packets by array-shifting the final node's HMAC out of the packet when adding an intermediate onion layer, causing the receiver to error with "final payload provided for us as an intermediate node."
ca25ca6
to
80ba9ac
Compare
Rebased to fix CI. |
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.
Both fixes are exceedingly simple, and both feature a test which fails if the fix is reverted. Gonna go ahead and land this.
See the last two commit messages. We had a debug assertion and packet construction code that are no longer valid now that final payloads may be large due to custom TLVs/metadata. H/t to @Evanfeenstra for pointing out the latter, which helped uncover the former.
Based on #2739.