From f63f1d3f4bdef2923a8395473ca59e4763769bd7 Mon Sep 17 00:00:00 2001 From: Gleb Naumenko Date: Fri, 17 Dec 2021 13:32:16 +0200 Subject: [PATCH] p2p: clear txreconciliation state for non-wtxid peers We optimistically pre-register a peer for txreconciliations upon sending txreconciliation support announcement. But if, at VERACK, we realize that the peer never sent WTXIDRELAY message, we should unregister the peer from txreconciliations, because txreconciliations rely on wtxids. --- src/net_processing.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 350187bdda..c87b0e7cd2 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -3414,6 +3414,16 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type, // they may wish to request compact blocks from us m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::SENDCMPCT, /*high_bandwidth=*/false, /*version=*/CMPCTBLOCKS_VERSION)); } + + if (m_txreconciliation) { + if (!peer->m_wtxid_relay || !m_txreconciliation->IsPeerRegistered(pfrom.GetId())) { + // We could have optimistically pre-registered/registered the peer. In that case, + // we should forget about the reconciliation state here if this wasn't followed + // by WTXIDRELAY (since WTXIDRELAY can't be announced later). + m_txreconciliation->ForgetPeer(pfrom.GetId()); + } + } + pfrom.fSuccessfullyConnected = true; return; }