Skip to content

Trampoline onion construction vectors - #2906

Merged
valentinewallace merged 3 commits into
lightningdevkit:mainfrom
arik-so:arik/trampoline/2024-02-trampoline-onion-construction-vectors
Mar 27, 2024
Merged

Trampoline onion construction vectors#2906
valentinewallace merged 3 commits into
lightningdevkit:mainfrom
arik-so:arik/trampoline/2024-02-trampoline-onion-construction-vectors

Conversation

@arik-so

@arik-soarik-so commented Feb 21, 2024

Copy link
Copy Markdown
Contributor

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.

@coderabbitai

Copy link
Copy Markdown

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

codecov-commenter commented Feb 21, 2024

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 58.53659% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.47%. Comparing base (68d5e88) to head (52039a2).
⚠️ Report is 4283 commits behind head on main.

Files with missing linesPatch %Lines
lightning/src/ln/onion_utils.rs0.00%16 Missing ⚠️
lightning/src/ln/msgs.rs88.88%0 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #2906 +/- ##
==========================================
- Coverage 89.49% 89.47% -0.02% 
==========================================
Files 117 117 Lines 95148 95189 +41 Branches 95148 95189 +41 ==========================================
+ Hits 85152 85172 +20 - Misses 7780 7794 +14 - Partials 2216 2223 +7 

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment threadlightning/src/ln/msgs.rs Outdated
amt_to_forward: u64,
outgoing_cltv_value: u32,
},
// This should only be used for nested Trampoline onions

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
ContributorAuthor

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.

Comment threadlightning/src/ln/msgs.rs Outdated
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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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-soarik-so mentioned this pull request Mar 6, 2024
32 tasks
@arik-so
arik-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch 4 times, most recently from 5f8ebaa to a401faeCompareMarch 22, 2024 01:04
Comment threadlightning/src/ln/msgs.rs Outdated
cltv_expiry_height: u32,
},
#[allow(unused)]
// This should only be used for nested Trampoline onions

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

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-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch from a401fae to 45e131fCompareMarch 22, 2024 17:22
@arik-so
arik-so marked this pull request as ready for review March 22, 2024 17:23
@arik-so
arik-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch 2 times, most recently from 9493c28 to a5e0921CompareMarch 22, 2024 18:02
@arik-so

Copy link
Copy Markdown
ContributorAuthor

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-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch from a5e0921 to 671a009CompareMarch 22, 2024 19:53
Comment threadlightning/src/ln/msgs.rs Outdated
outgoing_node_id: PublicKey,
},
#[allow(unused)]
Receive {

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch 2 times, most recently from 32044ca to 3e56abeCompareMarch 27, 2024 07:01
@arik-so
arik-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch from 3e56abe to 52039a2CompareMarch 27, 2024 07:42
use crate::io;
use crate::prelude::*;
use core::default::Default;
use bitcoin::hashes::hex::FromHex;

Copy link
Copy Markdown
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:mainMar 27, 2024
Sign up for freeto 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

@arik-so@codecov-commenter@TheBlueMatt@valentinewallace
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Trampoline onion construction vectors by arik-so · Pull Request #2906 · lightningdevkit/rust-lightning · GitHub
Skip to content

Trampoline onion construction vectors - #2906

Merged
valentinewallace merged 3 commits into
lightningdevkit:mainfrom
arik-so:arik/trampoline/2024-02-trampoline-onion-construction-vectors
Mar 27, 2024
Merged

Trampoline onion construction vectors#2906
valentinewallace merged 3 commits into
lightningdevkit:mainfrom
arik-so:arik/trampoline/2024-02-trampoline-onion-construction-vectors

Conversation

@arik-so

@arik-soarik-so commented Feb 21, 2024

Copy link
Copy Markdown
Contributor

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.

@coderabbitai

Copy link
Copy Markdown

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

codecov-commenter commented Feb 21, 2024

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 58.53659% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.47%. Comparing base (68d5e88) to head (52039a2).
⚠️ Report is 4283 commits behind head on main.

Files with missing linesPatch %Lines
lightning/src/ln/onion_utils.rs0.00%16 Missing ⚠️
lightning/src/ln/msgs.rs88.88%0 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #2906 +/- ##
==========================================
- Coverage 89.49% 89.47% -0.02% 
==========================================
Files 117 117 Lines 95148 95189 +41 Branches 95148 95189 +41 ==========================================
+ Hits 85152 85172 +20 - Misses 7780 7794 +14 - Partials 2216 2223 +7 

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment threadlightning/src/ln/msgs.rs Outdated
amt_to_forward: u64,
outgoing_cltv_value: u32,
},
// This should only be used for nested Trampoline onions

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
ContributorAuthor

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.

