net: Avoid duplicate getheaders requests. #8054

pull domob1812 wants to merge 1 commits into bitcoin:master from domob1812:per-client-duplicate-getheaders changing 1 files +8 −1
  1. 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.

  2. MarcoFalke added the label P2P on May 14, 2016
  3. sipa commented at 9:50 PM on May 14, 2016: member

    Concept ACK

    This is equivalent to just testing whether the last block is already known, by the way.

  4. domob1812 commented at 10:03 AM on May 15, 2016: contributor

    Oh yes, of course - nice catch! I will update the patch accordingly.

  5. domob1812 force-pushed on May 15, 2016
  6. 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.

  7. 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
  8. domob1812 force-pushed on May 15, 2016
  9. dcousens commented at 2:16 AM on May 16, 2016: contributor

    utACK f93c2a1

  10. sipa commented at 9:03 PM on May 16, 2016: member

    utACK f93c2a1b7ee912f0651ebb4c8a5eca220e434f4a

  11. pstratem commented at 5:28 AM on May 17, 2016: contributor

    utACK f93c2a1b7ee912f0651ebb4c8a5eca220e434f4a

  12. sdaftuar commented at 5:46 PM on May 17, 2016: member

    utACK f93c2a1b7ee912f0651ebb4c8a5eca220e434f4a

    Looks much better -- thanks for coming up with an alternate solution to this.

  13. laanwj merged this on May 18, 2016
  14. laanwj closed this on May 18, 2016

  15. laanwj referenced this in commit 8e8bebc040 on May 18, 2016
  16. domob1812 deleted the branch on May 18, 2016
  17. laanwj referenced this in commit 005d3b6430 on Jul 6, 2016
  18. 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"?

  19. 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!

  20. MarcoFalke commented at 8:36 AM on July 13, 2016: member

    @rebroad You are welcome to help with testing: https://github.com/bitcoin/bitcoin#testing

    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.

  21. 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.

  22. 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.

  23. 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.

  24. dexX7 referenced this in commit a400d26561 on Jun 8, 2017
  25. dexX7 referenced this in commit 2476c64723 on Jun 8, 2017
  26. dexX7 referenced this in commit 3edbe7cc79 on Jun 8, 2017
  27. codablock referenced this in commit 7bcbbcb47f on Aug 24, 2017
  28. codablock referenced this in commit 4e67e04e06 on Aug 24, 2017
  29. codablock referenced this in commit c3d6f5461d on Sep 1, 2017
  30. UdjinM6 referenced this in commit 169afafd50 on Sep 4, 2017
  31. MarkLTZ referenced this in commit 3120c258d3 on Apr 27, 2019
  32. DeckerSU referenced this in commit a9231ef60e on Apr 16, 2020
  33. DeckerSU referenced this in commit 431204467c on Apr 16, 2020
  34. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

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