-
Notifications
You must be signed in to change notification settings - Fork 374
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
Trampoline Onion Deserialization #3006
Trampoline Onion Deserialization #3006
Conversation
lightning/src/ln/msgs.rs
Outdated
while read_idx < hop_data_len { | ||
let mut read_buffer = [0; READ_BUFFER_SIZE]; | ||
let read_amt = cmp::min(hop_data_len - read_idx, READ_BUFFER_SIZE); | ||
r.read_exact(&mut read_buffer[..read_amt])?; | ||
hop_data.extend_from_slice(&read_buffer[..read_amt]); | ||
read_idx += read_amt; |
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 we just use WithoutLength<Vec<u8>>
?
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.
To clarify, you mean using WithoutLength with some sort of length-limiting mechanism like read_exact
? Such that it doesn't run over into reading the HMAC?
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.
Why is this draft?
25fffeb
to
1fd3b34
Compare
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #3006 +/- ##
==========================================
+ Coverage 89.42% 91.47% +2.04%
==========================================
Files 117 118 +1
Lines 96290 109654 +13364
Branches 96290 109654 +13364
==========================================
+ Hits 86109 100307 +14198
+ Misses 7962 6970 -992
- Partials 2219 2377 +158 ☔ View full report in Codecov by Sentry. |
091cc6d
to
325d93b
Compare
lightning/src/ln/msgs.rs
Outdated
let hop_data_len = r.total_bytes().saturating_sub(66) as usize; // 1 (version) + 33 (pubkey) + 32 (HMAC) = 66 | ||
let mut rd = FixedLengthReader::new(r, hop_data_len as u64); |
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.
as usize as u64
:)
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.
jesus christ, I'm sorry. That was next-level stupid
325d93b
to
98a926f
Compare
Implement deserialization using LengthReadable.