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

contractcourt: detect local force closes based on commitment outputs #2855

Merged

Conversation

Roasbeef
Copy link
Member

In this commit, we modify the way we detect local force closes. Before
this commit, we would directly check the broadcast commitment's txid
against what we know to be our best local commitment. In the case of DLP
recovery from an SCB, it's possible that the user force closed, then
attempted to recover their channels. As a result, we need to check the
outputs directly in order to also handle this rare, but
possible recovery scenario.

The new detection method uses the outputs to detect if it's a local
commitment or not. Based on the state number, we'll re-derive the
expected scripts, and check to see if they're on the commitment. If not,
then we know it's a remote force close. A new test has been added to
exercise this new behavior, ensuring we catch local closes where we have
and don't have a direct output.

@Roasbeef Roasbeef force-pushed the output-based-force-close-detection branch from b66d84e to 203a394 Compare March 30, 2019 02:08
Copy link
Contributor

@cfromknecht cfromknecht left a comment

Choose a reason for hiding this comment

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

ACK for more generic commitment identification, changes themselves lgtm. Needs rebase tho now that #2313 is in

contractcourt/chain_watcher_test.go Outdated Show resolved Hide resolved
contractcourt/chain_watcher.go Show resolved Hide resolved
contractcourt/chain_watcher_test.go Outdated Show resolved Hide resolved
@cfromknecht cfromknecht added this to the 0.7 milestone Apr 11, 2019
@Roasbeef Roasbeef modified the milestones: 0.7, 0.6.1 Apr 12, 2019
@cfromknecht
Copy link
Contributor

needs rebase

@Roasbeef Roasbeef force-pushed the output-based-force-close-detection branch from 203a394 to 46d7f93 Compare April 19, 2019 23:22
@Roasbeef
Copy link
Member Author

Rebased with comments addressed. Planning on making a follow up PR to the DLP chain watcher tests to improve the execution time of the tests as I did these ones.

@Roasbeef Roasbeef added commitments Commitment transactions containing the state of the channel enhancement Improvements to existing features / behaviour safety General label for issues/PRs related to the safety of using the software SCB Related to static channel backup labels Apr 20, 2019
@Roasbeef
Copy link
Member Author

PTAL @cfromknecht @halseth

@Roasbeef Roasbeef force-pushed the output-based-force-close-detection branch from 46d7f93 to 32569ef Compare April 25, 2019 00:01
contractcourt/chain_watcher.go Show resolved Hide resolved
contractcourt/chain_watcher_test.go Outdated Show resolved Hide resolved
contractcourt/chain_watcher_test.go Show resolved Hide resolved
contractcourt/chain_watcher_test.go Show resolved Hide resolved
@Roasbeef Roasbeef force-pushed the output-based-force-close-detection branch from 32569ef to 4f5e23f Compare April 25, 2019 23:09
@Roasbeef
Copy link
Member Author

PTAL @halseth

In this commit, we modify the way we detect local force closes. Before
this commit, we would directly check the broadcast commitment's txid
against what we know to be our best local commitment. In the case of DLP
recovery from an SCB, it's possible that the user force closed, _then_
attempted to recover their channels. As a result, we need to check the
outputs directly in order to also handle this rare, but
possible recovery scenario.

The new detection method uses the outputs to detect if it's a local
commitment or not. Based on the state number, we'll re-derive the
expected scripts, and check to see if they're on the commitment. If not,
then we know it's a remote force close. A new test has been added to
exercise this new behavior, ensuring we catch local closes where we have
and don't have a direct output.
@Roasbeef Roasbeef force-pushed the output-based-force-close-detection branch from 4f5e23f to bdf1194 Compare April 26, 2019 22:13
@Roasbeef
Copy link
Member Author

Rebased after the other related PR landed before this one.

Copy link
Contributor

@cfromknecht cfromknecht left a comment

Choose a reason for hiding this comment

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

LGTM 👌

@Roasbeef
Copy link
Member Author

PTAL @halseth

Copy link
Contributor

@halseth halseth left a comment

Choose a reason for hiding this comment

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

LGTM 💯

@Roasbeef Roasbeef merged commit 1acd38e into lightningnetwork:master Apr 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commitments Commitment transactions containing the state of the channel enhancement Improvements to existing features / behaviour safety General label for issues/PRs related to the safety of using the software SCB Related to static channel backup
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants