{"action":"created","comment":{"url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/comments/201965131","pull_request_review_id":136566698,"id":201965131,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMTk2NTEzMQ==","diff_hunk":"@@ -66,20 +66,40 @@ var (\n \n \t// ErrCannotSyncCommitChains is returned if, upon receiving a ChanSync\n \t// message, the state machine deems that is unable to properly\n-\t// synchronize states with the remote peer.\n+\t// synchronize states with the remote peer. In this case we should fail\n+\t// the channel, but we won't automatically force close.\n \tErrCannotSyncCommitChains = fmt.Errorf(\"unable to sync commit chains\")\n \n \t// ErrInvalidLastCommitSecret is returned in the case that the\n \t// commitment secret sent by the remote party in their\n \t// ChannelReestablish message doesn't match the last secret we sent.\n \tErrInvalidLastCommitSecret = fmt.Errorf(\"commit secret is incorrect\")\n \n-\t// ErrCommitSyncDataLoss is returned in the case that we receive a\n+\t// ErrInvalidLocalUnrevokedCommitPoint is returned in the case that the\n+\t// commitment point sent by the remote party in their\n+\t// ChannelReestablish message doesn't match the last unrevoked commit\n+\t// point they sent us.\n+\tErrInvalidLocalUnrevokedCommitPoint = fmt.Errorf(\"unrevoked commit \" +\n+\t\t\"point is invalid\")\n+\n+\t// ErrCommitSyncLocalDataLoss is returned in the case that we receive a\n \t// valid commit secret within the ChannelReestablish message from the\n \t// remote node AND they advertise a RemoteCommitTailHeight higher than\n-\t// our current known height.\n-\tErrCommitSyncDataLoss = fmt.Errorf(\"possible commitment state data \" +\n-\t\t\"loss\")\n+\t// our current known height. This means we have lost some critical\n+\t// data, and must fail the channel and MUST NOT force close it. Instead\n+\t// we should wait for the remote to force close it, such that we can\n+\t// attempt to sweep our funds.\n+\tErrCommitSyncLocalDataLoss = fmt.Errorf(\"possible local commitment \" +","path":"lnwallet/channel.go","position":32,"original_position":32,"commit_id":"d0af65199635c81d80cb3292e3c75493d77ff141","original_commit_id":"fb031f9300636716ce02071f37814192f5aa89c1","user":{"login":"halseth","id":3765732,"node_id":"MDQ6VXNlcjM3NjU3MzI=","avatar_url":"https://avatars1.githubusercontent.com/u/3765732?v=4","gravatar_id":"","url":"https://api.github.com/users/halseth","html_url":"https://github.com/halseth","followers_url":"https://api.github.com/users/halseth/followers","following_url":"https://api.github.com/users/halseth/following{/other_user}","gists_url":"https://api.github.com/users/halseth/gists{/gist_id}","starred_url":"https://api.github.com/users/halseth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/halseth/subscriptions","organizations_url":"https://api.github.com/users/halseth/orgs","repos_url":"https://api.github.com/users/halseth/repos","events_url":"https://api.github.com/users/halseth/events{/privacy}","received_events_url":"https://api.github.com/users/halseth/received_events","type":"User","site_admin":false},"body":"Added a few TODOs to address this. Makes sense to do in a follow up as this PR doesn't alter how this is already enforced in master (it is not).\r\n\r\nWill create issue when merged.","created_at":"2018-07-12T09:17:41Z","updated_at":"2018-07-12T09:17:42Z","html_url":"https://github.com/lightningnetwork/lnd/pull/1364#discussion_r201965131","pull_request_url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/1364","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/comments/201965131"},"html":{"href":"https://github.com/lightningnetwork/lnd/pull/1364#discussion_r201965131"},"pull_request":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/1364"}},"in_reply_to_id":198698390},"pull_request":{"url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/1364","id":193978473,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkzOTc4NDcz","html_url":"https://github.com/lightningnetwork/lnd/pull/1364","diff_url":"https://github.com/lightningnetwork/lnd/pull/1364.diff","patch_url":"https://github.com/lightningnetwork/lnd/pull/1364.patch","issue_url":"https://api.github.com/repos/lightningnetwork/lnd/issues/1364","number":1364,"state":"open","locked":false,"title":"Data loss protection","user":{"login":"halseth","id":3765732,"node_id":"MDQ6VXNlcjM3NjU3MzI=","avatar_url":"https://avatars1.githubusercontent.com/u/3765732?v=4","gravatar_id":"","url":"https://api.github.com/users/halseth","html_url":"https://github.com/halseth","followers_url":"https://api.github.com/users/halseth/followers","following_url":"https://api.github.com/users/halseth/following{/other_user}","gists_url":"https://api.github.com/users/halseth/gists{/gist_id}","starred_url":"https://api.github.com/users/halseth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/halseth/subscriptions","organizations_url":"https://api.github.com/users/halseth/orgs","repos_url":"https://api.github.com/users/halseth/repos","events_url":"https://api.github.com/users/halseth/events{/privacy}","received_events_url":"https://api.github.com/users/halseth/received_events","type":"User","site_admin":false},"body":"This PR implements the logic required for \"data loss protection\", as described in BOLT#2: https://github.com/lightningnetwork/lightning-rfc/blob/master/02-peer-protocol.md#message-retransmission\r\n\r\nWhen syncing channel states we will now detect the cases where _we_ probably have lost our local state, meaning broadcasting our commitment would be unsafe as it could be considered a breach. Instead we store the `my_current_per_commitment_point` sent to us by the remote in the database. This commitment point can later be used to reclaim our funds if the remote party decides to unilaterally close the channel using the corresponding state.\r\n\r\nIf we detect that the remote party probably has lost state, we'll be a good citizen and force close the channel using our latest commitment.\r\n\r\n@Roasbeef: what is meant by:\r\n> In order to ensure we can carry out this process reliably we may need to ensure that they remote party first sends their re-sync message before we do. We can enforce this by requiring the initiator to send their message first.\r\n\r\n?\r\n\r\nFixes #1131","created_at":"2018-06-11T13:18:14Z","updated_at":"2018-07-12T09:17:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ab79728c5449c4eacaf6a5aa4cffcb34a2822bc3","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":990013318,"node_id":"MDU6TGFiZWw5OTAwMTMzMTg=","url":"https://api.github.com/repos/lightningnetwork/lnd/labels/P2","name":"P2","color":"fbca04","default":false},{"id":990064221,"node_id":"MDU6TGFiZWw5OTAwNjQyMjE=","url":"https://api.github.com/repos/lightningnetwork/lnd/labels/needs%20review","name":"needs review","color":"d4c5f9","default":false},{"id":990064318,"node_id":"MDU6TGFiZWw5OTAwNjQzMTg=","url":"https://api.github.com/repos/lightningnetwork/lnd/labels/needs%20testing","name":"needs testing","color":"a4f963","default":false},{"id":814687831,"node_id":"MDU6TGFiZWw4MTQ2ODc4MzE=","url":"https://api.github.com/repos/lightningnetwork/lnd/labels/recovery","name":"recovery","color":"ffeac4","default":false},{"id":537572675,"node_id":"MDU6TGFiZWw1Mzc1NzI2NzU=","url":"https://api.github.com/repos/lightningnetwork/lnd/labels/safety","name":"safety","color":"e99695","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/1364/commits","review_comments_url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/1364/comments","review_comment_url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lightningnetwork/lnd/issues/1364/comments","statuses_url":"https://api.github.com/repos/lightningnetwork/lnd/statuses/d0af65199635c81d80cb3292e3c75493d77ff141","head":{"label":"halseth:data-loss-protect","ref":"data-loss-protect","sha":"d0af65199635c81d80cb3292e3c75493d77ff141","user":{"login":"halseth","id":3765732,"node_id":"MDQ6VXNlcjM3NjU3MzI=","avatar_url":"https://avatars1.githubusercontent.com/u/3765732?v=4","gravatar_id":"","url":"https://api.github.com/users/halseth","html_url":"https://github.com/halseth","followers_url":"https://api.github.com/users/halseth/followers","following_url":"https://api.github.com/users/halseth/following{/other_user}","gists_url":"https://api.github.com/users/halseth/gists{/gist_id}","starred_url":"https://api.github.com/users/halseth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/halseth/subscriptions","organizations_url":"https://api.github.com/users/halseth/orgs","repos_url":"https://api.github.com/users/halseth/repos","events_url":"https://api.github.com/users/halseth/events{/privacy}","received_events_url":"https://api.github.com/users/halseth/received_events","type":"User","site_admin":false},"repo":{"id":86519132,"node_id":"MDEwOlJlcG9zaXRvcnk4NjUxOTEzMg==","name":"lnd","full_name":"halseth/lnd","owner":{"login":"halseth","id":3765732,"node_id":"MDQ6VXNlcjM3NjU3MzI=","avatar_url":"https://avatars1.githubusercontent.com/u/3765732?v=4","gravatar_id":"","url":"https://api.github.com/users/halseth","html_url":"https://github.com/halseth","followers_url":"https://api.github.com/users/halseth/followers","following_url":"https://api.github.com/users/halseth/following{/other_user}","gists_url":"https://api.github.com/users/halseth/gists{/gist_id}","starred_url":"https://api.github.com/users/halseth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/halseth/subscriptions","organizations_url":"https://api.github.com/users/halseth/orgs","repos_url":"https://api.github.com/users/halseth/repos","events_url":"https://api.github.com/users/halseth/events{/privacy}","received_events_url":"https://api.github.com/users/halseth/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/halseth/lnd","description":"Lightning Network Daemon ⚡️","fork":true,"url":"https://api.github.com/repos/halseth/lnd","forks_url":"https://api.github.com/repos/halseth/lnd/forks","keys_url":"https://api.github.com/repos/halseth/lnd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/halseth/lnd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/halseth/lnd/teams","hooks_url":"https://api.github.com/repos/halseth/lnd/hooks","issue_events_url":"https://api.github.com/repos/halseth/lnd/issues/events{/number}","events_url":"https://api.github.com/repos/halseth/lnd/events","assignees_url":"https://api.github.com/repos/halseth/lnd/assignees{/user}","branches_url":"https://api.github.com/repos/halseth/lnd/branches{/branch}","tags_url":"https://api.github.com/repos/halseth/lnd/tags","blobs_url":"https://api.github.com/repos/halseth/lnd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/halseth/lnd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/halseth/lnd/git/refs{/sha}","trees_url":"https://api.github.com/repos/halseth/lnd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/halseth/lnd/statuses/{sha}","languages_url":"https://api.github.com/repos/halseth/lnd/languages","stargazers_url":"https://api.github.com/repos/halseth/lnd/stargazers","contributors_url":"https://api.github.com/repos/halseth/lnd/contributors","subscribers_url":"https://api.github.com/repos/halseth/lnd/subscribers","subscription_url":"https://api.github.com/repos/halseth/lnd/subscription","commits_url":"https://api.github.com/repos/halseth/lnd/commits{/sha}","git_commits_url":"https://api.github.com/repos/halseth/lnd/git/commits{/sha}","comments_url":"https://api.github.com/repos/halseth/lnd/comments{/number}","issue_comment_url":"https://api.github.com/repos/halseth/lnd/issues/comments{/number}","contents_url":"https://api.github.com/repos/halseth/lnd/contents/{+path}","compare_url":"https://api.github.com/repos/halseth/lnd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/halseth/lnd/merges","archive_url":"https://api.github.com/repos/halseth/lnd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/halseth/lnd/downloads","issues_url":"https://api.github.com/repos/halseth/lnd/issues{/number}","pulls_url":"https://api.github.com/repos/halseth/lnd/pulls{/number}","milestones_url":"https://api.github.com/repos/halseth/lnd/milestones{/number}","notifications_url":"https://api.github.com/repos/halseth/lnd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/halseth/lnd/labels{/name}","releases_url":"https://api.github.com/repos/halseth/lnd/releases{/id}","deployments_url":"https://api.github.com/repos/halseth/lnd/deployments","created_at":"2017-03-29T00:00:37Z","updated_at":"2018-07-12T08:54:41Z","pushed_at":"2018-07-12T09:15:23Z","git_url":"git://github.com/halseth/lnd.git","ssh_url":"git@github.com:halseth/lnd.git","clone_url":"https://github.com/halseth/lnd.git","svn_url":"https://github.com/halseth/lnd","homepage":"","size":24937,"stargazers_count":3,"watchers_count":3,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":1,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":3,"open_issues":1,"watchers":3,"default_branch":"master"}},"base":{"label":"lightningnetwork:master","ref":"master","sha":"515ba7a4d0164ad9264287f6589821a2765c8528","user":{"login":"lightningnetwork","id":13424735,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNDI0NzM1","avatar_url":"https://avatars0.githubusercontent.com/u/13424735?v=4","gravatar_id":"","url":"https://api.github.com/users/lightningnetwork","html_url":"https://github.com/lightningnetwork","followers_url":"https://api.github.com/users/lightningnetwork/followers","following_url":"https://api.github.com/users/lightningnetwork/following{/other_user}","gists_url":"https://api.github.com/users/lightningnetwork/gists{/gist_id}","starred_url":"https://api.github.com/users/lightningnetwork/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lightningnetwork/subscriptions","organizations_url":"https://api.github.com/users/lightningnetwork/orgs","repos_url":"https://api.github.com/users/lightningnetwork/repos","events_url":"https://api.github.com/users/lightningnetwork/events{/privacy}","received_events_url":"https://api.github.com/users/lightningnetwork/received_events","type":"Organization","site_admin":false},"repo":{"id":49765480,"node_id":"MDEwOlJlcG9zaXRvcnk0OTc2NTQ4MA==","name":"lnd","full_name":"lightningnetwork/lnd","owner":{"login":"lightningnetwork","id":13424735,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNDI0NzM1","avatar_url":"https://avatars0.githubusercontent.com/u/13424735?v=4","gravatar_id":"","url":"https://api.github.com/users/lightningnetwork","html_url":"https://github.com/lightningnetwork","followers_url":"https://api.github.com/users/lightningnetwork/followers","following_url":"https://api.github.com/users/lightningnetwork/following{/other_user}","gists_url":"https://api.github.com/users/lightningnetwork/gists{/gist_id}","starred_url":"https://api.github.com/users/lightningnetwork/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lightningnetwork/subscriptions","organizations_url":"https://api.github.com/users/lightningnetwork/orgs","repos_url":"https://api.github.com/users/lightningnetwork/repos","events_url":"https://api.github.com/users/lightningnetwork/events{/privacy}","received_events_url":"https://api.github.com/users/lightningnetwork/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lightningnetwork/lnd","description":"Lightning Network Daemon ⚡️","fork":false,"url":"https://api.github.com/repos/lightningnetwork/lnd","forks_url":"https://api.github.com/repos/lightningnetwork/lnd/forks","keys_url":"https://api.github.com/repos/lightningnetwork/lnd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lightningnetwork/lnd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lightningnetwork/lnd/teams","hooks_url":"https://api.github.com/repos/lightningnetwork/lnd/hooks","issue_events_url":"https://api.github.com/repos/lightningnetwork/lnd/issues/events{/number}","events_url":"https://api.github.com/repos/lightningnetwork/lnd/events","assignees_url":"https://api.github.com/repos/lightningnetwork/lnd/assignees{/user}","branches_url":"https://api.github.com/repos/lightningnetwork/lnd/branches{/branch}","tags_url":"https://api.github.com/repos/lightningnetwork/lnd/tags","blobs_url":"https://api.github.com/repos/lightningnetwork/lnd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lightningnetwork/lnd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lightningnetwork/lnd/git/refs{/sha}","trees_url":"https://api.github.com/repos/lightningnetwork/lnd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lightningnetwork/lnd/statuses/{sha}","languages_url":"https://api.github.com/repos/lightningnetwork/lnd/languages","stargazers_url":"https://api.github.com/repos/lightningnetwork/lnd/stargazers","contributors_url":"https://api.github.com/repos/lightningnetwork/lnd/contributors","subscribers_url":"https://api.github.com/repos/lightningnetwork/lnd/subscribers","subscription_url":"https://api.github.com/repos/lightningnetwork/lnd/subscription","commits_url":"https://api.github.com/repos/lightningnetwork/lnd/commits{/sha}","git_commits_url":"https://api.github.com/repos/lightningnetwork/lnd/git/commits{/sha}","comments_url":"https://api.github.com/repos/lightningnetwork/lnd/comments{/number}","issue_comment_url":"https://api.github.com/repos/lightningnetwork/lnd/issues/comments{/number}","contents_url":"https://api.github.com/repos/lightningnetwork/lnd/contents/{+path}","compare_url":"https://api.github.com/repos/lightningnetwork/lnd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lightningnetwork/lnd/merges","archive_url":"https://api.github.com/repos/lightningnetwork/lnd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lightningnetwork/lnd/downloads","issues_url":"https://api.github.com/repos/lightningnetwork/lnd/issues{/number}","pulls_url":"https://api.github.com/repos/lightningnetwork/lnd/pulls{/number}","milestones_url":"https://api.github.com/repos/lightningnetwork/lnd/milestones{/number}","notifications_url":"https://api.github.com/repos/lightningnetwork/lnd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lightningnetwork/lnd/labels{/name}","releases_url":"https://api.github.com/repos/lightningnetwork/lnd/releases{/id}","deployments_url":"https://api.github.com/repos/lightningnetwork/lnd/deployments","created_at":"2016-01-16T08:19:33Z","updated_at":"2018-07-12T02:14:46Z","pushed_at":"2018-07-12T09:15:26Z","git_url":"git://github.com/lightningnetwork/lnd.git","ssh_url":"git@github.com:lightningnetwork/lnd.git","clone_url":"https://github.com/lightningnetwork/lnd.git","svn_url":"https://github.com/lightningnetwork/lnd","homepage":"","size":16750,"stargazers_count":2773,"watchers_count":2773,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":678,"mirror_url":null,"archived":false,"open_issues_count":199,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":678,"open_issues":199,"watchers":2773,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/1364"},"html":{"href":"https://github.com/lightningnetwork/lnd/pull/1364"},"issue":{"href":"https://api.github.com/repos/lightningnetwork/lnd/issues/1364"},"comments":{"href":"https://api.github.com/repos/lightningnetwork/lnd/issues/1364/comments"},"review_comments":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/1364/comments"},"review_comment":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/1364/commits"},"statuses":{"href":"https://api.github.com/repos/lightningnetwork/lnd/statuses/d0af65199635c81d80cb3292e3c75493d77ff141"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"halseth"}}