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 construction vectors #2906

Conversation

arik-so
Copy link
Contributor

@arik-so arik-so commented Feb 21, 2024

Non-polluting replacement for 2899. Would appreciate a concept ACK prior to undrafting, thanks!

If the methodology for constructing variable-length onions for Trampoline employed in the last commit of this PR is acceptable, it will inform an upstream refactor of #2756 pertaining to the Trampoline onion packet struct type.

Copy link

coderabbitai bot commented Feb 21, 2024

Important

Auto Review Skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository.

To trigger a single review, invoke the @coderabbitai review command.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@codecov-commenter
Copy link

codecov-commenter commented Feb 21, 2024

Codecov Report

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

Project coverage is 89.47%. Comparing base (68d5e88) to head (52039a2).

Files Patch % Lines
lightning/src/ln/onion_utils.rs 0.00% 16 Missing ⚠️
lightning/src/ln/msgs.rs 88.88% 0 Missing and 1 partial ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2906      +/-   ##
==========================================
- Coverage   89.47%   89.47%   -0.01%     
==========================================
  Files         117      117              
  Lines       95148    95189      +41     
  Branches    95148    95189      +41     
==========================================
+ Hits        85138    85172      +34     
- Misses       7787     7794       +7     
  Partials     2223     2223              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -1688,13 +1688,22 @@ mod fuzzy_internal_msgs {
amt_to_forward: u64,
outgoing_cltv_value: u32,
},
// This should only be used for nested Trampoline onions
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wait, so we're gonna read an onion then it'll say trampoline packet then we'll read exactly this enum variant? Shouldn't we do this as a separate struct instead cause we know what we're gonna read?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, I believe I had a comment on the previous PR pointing out an alternative approach, which I will resurface

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, this is the external onion, where the receive hop may or may not contain an inner trampoline onion. So I'm not quite sure why we'd use a separate struct altogether.

Receive {
payment_data: Option<FinalOnionHopData>,
payment_metadata: Option<Vec<u8>>,
keysend_preimage: Option<PaymentPreimage>,
custom_tlvs: Vec<(u64, Vec<u8>)>,
sender_intended_htlc_amt_msat: u64,
cltv_expiry_height: u32,
trampoline_packet: Option<crate::onion_message::packet::Packet>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we go ahead and decode the inner onion here instead of storing it as the raw bytes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No strong opinions on my end. I think not needing to decode it until we actually support routing incoming trampolines doesn't make much of a difference in terms of utility, but saves on deserialization complexity.

But also totally see the benefit of just deserializing it.

@arik-so arik-so mentioned this pull request Mar 6, 2024
30 tasks
@arik-so arik-so force-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch 4 times, most recently from 5f8ebaa to a401fae Compare March 22, 2024 01:04
@@ -1706,6 +1713,15 @@ mod fuzzy_internal_msgs {
sender_intended_htlc_amt_msat: u64,
cltv_expiry_height: u32,
},
#[allow(unused)]
// This should only be used for nested Trampoline onions
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a decision on if we can swap this for a wholly separate enum? It seems strange that we have invalid states here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, I switched it out. Seems to be working.

@arik-so arik-so force-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch from a401fae to 45e131f Compare March 22, 2024 17:22
@arik-so arik-so marked this pull request as ready for review March 22, 2024 17:23
@arik-so arik-so force-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch 2 times, most recently from 9493c28 to a5e0921 Compare March 22, 2024 18:02
@arik-so
Copy link
Contributor Author

arik-so commented Mar 22, 2024

This PR requires a couple allow(unused)s due to the methods being only called in tests. I hope these are few enough that it can stand on its own.

@arik-so arik-so force-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch from a5e0921 to 671a009 Compare March 22, 2024 19:53
outgoing_node_id: PublicKey,
},
#[allow(unused)]
Receive {
Copy link
Collaborator

Choose a reason for hiding this comment

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

IMO we shouldn't support this and should only support the blinded path receive variant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not the legacy receive mechanism, but where the final node understands Trampoline.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Mmm, right, I was a bit confused. I'm not sure we have a need to support this either, though. We really only care about the trampoline -> blinded path case because that's what all of BOLT12 (and async payments) will do, and less code is less code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can remove this scenario, but I do need it for interop testing.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean we can interop test only a subset, anyway? I imagine this variant may never make it into the BOLTs anyway, if we move towards blinded-path-recipients-everywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can definitely interop only a subset, but having the least complex scenario for reference is helpful initially. This scenario is also the one described in the test vectors.

@arik-so arik-so force-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch 2 times, most recently from 32044ca to 3e56abe Compare March 27, 2024 07:01
@arik-so arik-so force-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch from 3e56abe to 52039a2 Compare March 27, 2024 07:42

use crate::io;
use crate::prelude::*;
use core::default::Default;
use bitcoin::hashes::hex::FromHex;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: import out of order

@valentinewallace valentinewallace merged commit beef584 into lightningdevkit:main Mar 27, 2024
13 of 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