Skip to content

Misc Followups #3942

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 6 commits into
base: main
Choose a base branch
from

Conversation

TheBlueMatt
Copy link
Collaborator

Mostly post-#3801 things, not entirely.

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Jul 18, 2025

👋 Thanks for assigning @joostjager 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.

/// Because of unavailability of hold times, the list may be shorter than the number of hops in the path.
/// The time that each hop indicated it held the HTLC.
///
/// We expect that at each hop the hold time will be strictly greater than the hold time of
Copy link
Contributor

Choose a reason for hiding this comment

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

The unrounded hold times should be strictly greater, but clearly after rounding that may not be the case anymore. Not sure if that's fully clear now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think that's true? As long as everyone rounds in the same way (truncating, rather than rounding) a >= condition will hold after rounding.

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought strictly greater means > not >=

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh lol, yea, I see why its confusing. Pushed a fixup:

$ git diff-tree -U2 517610c2c 15a70f1d9
diff --git a/lightning/src/events/mod.rs b/lightning/src/events/mod.rs
index 1a6a18d928..e4fd7ad2ef 100644
--- a/lightning/src/events/mod.rs
+++ b/lightning/src/events/mod.rs
@@ -1105,11 +1105,12 @@ pub enum Event {
 		/// The time that each hop indicated it held the HTLC.
 		///
-		/// We expect that at each hop the hold time will be strictly greater than the hold time of
-		/// the following hops, as a node along the path shouldn't have completed the HTLC until
-		/// the next node has completed it.
-		///
 		/// The unit in which the hold times are expressed are 100's of milliseconds. So a hop
 		/// reporting 2 is a hold time that corresponds to between 200 and 299 milliseconds.
 		///
+		/// We expect that at each hop the actual hold time will be strictly greater than the hold
+		/// time of the following hops, as a node along the path shouldn't have completed the HTLC
+		/// until the next node has completed it. Note that because hold times are in 100's of ms,
+		/// hold times as reported are likely to often be equal across hops.
+		///
 		/// If our peer didn't provide attribution data or the HTLC resolved on chain, the list
 		/// will be empty.
@@ -1172,11 +1173,12 @@ pub enum Event {
 		/// The time that each hop indicated it held the HTLC.
 		///
-		/// We expect that at each hop the hold time will be strictly greater than the hold time of
-		/// the following hops, as a node along the path shouldn't have completed the HTLC until
-		/// the next node has completed it.
-		///
 		/// The unit in which the hold times are expressed are 100's of milliseconds. So a hop
 		/// reporting 2 is a hold time that corresponds to between 200 and 299 milliseconds.
 		///
+		/// We expect that at each hop the actual hold time will be strictly greater than the hold
+		/// time of the following hops, as a node along the path shouldn't have completed the HTLC
+		/// until the next node has completed it. Note that because hold times are in 100's of ms,
+		/// hold times as reported are likely to often be equal across hops.
+		///
 		/// If our peer didn't provide attribution data or the HTLC resolved on chain, the list
 		/// will be empty.

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

Most of the message handlers in LDK pass messages to the handler by
reference. This is unnecessarily inefficient and there's no real
reason to do so.

Because we just tweaked what `UpdateFulfillHTLC` messages look
like, this is a good opportunity to make progress here, passing at
least one message owned rather than by reference.
In the previous commit we switched to passing `UpdateFulfillHTLC`
messages to handlers owned, rather than by reference. Here we
update `ChanelManager`'s handling of fulfill attribution data to
avoid unnecessary clones now that we own the object.
@TheBlueMatt TheBlueMatt force-pushed the 2025-07-misc-followups branch from 865519c to 517610c Compare July 20, 2025 11:42
@TheBlueMatt
Copy link
Collaborator Author

Fixed a bug in the bench build:

$ git diff-tree -U3 865519c6b 517610c2c
diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs
index e9052209d4..76c972fe8a 100644
--- a/lightning/src/ln/channelmanager.rs
+++ b/lightning/src/ln/channelmanager.rs
@@ -18317,7 +18317,7 @@ pub mod bench {
 				expect_payment_claimed!(ANodeHolder { node: &$node_b }, payment_hash, 10_000);

 				match $node_b.get_and_clear_pending_msg_events().pop().unwrap() {
-					MessageSendEvent::UpdateHTLCs { node_id, channel_id: _, updates } => {
+					MessageSendEvent::UpdateHTLCs { node_id, mut updates, .. } => {
 						assert_eq!(node_id, $node_a.get_our_node_id());
 						let fulfill = updates.update_fulfill_htlcs.remove(0);
 						$node_a.handle_update_fulfill_htlc($node_b.get_our_node_id(), fulfill);

Copy link

codecov bot commented Jul 20, 2025

Codecov Report

Attention: Patch coverage is 96.86099% with 7 lines in your changes missing coverage. Please review.

Project coverage is 89.05%. Comparing base (2f9898c) to head (517610c).

Files with missing lines Patch % Lines
lightning/src/ln/chanmon_update_fail_tests.rs 96.20% 1 Missing and 2 partials ⚠️
lightning/src/util/test_utils.rs 0.00% 2 Missing ⚠️
lightning-net-tokio/src/lib.rs 0.00% 1 Missing ⚠️
lightning/src/ln/peer_handler.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3942   +/-   ##
=======================================
  Coverage   89.05%   89.05%           
=======================================
  Files         167      167           
  Lines      121800   121812   +12     
  Branches   121800   121812   +12     
=======================================
+ Hits       108464   108482   +18     
+ Misses      10928    10927    -1     
+ Partials     2408     2403    -5     
Flag Coverage Δ
fuzz 22.72% <61.11%> (-0.37%) ⬇️

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.

joostjager
joostjager previously approved these changes Jul 21, 2025
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.

3 participants