BIP155: change when sendaddrv2 is to be sent #1043

pull vasild wants to merge 1 commits into bitcoin:master from vasild:bip155_fix_send_recv_typo changing 1 files +1 −1
  1. vasild commented at 3:11 PM on December 7, 2020: contributor

    Mandate to send sendaddrv2 to the peer before sending our verack to them.

    This way we know that the peer does not support addrv2 if we did not receive sendaddrv2 from them before receiving their verack.

  2. vasild commented at 3:16 PM on December 7, 2020: contributor

    If the implementation is to be changed instead, then this patch is to be applied to it:

    <details> <summary>change net_processing.cpp</summary>

    diff --git i/src/net_processing.cpp w/src/net_processing.cpp
    index 1b4a05f0b..e46cbe487 100644
    --- i/src/net_processing.cpp
    +++ w/src/net_processing.cpp
    @@ -2361,15 +2361,12 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
             if (greatest_common_version >= WTXID_RELAY_VERSION) {
                 m_connman.PushMessage(&pfrom, msg_maker.Make(NetMsgType::WTXIDRELAY));
             }
     
             m_connman.PushMessage(&pfrom, msg_maker.Make(NetMsgType::VERACK));
     
    -        // Signal ADDRv2 support (BIP155).
    -        m_connman.PushMessage(&pfrom, msg_maker.Make(NetMsgType::SENDADDRV2));
    -
             pfrom.nServices = nServices;
             pfrom.SetAddrLocal(addrMe);
             {
                 LOCK(pfrom.cs_SubVer);
                 pfrom.cleanSubVer = cleanSubVer;
             }
    @@ -2509,12 +2506,14 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
                 uint64_t nCMPCTBLOCKVersion = 2;
                 if (pfrom.GetLocalServices() & NODE_WITNESS)
                     m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::SENDCMPCT, fAnnounceUsingCMPCTBLOCK, nCMPCTBLOCKVersion));
                 nCMPCTBLOCKVersion = 1;
                 m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::SENDCMPCT, fAnnounceUsingCMPCTBLOCK, nCMPCTBLOCKVersion));
             }
    +        // Signal ADDRv2 support (BIP155).
    +        m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::SENDADDRV2));
             pfrom.fSuccessfullyConnected = true;
             return;
         }
     
         // Feature negotiation of wtxidrelay should happen between VERSION and
         // VERACK, to avoid relay problems from switching after a connection is up
    

    </details>

    that would send sendaddrv2 at the same time as sending sendheaders and sendcmpct.

  3. MarcoFalke commented at 3:26 PM on December 7, 2020: member

    A third option would be to use the same feature negotiation order that was used for wtxidrelay

  4. vasild commented at 3:33 PM on December 7, 2020: contributor

    A third option would be to use the same feature negotiation order that was used for wtxidrelay

    That would be "sendaddrv2 SHOULD be sent before sending the verack message to the peer" and would require changing both the BIP and the code. Any of the 3 would work wrt the sendaddrv2 / addrv2 logic (= it does not matter when sendaddrv2 is sent).

  5. jonatack commented at 3:44 PM on December 7, 2020: contributor

    In the same way as wtxidrelay SGTM for being simpler rather than a different mechanism for each.

  6. vasild force-pushed on Dec 7, 2020
  7. vasild renamed this:
    BIP155: fix sending vs receiving verack typo
    BIP155: change when sendaddrv2 is to be sent
    on Dec 7, 2020
  8. vasild commented at 5:08 PM on December 7, 2020: contributor

    Changed to send it before sending verack (like wtxidrelay).

  9. laanwj commented at 5:14 PM on December 7, 2020: member

    ACK 50613bb82ce89d31027ad27daecf46f05aff198e

  10. sipa referenced this in commit b2eae52263 on Dec 7, 2020
  11. sipa cross-referenced this on Dec 7, 2020 from issue Don't send 'sendaddrv2' to pre-70016 software, and send before 'verack' by sipa
  12. benthecarman commented at 5:22 PM on December 7, 2020: contributor

    ACK 50613bb82ce89d31027ad27daecf46f05aff198e

  13. sipa referenced this in commit ccd0eaab95 on Dec 7, 2020
  14. in bip-0155.mediawiki:137 in 50613bb82c outdated
     133 | @@ -134,7 +134,7 @@ See the appendices for the address encodings to be used for the various networks
     134 |  
     135 |  Introduce a new message type <code>sendaddrv2</code>. Sending such a message indicates that a node can understand and prefers to receive <code>addrv2</code> messages instead of <code>addr</code> messages. I.e. "Send me addrv2".
     136 |  
     137 | -<code>sendaddrv2</code> SHOULD be sent after receiving the <code>verack</code> message from the peer.
     138 | +<code>sendaddrv2</code> SHOULD be sent before sending the <code>verack</code> message to the peer.
    


    jnewbery commented at 5:59 PM on December 7, 2020:

    I think the SHOULD here should be changed to MUST.

    The feature negotiation MUST be completed before the VERSION-VERACK handshake is completed.


    MarcoFalke commented at 6:00 PM on December 7, 2020:
    <code>sendaddrv2</code> MUST be sent before sending the <code>verack</code> message to the peer.
    

    I'd say to make the bip strict here. Otherwise the change doesn't have any benefit, as is simply says "the message should be sent before verack, but can actually be sent any time", which was true before already.


    jonatack commented at 6:01 PM on December 7, 2020:

    Perhaps pedantic, but for the sake of precision and strictness, should this state

    <code>sendaddrv2</code> MUST be sent after receiving the <code>version</code> message from the peer and before sending the <code>verack</code> message to the peer.
    

    Edit: s/SHOULD/MUST/


    jonatack commented at 6:14 PM on December 7, 2020:

    To compare with BIP 339: "The wtxidrelay message MUST be sent in response to a version message from a peer whose protocol version is >= 70016 and prior to sending a verack. A wtxidrelay message received after a verack message MUST be ignored or treated as invalid."


    MarcoFalke commented at 6:33 PM on December 7, 2020:

    I think wtxidrelay had to be stricter in enforcing that this happened before the verack. addrv2 doesn't have to be this strict (at least with the implementation as is now) and can leave this up to the implementation, see https://github.com/bitcoin/bitcoin/pull/20564#discussion_r537730772


    vasild commented at 6:05 AM on December 8, 2020:

    Changed to MUST and reworded to mimic BIP-339 / wtxidrelay.


    vasild commented at 6:05 AM on December 8, 2020:

    Changed to MUST and reworded to mimic BIP-339 / wtxidrelay.


    vasild commented at 6:06 AM on December 8, 2020:

    Changed to MUST and reworded to mimic BIP-339 / wtxidrelay. @jonatack, thanks for the BIP-339 quote!

  15. jonatack commented at 6:02 PM on December 7, 2020: contributor

    Concept ACK

  16. sipa referenced this in commit deef9340ae on Dec 7, 2020
  17. sipa cross-referenced this on Dec 8, 2020 from issue Btcd disconnects upon receiving sendaddrv2 by Sjors
  18. vasild force-pushed on Dec 8, 2020
  19. MarcoFalke commented at 6:41 AM on December 8, 2020: member

    ACK c2c55cfbf0284d20cc3080871cbceb9a55d1894e

  20. BIP155: change when sendaddrv2 is to be sent
    Mandate to send `sendaddrv2` to the peer before sending our `verack`
    to them.
    
    This way we know that the peer does not support `addrv2` if we did not
    receive `sendaddrv2` from them before receiving their `verack`.
    e549ed36e8
  21. in bip-0155.mediawiki:137 in c2c55cfbf0 outdated
     133 | @@ -134,7 +134,7 @@ See the appendices for the address encodings to be used for the various networks
     134 |  
     135 |  Introduce a new message type <code>sendaddrv2</code>. Sending such a message indicates that a node can understand and prefers to receive <code>addrv2</code> messages instead of <code>addr</code> messages. I.e. "Send me addrv2".
     136 |  
     137 | -<code>sendaddrv2</code> SHOULD be sent after receiving the <code>verack</code> message from the peer.
     138 | +The <code>sendaddrv2</code> message MUST be sent in response to the <code>version</code> message from a peer and prior to sending the <code>verack</code> message.
    


    harding commented at 8:26 AM on December 8, 2020:

    I think this would be a bit clearer as s/MUST be sent/MUST only be sent/ to indicate that the message may only be sent during a specific window rather than that the message must be sent by any nodes that comply with BIP155. Without the addition of "only", I think you could argue that https://github.com/bitcoin/bitcoin/pull/20564 would be a violation of the spec since it implements BIP155 but won't send sendaddrv2 to pre-70016 nodes.

    Otherwise, this LGTM.


    vasild commented at 9:35 AM on December 8, 2020:

    Done

  22. vasild force-pushed on Dec 8, 2020
  23. vasild commented at 9:37 AM on December 8, 2020: contributor

    There are many ways to say it, I hope the current phrasing is clear enough and good for everybody.

  24. MarcoFalke commented at 9:40 AM on December 8, 2020: member

    ACK e549ed36e8bbb0d15b1bd245cc5bb2c5664d5aa2

  25. harding commented at 10:13 AM on December 8, 2020: contributor

    ACK e549ed36e8bbb0d15b1bd245cc5bb2c5664d5aa2

    Thanks for updating!

  26. jnewbery commented at 10:16 AM on December 8, 2020: member

    ACK e549ed36e8bbb0d15b1bd245cc5bb2c5664d5aa2

  27. jonatack commented at 10:21 AM on December 8, 2020: contributor

    ACK e549ed3

  28. hebasto approved
  29. hebasto commented at 10:39 AM on December 8, 2020: member

    ACK e549ed36e8bbb0d15b1bd245cc5bb2c5664d5aa2, I believe that the establishing of connection invariants in a such manner--in response to the version and prior to sending the verack--is the right way both for new addrv2 message and for other future features.

  30. MarcoFalke commented at 11:51 AM on December 8, 2020: member

    According to the BIP process, this needs an ACK by the BIP champion @laanwj :)

  31. laanwj commented at 2:04 PM on December 8, 2020: member

    re-ACK e549ed36e8bbb0d15b1bd245cc5bb2c5664d5aa2

  32. MarcoFalke commented at 4:18 PM on December 8, 2020: member
  33. sipa referenced this in commit 76fe446e8c on Dec 8, 2020
  34. sipa referenced this in commit dd2a03b492 on Dec 8, 2020
  35. sipa referenced this in commit 1583498fb6 on Dec 8, 2020
  36. vasild referenced this in commit f432b600b6 on Dec 9, 2020
  37. MarcoFalke referenced this in commit 90ef622ab5 on Dec 9, 2020
  38. laanwj merged this on Dec 9, 2020
  39. laanwj closed this on Dec 9, 2020

  40. sidhujag referenced this in commit b3d84bcd0b on Dec 9, 2020
  41. MarcoFalke referenced this in commit bead935470 on Dec 10, 2020
  42. furszy referenced this in commit 7d6bb1fe16 on Jun 12, 2021
  43. furszy referenced this in commit 871bfe4cf0 on Jun 12, 2021
  44. furszy referenced this in commit 0f5e1cf675 on Jun 12, 2021
  45. furszy referenced this in commit 3465a50100 on Jun 14, 2021
  46. furszy referenced this in commit 3fca403ef7 on Jun 14, 2021
  47. vasild deleted the branch on Jun 16, 2021
  48. furszy referenced this in commit 3f57e8f658 on Jun 22, 2021
  49. furszy referenced this in commit c25e2617d6 on Jun 24, 2021
  50. furszy referenced this in commit 7a4dbdd2c1 on Jun 28, 2021
  51. furszy referenced this in commit d6be5c5306 on Jun 28, 2021
  52. furszy referenced this in commit 0518abc26a on Jul 1, 2021
  53. furszy referenced this in commit a205c88e90 on Jul 5, 2021
  54. furszy referenced this in commit da84f20c3d on Jul 6, 2021
  55. furszy referenced this in commit bb70acb391 on Jul 9, 2021
  56. furszy referenced this in commit 0ed3bb5edd on Jul 9, 2021
  57. furszy referenced this in commit b2a0e33fb0 on Jul 12, 2021
  58. furszy referenced this in commit 5a44405864 on Jul 14, 2021
  59. furszy referenced this in commit 21b7f3d641 on Jul 15, 2021
  60. furszy referenced this in commit 038d8a8579 on Jul 15, 2021
  61. furszy referenced this in commit 01e3883922 on Jul 18, 2021
  62. furszy referenced this in commit 20476ddd61 on Jul 18, 2021
  63. furszy referenced this in commit 9e5ac495c2 on Jul 21, 2021
  64. furszy referenced this in commit 903d927edf on Jul 23, 2021
  65. furszy referenced this in commit 81d56e0884 on Jul 25, 2021
  66. furszy referenced this in commit f1a05cd876 on Jul 26, 2021
  67. furszy referenced this in commit 4c79ce45aa on Jul 27, 2021
  68. furszy referenced this in commit 0197517dcc on Jul 27, 2021
  69. furszy referenced this in commit 328f89a6b1 on Jul 29, 2021
  70. furszy referenced this in commit 8606df4897 on Jul 29, 2021
  71. furszy referenced this in commit 903ec325c2 on Jul 29, 2021
  72. furszy referenced this in commit 943a767ed6 on Jul 30, 2021
  73. furszy referenced this in commit 83bd27757e on Jul 31, 2021
  74. furszy referenced this in commit 3cc5a3b1aa on Aug 1, 2021
  75. furszy referenced this in commit 6c085345a4 on Aug 4, 2021
  76. furszy referenced this in commit 778c7c4ae4 on Aug 5, 2021
  77. furszy referenced this in commit 021ec143a3 on Aug 8, 2021
  78. furszy referenced this in commit ba954cabdc on Aug 10, 2021
  79. jaysonmald35 commented at 11:14 PM on August 14, 2021: none

    Thank you

  80. apoelstra referenced this in commit b207c11125 on Sep 1, 2021
  81. apoelstra referenced this in commit 9ae0204574 on Sep 18, 2021
  82. apoelstra referenced this in commit f15c72cbd2 on Sep 22, 2021
  83. Vasundhara383 referenced this in commit 22065c07af on Apr 6, 2022
  84. UdjinM6 referenced this in commit cc9dd09be6 on Jun 7, 2022
  85. UdjinM6 referenced this in commit fbacffe035 on Jun 7, 2022
  86. UdjinM6 referenced this in commit 7b2026e49b on Jun 7, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bips. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-14 18:10 UTC

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