Comment threadlightning/src/ln/msgs.rs Outdated
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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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-soarik-so mentioned this pull request Mar 6, 2024
32 tasks
@arik-so
arik-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch 4 times, most recently from 5f8ebaa to a401faeCompareMarch 22, 2024 01:04
Comment threadlightning/src/ln/msgs.rs Outdated
cltv_expiry_height: u32,
},
#[allow(unused)]
// This should only be used for nested Trampoline onions

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

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-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch from a401fae to 45e131fCompareMarch 22, 2024 17:22
@arik-so
arik-so marked this pull request as ready for review March 22, 2024 17:23
@arik-so
arik-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch 2 times, most recently from 9493c28 to a5e0921CompareMarch 22, 2024 18:02
@arik-so

Copy link
Copy Markdown
ContributorAuthor

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-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch from a5e0921 to 671a009CompareMarch 22, 2024 19:53
Comment threadlightning/src/ln/msgs.rs Outdated
outgoing_node_id: PublicKey,
},
#[allow(unused)]
Receive {

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch 2 times, most recently from 32044ca to 3e56abeCompareMarch 27, 2024 07:01
@arik-so
arik-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch from 3e56abe to 52039a2CompareMarch 27, 2024 07:42
use crate::io;
use crate::prelude::*;
use core::default::Default;
use bitcoin::hashes::hex::FromHex;

Copy link
Copy Markdown
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:mainMar 27, 2024
Sign up for freeto 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

@arik-so@codecov-commenter@TheBlueMatt@valentinewallace
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Trampoline onion construction vectors by arik-so · Pull Request #2906 · lightningdevkit/rust-lightning · GitHub
Skip to content

Trampoline onion construction vectors - #2906

Merged
valentinewallace merged 3 commits into
lightningdevkit:mainfrom
arik-so:arik/trampoline/2024-02-trampoline-onion-construction-vectors
Mar 27, 2024
Merged

Trampoline onion construction vectors#2906
valentinewallace merged 3 commits into
lightningdevkit:mainfrom
arik-so:arik/trampoline/2024-02-trampoline-onion-construction-vectors

Conversation

@arik-so

@arik-soarik-so commented Feb 21, 2024

Copy link
Copy Markdown
Contributor

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.

@coderabbitai

Copy link
Copy Markdown

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

codecov-commenter commented Feb 21, 2024

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 58.53659% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.47%. Comparing base (68d5e88) to head (52039a2).
⚠️ Report is 4283 commits behind head on main.

Files with missing linesPatch %Lines
lightning/src/ln/onion_utils.rs0.00%16 Missing ⚠️
lightning/src/ln/msgs.rs88.88%0 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #2906 +/- ##
==========================================
- Coverage 89.49% 89.47% -0.02% 
==========================================
Files 117 117 Lines 95148 95189 +41 Branches 95148 95189 +41 ==========================================
+ Hits 85152 85172 +20 - Misses 7780 7794 +14 - Partials 2216 2223 +7 

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment threadlightning/src/ln/msgs.rs Outdated
amt_to_forward: u64,
outgoing_cltv_value: u32,
},
// This should only be used for nested Trampoline onions

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
ContributorAuthor

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.

Comment threadlightning/src/ln/msgs.rs Outdated
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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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-soarik-so mentioned this pull request Mar 6, 2024
32 tasks
@arik-so
arik-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch 4 times, most recently from 5f8ebaa to a401faeCompareMarch 22, 2024 01:04
Comment threadlightning/src/ln/msgs.rs Outdated
cltv_expiry_height: u32,
},
#[allow(unused)]
// This should only be used for nested Trampoline onions

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

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-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch from a401fae to 45e131fCompareMarch 22, 2024 17:22
@arik-so
arik-so marked this pull request as ready for review March 22, 2024 17:23
@arik-so
arik-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch 2 times, most recently from 9493c28 to a5e0921CompareMarch 22, 2024 18:02
@arik-so

