{"action":"created","comment":{"url":"https://api.github.com/repos/raiden-network/raiden/pulls/comments/232287803","pull_request_review_id":173454909,"id":232287803,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMjI4NzgwMw==","diff_hunk":"@@ -624,37 +652,54 @@ def set_total_deposit(\n             receipt_or_none = check_transaction_threw(self.client, transaction_hash)\n \n             if receipt_or_none:\n-                latest_deposit = self.detail_participant(\n-                    channel_identifier,\n-                    self.node_address,\n-                    partner,\n-                ).deposit\n+                self._check_why_deposit_failed(\n+                    channel_identifier=channel_identifier,\n+                    partner=partner,\n+                    token=token,\n+                    amount_to_deposit=amount_to_deposit,\n+                    total_deposit=total_deposit,\n+                    log_details=log_details,\n+                )\n+                raise TransactionThrew('Deposit', receipt_or_none)\n \n-                if token.allowance(self.node_address, self.address) < amount_to_deposit:\n-                    log_msg = (\n-                        'setTotalDeposit failed. The allowance is insufficient, '\n-                        'check concurrent deposits for the same token network '\n-                        'but different proxies.'\n-                    )\n-                elif token.balance_of(self.node_address) < amount_to_deposit:\n-                    log_msg = 'setTotalDeposit failed. The address doesnt have funds'\n-                elif latest_deposit < total_deposit:\n-                    log_msg = 'setTotalDeposit failed. The tokens were not transferred'\n-                else:\n-                    log_msg = 'setTotalDeposit failed'\n+            log.info('setTotalDeposit successful', **log_details)\n \n-                log.critical(log_msg, **log_details)\n+    def _check_why_deposit_failed(\n+            self,\n+            channel_identifier: typing.ChannelID,\n+            partner: typing.Address,\n+            token: Token,\n+            amount_to_deposit: typing.TokenAmount,\n+            total_deposit: typing.TokenAmount,\n+            log_details: typing.Dict,\n+    ):\n+        latest_deposit = self.detail_participant(\n+            channel_identifier,\n+            self.node_address,\n+            partner,\n+        ).deposit\n \n-                self._check_channel_state_for_deposit(\n-                    self.node_address,\n-                    partner,\n-                    channel_identifier,\n-                    total_deposit,\n-                )\n+        if token.allowance(self.node_address, self.address) < amount_to_deposit:\n+            log_msg = (\n+                'setTotalDeposit failed. The allowance is insufficient, '\n+                'check concurrent deposits for the same token network '\n+                'but different proxies.'\n+            )\n+        elif token.balance_of(self.node_address) < amount_to_deposit:\n+            log_msg = 'setTotalDeposit failed. The address doesnt have funds'\n+        elif latest_deposit < total_deposit:\n+            log_msg = 'setTotalDeposit failed. The tokens were not transferred'\n+        else:\n+            log_msg = 'setTotalDeposit failed'\n \n-                raise TransactionThrew('Deposit', receipt_or_none)\n+        log.critical(log_msg, **log_details)\n \n-            log.info('setTotalDeposit successful', **log_details)\n+        self._check_channel_state_for_deposit(\n+            self.node_address,","path":"raiden/network/proxies/token_network.py","position":166,"original_position":166,"commit_id":"8776c8fdc9e19aa80f4a7f93230bea4af4422311","original_commit_id":"8776c8fdc9e19aa80f4a7f93230bea4af4422311","user":{"login":"palango","id":90851,"node_id":"MDQ6VXNlcjkwODUx","avatar_url":"https://avatars1.githubusercontent.com/u/90851?v=4","gravatar_id":"","url":"https://api.github.com/users/palango","html_url":"https://github.com/palango","followers_url":"https://api.github.com/users/palango/followers","following_url":"https://api.github.com/users/palango/following{/other_user}","gists_url":"https://api.github.com/users/palango/gists{/gist_id}","starred_url":"https://api.github.com/users/palango/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palango/subscriptions","organizations_url":"https://api.github.com/users/palango/orgs","repos_url":"https://api.github.com/users/palango/repos","events_url":"https://api.github.com/users/palango/events{/privacy}","received_events_url":"https://api.github.com/users/palango/received_events","type":"User","site_admin":false},"body":"nit: use kwargs","created_at":"2018-11-09T15:17:37Z","updated_at":"2018-11-09T15:19:50Z","html_url":"https://github.com/raiden-network/raiden/pull/2988#discussion_r232287803","pull_request_url":"https://api.github.com/repos/raiden-network/raiden/pulls/2988","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/raiden-network/raiden/pulls/comments/232287803"},"html":{"href":"https://github.com/raiden-network/raiden/pull/2988#discussion_r232287803"},"pull_request":{"href":"https://api.github.com/repos/raiden-network/raiden/pulls/2988"}}},"pull_request":{"url":"https://api.github.com/repos/raiden-network/raiden/pulls/2988","id":229540009,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI5NTQwMDA5","html_url":"https://github.com/raiden-network/raiden/pull/2988","diff_url":"https://github.com/raiden-network/raiden/pull/2988.diff","patch_url":"https://github.com/raiden-network/raiden/pull/2988.patch","issue_url":"https://api.github.com/repos/raiden-network/raiden/issues/2988","number":2988,"state":"open","locked":false,"title":"Try to handle estimateGas predicting that a call will fail","user":{"login":"LefterisJP","id":1658405,"node_id":"MDQ6VXNlcjE2NTg0MDU=","avatar_url":"https://avatars1.githubusercontent.com/u/1658405?v=4","gravatar_id":"","url":"https://api.github.com/users/LefterisJP","html_url":"https://github.com/LefterisJP","followers_url":"https://api.github.com/users/LefterisJP/followers","following_url":"https://api.github.com/users/LefterisJP/following{/other_user}","gists_url":"https://api.github.com/users/LefterisJP/gists{/gist_id}","starred_url":"https://api.github.com/users/LefterisJP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LefterisJP/subscriptions","organizations_url":"https://api.github.com/users/LefterisJP/orgs","repos_url":"https://api.github.com/users/LefterisJP/repos","events_url":"https://api.github.com/users/LefterisJP/events{/privacy}","received_events_url":"https://api.github.com/users/LefterisJP/received_events","type":"User","site_admin":false},"body":"After the changes introduced by https://github.com/raiden-network/raiden/pull/2623/ we again rely on gas estimation for the gas limit to provide to an onchain call which is great since it reduces our overall ETH balance requirements.\r\n\r\nBut we don't take into account the fact that if estimateGas returns `None` it's\r\nbecause the transaction will fail, either due to our account not having enough\r\nfunds or because the call will just revert somewhere down the line due to the\r\ncontract logic (e.g. calling settle before closing).\r\n\r\nWith that in mind we can now detect those bad cases a bit earlier and handle\r\nthem without sending an onchain transaction. This is what this PR is trying to achieve.\r\n\r\nAdmittedly all those cases are bad ones. Since all the checks should have stopped us from getting into that part of the code in the first place, unless we expected that sending an onchain transaction will succeed.","created_at":"2018-11-08T23:16:54Z","updated_at":"2018-11-09T15:19:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5dcf3511dcc5a22dbf0b0eeeaeebf7df343c5c17","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":456350195,"node_id":"MDU6TGFiZWw0NTYzNTAxOTU=","url":"https://api.github.com/repos/raiden-network/raiden/labels/dev:%20Please%20Review","name":"dev: Please Review","color":"006b75","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/raiden-network/raiden/pulls/2988/commits","review_comments_url":"https://api.github.com/repos/raiden-network/raiden/pulls/2988/comments","review_comment_url":"https://api.github.com/repos/raiden-network/raiden/pulls/comments{/number}","comments_url":"https://api.github.com/repos/raiden-network/raiden/issues/2988/comments","statuses_url":"https://api.github.com/repos/raiden-network/raiden/statuses/8776c8fdc9e19aa80f4a7f93230bea4af4422311","head":{"label":"LefterisJP:when_estimate_gas_returns_none_call_will_fail","ref":"when_estimate_gas_returns_none_call_will_fail","sha":"8776c8fdc9e19aa80f4a7f93230bea4af4422311","user":{"login":"LefterisJP","id":1658405,"node_id":"MDQ6VXNlcjE2NTg0MDU=","avatar_url":"https://avatars1.githubusercontent.com/u/1658405?v=4","gravatar_id":"","url":"https://api.github.com/users/LefterisJP","html_url":"https://github.com/LefterisJP","followers_url":"https://api.github.com/users/LefterisJP/followers","following_url":"https://api.github.com/users/LefterisJP/following{/other_user}","gists_url":"https://api.github.com/users/LefterisJP/gists{/gist_id}","starred_url":"https://api.github.com/users/LefterisJP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LefterisJP/subscriptions","organizations_url":"https://api.github.com/users/LefterisJP/orgs","repos_url":"https://api.github.com/users/LefterisJP/repos","events_url":"https://api.github.com/users/LefterisJP/events{/privacy}","received_events_url":"https://api.github.com/users/LefterisJP/received_events","type":"User","site_admin":false},"repo":{"id":69238217,"node_id":"MDEwOlJlcG9zaXRvcnk2OTIzODIxNw==","name":"raiden","full_name":"LefterisJP/raiden","private":false,"owner":{"login":"LefterisJP","id":1658405,"node_id":"MDQ6VXNlcjE2NTg0MDU=","avatar_url":"https://avatars1.githubusercontent.com/u/1658405?v=4","gravatar_id":"","url":"https://api.github.com/users/LefterisJP","html_url":"https://github.com/LefterisJP","followers_url":"https://api.github.com/users/LefterisJP/followers","following_url":"https://api.github.com/users/LefterisJP/following{/other_user}","gists_url":"https://api.github.com/users/LefterisJP/gists{/gist_id}","starred_url":"https://api.github.com/users/LefterisJP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LefterisJP/subscriptions","organizations_url":"https://api.github.com/users/LefterisJP/orgs","repos_url":"https://api.github.com/users/LefterisJP/repos","events_url":"https://api.github.com/users/LefterisJP/events{/privacy}","received_events_url":"https://api.github.com/users/LefterisJP/received_events","type":"User","site_admin":false},"html_url":"https://github.com/LefterisJP/raiden","description":"Raiden Network","fork":true,"url":"https://api.github.com/repos/LefterisJP/raiden","forks_url":"https://api.github.com/repos/LefterisJP/raiden/forks","keys_url":"https://api.github.com/repos/LefterisJP/raiden/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LefterisJP/raiden/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LefterisJP/raiden/teams","hooks_url":"https://api.github.com/repos/LefterisJP/raiden/hooks","issue_events_url":"https://api.github.com/repos/LefterisJP/raiden/issues/events{/number}","events_url":"https://api.github.com/repos/LefterisJP/raiden/events","assignees_url":"https://api.github.com/repos/LefterisJP/raiden/assignees{/user}","branches_url":"https://api.github.com/repos/LefterisJP/raiden/branches{/branch}","tags_url":"https://api.github.com/repos/LefterisJP/raiden/tags","blobs_url":"https://api.github.com/repos/LefterisJP/raiden/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LefterisJP/raiden/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LefterisJP/raiden/git/refs{/sha}","trees_url":"https://api.github.com/repos/LefterisJP/raiden/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LefterisJP/raiden/statuses/{sha}","languages_url":"https://api.github.com/repos/LefterisJP/raiden/languages","stargazers_url":"https://api.github.com/repos/LefterisJP/raiden/stargazers","contributors_url":"https://api.github.com/repos/LefterisJP/raiden/contributors","subscribers_url":"https://api.github.com/repos/LefterisJP/raiden/subscribers","subscription_url":"https://api.github.com/repos/LefterisJP/raiden/subscription","commits_url":"https://api.github.com/repos/LefterisJP/raiden/commits{/sha}","git_commits_url":"https://api.github.com/repos/LefterisJP/raiden/git/commits{/sha}","comments_url":"https://api.github.com/repos/LefterisJP/raiden/comments{/number}","issue_comment_url":"https://api.github.com/repos/LefterisJP/raiden/issues/comments{/number}","contents_url":"https://api.github.com/repos/LefterisJP/raiden/contents/{+path}","compare_url":"https://api.github.com/repos/LefterisJP/raiden/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LefterisJP/raiden/merges","archive_url":"https://api.github.com/repos/LefterisJP/raiden/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LefterisJP/raiden/downloads","issues_url":"https://api.github.com/repos/LefterisJP/raiden/issues{/number}","pulls_url":"https://api.github.com/repos/LefterisJP/raiden/pulls{/number}","milestones_url":"https://api.github.com/repos/LefterisJP/raiden/milestones{/number}","notifications_url":"https://api.github.com/repos/LefterisJP/raiden/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LefterisJP/raiden/labels{/name}","releases_url":"https://api.github.com/repos/LefterisJP/raiden/releases{/id}","deployments_url":"https://api.github.com/repos/LefterisJP/raiden/deployments","created_at":"2016-09-26T10:14:16Z","updated_at":"2018-11-08T10:59:29Z","pushed_at":"2018-11-09T13:33:24Z","git_url":"git://github.com/LefterisJP/raiden.git","ssh_url":"git@github.com:LefterisJP/raiden.git","clone_url":"https://github.com/LefterisJP/raiden.git","svn_url":"https://github.com/LefterisJP/raiden","homepage":null,"size":13214,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"raiden-network:master","ref":"master","sha":"81cd7b6279ebce3a22495a4787130e0cbac9be06","user":{"login":"raiden-network","id":19666847,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5NjY2ODQ3","avatar_url":"https://avatars1.githubusercontent.com/u/19666847?v=4","gravatar_id":"","url":"https://api.github.com/users/raiden-network","html_url":"https://github.com/raiden-network","followers_url":"https://api.github.com/users/raiden-network/followers","following_url":"https://api.github.com/users/raiden-network/following{/other_user}","gists_url":"https://api.github.com/users/raiden-network/gists{/gist_id}","starred_url":"https://api.github.com/users/raiden-network/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raiden-network/subscriptions","organizations_url":"https://api.github.com/users/raiden-network/orgs","repos_url":"https://api.github.com/users/raiden-network/repos","events_url":"https://api.github.com/users/raiden-network/events{/privacy}","received_events_url":"https://api.github.com/users/raiden-network/received_events","type":"Organization","site_admin":false},"repo":{"id":50646767,"node_id":"MDEwOlJlcG9zaXRvcnk1MDY0Njc2Nw==","name":"raiden","full_name":"raiden-network/raiden","private":false,"owner":{"login":"raiden-network","id":19666847,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE5NjY2ODQ3","avatar_url":"https://avatars1.githubusercontent.com/u/19666847?v=4","gravatar_id":"","url":"https://api.github.com/users/raiden-network","html_url":"https://github.com/raiden-network","followers_url":"https://api.github.com/users/raiden-network/followers","following_url":"https://api.github.com/users/raiden-network/following{/other_user}","gists_url":"https://api.github.com/users/raiden-network/gists{/gist_id}","starred_url":"https://api.github.com/users/raiden-network/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raiden-network/subscriptions","organizations_url":"https://api.github.com/users/raiden-network/orgs","repos_url":"https://api.github.com/users/raiden-network/repos","events_url":"https://api.github.com/users/raiden-network/events{/privacy}","received_events_url":"https://api.github.com/users/raiden-network/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/raiden-network/raiden","description":"Raiden Network","fork":false,"url":"https://api.github.com/repos/raiden-network/raiden","forks_url":"https://api.github.com/repos/raiden-network/raiden/forks","keys_url":"https://api.github.com/repos/raiden-network/raiden/keys{/key_id}","collaborators_url":"https://api.github.com/repos/raiden-network/raiden/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/raiden-network/raiden/teams","hooks_url":"https://api.github.com/repos/raiden-network/raiden/hooks","issue_events_url":"https://api.github.com/repos/raiden-network/raiden/issues/events{/number}","events_url":"https://api.github.com/repos/raiden-network/raiden/events","assignees_url":"https://api.github.com/repos/raiden-network/raiden/assignees{/user}","branches_url":"https://api.github.com/repos/raiden-network/raiden/branches{/branch}","tags_url":"https://api.github.com/repos/raiden-network/raiden/tags","blobs_url":"https://api.github.com/repos/raiden-network/raiden/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/raiden-network/raiden/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/raiden-network/raiden/git/refs{/sha}","trees_url":"https://api.github.com/repos/raiden-network/raiden/git/trees{/sha}","statuses_url":"https://api.github.com/repos/raiden-network/raiden/statuses/{sha}","languages_url":"https://api.github.com/repos/raiden-network/raiden/languages","stargazers_url":"https://api.github.com/repos/raiden-network/raiden/stargazers","contributors_url":"https://api.github.com/repos/raiden-network/raiden/contributors","subscribers_url":"https://api.github.com/repos/raiden-network/raiden/subscribers","subscription_url":"https://api.github.com/repos/raiden-network/raiden/subscription","commits_url":"https://api.github.com/repos/raiden-network/raiden/commits{/sha}","git_commits_url":"https://api.github.com/repos/raiden-network/raiden/git/commits{/sha}","comments_url":"https://api.github.com/repos/raiden-network/raiden/comments{/number}","issue_comment_url":"https://api.github.com/repos/raiden-network/raiden/issues/comments{/number}","contents_url":"https://api.github.com/repos/raiden-network/raiden/contents/{+path}","compare_url":"https://api.github.com/repos/raiden-network/raiden/compare/{base}...{head}","merges_url":"https://api.github.com/repos/raiden-network/raiden/merges","archive_url":"https://api.github.com/repos/raiden-network/raiden/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/raiden-network/raiden/downloads","issues_url":"https://api.github.com/repos/raiden-network/raiden/issues{/number}","pulls_url":"https://api.github.com/repos/raiden-network/raiden/pulls{/number}","milestones_url":"https://api.github.com/repos/raiden-network/raiden/milestones{/number}","notifications_url":"https://api.github.com/repos/raiden-network/raiden/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/raiden-network/raiden/labels{/name}","releases_url":"https://api.github.com/repos/raiden-network/raiden/releases{/id}","deployments_url":"https://api.github.com/repos/raiden-network/raiden/deployments","created_at":"2016-01-29T07:40:47Z","updated_at":"2018-11-09T14:55:03Z","pushed_at":"2018-11-09T14:54:58Z","git_url":"git://github.com/raiden-network/raiden.git","ssh_url":"git@github.com:raiden-network/raiden.git","clone_url":"https://github.com/raiden-network/raiden.git","svn_url":"https://github.com/raiden-network/raiden","homepage":null,"size":11780,"stargazers_count":1588,"watchers_count":1588,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":330,"mirror_url":null,"archived":false,"open_issues_count":193,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":330,"open_issues":193,"watchers":1588,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/raiden-network/raiden/pulls/2988"},"html":{"href":"https://github.com/raiden-network/raiden/pull/2988"},"issue":{"href":"https://api.github.com/repos/raiden-network/raiden/issues/2988"},"comments":{"href":"https://api.github.com/repos/raiden-network/raiden/issues/2988/comments"},"review_comments":{"href":"https://api.github.com/repos/raiden-network/raiden/pulls/2988/comments"},"review_comment":{"href":"https://api.github.com/repos/raiden-network/raiden/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/raiden-network/raiden/pulls/2988/commits"},"statuses":{"href":"https://api.github.com/repos/raiden-network/raiden/statuses/8776c8fdc9e19aa80f4a7f93230bea4af4422311"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"palango"}}