-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Introduce preferred download peers #5157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/main.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this correct, to prefer inbound?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, fixed.
|
@gavinandresen please test again; it was preferring inbound now, as noticed by @cozz. |
src/main.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IsPreferredDownload doesn't look at node->fPreferredDownload, is this intentional? (if so, the naming may be a bit confusing)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. IsPreferredDownload() checks whether a node should be preferred. fPreferredDownload remembers whether we've already counted it as a preferred downloader. Better naming suggestions are welcome :)
|
Going to test this |
|
Reworked the functions/names a bit; maybe it's less confusing now. |
|
Still issues with sync never starting, here's a test case (put in qa/rpc-tests, run with --tracerpc to see behavior): Connecting node 0 to node 1 (instead of 1 to 0) and all is well. |
|
@gavinandresen did the previous version of the PR work? |
|
I don't know if previous version worked-- I reversed connection direction to better test for this version, didn't test previous that way.
|
|
Can those looking at this also look at #5099 please? I've been developing and testing functionality to do with preferred downloads and optimising the IBD since June, and it's almost near perfect now (although I'm not so sure about my C++ coding style!). |
|
I'd like to code a pull request to make download of headers faster, but given that #5099 hasn't received any attention, would I be wasting my time and effort? |
|
@rebroad This is not about making it faster, but fixing the bug of it not starting downloads at all in some situations. The problem is the logic that tries to avoid downloading from incoming peers (because of the current expectation that you don't get much bandwidth usage from making just outgoing connections). It seems overeager and sometimes causes no download at all to start. I'll get to looking at your pull request, but it's a lot of code, and getting the bugs out has higher priority now. |
|
Tested ACK |
b4ee0bd Introduce preferred download peers (Pieter Wuille)
…c_invalidateblock fae961d test: Establish only one connection between nodes in rpc_invalidateblock (MarcoFalke) Pull request description: Headers and block sync should eventually converge to the same result, regardless of whether the peers treat each other as "inbound" or "outbound". `connect_nodes_bi` has been introduced as a (temporary?) workaround for bug #5113 and #5138, which has long been fixed in #5157 and #5662. Thus remove the `connect_nodes_bi` workaround from the rpc_invalidateblock test. Conveniently, this also closes #16453. See #16444 (comment) for rationale ACKs for top commit: laanwj: ACK fae961d Tree-SHA512: b3614c66a205823df73f64d19cacfbec269beb5db52ff79004d746e17d7c0dfb43ab9785fdddc97e2a76fe76286c8c605b34df3dda4a2bf5be035f01169ae89a
…s in rpc_invalidateblock fae961d test: Establish only one connection between nodes in rpc_invalidateblock (MarcoFalke) Pull request description: Headers and block sync should eventually converge to the same result, regardless of whether the peers treat each other as "inbound" or "outbound". `connect_nodes_bi` has been introduced as a (temporary?) workaround for bug bitcoin#5113 and bitcoin#5138, which has long been fixed in bitcoin#5157 and bitcoin#5662. Thus remove the `connect_nodes_bi` workaround from the rpc_invalidateblock test. Conveniently, this also closes bitcoin#16453. See bitcoin#16444 (comment) for rationale ACKs for top commit: laanwj: ACK fae961d Tree-SHA512: b3614c66a205823df73f64d19cacfbec269beb5db52ff79004d746e17d7c0dfb43ab9785fdddc97e2a76fe76286c8c605b34df3dda4a2bf5be035f01169ae89a
fadfd84 test: Remove unused connect_nodes_bi (MarcoFalke) fa3b9ee scripted-diff: test: Replace connect_nodes_bi with connect_nodes (MarcoFalke) faaee1e test: Use connect_nodes when connecting nodes in the test_framework (MarcoFalke) 1111bb9 test: Reformat python imports to aid scripted diff (MarcoFalke) Pull request description: By default all test nodes are connected in a chain. However, instead of just a single connection between each pair of nodes, we end up with up to four connections for a "middle" node (two outbound, two inbound, from each side). This is generally redundant (tx and block relay should succeed with just a single connection) and confusing. For example, test timeouts after a call to `sync_` may be racy and hard to reproduce. On top of that, the test `debug.log`s are hard to read because txs and block invs may be relayed on the same connection multiple times. Fix this by inlining `connect_nodes_bi` in the two tests that need it, and then replace it with a single `connect_nodes` in all other tests. Historic background: `connect_nodes_bi` has been introduced as a (temporary?) workaround for bug #5113 and #5138, which has long been fixed in #5157 and #5662. ACKs for top commit: laanwj: ACK fadfd84 jonasschnelli: utACK fadfd84 - more of less a cleanup PR. promag: Tested ACK fadfd84, ran extended tests. Tree-SHA512: 2d027a8fd150749c071b64438a0a78ec922178628a7dbb89fd1212b0fa34febd451798c940101155d3617c0426c2c4865174147709894f1f1bb6cfa336aa7e24
3e9081c [Tests] Fix tests duration and sorting in test_runner.py (random-zebra) 57dd5e7 [Tests][Refactor] Move connect_nodes_bi to p2p_time_offset (random-zebra) 9b36468 test: Replace connect_nodes_bi with connect_nodes (random-zebra) c2a701e test: Use connect_nodes when connecting nodes in the test_framework (random-zebra) 5d3f2a1 test: Reformat python imports to aid scripted diff (random-zebra) Pull request description: Mostly from upstream bitcoin#16898 > By default all test nodes are connected in a chain. However, instead of just a single connection between each pair of nodes, we end up with up to four connections for a "middle" node (two outbound, two inbound, from each side). > > This is generally redundant (tx and block relay should succeed with just a single connection) and confusing. For example, test timeouts after a call to sync_ may be racy and hard to reproduce. On top of that, the test debug.logs are hard to read because txs and block invs may be relayed on the same connection multiple times. > > Fix this by inlining connect_nodes_bi in the two tests that need it, and then replace it with a single connect_nodes in all other tests. > > Historic background: > > connect_nodes_bi has been introduced as a (temporary?) workaround for bug dashpay#5113 and dashpay#5138, which has long been fixed in dashpay#5157 and dashpay#5662. ACKs for top commit: furszy: Tested ACK 3e9081c . Tree-SHA512: 4af3223c7e5a4b130855d9364b7ec3df5e141151fd1e108c55ef80dd523522780b6130e69cacd467906215c15da9a50496f12298246eb67876fcaa181463cae9
Keep track of whether we have peers that are preferred candidates for downloading blocks from, but if there are none, also use others.