Skip to content

Conversation

@valentinewallace
Copy link
Contributor

@valentinewallace valentinewallace commented Dec 16, 2025

Addresses a chunk of the feedback from #4227 (review) (#4280). Splitting it out for ease of review.

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.
We are working on removing the requirement of regularly persisting the
ChannelManager, and as a result began reconstructing the manager's
decode_update_add_htlcs map from Channel data on startup in a recent PR.

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

Instead, prefer to use the old maps if they are present (which will always be
the case in prod), but avoid writing the legacy maps in test mode so tests will
always exercise the new paths.
@ldk-reviews-bot
Copy link

👋 Hi! I see this is a draft PR.
I'll wait to assign reviewers until you mark it as ready for review.
Just convert it out of draft status when you're ready for review!

@valentinewallace
Copy link
Contributor Author

Going to take another look at this tomorrow before un-drafting it

@codecov
Copy link

codecov bot commented Dec 17, 2025

Codecov Report

❌ Patch coverage is 91.74757% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.33%. Comparing base (593d6aa) to head (89f5d07).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/ln/channelmanager.rs 89.88% 14 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4289      +/-   ##
==========================================
- Coverage   89.37%   89.33%   -0.04%     
==========================================
  Files         180      180              
  Lines      139847   139821      -26     
  Branches   139847   139821      -26     
==========================================
- Hits       124983   124910      -73     
- Misses      12269    12333      +64     
+ Partials     2595     2578      -17     
Flag Coverage Δ
fuzzing 35.25% <17.64%> (+0.03%) ⬆️
tests 88.67% <91.74%> (-0.04%) ⬇️

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.

Sign up for free to 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.

2 participants