-
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
Shutdown and UpdateFee should not be intertwined #1661
Conversation
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/test/scala/fr/acinq/eclair/channel/states/e/NormalStateSpec.scala
Show resolved
Hide resolved
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.
I think there is also this scenario, where the fundee initiates the close:
UpdateFee ----->
<----- Shutdown
Shutdown ----->
CommigSig ----->
I'll add a test case for that, I believe it will be covered by the code change already. |
f8f61b3
to
838d2d4
Compare
Done in 838d2d4 |
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 UpdateFee
handler should be removed in state SHUTDOWN
I think, because IIUC the assumption is now that new changes cannot be added in that state (we treat UpdateFee
exactly like UpdateAddHtlc
) . It looks like an issue at the spec level.
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/Commitments.scala
Outdated
Show resolved
Hide resolved
I think you're right. To avoid being too strict with senders, I changed our behavior to stop emitting |
I think it works but I'm a bit confused as to why. How can it work where the whole purpose of this PR was to precisely prevent that from happening. |
We were not correctly handling this scenario and could end up stuck between shutdown and negotiating.
8a78b74
to
240fb31
Compare
I simplified the PR, it's much closer now to #1691 with additional tests. |
Codecov Report
@@ Coverage Diff @@
## master #1661 +/- ##
==========================================
+ Coverage 85.95% 86.04% +0.08%
==========================================
Files 151 151
Lines 11474 11486 +12
Branches 495 483 -12
==========================================
+ Hits 9863 9883 +20
+ Misses 1611 1603 -8
|
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.
Looking good! Just an OCD nit
eclair-core/src/main/scala/fr/acinq/eclair/channel/Commitments.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/channel/Commitments.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/channel/ChannelExceptions.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
Done, I added |
We were not correctly handling intertwined `update_fee` and `shutdown` and could end up stuck between shutdown and negotiating. See ACINQ/eclair#1661 for additional details.
We were not correctly handling intertwined `update_fee` and `shutdown` and could end up stuck between shutdown and negotiating. See ACINQ/eclair#1661 for additional details.
If a plugin (or a very reactive user) tries to mutual-close a channel right when our peer reconnects, we can end up with the following message flow:
Which was not properly handled and ended up in a locked state between shutdown and negotiating.
Just like we don't initiate a mutual close while we have unsigned outgoing htlcs, we should not initiate a mutual close if we have a pending unsigned fee update. We'll be signing it almost immediately, and the
CMD_CLOSE
can be replayed after a small delay.We also now correctly handle the transition to the negotiating state in case our peer sends us messages in this order.