{"action":"created","comment":{"url":"https://api.github.com/repos/lightningnetwork/lnd/pulls/comments/201966696","pull_request_review_id":136568469,"id":201966696,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMTk2NjY5Ng==","diff_hunk":"@@ -3311,10 +3306,52 @@ func (lc *LightningChannel) ProcessChanSyncMsg(\n \t\treturn nil, nil, nil, ErrCannotSyncCommitChains\n \t}\n \n-\t// If we owe them a commitment, then we'll read from disk our\n-\t// commitment diff, so we can re-send them to the remote party.\n-\tif oweCommitment {\n-\t\t// Grab the current remote chain tip from the database. This\n+\t// Now check if our view of the remote chain is consistent with what\n+\t// they tell us.\n+\tswitch {\n+\n+\t// The remote's view of what their next commit height is 2+ states\n+\t// ahead of us, we most likely lost data, or the remote is trying to\n+\t// trick us. Since we have no way of verifying whether they are lying\n+\t// or not, we will fail the channel, but should not force close it\n+\t// automatically.\n+\tcase msg.NextLocalCommitHeight > remoteTipHeight+1:","path":"lnwallet/channel.go","position":238,"original_position":40,"commit_id":"d0af65199635c81d80cb3292e3c75493d77ff141","original_commit_id":"d6f4e8f1529d2e76e96d1d52a627177f7ae6190a","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":"It has already been checked in the above `switch`.","created_at":"2018-07-12T09:22:24Z","updated_at":"2018-07-12T09:22:24Z","html_url":"https://github.com/lightningnetwork/lnd/pull/1364#discussion_r201966696","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/201966696"},"html":{"href":"https://github.com/lightningnetwork/lnd/pull/1364#discussion_r201966696"},"pull_request":{"href":"https://api.github.com/repos/lightningnetwork/lnd/pulls/1364"}},"in_reply_to_id":200797560},"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:22:24Z","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"}}