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

backups: Keep channel backup in case of local force close #5528

Merged

Conversation

guggero
Copy link
Collaborator

@guggero guggero commented Jul 15, 2021

In case we force close a channel from our end the funds can be time
locked for up to 2 weeks worst case. If something happens to our node in
that time, we don't have any information on that channel anymore because
currently the channel is removed from the channel backup file the moment
the commitment transaction confirms.
Instead we want to keep the channel around in the SCB file until we've
actually swept the time locked funds.

It looks like lnd even supports recovering from such a case if the peer
is still online and can tell us what commit height to use for deriving
the commit point. If the peer isn't around anymore then external tools
could be used to brute force the commit height.

Thanks to @joostjager for making me aware this problem existed.

@guggero guggero added safety General label for issues/PRs related to the safety of using the software recovery Related to the backup/restoration of LND data (e.g. wallet seeds) backups labels Jul 15, 2021
@Roasbeef Roasbeef added this to the v0.14.0 milestone Jul 22, 2021
Copy link
Member

@Roasbeef Roasbeef left a comment

Choose a reason for hiding this comment

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

LGTM 📽

// by Carol since it was already force closed before we started the
// recovery. All we need is for Carol to send us over the commit height
// so we can sweep the time locked output with the correct commit point.
if testCase.localForceClose {
Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Member

Choose a reason for hiding this comment

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

As you mentioned in the OP, in the future we could provide the brute force logic locally in the chain watcher if we detect this case.

@guggero guggero force-pushed the keep-channel-backup-local-force-close branch 2 times, most recently from f56bfb4 to aa2706f Compare July 23, 2021 09:00
@Roasbeef
Copy link
Member

Roasbeef commented Aug 5, 2021

With the latest test run, looks like some other tests need to be updated for the extra even that gets emitted now (itests).

We'll want to be informed about a channel that's been fully resolved on
chain in case it was involved in a force close. We add a new event type
and emit method for it.
We might want to react to a channel being fully resolved after being
involved in a force close. For this we add a new callback and invoke it
where appropriate.
In case we force close a channel from our end the funds can be time
locked for up to 2 weeks worst case. If something happens to our node in
that time, we don't have any information on that channel anymore because
currently the channel is removed from the channel backup file the moment
the commitment transaction confirms.
Instead we want to keep the channel around in the SCB file until we've
actually swept the time locked funds.

It looks like lnd even supports recovering from such a case if the peer
is still online and can tell us what commit height to use for deriving
the commit point. If the peer isn't around anymore then external tools
could be used to brute force the commit height.
This commit adds the new channel update event for a channel that is now
fully resolved to the event subscription RPC.
With one more notification event being dispatched in the local force
close case we need to update one of the integration tests to account for
the additional message.
We want to make sure we can recover funds from a channel that was force
closed by the local node just before the node needed to be restored. We
add a special test case with specific assertions for that scenario.
@guggero guggero force-pushed the keep-channel-backup-local-force-close branch from aa2706f to dee28ee Compare August 9, 2021 12:49
Because we now get one more update per channel when closing it, we need
to update our test that looks at the close notifications sent by the
SubscribeChannelEvent RPC.
@guggero guggero force-pushed the keep-channel-backup-local-force-close branch from dee28ee to 527c6f0 Compare August 9, 2021 14:07
@Roasbeef Roasbeef merged commit be341bc into lightningnetwork:master Aug 11, 2021
@guggero guggero deleted the keep-channel-backup-local-force-close branch August 11, 2021 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backups recovery Related to the backup/restoration of LND data (e.g. wallet seeds) safety General label for issues/PRs related to the safety of using the software
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants