Support HTLC interception by source channel#4338
Support HTLC interception by source channel#4338TheBlueMatt wants to merge 2 commits intolightningdevkit:mainfrom
Conversation
|
👋 Thanks for assigning @tnull as a reviewer! |
|
🔔 1st Reminder Hey @tnull! This PR has been waiting for your review. |
b793c1e to
79952e1
Compare
|
Rebased. |
79952e1 to
779fce3
Compare
tnull
left a comment
There was a problem hiding this comment.
Seems CI is very unhappy as this doesn't build currently.
|
👋 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. |
We jump through some hoops in order to pass a small list of objects to `forward_htlcs` on a per-channel basis rather than per-HTLC. Then, `forward_htlcs` builds a `PendingAddHTLCInfo` for each HTLC for insertion. Worse, in some `forward_htlcs` callsites we're actually starting with a `PendingAddHTLCInfo`, converting it to a tuple, then back inside `forward_htlcs`. Instead, here we just pass a list of built `PendingAddHTLCInfo`s to `forward_htlcs`, cleaning up a good bit of code and even avoiding an allocation of the HTLCs vec in many cases.
It may be useful in some situations to select HTLCs for interception based on the source channel in addition to the sink. Here we add the ability to do so by adding new flags to `HTLCInterceptionFlags`.
779fce3 to
0bf2200
Compare
|
Oops, silent conflict. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4338 +/- ##
=========================================
+ Coverage 0 86.11% +86.11%
=========================================
Files 0 156 +156
Lines 0 102606 +102606
Branches 0 102606 +102606
=========================================
+ Hits 0 88355 +88355
- Misses 0 11762 +11762
- Partials 0 2489 +2489
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
🔔 1st Reminder Hey @tnull! This PR has been waiting for your review. |
|
🔔 2nd Reminder Hey @tnull! This PR has been waiting for your review. |
elnosh
left a comment
There was a problem hiding this comment.
rustfmt is unhappy but code changes look good to me
| prev_user_channel_id, | ||
| forward_info, | ||
| }; | ||
| fn forward_htlcs<I: IntoIterator<Item = PendingAddHTLCInfo>>(&self, pending_forwards: I) { |
There was a problem hiding this comment.
now that this method takes PendingAddHTLCInfo, I think this comment: https://github.com/TheBlueMatt/rust-lightning/blob/77d3659d8af798c11750cb5826e45d29691dadd9/lightning/src/ln/channelmanager.rs#L455 can be removed
| chan.context.get_counterparty_node_id(), | ||
| chan.context.channel_id(), | ||
| chan.funding.get_funding_txo().unwrap(), | ||
| chan.context.get_user_id(), | ||
| chan.context.config().accept_underpaying_htlcs, | ||
| chan.context.should_announce(), |
There was a problem hiding this comment.
nit: this feels slightly more readable
let (
incoming_counterparty_node_id,
incoming_channel_id,
incoming_funding_txo,
incoming_user_channel_id,
incoming_accept_underpaying_htlcs,
incoming_chan_is_public,
) = match self.do_funded_channel_callback(
incoming_scid_alias,
|chan: &mut FundedChannel<SP>| {
(
chan.context.get_counterparty_node_id(),
chan.context.channel_id(),
chan.funding.get_funding_txo().unwrap(),
chan.context.get_user_id(),
chan.context.config().accept_underpaying_htlcs,
chan.context.should_announce(),
)
},
) {
Some(incoming_channel_details) => incoming_channel_details,
None => continue,
};
| /// public channel will instead generate an [`Event::HTLCIntercepted`] which must be handled | ||
| /// the same as any other intercepted HTLC. | ||
| /// | ||
| /// This primarily exists for completeness, and generally interception of of HTLCs between |
| forward_info, | ||
| prev_outbound_scid_alias: outbound_scid_alias, | ||
| prev_htlc_id, | ||
| prev_counterparty_node_id: channel.context.get_counterparty_node_id(), |
There was a problem hiding this comment.
can use counterparty_node_id from above
|
🔔 3rd Reminder Hey @tnull! This PR has been waiting for your review. |
Just a few more flags and a small cleanup.
Based on #4300