Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

arik-so
Copy link
Contributor

@arik-so arik-so commented Apr 19, 2024

Implement deserialization using LengthReadable.

Comment on lines 1870 to 1875
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;
Copy link
Collaborator

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>>?

Copy link
Contributor Author

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?

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a 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?

@arik-so arik-so mentioned this pull request Apr 22, 2024
29 tasks
@arik-so arik-so marked this pull request as ready for review April 22, 2024 23:17
@arik-so arik-so force-pushed the arik/trampoline/2024-04-trampoline-onion-deserialization branch from 25fffeb to 1fd3b34 Compare April 24, 2024 02:09
@codecov-commenter
Copy link

codecov-commenter commented Apr 24, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 90.24%. Comparing base (ac9a2c8) to head (325d93b).
Report is 52 commits behind head on main.

Files Patch % Lines
lightning/src/ln/msgs.rs 80.00% 0 Missing and 5 partials ⚠️

❗ 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.
📢 Have feedback on the report? Share it here.

@arik-so arik-so force-pushed the arik/trampoline/2024-04-trampoline-onion-deserialization branch from 1fd3b34 to 091cc6d Compare April 24, 2024 05:13
@arik-so arik-so force-pushed the arik/trampoline/2024-04-trampoline-onion-deserialization branch from 091cc6d to 325d93b Compare April 24, 2024 05:24
Comment on lines +1864 to +1865
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);
Copy link
Collaborator

Choose a reason for hiding this comment

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

as usize as u64 :)

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.

None yet

3 participants