-
Notifications
You must be signed in to change notification settings - Fork 275
Add support for zero-fee commitment format #3192
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
base: master
Are you sure you want to change the base?
Conversation
107182e to
03d3ac3
Compare
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3192 +/- ##
==========================================
+ Coverage 86.43% 88.95% +2.51%
==========================================
Files 242 218 -24
Lines 22607 20538 -2069
Branches 832 810 -22
==========================================
- Hits 19541 18270 -1271
+ Misses 3066 2268 -798
🚀 New features to boost your workflow:
|
7532699 to
169c7a6
Compare
de9520c to
b13e59b
Compare
pm47
left a comment
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.
LGTM, didn't review the publishing/funding logic.
eclair-core/src/main/scala/fr/acinq/eclair/transactions/Transactions.scala
Show resolved
Hide resolved
We add support for the zero-fee commitment format specified in lightning/bolts#1228. Channels using this commitment format benefit from better protection against pinning attacks (thanks to TRUC/v3 transactions), don't need the `update_fee` mechanism, have less dust exposure risk, and use an overall simpler state machine. In this commit, we simply introduce the commitment format and create the corresponding transactions.
It isn't delayed anymore for v3 transactions. We could use static wallet public key, but in most cases it wouldn't work and adds extra complexity so we don't do it. We add a comment in the documentation of this class to explain why we're always making a 2nd-stage transaction.
We apply slightly different validation for zero-fee commitments: - the commit feerate must be `0 sat/byte` - the max number of accepted HTLCs must be at most 114 - `update_fee` cannot be used We verify those requirements during channel creation and add tests for normal channel operation.
We add support for force-close zero-fee channels. When publishing the local commit, this works mostly the same way as other channel types. The only difference is that we don't even attempt to publish the commit tx individually: we always bundle it with the anchor transaction. When we detect the remote commit though, we're able to introduce some new behavior: - if we have a large enough main output, we use that to pay the fees of the remote commit tx (unless it is already confirmed), which avoids using a wallet input - otherwise, we spend the anchor output, which competes with the remote peer package Since we're only using the anchor transaction or our main output to spend the ephemeral anchor, we cannot publish HTLC txs until the commit tx is confirmed. We will in the future make *all* transactions go through the `ReplaceableTxPublisher`, and at the point we'll be able to simplify this, but it's too early for this refactoring, so for now we simply wait for the commit tx to be confirmed before publishing HTLC txs.
When using zero-fee commitments, we don't force-close when receiving an `error` from our peer: if they want to force-close the channel, they can publish their commitment instead of forcing us to publish ours. It is especially true when the commit tx doesn't pay any fees, because the publisher will pay the entire fees for the force-close. Note that for wallet peers, we could introduce a mechanism where they send us their signed commit tx in the error message if they don't have any wallet input to pay the fees, and we could be nice and publish it while paying the fees from our main output (which isn't delayed since it is the remote commit from our point of view).
1e7b755 to
00eb098
Compare
We add support for the zero-fee commitment format specified in lightning/bolts#1228.
Channels using this commitment format benefit from better protection against pinning attacks (thanks to TRUC/v3 transactions), don't need the
update_feemechanism, have less dust exposure risk, and use an overall simpler state machine.If our peer publishes their commitment transaction, we use our main output to CPFP it (by also spending the ephemeral anchor), which provides a very efficient way (no additional wallet inputs involved) to force-close a channel.
In the future, we may want to use the
ReplaceableTxPublisherfor all force-close transactions, and use any transaction available to pay the commit fees directly from channel funds. This would make our codebase more consistent, but is a bigger change.