Copy link
Copy Markdown
ContributorAuthor

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-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch from a5e0921 to 671a009CompareMarch 22, 2024 19:53
Comment threadlightning/src/ln/msgs.rs Outdated
outgoing_node_id: PublicKey,
},
#[allow(unused)]
Receive {

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch 2 times, most recently from 32044ca to 3e56abeCompareMarch 27, 2024 07:01
@arik-so
arik-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch from 3e56abe to 52039a2CompareMarch 27, 2024 07:42
use crate::io;
use crate::prelude::*;
use core::default::Default;
use bitcoin::hashes::hex::FromHex;

Copy link
Copy Markdown
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:mainMar 27, 2024
Sign up for freeto 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

@arik-so@codecov-commenter@TheBlueMatt@valentinewallace
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Trampoline onion construction vectors by arik-so · Pull Request #2906 · lightningdevkit/rust-lightning · GitHub
Skip to content

Trampoline onion construction vectors - #2906

Merged
valentinewallace merged 3 commits into
lightningdevkit:mainfrom
arik-so:arik/trampoline/2024-02-trampoline-onion-construction-vectors
Mar 27, 2024
Merged

Trampoline onion construction vectors#2906
valentinewallace merged 3 commits into
lightningdevkit:mainfrom
arik-so:arik/trampoline/2024-02-trampoline-onion-construction-vectors

Conversation

@arik-so

@arik-soarik-so commented Feb 21, 2024

Copy link
Copy Markdown
Contributor

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.

@coderabbitai

Copy link
Copy Markdown

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

codecov-commenter commented Feb 21, 2024

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 58.53659% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.47%. Comparing base (68d5e88) to head (52039a2).
⚠️ Report is 4283 commits behind head on main.

Files with missing linesPatch %Lines
lightning/src/ln/onion_utils.rs0.00%16 Missing ⚠️
lightning/src/ln/msgs.rs88.88%0 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #2906 +/- ##
==========================================
- Coverage 89.49% 89.47% -0.02% 
==========================================
Files 117 117 Lines 95148 95189 +41 Branches 95148 95189 +41 ==========================================
+ Hits 85152 85172 +20 - Misses 7780 7794 +14 - Partials 2216 2223 +7 

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment threadlightning/src/ln/msgs.rs Outdated
amt_to_forward: u64,
outgoing_cltv_value: u32,
},
// This should only be used for nested Trampoline onions

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
ContributorAuthor

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.

Comment threadlightning/src/ln/msgs.rs Outdated
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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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-soarik-so mentioned this pull request Mar 6, 2024
32 tasks
@arik-so
arik-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch 4 times, most recently from 5f8ebaa to a401faeCompareMarch 22, 2024 01:04
Comment threadlightning/src/ln/msgs.rs Outdated
cltv_expiry_height: u32,
},
#[allow(unused)]
// This should only be used for nested Trampoline onions

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

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-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch from a401fae to 45e131fCompareMarch 22, 2024 17:22
@arik-so
arik-so marked this pull request as ready for review March 22, 2024 17:23
@arik-so
arik-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch 2 times, most recently from 9493c28 to a5e0921CompareMarch 22, 2024 18:02
@arik-so

Copy link
Copy Markdown
ContributorAuthor

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-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch from a5e0921 to 671a009CompareMarch 22, 2024 19:53
Comment threadlightning/src/ln/msgs.rs Outdated
outgoing_node_id: PublicKey,
},
#[allow(unused)]
Receive {

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch 2 times, most recently from 32044ca to 3e56abeCompareMarch 27, 2024 07:01
@arik-so
arik-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch from 3e56abe to 52039a2CompareMarch 27, 2024 07:42
use crate::io;
use crate::prelude::*;
use core::default::Default;
use bitcoin::hashes::hex::FromHex;

Copy link
Copy Markdown
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:mainMar 27, 2024
Sign up for freeto 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

@arik-so@codecov-commenter@TheBlueMatt@valentinewallace
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' Trampoline onion construction vectors by arik-so · Pull Request #2906 · lightningdevkit/rust-lightning · GitHub
Skip to content

Trampoline onion construction vectors - #2906

Merged
valentinewallace merged 3 commits into
lightningdevkit:mainfrom
arik-so:arik/trampoline/2024-02-trampoline-onion-construction-vectors
Mar 27, 2024
Merged

Trampoline onion construction vectors#2906
valentinewallace merged 3 commits into
lightningdevkit:mainfrom
arik-so:arik/trampoline/2024-02-trampoline-onion-construction-vectors

Conversation

@arik-so

@arik-soarik-so commented Feb 21, 2024

Copy link
Copy Markdown
Contributor

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.

@coderabbitai

Copy link
Copy Markdown

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

codecov-commenter commented Feb 21, 2024

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 58.53659% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.47%. Comparing base (68d5e88) to head (52039a2).
⚠️ Report is 4283 commits behind head on main.

Files with missing linesPatch %Lines
lightning/src/ln/onion_utils.rs0.00%16 Missing ⚠️
lightning/src/ln/msgs.rs88.88%0 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #2906 +/- ##
==========================================
- Coverage 89.49% 89.47% -0.02% 
==========================================
Files 117 117 Lines 95148 95189 +41 Branches 95148 95189 +41 ==========================================
+ Hits 85152 85172 +20 - Misses 7780 7794 +14 - Partials 2216 2223 +7 

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment threadlightning/src/ln/msgs.rs Outdated
amt_to_forward: u64,
outgoing_cltv_value: u32,
},
// This should only be used for nested Trampoline onions

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
ContributorAuthor

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.

