[Net] Reduce preferential Graphene/Xthin timers to 1 second each #1511
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Recently, the consecutive 10 second preferential download timers for Xthin/Graphene caused an orphan race on BCH mainnet:
https://www.reddit.com/r/btc/comments/a1bp0b/please_send_me_your_debuglog_files_from_the_bsv/eb2ogw0/?context=3
These 10 second timers often result in BU not downloading a block (even a tiny, 20 kB one!) from peers until 20 seconds have elapsed. Since no BU nodes support Compact Blocks, and almost no other nodes (except XT) supports both CB and Xthin, this means that any time a block is mined by BSV or ABC, no BU nodes on the network will receive it for at least 10 seconds, and when XT network bridging doesn't work (e.g. on BSV) all BU nodes will be delayed by 20 seconds. This causes a 3.27% higher orphan rate than necessary for any miners using BU.
This preferential download mechanism should probably be completely redesigned and replaced. I proposed one such idea in the reddit thread above. However, as a short-term fix, I suggest lowering the timers to 1 second instead of 10 seconds. This is long enough that a node that sees an Xthin or Graphene peer with the block will usually be able to download it in time, but short enough that orphan rates will not increase very much for BU miners. This PR implements this 1 second timer.
Based on my test results from mainnet, it seems to work as intended. My test node is probably already effectively bridging the BU and ABC subsets of the BCH network:
2018-12-04 19:48:25 AskFor block via headers direct fetch 0000000000000000001ffe762dbd324320a4112a43cac97ef7ebb0c18ba304c7 (559418) peer=19
2018-12-04 19:48:26 Preferential Graphene Block timer exceeded
2018-12-04 19:48:26 Starting Preferential Thinblock timer (1169 millis)
2018-12-04 19:48:27 Preferential Thinblock timer exceeded - downloading regular block instead
2018-12-04 19:48:27 Clearing Preferential Thinblock timer
2018-12-04 19:48:27 Clearing Preferential Graphene Block timer
2018-12-04 19:48:27 sending msg: getdata (37 bytes) peer=39
2018-12-04 19:48:27 Requesting Regular Block 0000000000000000001ffe762dbd324320a4112a43cac97ef7ebb0c18ba304c7 from peer 47.95.32.37:8333 (39)
This PR is identical to #1510, but rebased on the dev branch instead of release.