-
Notifications
You must be signed in to change notification settings - Fork 265
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
Avoid unusable channels after a large splice #2761
Conversation
Codecov Report
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. @@ Coverage Diff @@
## master #2761 +/- ##
==========================================
+ Coverage 85.84% 85.85% +0.01%
==========================================
Files 216 216
Lines 18102 18094 -8
Branches 762 768 +6
==========================================
- Hits 15540 15535 -5
+ Misses 2562 2559 -3
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code and test looks good!
Is there already a test that exercises the case where bob (sender/non-initiator) rejects an htlc because the commit fees would take alice (receiver/initiator) below the commit-tx fee limit?
I couldn't find this tested elsewhere. Perhaps a test with a large fee update or reduced reserve percent could accomplish it.
Good point, we test that in the |
Actually I was wrong, there are already tests for that (it would have been surprising that we missed that scenario):
|
While these tests do cover this, none of them specifically exercise the clause:
where My conclusion is that although we don't actually need a separate test for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! - after even a large splice the channel partner with the most value should always be able to make progress towards refilling the reserve of the other side and the rate limit will prevent dipping too far into the the reserve from tx fees.
In the case of going from a very small capacity to splicing in a much larger amount, the channel may be rate limited for some time. As long as htlcs are not getting stuck though, even micropayment flows should not cause payment failures while waiting for the remote's reserve to refill.
Splicing (and dual funding as well) introduce a new scenario that could not happen before, where the channel initiator (who pays the fees for the commit tx) can end up below the channel reserve, or right above it. In that case it means that most of the channels funds are on the non initiator side, so we should allow HTLCs from the non-initiator to the initiator to move funds towards the initiator. We allow slightly dipping into the channel reserve in that case, for at most 5 pending HTLCs.
d149415
to
3201d61
Compare
#2761 introduced the ability for the HTLC sender to let a remote initiator dip into its reserve to unblock channels after a large splice. However, we relaxed that condition for all channels, even those that don't use splice. This creates compatibility issues with other implementations that are stricter than what the specification requires, and will force-close in those situations.
#2761 introduced the ability for the HTLC sender to let a remote initiator dip into its reserve to unblock channels after a large splice. However, we relaxed that condition for all channels, even those that don't use splice. This creates compatibility issues with other implementations that are stricter than what the specification requires, and will force-close in those situations.
Splicing (and dual funding as well) introduce a new scenario that could not happen before, where the channel initiator (who pays the fees for the commit tx) can end up below the channel reserve, or right above it but any additional HTLC would make it go below the reserve.
In that case it means that most of the channels funds are on the non initiator side, so we should allow HTLCs from the non-initiator to the initiator to move funds towards the initiator (towards a more balanced channel where both sides meet the channel reserve requirements). We allow slightly dipping into the channel reserve in that case, for at most 5 pending HTLCs (to limit our exposure).
We limit this to only a few HTLCs to make sure that the initiator still has funds in the channel, that are close enough to their channel reserve. If they ended up with a commit tx where they have 0 sats, they would always have an incentive to broadcast this transaction once it's revoked, because they'd have nothing at stake in it.
This was proposed in the spec: lightning/bolts#1083. But the other implementations didn't like it and preferred tracking the previous channel reserve (which was usually met before) until the new channel reserve is met. I don't like this because it's awkward to track (where would we put that state?) and not completely trivial to keep up-to-date. I believe that simply allowing a few HTLCs provides the same benefits (in practice that will stay within the bound of the previous channel reserve) with less complexity.
Note that on the receiver side, if the sender lets us dip into our channel reserve, we gladly accept it, because it's in our favor.