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
base: main
Are you sure you want to change the base?
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% 90.24% +0.81%
==========================================
Files 117 118 +1
Lines 96290 105246 +8956
Branches 96290 105246 +8956
==========================================
+ Hits 86109 94979 +8870
- Misses 7962 8100 +138
+ Partials 2219 2167 -52 ☔ View full report in Codecov by Sentry. |
1fd3b34
to
091cc6d
Compare
091cc6d
to
325d93b
Compare
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
:)
Implement deserialization using LengthReadable.