From b3caa9b7fa7695e60fc4002229b77f43db8ded67 Mon Sep 17 00:00:00 2001 From: Patick Strateman Date: Tue, 24 Nov 2015 01:47:32 -0800 Subject: [PATCH 1/3] Move bloom filter filtering logic outside of command "switch" (giant if/else). Moving this logic outside of the "switch" makes it far simpler to enable the forced disconnect by a parameter. --- src/main.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 2579b642b..fd5637a8c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3989,6 +3989,21 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } + if (!(nLocalServices & NODE_BLOOM) && + (strCommand == "filterload" || + strCommand == "filteradd" || + strCommand == "filterclear")) + { + if (pfrom->nVersion >= NO_BLOOM_VERSION) { + Misbehaving(pfrom->GetId(), 100); + return false; + } + //TODO: Enable this after reasonable network upgrade + //else { + // pfrom->fDisconnect = true; + // return false; + //} + } if (strCommand == "version") @@ -4750,21 +4765,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } - else if (!(nLocalServices & NODE_BLOOM) && - (strCommand == "filterload" || - strCommand == "filteradd" || - strCommand == "filterclear") && - //TODO: Remove this line after reasonable network upgrade - pfrom->nVersion >= NO_BLOOM_VERSION) - { - if (pfrom->nVersion >= NO_BLOOM_VERSION) - Misbehaving(pfrom->GetId(), 100); - //TODO: Enable this after reasonable network upgrade - //else - // pfrom->fDisconnect = true; - } - - else if (strCommand == "filterload") { CBloomFilter filter; From 0f4dc53fd6a19a763922b4c3888ce6542c594e01 Mon Sep 17 00:00:00 2001 From: Patick Strateman Date: Tue, 24 Nov 2015 01:51:53 -0800 Subject: [PATCH 2/3] Add enforcenodebloom option. Previously peers which implement a protocol version less than NO_BLOOM_VERSION would not be disconnected for sending a filter command, regardless of the peerbloomfilter option. Many node operators do not wish to provide expensive bloom filtering for SPV clients, previously they had to cherry pick the commit which enabled the disconnect logic. The default should remain false until a sufficient percent of SPV clients have updated. --- src/main.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index fd5637a8c..b0b58141a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3997,12 +3997,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, if (pfrom->nVersion >= NO_BLOOM_VERSION) { Misbehaving(pfrom->GetId(), 100); return false; + } else if (GetBoolArg("-enforcenodebloom", false)) { + pfrom->fDisconnect = true; + return false; } - //TODO: Enable this after reasonable network upgrade - //else { - // pfrom->fDisconnect = true; - // return false; - //} } From 9cf668844eebee18ea08a8c6e63758871ef4ea86 Mon Sep 17 00:00:00 2001 From: Patick Strateman Date: Tue, 24 Nov 2015 01:57:08 -0800 Subject: [PATCH 3/3] Document both the peerbloomfilters and enforcenodebloom options. --- src/init.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/init.cpp b/src/init.cpp index cd84e7747..5d5c68553 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -362,6 +362,9 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-onion=", strprintf(_("Use separate SOCKS5 proxy to reach peers via Tor hidden services (default: %s)"), "-proxy")); strUsage += HelpMessageOpt("-onlynet=", _("Only connect to nodes in network (ipv4, ipv6 or onion)")); strUsage += HelpMessageOpt("-permitbaremultisig", strprintf(_("Relay non-P2SH multisig (default: %u)"), 1)); + strUsage += HelpMessageOpt("-peerbloomfilters", strprintf(_("Support filtering of blocks and transaction with bloom filters (default: %u)"), 1)); + if (showDebug) + strUsage += HelpMessageOpt("-enforcenodebloom", strprintf("Enforce minimum protocol version to limit use of bloom filters (default: %u)", 0)); strUsage += HelpMessageOpt("-port=", strprintf(_("Listen for connections on (default: %u or testnet: %u)"), 8333, 18333)); strUsage += HelpMessageOpt("-proxy=", _("Connect through SOCKS5 proxy")); strUsage += HelpMessageOpt("-proxyrandomize", strprintf(_("Randomize credentials for every proxy connection. This enables Tor stream isolation (default: %u)"), 1));