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.
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.
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.
A third option would be to use the same feature negotiation order that was used for wtxidrelay
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).
In the same way as wtxidrelay SGTM for being simpler rather than a different mechanism for each.
Changed to send it before sending verack (like wtxidrelay).
ACK 50613bb82ce89d31027ad27daecf46f05aff198e
ACK 50613bb82ce89d31027ad27daecf46f05aff198e
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.
I think the SHOULD here should be changed to MUST.
The feature negotiation MUST be completed before the VERSION-VERACK handshake is completed.
<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.
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/
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."
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
Changed to MUST and reworded to mimic BIP-339 / wtxidrelay.
Changed to MUST and reworded to mimic BIP-339 / wtxidrelay.
Concept ACK
ACK c2c55cfbf0284d20cc3080871cbceb9a55d1894e
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`.
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.
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.
Done
There are many ways to say it, I hope the current phrasing is clear enough and good for everybody.
ACK e549ed36e8bbb0d15b1bd245cc5bb2c5664d5aa2
ACK e549ed36e8bbb0d15b1bd245cc5bb2c5664d5aa2
Thanks for updating!
ACK e549ed36e8bbb0d15b1bd245cc5bb2c5664d5aa2
ACK e549ed3
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.
According to the BIP process, this needs an ACK by the BIP champion @laanwj :)
re-ACK e549ed36e8bbb0d15b1bd245cc5bb2c5664d5aa2
Thank you