Skip to content

Conversation

@valentinewallace
Copy link
Contributor

@valentinewallace valentinewallace commented Feb 9, 2026

Previously, the InboundUpdateAdd::Forwarded enum variant contained an
HTLCPreviousHopData, which had a lot of fields that were redundant with the
outer InboundHTLCOutput/Channel structs. Here we dedup those fields, which is
important because the pending InboundUpdateAdds are persisted whenever the
ChannelManager is persisted.

Based on #4303
Partially addresses #4286

@valentinewallace valentinewallace added this to the 0.3 milestone Feb 9, 2026
@valentinewallace valentinewallace self-assigned this Feb 9, 2026
@valentinewallace valentinewallace added the weekly goal Someone wants to land this this week label Feb 9, 2026
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Feb 9, 2026

👋 Thanks for assigning @TheBlueMatt as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@codecov
Copy link

codecov bot commented Feb 9, 2026

Codecov Report

❌ Patch coverage is 99.38650% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 86.07%. Comparing base (caf0aac) to head (58edcb2).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/ln/channelmanager.rs 98.76% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4405      +/-   ##
==========================================
+ Coverage   86.05%   86.07%   +0.02%     
==========================================
  Files         156      156              
  Lines      103384   103479      +95     
  Branches   103384   103479      +95     
==========================================
+ Hits        88964    89073     +109     
+ Misses      11905    11894      -11     
+ Partials     2515     2512       -3     
Flag Coverage Δ
tests 86.07% <99.38%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

valentinewallace and others added 6 commits February 10, 2026 13:19
Useful when using these macros in lightning-tests/upgrade_downgrade_tests
In the next commit, we want to dedup fields between the
InboundUpdateAdd::Forwarded's HTLCPreviousHopData and the outer
InboundHTLCOutput/Channel structs, since many fields are duplicated in both
places at the moment. As part of doing this cleanly, we first refactor the
method that retrieves these InboundUpdateAdds for reconstructing the set of
pending HTLCs during ChannelManager deconstruction.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Previously, the InboundUpdateAdd::Forwarded enum variant contained an
HTLCPreviousHopData, which had a lot of fields that were redundant with the
outer InboundHTLCOutput/Channel structs. Here we dedup those fields, which is
important because the pending InboundUpdateAdds are persisted whenever the
ChannelManager is persisted.
We need these fields to generate a correct PaymentForwarded event if we need to
claim this inbound HTLC backwards after restart and it's already been claimed
and removed on the outbound edge.
Previously, we were spuriously using the upstream channel's info when we
should've been using the downstream channel's.
Previously, if a forwarding node reloaded mid-HTLC-forward with a preimage in
the outbound edge monitor and the outbound edge channel still open, and
subsequently reclaimed the inbound HTLC backwards, the PaymetForwarded event
would be missing the next_user_channel_id field.
@valentinewallace valentinewallace force-pushed the 2026-02-dedup-htlc-fwd-data branch from 0d38512 to 94cb95d Compare February 10, 2026 22:42
Test that if we restart and had two inbound MPP-part HTLCs received over the
same channel in the holding cell prior to shutdown, and we lost the holding
cell prior to restart, those HTLCs will still be claimed backwards.

Test largely written by Claude
@valentinewallace
Copy link
Contributor Author

Still need to finalize what manager version to write (#4303 (comment)), but otherwise this should be good to go.

@valentinewallace valentinewallace marked this pull request as ready for review February 11, 2026 22:55
@valentinewallace valentinewallace changed the title Dedup InboundUpdateAdd::Forwarded data with outer structs Dedup InboundUpdateAdd::Forwarded data; fix PaymentForwarded fields Feb 11, 2026
@valentinewallace valentinewallace requested review from TheBlueMatt and joostjager and removed request for tankyleo February 11, 2026 23:00
}

#[test]
fn test_reclaim_after_reload_payment_forwarded_ev() {
Copy link
Contributor Author

@valentinewallace valentinewallace Feb 12, 2026

Choose a reason for hiding this comment

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

I need to fix this test, thought it was right at one point but it passes incorrectly. Will fix on the next push.

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

Didn't review the test changes but otherwise basically lgtm.

pub(super) fn inbound_forwarded_htlcs(
&self,
) -> impl Iterator<
Item = (PaymentHash, HTLCPreviousHopData, u64, ChannelId, PublicKey, OutPoint, u128),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Heh, this looks like it needs a struct now. Maybe even leave the payment_hash out of it so that we can reuse it as the map value in channelmanager.rs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

weekly goal Someone wants to land this this week

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants