Skip to content

Commit 90ef2d5

Browse files
refactor: Enable BIP157 block filters only for masternodes
Instead of enabling peerblockfilters by default for all nodes, this change: - Keeps DEFAULT_PEERBLOCKFILTERS as false (unchanged from current behavior) - Automatically enables peerblockfilters and blockfilterindex for masternodes - Allows masternodes to still explicitly disable with -peerblockfilters=0 This approach: - Deploys block filters to the nodes that provide the majority of network services - Avoids breaking changes for regular nodes - Follows existing Dash patterns (like auto-disabling wallet for masternodes) - Eliminates the need for extensive test suite modifications The parameter interaction happens in InitParameterInteraction() where masternodes (identified by -masternodeblsprivkey) automatically get: - peerblockfilters=1 - blockfilterindex=basic 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent d40ae45 commit 90ef2d5

File tree

6 files changed

+18
-9
lines changed

6 files changed

+18
-9
lines changed

src/init.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,8 +1018,17 @@ void InitParameterInteraction(ArgsManager& args)
10181018
LogPrintf("%s: parameter interaction: additional indexes -> setting -checklevel=4\n", __func__);
10191019
}
10201020

1021-
if (args.IsArgSet("-masternodeblsprivkey") && args.SoftSetBoolArg("-disablewallet", true)) {
1022-
LogPrintf("%s: parameter interaction: -masternodeblsprivkey set -> setting -disablewallet=1\n", __func__);
1021+
if (args.IsArgSet("-masternodeblsprivkey")) {
1022+
if (args.SoftSetBoolArg("-disablewallet", true)) {
1023+
LogPrintf("%s: parameter interaction: -masternodeblsprivkey set -> setting -disablewallet=1\n", __func__);
1024+
}
1025+
// Enable block filters for masternodes to improve network services
1026+
if (args.SoftSetBoolArg("-peerblockfilters", true)) {
1027+
LogPrintf("%s: parameter interaction: -masternodeblsprivkey set -> setting -peerblockfilters=1\n", __func__);
1028+
}
1029+
if (args.SoftSetArg("-blockfilterindex", "basic")) {
1030+
LogPrintf("%s: parameter interaction: -masternodeblsprivkey set -> setting -blockfilterindex=basic\n", __func__);
1031+
}
10231032
}
10241033
}
10251034

src/net_processing.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS_SIZE = 10; // this all
3333
/** Default number of orphan+recently-replaced txn to keep around for block reconstruction */
3434
static const unsigned int DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN = 100;
3535
static const bool DEFAULT_PEERBLOOMFILTERS = true;
36-
static const bool DEFAULT_PEERBLOCKFILTERS = true;
36+
static const bool DEFAULT_PEERBLOCKFILTERS = false;
3737
/** Threshold for marking a node to be discouraged, e.g. disconnected and added to the discouragement filter. */
3838
static const int DISCOURAGEMENT_THRESHOLD{100};
3939

test/functional/feature_index_prune.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def set_test_params(self):
2222
self.num_nodes = 4
2323
self.extra_args = [
2424
["-fastprune", "-prune=1", "-blockfilterindex=1"] + DEPLOYMENT_ARGS,
25-
["-fastprune", "-prune=1", "-coinstatsindex=1", "-blockfilterindex=0", "-peerblockfilters=0"] + DEPLOYMENT_ARGS,
25+
["-fastprune", "-prune=1", "-coinstatsindex=1"] + DEPLOYMENT_ARGS,
2626
["-fastprune", "-prune=1", "-blockfilterindex=1", "-coinstatsindex=1"] + DEPLOYMENT_ARGS,
2727
[] + DEPLOYMENT_ARGS,
2828
]
@@ -54,7 +54,7 @@ def mine_batches(self, blocks):
5454

5555
def restart_without_indices(self):
5656
for i in range(3):
57-
self.restart_node(i, extra_args=["-fastprune", "-prune=1", "-blockfilterindex=0", "-coinstatsindex=0", "-peerblockfilters=0"] + DEPLOYMENT_ARGS, expected_stderr=EXPECTED_STDERR_NO_GOV_PRUNE)
57+
self.restart_node(i, extra_args=["-fastprune", "-prune=1"] + DEPLOYMENT_ARGS, expected_stderr=EXPECTED_STDERR_NO_GOV_PRUNE)
5858
self.reconnect_nodes()
5959

6060
def run_test(self):

test/functional/feature_reindex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def reindex(self, justchainstate=False, txindex=0):
2525
self.generatetoaddress(self.nodes[0], 3, self.nodes[0].get_deterministic_priv_key().address)
2626
blockcount = self.nodes[0].getblockcount()
2727
self.stop_nodes()
28-
extra_args = [["-reindex-chainstate", "-txindex=0", "-blockfilterindex=0"]] if justchainstate else [["-reindex", f"-txindex={txindex}"]]
28+
extra_args = [["-reindex-chainstate", "-txindex=0"]] if justchainstate else [["-reindex", f"-txindex={txindex}"]]
2929
self.start_nodes(extra_args)
3030
assert_equal(self.nodes[0].getblockcount(), blockcount) # start_node is blocking on reindex
3131
self.log.info("Success")

test/functional/feature_unsupported_utxo_db.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def run_test(self):
5353
)
5454

5555
self.log.info("Drop legacy utxo db")
56-
self.start_node(1, extra_args=["-reindex-chainstate", "-txindex=0", "-blockfilterindex=0"])
56+
self.start_node(1, extra_args=["-reindex-chainstate", "-txindex=0"])
5757
assert_equal(self.nodes[1].getbestblockhash(), block)
5858
assert_equal(self.nodes[1].gettxoutsetinfo()["total_amount"], 500)
5959

test/functional/p2p_blockfilters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def set_test_params(self):
4747
self.num_nodes = 2
4848
self.extra_args = [
4949
["-blockfilterindex", "-peerblockfilters"],
50-
["-blockfilterindex", "-peerblockfilters=0"],
50+
["-blockfilterindex"],
5151
]
5252

5353
def run_test(self):
@@ -264,7 +264,7 @@ def run_test(self):
264264

265265
self.log.info("Test -peerblockfilters without -blockfilterindex raises an error")
266266
self.stop_node(0)
267-
self.nodes[0].extra_args = ["-peerblockfilters", "-blockfilterindex=0"]
267+
self.nodes[0].extra_args = ["-peerblockfilters"]
268268
msg = "Error: Cannot set -peerblockfilters without -blockfilterindex."
269269
self.nodes[0].assert_start_raises_init_error(expected_msg=msg)
270270

0 commit comments

Comments
 (0)