Comment threadlightning/src/ln/msgs.rs Outdated
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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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-soarik-so mentioned this pull request Mar 6, 2024
32 tasks
@arik-so
arik-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch 4 times, most recently from 5f8ebaa to a401faeCompareMarch 22, 2024 01:04
Comment threadlightning/src/ln/msgs.rs Outdated
cltv_expiry_height: u32,
},
#[allow(unused)]
// This should only be used for nested Trampoline onions

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

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-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch from a401fae to 45e131fCompareMarch 22, 2024 17:22
@arik-so
arik-so marked this pull request as ready for review March 22, 2024 17:23
@arik-so
arik-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch 2 times, most recently from 9493c28 to a5e0921CompareMarch 22, 2024 18:02
@arik-so

Copy link
Copy Markdown
ContributorAuthor

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-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch from a5e0921 to 671a009CompareMarch 22, 2024 19:53
Comment threadlightning/src/ln/msgs.rs Outdated
outgoing_node_id: PublicKey,
},
#[allow(unused)]
Receive {

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch 2 times, most recently from 32044ca to 3e56abeCompareMarch 27, 2024 07:01
@arik-so
arik-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch from 3e56abe to 52039a2CompareMarch 27, 2024 07:42
use crate::io;
use crate::prelude::*;
use core::default::Default;
use bitcoin::hashes::hex::FromHex;

Copy link
Copy Markdown
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:mainMar 27, 2024
Sign up for freeto 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

@arik-so@codecov-commenter@TheBlueMatt@valentinewallace
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Trampoline onion construction vectors by arik-so · Pull Request #2906 · lightningdevkit/rust-lightning · GitHub
Skip to content

Trampoline onion construction vectors - #2906

Merged
valentinewallace merged 3 commits into
lightningdevkit:mainfrom
arik-so:arik/trampoline/2024-02-trampoline-onion-construction-vectors
Mar 27, 2024
Merged

Trampoline onion construction vectors#2906
valentinewallace merged 3 commits into
lightningdevkit:mainfrom
arik-so:arik/trampoline/2024-02-trampoline-onion-construction-vectors

Conversation

@arik-so

@arik-soarik-so commented Feb 21, 2024

Copy link
Copy Markdown
Contributor

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.

@coderabbitai

Copy link
Copy Markdown

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

codecov-commenter commented Feb 21, 2024

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 58.53659% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.47%. Comparing base (68d5e88) to head (52039a2).
⚠️ Report is 4283 commits behind head on main.

Files with missing linesPatch %Lines
lightning/src/ln/onion_utils.rs0.00%16 Missing ⚠️
lightning/src/ln/msgs.rs88.88%0 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #2906 +/- ##
==========================================
- Coverage 89.49% 89.47% -0.02% 
==========================================
Files 117 117 Lines 95148 95189 +41 Branches 95148 95189 +41 ==========================================
+ Hits 85152 85172 +20 - Misses 7780 7794 +14 - Partials 2216 2223 +7 

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment threadlightning/src/ln/msgs.rs Outdated
amt_to_forward: u64,
outgoing_cltv_value: u32,
},
// This should only be used for nested Trampoline onions

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
ContributorAuthor

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.

Comment threadlightning/src/ln/msgs.rs Outdated
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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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-soarik-so mentioned this pull request Mar 6, 2024
32 tasks
@arik-so
arik-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch 4 times, most recently from 5f8ebaa to a401faeCompareMarch 22, 2024 01:04
Comment threadlightning/src/ln/msgs.rs Outdated
cltv_expiry_height: u32,
},
#[allow(unused)]
// This should only be used for nested Trampoline onions

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

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-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch from a401fae to 45e131fCompareMarch 22, 2024 17:22
@arik-so
arik-so marked this pull request as ready for review March 22, 2024 17:23
@arik-so
arik-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch 2 times, most recently from 9493c28 to a5e0921CompareMarch 22, 2024 18:02
@arik-so

