Skip to content

Conversation

@valentinewallace
Copy link
Contributor

Closes #4280

Based on #4289

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Jan 6, 2026

👋 I see @wpaulino was un-assigned.
If you'd like another reviewer assignment, please click here.

@codecov
Copy link

codecov bot commented Jan 6, 2026

Codecov Report

❌ Patch coverage is 81.48148% with 60 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.61%. Comparing base (c9f022b) to head (e2ea1ed).

Files with missing lines Patch % Lines
lightning/src/ln/channelmanager.rs 84.78% 30 Missing and 5 partials ⚠️
lightning/src/ln/channel.rs 73.40% 16 Missing and 9 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4303      +/-   ##
==========================================
+ Coverage   86.58%   86.61%   +0.03%     
==========================================
  Files         158      158              
  Lines      102287   102210      -77     
  Branches   102287   102210      -77     
==========================================
- Hits        88568    88533      -35     
+ Misses      11304    11266      -38     
+ Partials     2415     2411       -4     
Flag Coverage Δ
fuzzing 36.92% <34.55%> (+0.07%) ⬆️
tests 85.90% <81.48%> (+0.03%) ⬆️

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 valentinewallace force-pushed the 2025-12-reconstruct-fwds-followup-2 branch from 01aa4c0 to 4012864 Compare January 7, 2026 21:50
@valentinewallace valentinewallace self-assigned this Jan 8, 2026
Necessary for the next commit and makes it easier to read.
We recently began reconstructing ChannelManager::decode_update_add_htlcs on
startup, using data present in the Channels. However, we failed to prune HTLCs
from this rebuilt map if a given HTLC was already forwarded to the outbound
edge (we pruned correctly if the outbound edge was a closed channel, but not
otherwise).  Here we fix this bug that would have caused us to double-forward
inbound HTLC forwards.
No need to iterate through all entries in the map, we can instead pull out the
specific entry that we want.
@valentinewallace valentinewallace added the weekly goal Someone wants to land this this week label Jan 8, 2026
We are working on removing the requirement of regularly persisting the
ChannelManager, and as a result began reconstructing the manager's forwards
maps from Channel data on startup in a recent PR, see
cb398f6 and parent commits.

At the time, we implemented ChannelManager::read to prefer to use the newly
reconstructed maps, partly to ensure we have test coverage of the new maps'
usage. This resulted in a lot of code that would deduplicate HTLCs that were
present in the old maps to avoid redundant HTLC handling/duplicate forwards,
adding extra complexity.

Instead, always use the old maps in prod, but randomly use the newly
reconstructed maps in testing, to exercise the new codepaths (see
reconstruct_manager_from_monitors in ChannelManager::read).
We store inbound committed HTLCs' onions in Channels for use in reconstructing
the pending HTLC set on ChannelManager read. If an HTLC has been irrevocably
forwarded to the outbound edge, we no longer need to persist the inbound edge's
onion and can prune it here.
Used in the next commit when we log on some read errors.
We already pretty much deprecated handling of these HTLCs already in 0.1, see
the 0.1 CHANGELOG.md entry.

But as of 4f055ac, we really no longer handle
these deprecated HTLCs properly (see comment in Channel::revoke_and_ack).
Therefore, remove support for them more explicitly here.
In the previous commit, we removed the InboundHTLCResolution::Resolved enum
variant, which caused us to never provide any HTLCs in this now-removed
parameter.
Previously, several variants of InboundHTLCState contained an
InboundHTLCResolution enum.  Now that the resolution enum only has one variant,
we can get rid of it and simplify the parent InboundHTLCState type.
We stopped adding any HTLCs to this vec a few commits ago when we removed
support for HTLCs that were originally received on LDK 0.0.123-.
We stopped adding any HTLCs to this vec a few commits ago when we removed
support for HTLCs that were originally received on LDK 0.0.123-.
We stopped using this struct a few commits ago when we removed
support for HTLCs that were originally received on LDK 0.0.123-.
@valentinewallace valentinewallace force-pushed the 2025-12-reconstruct-fwds-followup-2 branch from 4012864 to e2ea1ed Compare January 8, 2026 21:16
@valentinewallace valentinewallace marked this pull request as ready for review January 8, 2026 21:16
@valentinewallace valentinewallace removed the request for review from wpaulino January 8, 2026 21:16
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

Status: No status

Development

Successfully merging this pull request may close these issues.

#4227 Followups

2 participants