mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 07:39:08 +01:00
Merge #19260: p2p: disconnect peers that send filterclear + update existing filter msg disconnect logic
3a10d935ac[p2p/refactor] move disconnect logic and remove misbehaving (gzhao408)ff8c430c65[test] test disconnect for filterclear (gzhao408)1c6b787e03[netprocessing] disconnect node that sends filterclear (gzhao408) Pull request description: Nodes that don't have bloomfilters turned on (i.e. no `NODE_BLOOM` service) should disconnect peers that send them `filterclear` P2P messages. Non-bloomfilter nodes already disconnect peers for [`filteradd` and `filterload`](19e919217e/src/net_processing.cpp (L2218)), but #8709 removed `filterclear` so it could be used to reset tx relay. This isn't needed now because using `feefilter` message is much better for this purpose (See #19204). Also refactors existing disconnect logic for `filteradd` and `filterload` into respective message handlers and removes banning for them. ACKs for top commit: jnewbery: Code review ACK3a10d935acnaumenkogs: utACK3a10d93gillichu: tested ACK: quick test_runner on macOS [`3a10d93`](3a10d935ac) MarcoFalke: re-ACK3a10d935aconly change is replacing false with true 🚝 Tree-SHA512: 7aad8b3c0b0e776a47ad52544f0c1250feb242320f9a2962542f5905042f77e297a1486f8cdc3bf0fb93cd00c1ab66a67b2ec426eb6da3fe4cda56b5e623620f
This commit is contained in:
@@ -2215,20 +2215,6 @@ bool ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStream& vRec
|
||||
}
|
||||
|
||||
|
||||
if (!(pfrom.GetLocalServices() & NODE_BLOOM) &&
|
||||
(msg_type == NetMsgType::FILTERLOAD ||
|
||||
msg_type == NetMsgType::FILTERADD))
|
||||
{
|
||||
if (pfrom.nVersion >= NO_BLOOM_VERSION) {
|
||||
LOCK(cs_main);
|
||||
Misbehaving(pfrom.GetId(), 100);
|
||||
return false;
|
||||
} else {
|
||||
pfrom.fDisconnect = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (msg_type == NetMsgType::VERSION) {
|
||||
// Each connection can only send one version message
|
||||
if (pfrom.nVersion != 0)
|
||||
@@ -3447,6 +3433,10 @@ bool ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStream& vRec
|
||||
}
|
||||
|
||||
if (msg_type == NetMsgType::FILTERLOAD) {
|
||||
if (!(pfrom.GetLocalServices() & NODE_BLOOM)) {
|
||||
pfrom.fDisconnect = true;
|
||||
return true;
|
||||
}
|
||||
CBloomFilter filter;
|
||||
vRecv >> filter;
|
||||
|
||||
@@ -3466,6 +3456,10 @@ bool ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStream& vRec
|
||||
}
|
||||
|
||||
if (msg_type == NetMsgType::FILTERADD) {
|
||||
if (!(pfrom.GetLocalServices() & NODE_BLOOM)) {
|
||||
pfrom.fDisconnect = true;
|
||||
return true;
|
||||
}
|
||||
std::vector<unsigned char> vData;
|
||||
vRecv >> vData;
|
||||
|
||||
@@ -3490,13 +3484,15 @@ bool ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStream& vRec
|
||||
}
|
||||
|
||||
if (msg_type == NetMsgType::FILTERCLEAR) {
|
||||
if (!(pfrom.GetLocalServices() & NODE_BLOOM)) {
|
||||
pfrom.fDisconnect = true;
|
||||
return true;
|
||||
}
|
||||
if (pfrom.m_tx_relay == nullptr) {
|
||||
return true;
|
||||
}
|
||||
LOCK(pfrom.m_tx_relay->cs_filter);
|
||||
if (pfrom.GetLocalServices() & NODE_BLOOM) {
|
||||
pfrom.m_tx_relay->pfilter = nullptr;
|
||||
}
|
||||
pfrom.m_tx_relay->pfilter = nullptr;
|
||||
pfrom.m_tx_relay->fRelayTxes = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user