Skip to content

Only mark all mon updates complete if there are no blocked updates #3907

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

TheBlueMatt
Copy link
Collaborator

In handle_new_monitor_update!, we correctly check that the channel doesn't have any blocked monitor updates pending before calling handle_monitor_update_completion! (which calls Channel::monitor_updating_restored, which in turn assumes that all generated ChannelMonitorUpdates, including blocked ones, have completed).

We, however, did not do the same check at several other places where we called handle_monitor_update_completion!. Specifically, after a monitor update completes during reload (processed via a BackgroundEvent or when monitor update completes async, we didn't check if there were any blocked monitor updates before completing).

Here we add the missing check, as well as an assertion in Channel::monitor_updating_restored.

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Jul 3, 2025

I've assigned @wpaulino 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.

@TheBlueMatt TheBlueMatt force-pushed the 2025-06-no-mon-compl-with-blocked-updates branch 2 times, most recently from 6bfe0bd to 49ad15c Compare July 3, 2025 01:33
@TheBlueMatt TheBlueMatt force-pushed the 2025-06-no-mon-compl-with-blocked-updates branch 2 times, most recently from 7759b4d to 95c0696 Compare July 3, 2025 01:36
In `handle_new_monitor_update!`, we correctly check that the
channel doesn't have any blocked monitor updates pending before
calling `handle_monitor_update_completion!` (which calls
`Channel::monitor_updating_restored`, which in turn assumes that
all generated `ChannelMonitorUpdate`s, including blocked ones, have
completed).

We, however, did not do the same check at several other places
where we called `handle_monitor_update_completion!`. Specifically,
after a monitor update completes during reload (processed via a
`BackgroundEvent` or when monitor update completes async, we didn't
check if there were any blocked monitor updates before completing).

Here we add the missing check, as well as an assertion in
`Channel::monitor_updating_restored`.
@TheBlueMatt TheBlueMatt force-pushed the 2025-06-no-mon-compl-with-blocked-updates branch from 95c0696 to ab0dda7 Compare July 3, 2025 01:36
@ldk-reviews-bot ldk-reviews-bot requested a review from wpaulino July 3, 2025 01:42
Copy link

codecov bot commented Jul 3, 2025

Codecov Report

Attention: Patch coverage is 97.05882% with 2 lines in your changes missing coverage. Please review.

Project coverage is 88.80%. Comparing base (257ebad) to head (ab0dda7).

Files with missing lines Patch % Lines
lightning/src/ln/chanmon_update_fail_tests.rs 97.95% 0 Missing and 1 partial ⚠️
lightning/src/ln/quiescence_tests.rs 91.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3907      +/-   ##
==========================================
- Coverage   88.82%   88.80%   -0.02%     
==========================================
  Files         165      165              
  Lines      119075   119123      +48     
  Branches   119075   119123      +48     
==========================================
+ Hits       105769   105790      +21     
- Misses      10986    11003      +17     
- Partials     2320     2330      +10     

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

@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @wpaulino! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@ldk-reviews-bot
Copy link

🔔 2nd Reminder

Hey @wpaulino! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

@@ -8227,7 +8229,9 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
{
if chan.is_awaiting_monitor_update() {
log_trace!(logger, "Channel is open and awaiting update, resuming it");
handle_monitor_update_completion!(self, peer_state_lock, peer_state, per_peer_state, chan);
if chan.blocked_monitor_updates_pending() == 0 {
handle_monitor_update_completion!(self, peer_state_lock, peer_state, per_peer_state, chan);
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't we still want to call self.handle_monitor_update_completion_actions so that we can actually unblock any monitor updates that are pending blocked?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm, we don't do so in handle_new_monitor_update's base case, which I was trying to match everywhere. A few tests fail if we change it there (with almost-harmless message ordering changes, so nothing major, but we'd have to fix that), but I'm not convinced its a bug - a channel should never block itself, and the unblocking of the next monitor update in a channel has to come in from a different channel or from an event, not from the channel itself. So that other channel, once it makes progress, should always unblock us.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah that's what I figured, was just being overly-cautious in case we ever introduce such a monitor update that blocks the same channel.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yea, I think you're right that that change makes sense, but I don't think it makes sense as a backport and we should do it everywhere, not just in the new places, in a separate PR.

@wpaulino
Copy link
Contributor

wpaulino commented Jul 8, 2025

LGTM after squash

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

Successfully merging this pull request may close these issues.

3 participants