domob1812
commented at 6:10 PM on May 14, 2016:
contributor
The current logic for syncing headers may lead to lots of duplicate getheaders requests being sent: If a new block arrives while the node is in headers sync, it will send getheaders in response to the block announcement. When the headers arrive, the message will be of maximum size and so a follow-up request will be sent---all of that in addition to the existing headers syncing. This will create a second "chain" of getheaders requests. If more blocks arrive, this may even lead to arbitrarily many parallel chains of redundant requests. (See #6755.)
This patch changes the behaviour to only request more headers after a maximum-sized message when it contained at least one unknown header. This avoids sustaining parallel chains of redundant requests.
Note that this patch avoids the issues raised in the discussion of #6821: There is no risk of the node being permanently blocked. At the latest when a new block arrives this will trigger a new getheaders request and restart syncing.
This is equivalent to just testing whether the last block is already known, by the way.
domob1812
commented at 10:03 AM on May 15, 2016:
contributor
Oh yes, of course - nice catch! I will update the patch accordingly.
domob1812 force-pushed on May 15, 2016
domob1812
commented at 4:40 PM on May 15, 2016:
contributor
I've now updated the patch - which further simplifies it. When the message contains no previously unknown headers (i. e., the last header is already known), simply ignore it.
net: Avoid duplicate getheaders requests.
The current logic for syncing headers may lead to lots of duplicate
getheaders requests being sent: If a new block arrives while the node
is in headers sync, it will send getheaders in response to the block
announcement. When the headers arrive, the message will be of maximum
size and so a follow-up request will be sent---all of that in addition
to the existing headers syncing. This will create a second "chain" of
getheaders requests. If more blocks arrive, this may even lead to
arbitrarily many parallel chains of redundant requests.
This patch changes the behaviour to only request more headers after a
maximum-sized message when it contained at least one unknown header.
This avoids sustaining parallel chains of redundant requests.
Note that this patch avoids the issues raised in the discussion of
https://github.com/bitcoin/bitcoin/pull/6821: There is no risk of the
node being permanently blocked. At the latest when a new block arrives
this will trigger a new getheaders request and restart syncing.
f93c2a1b7e
domob1812 force-pushed on May 15, 2016
dcousens
commented at 2:16 AM on May 16, 2016:
contributor
pstratem
commented at 5:28 AM on May 17, 2016:
contributor
utACKf93c2a1b7ee912f0651ebb4c8a5eca220e434f4a
sdaftuar
commented at 5:46 PM on May 17, 2016:
member
utACKf93c2a1b7ee912f0651ebb4c8a5eca220e434f4a
Looks much better -- thanks for coming up with an alternate solution to this.
laanwj merged this on May 18, 2016
laanwj closed this on May 18, 2016
laanwj referenced this in commit 8e8bebc040 on May 18, 2016
domob1812 deleted the branch on May 18, 2016
laanwj referenced this in commit 005d3b6430 on Jul 6, 2016
rebroad
commented at 1:55 AM on July 13, 2016:
contributor
this clearly got merged with insufficient testing - I guess the testing policy is "merge first test later"?
gmaxwell
commented at 3:00 AM on July 13, 2016:
contributor
No amount of simple testing would turn up the problems with this; if you'd like to argue that we need better test harnesses... I'd agree. Patches accepted!
MarcoFalke
commented at 8:36 AM on July 13, 2016:
member
Also note, that master is not considered stable. Pull request get merged after they received some review, but it is impossible to detect all issues which might arise in the future. Whenever a pull received enough review, merging it into master is a good way to expose the patch to a larger group of developers and get feedback about tricky issues which might arise in very rare and special circumstances.
laanwj
commented at 7:13 AM on July 18, 2016:
member
Agree with @MarcoFalke. If you can't handle things breaking here and there momentarily, you certainly shouldn't be using the master branch.
These things happen, and posting here complaining months after the fact is just sad.
rebroad
commented at 4:36 PM on July 31, 2016:
contributor
@laanwj Thanks for the clarification. I think it could be made clearer somewhere that the master branch is largely untested - I had assumed that some effort was made to test things before they were merged - it certainly used to be the case.
sipa
commented at 4:39 PM on July 31, 2016:
member
Of course things are tested before merge. But we can't test everything.
That is why release candidates and releases exist: to give external people
a chance to test code before we label it ready to be used by everyone.
dexX7 referenced this in commit a400d26561 on Jun 8, 2017
dexX7 referenced this in commit 2476c64723 on Jun 8, 2017
dexX7 referenced this in commit 3edbe7cc79 on Jun 8, 2017
codablock referenced this in commit 7bcbbcb47f on Aug 24, 2017
codablock referenced this in commit 4e67e04e06 on Aug 24, 2017
codablock referenced this in commit c3d6f5461d on Sep 1, 2017
UdjinM6 referenced this in commit 169afafd50 on Sep 4, 2017
MarkLTZ referenced this in commit 3120c258d3 on Apr 27, 2019
DeckerSU referenced this in commit a9231ef60e on Apr 16, 2020
DeckerSU referenced this in commit 431204467c on Apr 16, 2020
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2026-04-14 18:15 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me