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 1 commit 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
Comment on lines 264 to 267
let (_, latest_update) =
chain_monitor.latest_monitor_update_id.lock().unwrap().get(&chan_id).unwrap().clone();
Copy link

Choose a reason for hiding this comment

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

There appears to be a syntax error in this line - the object reference before .chain_monitor is missing. The correct statement should be:

let (_, latest_update) = nodes[0].chain_monitor.latest_monitor_update_id.lock().unwrap().get(&chan_id).unwrap().clone();

This ensures proper access to the chain monitor from the nodes[0] object.

Suggested change
let (_, latest_update) =
chain_monitor.latest_monitor_update_id.lock().unwrap().get(&chan_id).unwrap().clone();
let (_, latest_update) =
nodes[0].chain_monitor.latest_monitor_update_id.lock().unwrap().get(&chan_id).unwrap().clone();

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

@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`.
let chain_monitor = &nodes[0].chain_monitor;
let (_, new_latest_update) =
chain_monitor.latest_monitor_update_id.lock().unwrap().get(&chan_id).unwrap().clone();
assert_eq!(new_latest_update, latest_update + 1);
Copy link

Choose a reason for hiding this comment

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

There appears to be a typo in the variable name: lastest_update should be latest_update to match the variable defined earlier in the code.

Suggested change
assert_eq!(new_latest_update, latest_update + 1);
assert_eq!(new_latest_update, latest_update + 1);

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

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

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.

2 participants