Skip to content

Conversation

@vasild
Copy link
Contributor

@vasild vasild commented Dec 7, 2020

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.

@vasild
Copy link
Contributor Author

vasild commented Dec 7, 2020

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

change net_processing.cpp
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

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

@maflcko
Copy link
Member

maflcko commented Dec 7, 2020

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

@vasild
Copy link
Contributor Author

vasild commented Dec 7, 2020

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

@jonatack
Copy link
Member

jonatack commented Dec 7, 2020

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

@vasild vasild force-pushed the bip155_fix_send_recv_typo branch from 33db426 to 50613bb Compare December 7, 2020 17:06
@vasild vasild changed the title BIP155: fix sending vs receiving verack typo BIP155: change when sendaddrv2 is to be sent Dec 7, 2020
@vasild
Copy link
Contributor Author

vasild commented Dec 7, 2020

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

@laanwj
Copy link
Member

laanwj commented Dec 7, 2020

ACK 50613bb

@benthecarman
Copy link
Contributor

ACK 50613bb

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK

@maflcko
Copy link
Member

maflcko commented Dec 8, 2020

ACK c2c55cf

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`.
@vasild vasild force-pushed the bip155_fix_send_recv_typo branch from c2c55cf to e549ed3 Compare December 8, 2020 09:35
@vasild
Copy link
Contributor Author

vasild commented Dec 8, 2020

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

@maflcko
Copy link
Member

maflcko commented Dec 8, 2020

ACK e549ed3

@harding
Copy link
Contributor

harding commented Dec 8, 2020

ACK e549ed3

Thanks for updating!

@jnewbery
Copy link
Contributor

jnewbery commented Dec 8, 2020

ACK e549ed3

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK e549ed3

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK e549ed3, 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.

@maflcko
Copy link
Member

maflcko commented Dec 8, 2020

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

@laanwj
Copy link
Member

laanwj commented Dec 8, 2020

re-ACK e549ed3

furszy pushed a commit to furszy/bitcoin-core that referenced this pull request Aug 10, 2021
@jaysonmald35
Copy link

Thank you

apoelstra pushed a commit to apoelstra/elements that referenced this pull request Sep 1, 2021
See the corresponding BIP change: bitcoin/bips#1043

Github-Pull: #20564
Rebased-From: 1583498
(cherry picked from commit bead935)
apoelstra pushed a commit to apoelstra/elements that referenced this pull request Sep 18, 2021
See the corresponding BIP change: bitcoin/bips#1043

Github-Pull: #20564
Rebased-From: 1583498
(cherry picked from commit bead935)
apoelstra pushed a commit to apoelstra/elements that referenced this pull request Sep 22, 2021
See the corresponding BIP change: bitcoin/bips#1043

Github-Pull: #20564
Rebased-From: 1583498
(cherry picked from commit bead935)
Vasundhara383 pushed a commit to Vasundhara383/bitcoincash that referenced this pull request Apr 6, 2022
Summary
---

This is a backport of bitcoin/bitcoin@1583498

> See the corresponding BIP change: bitcoin/bips#1043

Test plan
---

* `ninja all check-all`
UdjinM6 pushed a commit to UdjinM6/dash that referenced this pull request Jun 7, 2022
…nd send before 'verack'

1583498 Send and require SENDADDRV2 before VERACK (Pieter Wuille)
c5a8919 Don't send 'sendaddrv2' to pre-70016 software (Pieter Wuille)

Pull request description:

  BIP155 defines addrv2 and sendaddrv2 for all protocol versions, but some implementations reject messages they don't know. As a courtesy, don't send it to nodes with a version before 70016, as no software is known to support BIP155 that doesn't announce at least that protocol version number.

  Also move the sending of sendaddrv2 earlier (before sending verack), as proposed in bitcoin/bips#1043. This has the side effect that local address broadcast of torv3 will work (as it'll only trigger after we know whether or not the peer supports addrv2).

ACKs for top commit:
  MarcoFalke:
    ACK 1583498
  jnewbery:
    ACK 1583498
  jonatack:
    ACK 1583498
  vasild:
    ACK 1583498

Tree-SHA512: 3bd5833fa8c8567b6dedd99e4a9b6bb71c127aa66d5284b217503c86d597dc59aa7382c41f3a4bf561bb658b89db81d1a7703a700eef4ffc17cb916660e23a82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants