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

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
30 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 78.26087% with 5 lines in your changes are missing coverage. Please review.

Project coverage is 91.47%. Comparing base (ac9a2c8) to head (98a926f).
Report is 159 commits behind head on main.

Files Patch % Lines
lightning/src/ln/msgs.rs 78.26% 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%   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.
📢 Have feedback on the report? Share it here.

@arik-so arik-so force-pushed the arik/trampoline/2024-04-trampoline-onion-deserialization branch 2 times, most recently 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 :)

Copy link
Contributor Author

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

@arik-so arik-so force-pushed the arik/trampoline/2024-04-trampoline-onion-deserialization branch from 325d93b to 98a926f Compare May 21, 2024 00:32
@valentinewallace valentinewallace merged commit 2c71923 into lightningdevkit:main May 28, 2024
16 checks passed
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.

4 participants