Skip to content

Remove direct calls to handle_monitor_update_completion! #3947

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

Merged

Conversation

TheBlueMatt
Copy link
Collaborator

handle_monitor_update_completion! (and
handle_monitor_update_completion_actions) are a pretty annoying API as they have several preconditions. Luckily, we already have channel_monitor_update which does the right work, handling both the open- and closed- channel cases and correctly checking the preconditions to handle_monitor_update_completion!, so here we convert calls to handle_monitor_update_completion! (aside from handle_new_monitor_update!) to just calling
channelMonitor_update.

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Jul 22, 2025

👋 Thanks for assigning @tnull 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
Copy link
Collaborator Author

Tagging 0.2 cause it technically fixes #3894 (comment)

wpaulino
wpaulino previously approved these changes Jul 22, 2025
@ldk-reviews-bot
Copy link

👋 The first review has been submitted!

Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer.

`handle_monitor_update_completion!` (and
`handle_monitor_update_completion_actions`) are a pretty annoying
API as they have several preconditions. Luckily, we already have
`channel_monitor_update` which does the right work, handling both
the open- and closed- channel cases and correctly checking the
preconditions to `handle_monitor_update_completion!`, so here we
convert calls to `handle_monitor_update_completion!` (aside from
`handle_new_monitor_update!`) to just calling
`channelMonitor_update`.
@TheBlueMatt
Copy link
Collaborator Author

$ git diff-tree -U7 -b 942cefcd47 8b9b078586
diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs
index 51247c173f..c47eaec623 100644
--- a/lightning/src/ln/channelmanager.rs
+++ b/lightning/src/ln/channelmanager.rs
@@ -8641,30 +8641,28 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
 				if let Some(highest_applied_update_id) = highest_applied_update_id {
 					pending.retain(|upd| upd.update_id > highest_applied_update_id);
 					log_trace!(
 						logger,
 						"ChannelMonitor updated to {highest_applied_update_id}. {} pending in-flight updates.",
 						pending.len()
 					);
-				} else {
-					if let Some(update) = pending.get(0) {
+				} else if let Some(update) = pending.get(0) {
 					log_trace!(
 						logger,
 						"ChannelMonitor updated to {}. {} pending in-flight updates.",
 						update.update_id - 1,
 						pending.len()
 					);
 				} else {
 					log_trace!(
 						logger,
 						"ChannelMonitor updated. {} pending in-flight updates.",
 						pending.len()
 					);
 				}
-				}
 				pending.len()
 			} else { 0 };

 		if remaining_in_flight != 0 {
 			return;
 		}

Copy link

codecov bot commented Jul 22, 2025

Codecov Report

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

Project coverage is 89.00%. Comparing base (4e4f128) to head (8b9b078).
Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/ln/channelmanager.rs 89.47% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3947      +/-   ##
==========================================
- Coverage   89.01%   89.00%   -0.01%     
==========================================
  Files         168      168              
  Lines      121784   121822      +38     
  Branches   121784   121822      +38     
==========================================
+ Hits       108411   108433      +22     
- Misses      10966    10983      +17     
+ Partials     2407     2406       -1     
Flag Coverage Δ
fuzzing 22.72% <52.63%> (+0.03%) ⬆️
tests 88.83% <89.47%> (-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.

@tnull tnull self-requested a review July 23, 2025 07:45
Copy link
Contributor

@tnull tnull left a comment

Choose a reason for hiding this comment

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

LGTM

@tnull tnull merged commit 20e51fe into lightningdevkit:main Jul 23, 2025
28 checks passed
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.

4 participants