-
Notifications
You must be signed in to change notification settings - Fork 400
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
Clean up create_onion_keys_callback_generic
#3668
base: main
Are you sure you want to change the base?
Clean up create_onion_keys_callback_generic
#3668
Conversation
👋 Thanks for assigning @arik-so as a reviewer! |
🔔 1st Reminder Hey @valentinewallace! This PR has been waiting for your review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how strongly we feel about tests passing in intermediate commits blocking PRs. Feel free to land IMO
👋 The first review has been submitted! Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer. |
lightning/src/ln/onion_utils.rs
Outdated
) | ||
.expect("Route we used spontaneously grew invalid keys in the middle of it?"); | ||
// if we have Trampoline hops, the blinded hops are part of the inner Trampoline onion | ||
let nontrampoline_bp = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not a blinding_point, it's the blinded_tail. Also, you think it makes sense to unify the terminology between non_trampoline_ and/or outer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, but there's no inner/outer if there's no trampoline?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, I guess that's fair. Do switch it to _bt
though, or, preferably, _blinded_tail
.
c77c1ed
to
51f8cb7
Compare
Oops, forgot about this one. Rebased and addressed comments. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3668 +/- ##
=======================================
Coverage 89.11% 89.11%
=======================================
Files 156 156
Lines 123514 123477 -37
Branches 123514 123477 -37
=======================================
- Hits 110066 110035 -31
+ Misses 10765 10763 -2
+ Partials 2683 2679 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There's no reason for anything outside of `onion_utils` to call an `_inner` method, so it shouldn't be pub.
51f8cb7
to
d26733b
Compare
Rebased and went ahead and squashed. |
07fa3b3
to
1014f6f
Compare
Onion keys construction can only fail if we have a key which is the inverse of a hash containing a public key which we generated (even indirectly). Because we prefer to panic if our RNG creates an insecure key (as it indicates operating is incredibly unsafe), we thus don't actually need to return an error from `construct_onion_keys_generic_callback`, which we clean up here.
1014f6f
to
f1a0ca9
Compare
The onion keys building logic is rather ancient and predates the `-> impl Trait` syntax in Rust, and thus used a callback. Here we move it to an `impl Iterator` which is much Rustier and cleans up the code a bit.
Now that `create_onion_keys_generic` returns an iterator rather than relying on a callback, making `process_onion_failure_inner` chain the non-trampoline and trampoline iterators is trivial. We do so here, avoiding the extra vec allocation.
f1a0ca9
to
ed0a525
Compare
It should return an iterator, not rely on callbacks (I think it predates
impl Iterator
lol) and doesn't need to return aResult
.