-
Notifications
You must be signed in to change notification settings - Fork 266
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
More flexible mutual close fees #1768
Conversation
c0b2bc3
to
c37a2ca
Compare
c37a2ca
to
073bd83
Compare
Codecov Report
@@ Coverage Diff @@
## master #1768 +/- ##
=========================================
- Coverage 8.99% 8.96% -0.04%
=========================================
Files 158 158
Lines 12273 12330 +57
Branches 531 530 -1
=========================================
+ Hits 1104 1105 +1
- Misses 11169 11225 +56
|
073bd83
to
3f90c3c
Compare
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.
Have you considered type-ifying the comparison of local_opt/remote closing fees? I'm not sure this would make the negotiation code simpler, but at least we would factor the state transitions instead of having multiple calls to handleMutualClose
etc.
def Closing.compare(localClosingSigned_opt, remoteClosingSigned): NegotiationResult = ???
sealed trait NegotiationResult
object NegotiationResult {
sealed trait Success extends NegotiationResult
case class TheyAcceptOurFee(...) extends Success
case class WeAcceptTheirFee(...) extends Success
sealed trait Failure extends NegotiationResult
}
Closing.checkClosingSignature(..) match {
case Right(...) =>
Closing.compare(localClosingSigned_opt, remoteClosingSigned) =>
case Success(...) =>
handleMutualClose(...)
case Failure(...) =>
stay()
case Left(...) =>
handleLocalError(...)
}
If it doesn't feel very clear, it's because it isn't 😅 .
Or we could also wait until we deprecate the iterative negotiation process and simplify the whole thing.
.typecase(UInt64(1), variableSizeBytesLong(varintoverflow, feeRange)) | ||
) |
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.
Side note: we should probably factorize this tlv codec boiler plate.
eclair-core/src/main/scala/fr/acinq/eclair/wire/internal/channel/version3/ChannelCodecs3.scala
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/channel/Channel.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/channel/Channel.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/channel/Channel.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/channel/Channel.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/channel/Channel.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/channel/Channel.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/channel/Channel.scala
Outdated
Show resolved
Hide resolved
I'll give it a try and we'll see if it's worth doing now or when we remove the legacy negotiation. |
I tried it but got lost in it, it quickly becomes a bit complex and increases the risk we introduce a regression... |
2de7d7f
to
fccdd7b
Compare
The corresponding spec PR has been merged, so we can (finally) merge this 🎉 |
As described in lightning/bolts#847 We also refactor the negotiating state, add many tests and fix #1742.
Add new fields to the `close` API to let users configure their preferred fees for mutual close.
fccdd7b
to
4ce2dde
Compare
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
I would wait for cross-testing before merging, WDYT |
I've tested cross-compatibility with c-lightning based on ElementsProject/lightning#4599 a while ago and everything looked good, so I think we can merge now. I'll test compatibility again once they merge this PR on their I wanted to also test against rust-lightning, but couldn't get the LDK running against the right branch where they implemented this quick close, I'll give it another try. |
I've been able to test against the latest LDK and it works, there's one small bug on their side but apart from that it looks good. |
This PR adds support for lightning/bolts#847
The fees negotiation has been refactored and more tests have been added.
With legacy nodes, we will keep the existing behavior (slowly converge on a fee).
But for nodes that support closing
fee_range
s, mutual close will take much less round-trips.It's possible to chose your desired feerates through new fields of the
close
API.Note however that they will be ignored if you're fundee, as you won't be the one initiating fee negotiation.
It's ok as you're not paying that fee and can rely on CPFP if you want to speed up confirmation (or even simply spend your unconfirmed output directly when you need it).
This PR fixes #1742 and #1583