mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Merge #20564: Don't send 'sendaddrv2' to pre-70016 software, and send before 'verack'
1583498fb6Send and require SENDADDRV2 before VERACK (Pieter Wuille)c5a8919660Don'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 https://github.com/bitcoin/bips/pull/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: ACK1583498fb6jnewbery: ACK1583498fb6jonatack: ACK1583498fb6vasild: ACK1583498Tree-SHA512: 3bd5833fa8c8567b6dedd99e4a9b6bb71c127aa66d5284b217503c86d597dc59aa7382c41f3a4bf561bb658b89db81d1a7703a700eef4ffc17cb916660e23a82
This commit is contained in:
@@ -2362,10 +2362,16 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
|
|||||||
m_connman.PushMessage(&pfrom, msg_maker.Make(NetMsgType::WTXIDRELAY));
|
m_connman.PushMessage(&pfrom, msg_maker.Make(NetMsgType::WTXIDRELAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_connman.PushMessage(&pfrom, msg_maker.Make(NetMsgType::VERACK));
|
|
||||||
|
|
||||||
// Signal ADDRv2 support (BIP155).
|
// Signal ADDRv2 support (BIP155).
|
||||||
m_connman.PushMessage(&pfrom, msg_maker.Make(NetMsgType::SENDADDRV2));
|
if (greatest_common_version >= 70016) {
|
||||||
|
// 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.
|
||||||
|
m_connman.PushMessage(&pfrom, msg_maker.Make(NetMsgType::SENDADDRV2));
|
||||||
|
}
|
||||||
|
|
||||||
|
m_connman.PushMessage(&pfrom, msg_maker.Make(NetMsgType::VERACK));
|
||||||
|
|
||||||
pfrom.nServices = nServices;
|
pfrom.nServices = nServices;
|
||||||
pfrom.SetAddrLocal(addrMe);
|
pfrom.SetAddrLocal(addrMe);
|
||||||
@@ -2535,6 +2541,17 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (msg_type == NetMsgType::SENDADDRV2) {
|
||||||
|
if (pfrom.fSuccessfullyConnected) {
|
||||||
|
// Disconnect peers that send SENDADDRV2 message after VERACK; this
|
||||||
|
// must be negotiated between VERSION and VERACK.
|
||||||
|
pfrom.fDisconnect = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pfrom.m_wants_addrv2 = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!pfrom.fSuccessfullyConnected) {
|
if (!pfrom.fSuccessfullyConnected) {
|
||||||
LogPrint(BCLog::NET, "Unsupported message \"%s\" prior to verack from peer=%d\n", SanitizeString(msg_type), pfrom.GetId());
|
LogPrint(BCLog::NET, "Unsupported message \"%s\" prior to verack from peer=%d\n", SanitizeString(msg_type), pfrom.GetId());
|
||||||
return;
|
return;
|
||||||
@@ -2602,11 +2619,6 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg_type == NetMsgType::SENDADDRV2) {
|
|
||||||
pfrom.m_wants_addrv2 = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msg_type == NetMsgType::SENDHEADERS) {
|
if (msg_type == NetMsgType::SENDHEADERS) {
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
State(pfrom.GetId())->fPreferHeaders = true;
|
State(pfrom.GetId())->fPreferHeaders = true;
|
||||||
|
|||||||
@@ -396,9 +396,9 @@ class P2PInterface(P2PConnection):
|
|||||||
assert message.nVersion >= MIN_VERSION_SUPPORTED, "Version {} received. Test framework only supports versions greater than {}".format(message.nVersion, MIN_VERSION_SUPPORTED)
|
assert message.nVersion >= MIN_VERSION_SUPPORTED, "Version {} received. Test framework only supports versions greater than {}".format(message.nVersion, MIN_VERSION_SUPPORTED)
|
||||||
if message.nVersion >= 70016:
|
if message.nVersion >= 70016:
|
||||||
self.send_message(msg_wtxidrelay())
|
self.send_message(msg_wtxidrelay())
|
||||||
self.send_message(msg_verack())
|
|
||||||
if self.support_addrv2:
|
if self.support_addrv2:
|
||||||
self.send_message(msg_sendaddrv2())
|
self.send_message(msg_sendaddrv2())
|
||||||
|
self.send_message(msg_verack())
|
||||||
self.nServices = message.nServices
|
self.nServices = message.nServices
|
||||||
|
|
||||||
# Connection helper methods
|
# Connection helper methods
|
||||||
|
|||||||
Reference in New Issue
Block a user