{"action":"created","issue":{"url":"https://api.github.com/repos/cryptonomex/graphene/issues/247","labels_url":"https://api.github.com/repos/cryptonomex/graphene/issues/247/labels{/name}","comments_url":"https://api.github.com/repos/cryptonomex/graphene/issues/247/comments","events_url":"https://api.github.com/repos/cryptonomex/graphene/issues/247/events","html_url":"https://github.com/cryptonomex/graphene/issues/247","id":101720028,"number":247,"title":"There are cases where blocks get pushed to the chain::database out-of-order","user":{"login":"bytemaster","id":347290,"avatar_url":"https://avatars.githubusercontent.com/u/347290?v=3","gravatar_id":"","url":"https://api.github.com/users/bytemaster","html_url":"https://github.com/bytemaster","followers_url":"https://api.github.com/users/bytemaster/followers","following_url":"https://api.github.com/users/bytemaster/following{/other_user}","gists_url":"https://api.github.com/users/bytemaster/gists{/gist_id}","starred_url":"https://api.github.com/users/bytemaster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bytemaster/subscriptions","organizations_url":"https://api.github.com/users/bytemaster/orgs","repos_url":"https://api.github.com/users/bytemaster/repos","events_url":"https://api.github.com/users/bytemaster/events{/privacy}","received_events_url":"https://api.github.com/users/bytemaster/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/cryptonomex/graphene/labels/bug","name":"bug","color":"e11d21"},{"url":"https://api.github.com/repos/cryptonomex/graphene/labels/High%20Priority","name":"High Priority","color":"fbca04"}],"state":"open","locked":false,"assignee":{"login":"bytemaster","id":347290,"avatar_url":"https://avatars.githubusercontent.com/u/347290?v=3","gravatar_id":"","url":"https://api.github.com/users/bytemaster","html_url":"https://github.com/bytemaster","followers_url":"https://api.github.com/users/bytemaster/followers","following_url":"https://api.github.com/users/bytemaster/following{/other_user}","gists_url":"https://api.github.com/users/bytemaster/gists{/gist_id}","starred_url":"https://api.github.com/users/bytemaster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bytemaster/subscriptions","organizations_url":"https://api.github.com/users/bytemaster/orgs","repos_url":"https://api.github.com/users/bytemaster/repos","events_url":"https://api.github.com/users/bytemaster/events{/privacy}","received_events_url":"https://api.github.com/users/bytemaster/received_events","type":"User","site_admin":false},"milestone":null,"comments":4,"created_at":"2015-08-18T18:26:56Z","updated_at":"2015-08-18T22:35:36Z","closed_at":null,"body":"https://bitsharestalk.org/index.php/topic,17962.msg229944.html#msg229944\r\n\r\nThe fork_database::push_block method requires that blocks are submitted in order by the network.\r\n\r\nThere appears to be some cases where blocks are pushed out-of-order causing syncing to halt.    Our options are to:\r\n\r\n1. make the fork database robust against out-of-order insertion \r\n2. prevent blocks from being inserted out-of-order.\r\n\r\nThis may or may not resolve the issues discussed in the bitsharestalk thread."},"comment":{"url":"https://api.github.com/repos/cryptonomex/graphene/issues/comments/132376539","html_url":"https://github.com/cryptonomex/graphene/issues/247#issuecomment-132376539","issue_url":"https://api.github.com/repos/cryptonomex/graphene/issues/247","id":132376539,"user":{"login":"bytemaster","id":347290,"avatar_url":"https://avatars.githubusercontent.com/u/347290?v=3","gravatar_id":"","url":"https://api.github.com/users/bytemaster","html_url":"https://github.com/bytemaster","followers_url":"https://api.github.com/users/bytemaster/followers","following_url":"https://api.github.com/users/bytemaster/following{/other_user}","gists_url":"https://api.github.com/users/bytemaster/gists{/gist_id}","starred_url":"https://api.github.com/users/bytemaster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bytemaster/subscriptions","organizations_url":"https://api.github.com/users/bytemaster/orgs","repos_url":"https://api.github.com/users/bytemaster/repos","events_url":"https://api.github.com/users/bytemaster/events{/privacy}","received_events_url":"https://api.github.com/users/bytemaster/received_events","type":"User","site_admin":false},"created_at":"2015-08-18T22:35:36Z","updated_at":"2015-08-18T22:35:36Z","body":"With the changes described above we have one last corner case:\r\n\r\nA new witness is elected after a maintenance block and a node receives their block prior to receiving the maintenance block.    \r\n\r\nIf this were to happen then the block would be \"rejected\" and the peer that provided the block would be disconnected.   The network will have marked that it already received and rejected the block and would not fetch it again leaving the user stuck.\r\n\r\nThe solution is: \r\n\r\n```\r\n    if next_block_should_be_maitenance_block\r\n       if received_block.block_num >  head_block.block_num + 1 \r\n          saved_blocks.push(received_block)\r\n          throw error pushing received_block\r\n      else // next_block_is maintenance block\r\n          push received_block (assuming it links) \r\n          for( block in saved_blocks )\r\n                 push( saved_block ) \r\n          saved_blocks.clear()     \r\n```\r\n          \r\nUnder this algorithm the network layer would catch the errors and punish any nodes that accumulate too many errors pushing blocks around the maintenance interval.\r\n\r\n\r\n\r\n\r\n\r\n"}}