Skip to content

Rework channel reestablish#629

Merged
pm47 merged 5 commits intomasterfrom
shutdown-reestablish
Apr 17, 2024
Merged

Rework channel reestablish#629
pm47 merged 5 commits intomasterfrom
shutdown-reestablish

Conversation

@pm47
Copy link
Copy Markdown
Member

@pm47 pm47 commented Apr 16, 2024

This PR does two things:

  • properly handle channel_reestablish in state Syncing(Shutdown)
  • implement the equivalent of Rework channel reestablish eclair#2036, a major rework/cleanup of the reestablish logic, with separation of concerns, strong typing, etc.

The two middle commits are intermediate steps and may not be necessarily useful to review. I recommend checking the first commit, then the last 3 commits.

The full reestablish rework is sensitive stuff (a bug here could cause mass force close of phoenix channels). However, the code is a litteral copy paste of eclair, ported to Kotlin. Tests have not been modified, except two of them, which is due to a change in behavior: we are not pro-actively force closing channels when we detect that our peer is behind. Instead, we stay in stand-by and force-close when we receive their error.

pm47 added 4 commits April 16, 2024 15:37
We use a full pattern matching on the `when` to prevent future
omissions.
Use exhaustive match.
This is inspired from eclair, but changes are kept minimal. We don't
support the `RemoteLate` case.

Eclair had a full rework in ACINQ/eclair#2036,
that separated concerns better and got completely rid of exceptions.
This is the equivalent of ACINQ/eclair#2036.

Notably we remove the `RevocationSyncError` exception, and in case the
peer has an outdated commitment we stay in stand by, waiting for their
`error` before force-closing.
@pm47 pm47 requested a review from t-bast April 16, 2024 17:02
t-bast
t-bast previously approved these changes Apr 17, 2024
Copy link
Copy Markdown
Member

@t-bast t-bast left a comment

Choose a reason for hiding this comment

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

I've compared this to both eclair and the previous version of lightning-kmp, it looks good 👍

Comment thread src/commonTest/kotlin/fr/acinq/lightning/channel/states/ShutdownTestsCommon.kt Outdated
@pm47 pm47 merged commit 4b73825 into master Apr 17, 2024
@pm47 pm47 deleted the shutdown-reestablish branch April 17, 2024 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants