Skip to content
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

Implement anchor outputs zero fee htlc txs #1932

Merged
merged 3 commits into from
Sep 10, 2021

Conversation

t-bast
Copy link
Member

@t-bast t-bast commented Sep 1, 2021

Implement lightning/bolts#824

This is a small variation of the original anchor outputs proposal, where the fees of the htlc 2nd-stage txs are set to 0 to fix a fee inflating attack when you're fundee (see https://lists.linuxfoundation.org/pipermail/lightning-dev/2020-September/002796.html for details).

The first commit creates the corresponding feature bit and lets peers negotiate its activation.
The second commit actually sets the htlc txs fee to 0 when this new channel type is negotiated.

I've tested cross-compatibility with lnd 0.13.1-beta (their latest release).
I verified that we were able to open channels and send payments to each other.
I also verified that HTLCs that were exactly at the dust limit were included in the commit tx (so the trimmed to dust calculation is compatible and correctly uses a 0-fee htlc tx) and htlcs just below the dust limit were not included in the commit tx.

@t-bast t-bast force-pushed the anchor-outputs-zero-fee-htlc-txs branch from 1ca266d to fae57ae Compare September 1, 2021 10:22
@codecov-commenter
Copy link

codecov-commenter commented Sep 1, 2021

Codecov Report

Merging #1932 (80941c2) into master (24dd613) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1932      +/-   ##
==========================================
- Coverage   87.66%   87.63%   -0.03%     
==========================================
  Files         159      159              
  Lines       12424    12438      +14     
  Branches      527      519       -8     
==========================================
+ Hits        10891    10900       +9     
- Misses       1533     1538       +5     
Impacted Files Coverage Δ
...core/src/main/scala/fr/acinq/eclair/Features.scala 99.04% <100.00%> (+0.03%) ⬆️
.../fr/acinq/eclair/blockchain/fee/FeeEstimator.scala 100.00% <100.00%> (ø)
...c/main/scala/fr/acinq/eclair/channel/Channel.scala 88.27% <100.00%> (ø)
...cala/fr/acinq/eclair/channel/ChannelFeatures.scala 100.00% <100.00%> (+2.94%) ⬆️
...in/scala/fr/acinq/eclair/channel/Commitments.scala 93.89% <100.00%> (ø)
...c/main/scala/fr/acinq/eclair/channel/Helpers.scala 96.16% <100.00%> (ø)
...clair/channel/publish/ReplaceableTxPublisher.scala 85.88% <100.00%> (-1.18%) ⬇️
.../fr/acinq/eclair/transactions/CommitmentSpec.scala 83.72% <100.00%> (+0.79%) ⬆️
...n/scala/fr/acinq/eclair/transactions/Scripts.scala 93.10% <100.00%> (ø)
...la/fr/acinq/eclair/transactions/Transactions.scala 96.78% <100.00%> (ø)
... and 2 more

@t-bast t-bast force-pushed the anchor-outputs-zero-fee-htlc-txs branch 3 times, most recently from f3fa135 to 57140b3 Compare September 2, 2021 08:46
@t-bast t-bast marked this pull request as ready for review September 2, 2021 09:39
@t-bast t-bast requested a review from pm47 September 2, 2021 09:39
@t-bast t-bast force-pushed the anchor-outputs-zero-fee-htlc-txs branch from 57140b3 to c537fcb Compare September 8, 2021 15:14
Copy link
Member

@pm47 pm47 left a comment

Choose a reason for hiding this comment

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

LGTM, just needs a rebase.

Create the corresponding feature bit and channel type.
Ensure it can be correctly negotiated and propagated
to the channel commitments.
When the channel type is anchor outputs with zero fee htlc txs, we set
the fees for the htlc txs to 0.

An important side-effect is that it changes the trimmed to dust calculation,
and outputs that were previously dust can now be included in the commit tx.
It makes sense to decouple the transaction code that doesn't need to know
anything about the channel type, but only the format of the transactions
that should be built.
@t-bast t-bast force-pushed the anchor-outputs-zero-fee-htlc-txs branch from c537fcb to 80941c2 Compare September 9, 2021 15:59
@t-bast t-bast requested a review from pm47 September 9, 2021 17:03
@t-bast t-bast merged commit a228bac into master Sep 10, 2021
@t-bast t-bast deleted the anchor-outputs-zero-fee-htlc-txs branch September 10, 2021 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants