Skip to content

Conversation

@wpaulino
Copy link
Contributor

@wpaulino wpaulino commented Feb 4, 2026

We previously assumed background events would eventually be processed prior to another ChannelManager write, so we would immediately remove all in-flight monitor updates that completed since the last ChannelManager serialization. This isn't always the case, so we now keep them all around until we're ready to handle them, i.e., when process_background_events is called.

This was discovered while fuzzing chanmon_consistency_target on the main branch with some changes that allow it to connect blocks. It was triggered by reloading the ChannelManager after a monitor update completion for an outgoing HTLC, calling ChannelManager::best_block_updated, and reloading the ChannelManager once again. A test is included that provides a minimal reproduction of this case.

We previously assumed background events would eventually be processed
prior to another `ChannelManager` write, so we would immediately remove
all in-flight monitor updates that completed since the last
`ChannelManager` serialization. This isn't always the case, so we now
keep them all around until we're ready to handle them, i.e., when
`process_background_events` is called.

This was discovered while fuzzing `chanmon_consistency_target` on the
main branch with some changes that allow it to connect blocks. It was
triggered by reloading the `ChannelManager` after a monitor update
completion for an outgoing HTLC, calling
`ChannelManager::best_block_updated`, and reloading the `ChannelManager`
once again. A test is included that provides a minimal reproduction of
this case.
@wpaulino wpaulino added this to the 0.3 milestone Feb 4, 2026
@wpaulino wpaulino requested a review from TheBlueMatt February 4, 2026 01:09
@wpaulino wpaulino self-assigned this Feb 4, 2026
@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Feb 4, 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 4, 2026

Codecov Report

❌ Patch coverage is 88.23529% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.01%. Comparing base (817ab5e) to head (2a15c45).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/ln/channelmanager.rs 88.23% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4377      +/-   ##
==========================================
- Coverage   86.01%   86.01%   -0.01%     
==========================================
  Files         156      156              
  Lines      102857   102869      +12     
  Branches   102857   102869      +12     
==========================================
+ Hits        88476    88483       +7     
- Misses      11871    11874       +3     
- Partials     2510     2512       +2     
Flag Coverage Δ
tests 86.01% <88.23%> (-0.01%) ⬇️

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