diff --git a/src/net_processing.cpp b/src/net_processing.cpp --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -4979,10 +4979,16 @@ } if (msg_type == NetMsgType::AVAHELLO) { - if (!pfrom.m_avalanche_state) { - pfrom.m_avalanche_state = std::make_unique(); + if (pfrom.m_avalanche_state) { + LogPrint( + BCLog::AVALANCHE, + "Ignoring avahello from peer %d: already in our node set\n", + pfrom.GetId()); + return; } + pfrom.m_avalanche_state = std::make_unique(); + CHashVerifier verifier(&vRecv); avalanche::Delegation delegation; verifier >> delegation; diff --git a/test/functional/abc_p2p_avalanche_peer_discovery.py b/test/functional/abc_p2p_avalanche_peer_discovery.py --- a/test/functional/abc_p2p_avalanche_peer_discovery.py +++ b/test/functional/abc_p2p_avalanche_peer_discovery.py @@ -250,6 +250,12 @@ self.wait_until(lambda: has_node_count(2)) + self.log.info("Check that repeated avahello messages are ignored") + for i in range(3): + with node.assert_debug_log(['Ignoring avahello from peer']): + peer_proof_known.send_avahello( + interface_delegation_hex, delegated_key) + self.log.info("Invalidate the proof and check the nodes are removed") tip = node.getbestblockhash() # Invalidate the block with the proof utxo