{"action":"created","issue":{"url":"https://api.github.com/repos/ethereum/go-ethereum/issues/1153","labels_url":"https://api.github.com/repos/ethereum/go-ethereum/issues/1153/labels{/name}","comments_url":"https://api.github.com/repos/ethereum/go-ethereum/issues/1153/comments","events_url":"https://api.github.com/repos/ethereum/go-ethereum/issues/1153/events","html_url":"https://github.com/ethereum/go-ethereum/pull/1153","id":82565957,"number":1153,"title":"eth/downloader: gather and ban hashes from invalid chains","user":{"login":"karalabe","id":129561,"avatar_url":"https://avatars.githubusercontent.com/u/129561?v=3","gravatar_id":"","url":"https://api.github.com/users/karalabe","html_url":"https://github.com/karalabe","followers_url":"https://api.github.com/users/karalabe/followers","following_url":"https://api.github.com/users/karalabe/following{/other_user}","gists_url":"https://api.github.com/users/karalabe/gists{/gist_id}","starred_url":"https://api.github.com/users/karalabe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karalabe/subscriptions","organizations_url":"https://api.github.com/users/karalabe/orgs","repos_url":"https://api.github.com/users/karalabe/repos","events_url":"https://api.github.com/users/karalabe/events{/privacy}","received_events_url":"https://api.github.com/users/karalabe/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/ethereum/go-ethereum/labels/in%20progress","name":"in progress","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-29T20:04:35Z","updated_at":"2015-05-29T20:35:43Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ethereum/go-ethereum/pulls/1153","html_url":"https://github.com/ethereum/go-ethereum/pull/1153","diff_url":"https://github.com/ethereum/go-ethereum/pull/1153.diff","patch_url":"https://github.com/ethereum/go-ethereum/pull/1153.patch"},"body":"This fix introduces a defense mechanism against downloader starvation, whereby if a peer tries to feed it a banned hash chain, the downloader will not only disconnect the bad peer, but also block a batch of hashes from said chain so that if the malicious/bad peer reappears, we can detect him faster.\r\n\r\nTo do this, if a banned hash is encountered, the downloader requests the previous 128 blocks, verifies that said blocks form a valid chain (hashes, parents) and are rooted in the banned hash. If validations pass, the hash of the head block of this batch is banned. Hence if the peer returns, next time it can feed us 128 less hashes.\r\n\r\nThe reason for not pulling the entire invalid chain is that it can be quite large and there's no need to waste resources on junk. If the peer reconencts, we block another batch, if it doesn't, then don't waste memory and bandwidth."},"comment":{"url":"https://api.github.com/repos/ethereum/go-ethereum/issues/comments/106928507","html_url":"https://github.com/ethereum/go-ethereum/pull/1153#issuecomment-106928507","issue_url":"https://api.github.com/repos/ethereum/go-ethereum/issues/1153","id":106928507,"user":{"login":"Gustav-Simonsson","id":293096,"avatar_url":"https://avatars.githubusercontent.com/u/293096?v=3","gravatar_id":"","url":"https://api.github.com/users/Gustav-Simonsson","html_url":"https://github.com/Gustav-Simonsson","followers_url":"https://api.github.com/users/Gustav-Simonsson/followers","following_url":"https://api.github.com/users/Gustav-Simonsson/following{/other_user}","gists_url":"https://api.github.com/users/Gustav-Simonsson/gists{/gist_id}","starred_url":"https://api.github.com/users/Gustav-Simonsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gustav-Simonsson/subscriptions","organizations_url":"https://api.github.com/users/Gustav-Simonsson/orgs","repos_url":"https://api.github.com/users/Gustav-Simonsson/repos","events_url":"https://api.github.com/users/Gustav-Simonsson/events{/privacy}","received_events_url":"https://api.github.com/users/Gustav-Simonsson/received_events","type":"User","site_admin":false},"created_at":"2015-05-29T20:35:43Z","updated_at":"2015-05-29T20:35:43Z","body":"I consider the hardcoded banned block hashes in core to be a quick hack used so far to enforce protocol changes & hard forks. I believe it's better if consensus is enforced using regular consensus validations based on the protocol specs in YP.\r\n\r\nWe also have protocol version which can be used if there is need for a hard fork.\r\n\r\nMoreover, the problem with this approach is that it mixes consensus logic for valid and invalid blocks. To validate that X blocks prior to a banned block are valid and then block them makes little sense. If they are valid according to the protocol rules they are valid and have nothing todo with the banned hash.\r\n\r\nAlso, while a chain re-organization of 128 or more blocks is unlikely in practice, it is possible that a block that is considered bad/banned is re-organized out if a new chain with higher TD arrives. And that chain may include blocks prior to the banned block within the range defined (e.g. 128)."}}