net processing: Only send a getheaders for one block in an INV #18962

pull jnewbery wants to merge 1 commits into bitcoin:master from jnewbery:2020-05-limit-block-inv changing 1 files +14 −10
  1. jnewbery commented at 8:30 pm on May 12, 2020: member

    Headers-first is the primary method of announcement on the network. If a node fell back sending blocks by inv, it’s probably for a re-org. The final block hash provided should be the highest, so send a getheaders and then fetch the blocks we need to catch up.

    Sending many GETHEADERS messages to the peer would cause them to send a large number of potentially large HEADERS messages with redundant data, which is a waste of bandwidth.

  2. [net processing] Only send a getheaders for one block in an INV
    Headers-first is the primary method of announcement on the network. If a
    node fell back sending blocks by inv, it's probably for a re-org. The
    final block hash provided should be the highest, so send a getheaders
    and then fetch the blocks we need to catch up.
    746736639e
  3. DrahtBot added the label P2P on May 12, 2020
  4. jonatack commented at 10:36 pm on May 12, 2020: member
    The code changes look good. I need to verify the concept more when it’s not late, e.g. that the final block hash will be the highest and the variation/savings in bandwidth.
  5. mzumsande commented at 11:37 pm on May 12, 2020: member
    Can the “waste of bandwidth scenario” you describe ever occur? My understanding was that it is currently taken care of by the send side by only including the tip in the INV in SendMessages(), so that there wouldn’t be multiple block hashes within an INV.
  6. fanquake requested review from ajtowns on May 13, 2020
  7. fanquake requested review from amitiuttarwar on May 13, 2020
  8. fanquake requested review from naumenkogs on May 13, 2020
  9. laanwj added the label Needs backport (0.20) on May 13, 2020
  10. jnewbery commented at 2:59 am on May 14, 2020: member

    My understanding was that it is currently taken care of by the send side by only including the tip in the INV in SendMessages()

    You’re right that current Bitcoin Core software should only send a single block in the INV message. The point about wasting bandwidth is more for other software that may send us many blocks in a single INV, which would cause us to reply with multiple getheaders.

  11. sipa commented at 3:03 am on May 14, 2020: member
    utACK 746736639e6d05acdb85c866d4c605c947d4c500
  12. naumenkogs approved
  13. naumenkogs commented at 11:44 am on May 14, 2020: member
    utACK 7467366
  14. ajtowns commented at 2:06 pm on May 14, 2020: member

    ACK 746736639e6d05acdb85c866d4c605c947d4c500

    I think this patch doesn’t change behaviour when the peer is a bitcoind (because it will only potentially send a single block in an inv message), and is not normally relevant because most peers will do headers first download and compact blocks so will find out about blocks that way. As such, which block in the inv is the best one to query doesn’t really seem decidable, so picking the last one seems as good a choice as any.

  15. mzumsande commented at 2:19 pm on May 14, 2020: member

    utACK 746736639e6d05acdb85c866d4c605c947d4c500 as per ajtowns’ reasoning.

    edit by laanwj: deleted a @

  16. jonatack commented at 2:21 pm on May 14, 2020: member

    ACK 746736639e6d05acdb85c866d4c605c947d4c500

    Code review and light sanity check running bitcoind with added debug logging in this change for a bit more than a day. Perhaps update the code comments with @ajtowns’ feedback.

  17. MarcoFalke added this to the milestone 0.20.0 on May 14, 2020
  18. laanwj merged this on May 14, 2020
  19. laanwj closed this on May 14, 2020

  20. jnewbery deleted the branch on May 14, 2020
  21. fanquake referenced this in commit 6161c94a61 on May 15, 2020
  22. fanquake removed the label Needs backport (0.20) on May 15, 2020
  23. MarcoFalke referenced this in commit 17bdf2afae on May 15, 2020
  24. sidhujag referenced this in commit e78924ac41 on May 17, 2020
  25. amitiuttarwar commented at 9:46 pm on June 6, 2020: contributor
    post merge ACK 7467366
  26. Fabcien referenced this in commit ba0016fcc6 on Feb 1, 2021
  27. backpacker69 referenced this in commit ec6fe7e9c2 on Mar 28, 2021
  28. DrahtBot locked this on Feb 15, 2022

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: 2024-11-21 15:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me