Skip to content

Don't generate a commitment if we cannot afford a holding cell feerate #3828

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
merged 1 commit into from
Jun 13, 2025

Conversation

tankyleo
Copy link
Contributor

@tankyleo tankyleo commented Jun 4, 2025

While an update_fee is in the holding cell, it is possible for HTLCs to get added to the commitment transaction such that when we release the holding cell, we can no longer afford this new feerate.

In that case, we previously would drop the fee update, but still send a commitment (at the old feerate), which is a break of the specification.

We now stop generating this lonely commitment when the fee update gets dropped upon release from the holding cell.

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Jun 4, 2025

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

@tankyleo tankyleo requested a review from wpaulino June 4, 2025 16:59
@tankyleo tankyleo force-pushed the lonely-commitment branch from 184efad to 413e895 Compare June 5, 2025 05:34
@tankyleo tankyleo removed the request for review from wpaulino June 5, 2025 05:36
@tankyleo tankyleo marked this pull request as draft June 5, 2025 05:36
@tankyleo tankyleo force-pushed the lonely-commitment branch 3 times, most recently from d0a4441 to b2a166c Compare June 5, 2025 06:00
Copy link

codecov bot commented Jun 5, 2025

Codecov Report

Attention: Patch coverage is 97.84173% with 3 lines in your changes missing coverage. Please review.

Project coverage is 90.36%. Comparing base (6133a6c) to head (cc03f48).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/ln/update_fee_tests.rs 97.77% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3828      +/-   ##
==========================================
+ Coverage   89.90%   90.36%   +0.46%     
==========================================
  Files         160      160              
  Lines      129272   133275    +4003     
  Branches   129272   133275    +4003     
==========================================
+ Hits       116218   120432    +4214     
+ Misses      10360    10142     -218     
- Partials     2694     2701       +7     

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

@tankyleo tankyleo force-pushed the lonely-commitment branch 2 times, most recently from e4f2142 to cc03f48 Compare June 6, 2025 00:28
@tankyleo tankyleo marked this pull request as ready for review June 6, 2025 00:34
@tankyleo tankyleo requested a review from wpaulino June 6, 2025 00:35
@tankyleo tankyleo force-pushed the lonely-commitment branch from cc03f48 to d94822c Compare June 6, 2025 21:31
@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

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

@wpaulino wpaulino requested a review from TheBlueMatt June 10, 2025 19:18
Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

I'm confused, why does this "violate the specification"? Our peer has no idea we had this update_fee queued, we never sent it to them AFAIU. It makes sense to me that we should want to send the commitment even if we can't update the fee, we definitely shouldn't sit on HTLCs!

@tankyleo
Copy link
Contributor Author

I'm confused, why does this "violate the specification"? Our peer has no idea we had this update_fee queued, we never sent it to them AFAIU. It makes sense to me that we should want to send the commitment even if we can't update the fee, we definitely shouldn't sit on HTLCs!

The problem is that currently the code makes it possible to send a commitment with zero updates, in the case we cannot afford the new feerate and there are no pending HTLC updates.

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

Ah! Duh, yea, okay, can you update the commit message to clarify that? The way I read the commit message it implied that we would be sending an update with HTLCs, just not a fee update. Otherwise LGTM

@tankyleo tankyleo force-pushed the lonely-commitment branch from d94822c to f8b74a7 Compare June 12, 2025 19:17
@tankyleo
Copy link
Contributor Author

tankyleo commented Jun 12, 2025

Ah! Duh, yea, okay, can you update the commit message to clarify that? The way I read the commit message it implied that we would be sending an update with HTLCs, just not a fee update. Otherwise LGTM

Thanks I agree it was not clear, I gave it another shot here hope this works :)

Upon releasing an `update_fee` from its holding cell, it can be dropped
and not sent to the peer in case we no longer can afford the new
feerate.

When this happens, we previously still sent a commitment to the peer,
which could break the spec if no other updates were sent to the
peer.

Now, when a fee update gets dropped from its holding cell, we also do
not produce a commitment if no other updates are to be sent to the
peer.
@tankyleo tankyleo force-pushed the lonely-commitment branch from f8b74a7 to d693047 Compare June 12, 2025 19:22
@tankyleo tankyleo requested a review from TheBlueMatt June 12, 2025 19:26
@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @TheBlueMatt! 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.

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

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

Thanks. LGTM, No changes since @wpaulino ACK'd, so landing.

get_route_and_payment_hash!(nodes[1], nodes[0], 5000 * 1000);
let onion = RecipientOnionFields::secret_only(payment_secret);
let id = PaymentId(payment_hash.0);
nodes[1].node.send_payment_with_route(route, payment_hash, onion, id).unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably we should be rejecting this (ie considering holding-cell fee updates when we decide if we can afford a new outbound HTLC).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean an inbound HTLC I think ? Is that a little too strict given that our peer had no idea we had a fee update in the holding cell when it sent the update_add_htlc ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oops, sorry, thought it was the same node, was reading too fast :)

@TheBlueMatt TheBlueMatt merged commit 3333b6d into lightningdevkit:main Jun 13, 2025
25 of 26 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