Copy link
Copy Markdown
ContributorAuthor

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-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch from a5e0921 to 671a009CompareMarch 22, 2024 19:53
Comment threadlightning/src/ln/msgs.rs Outdated
outgoing_node_id: PublicKey,
},
#[allow(unused)]
Receive {

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch 2 times, most recently from 32044ca to 3e56abeCompareMarch 27, 2024 07:01
@arik-so
arik-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch from 3e56abe to 52039a2CompareMarch 27, 2024 07:42
use crate::io;
use crate::prelude::*;
use core::default::Default;
use bitcoin::hashes::hex::FromHex;

Copy link
Copy Markdown
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:mainMar 27, 2024
Sign up for freeto 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

@arik-so@codecov-commenter@TheBlueMatt@valentinewallace
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); Trampoline onion construction vectors by arik-so · Pull Request #2906 · lightningdevkit/rust-lightning · GitHub
Skip to content

Trampoline onion construction vectors - #2906

Merged
valentinewallace merged 3 commits into
lightningdevkit:mainfrom
arik-so:arik/trampoline/2024-02-trampoline-onion-construction-vectors
Mar 27, 2024
Merged

Trampoline onion construction vectors#2906
valentinewallace merged 3 commits into
lightningdevkit:mainfrom
arik-so:arik/trampoline/2024-02-trampoline-onion-construction-vectors

Conversation

@arik-so

@arik-soarik-so commented Feb 21, 2024

Copy link
Copy Markdown
Contributor

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.

@coderabbitai

Copy link
Copy Markdown

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

codecov-commenter commented Feb 21, 2024

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 58.53659% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.47%. Comparing base (68d5e88) to head (52039a2).
⚠️ Report is 4283 commits behind head on main.

Files with missing linesPatch %Lines
lightning/src/ln/onion_utils.rs0.00%16 Missing ⚠️
lightning/src/ln/msgs.rs88.88%0 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #2906 +/- ##
==========================================
- Coverage 89.49% 89.47% -0.02% 
==========================================
Files 117 117 Lines 95148 95189 +41 Branches 95148 95189 +41 ==========================================
+ Hits 85152 85172 +20 - Misses 7780 7794 +14 - Partials 2216 2223 +7 

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment threadlightning/src/ln/msgs.rs Outdated
amt_to_forward: u64,
outgoing_cltv_value: u32,
},
// This should only be used for nested Trampoline onions

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
ContributorAuthor

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.

Comment threadlightning/src/ln/msgs.rs Outdated
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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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-soarik-so mentioned this pull request Mar 6, 2024
32 tasks
@arik-so
arik-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch 4 times, most recently from 5f8ebaa to a401faeCompareMarch 22, 2024 01:04
Comment threadlightning/src/ln/msgs.rs Outdated
cltv_expiry_height: u32,
},
#[allow(unused)]
// This should only be used for nested Trampoline onions

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

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-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch from a401fae to 45e131fCompareMarch 22, 2024 17:22
@arik-so
arik-so marked this pull request as ready for review March 22, 2024 17:23
@arik-so
arik-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch 2 times, most recently from 9493c28 to a5e0921CompareMarch 22, 2024 18:02
@arik-so

Copy link
Copy Markdown
ContributorAuthor

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-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch from a5e0921 to 671a009CompareMarch 22, 2024 19:53
Comment threadlightning/src/ln/msgs.rs Outdated
outgoing_node_id: PublicKey,
},
#[allow(unused)]
Receive {

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
ContributorAuthor

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-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch 2 times, most recently from 32044ca to 3e56abeCompareMarch 27, 2024 07:01
@arik-so
arik-soforce-pushed the arik/trampoline/2024-02-trampoline-onion-construction-vectors branch from 3e56abe to 52039a2CompareMarch 27, 2024 07:42
use crate::io;
use crate::prelude::*;
use core::default::Default;
use bitcoin::hashes::hex::FromHex;

Copy link
Copy Markdown
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:mainMar 27, 2024
Sign up for freeto 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

@arik-so@codecov-commenter@TheBlueMatt@valentinewallace