diff --git a/packages/dashmate/configs/defaults/getBaseConfigFactory.js b/packages/dashmate/configs/defaults/getBaseConfigFactory.js index 615381179b1..e21b2111e88 100644 --- a/packages/dashmate/configs/defaults/getBaseConfigFactory.js +++ b/packages/dashmate/configs/defaults/getBaseConfigFactory.js @@ -155,6 +155,13 @@ export default function getBaseConfigFactory() { }, }, indexes: [], + // BIP158 cfilter index + NODE_COMPACT_FILTERS service bit. + // Default-on across every preset so dashmate-managed nodes + // are BIP157 SPV-friendly out of the box. Operators who + // can't spare the cfilter index disk overhead (~10% of + // chain size on mainnet) can flip this off via + // `dashmate config set core.compactFilters false`. + compactFilters: true, }, platform: { quorumList: { diff --git a/packages/dashmate/configs/defaults/getLocalConfigFactory.js b/packages/dashmate/configs/defaults/getLocalConfigFactory.js index 409c36b1cee..9c9120b345f 100644 --- a/packages/dashmate/configs/defaults/getLocalConfigFactory.js +++ b/packages/dashmate/configs/defaults/getLocalConfigFactory.js @@ -36,6 +36,14 @@ export default function getLocalConfigFactory(getBaseConfig) { zmq: { port: 49998, }, + // Mirrors the `core.compactFilters: true` set on the base + // config; restated explicitly here because the local + // preset is the canonical surface where dev BIP157 SPV + // clients (e.g. the swift-sdk iOS example app pointed at + // `local_seed`) need cfilter sync to work, and we want + // that requirement to survive any future flip of the base + // default. + compactFilters: true, }, dashmate: { helper: { diff --git a/packages/dashmate/configs/getConfigFileMigrationsFactory.js b/packages/dashmate/configs/getConfigFileMigrationsFactory.js index a8d6018cb5e..adaa072685d 100644 --- a/packages/dashmate/configs/getConfigFileMigrationsFactory.js +++ b/packages/dashmate/configs/getConfigFileMigrationsFactory.js @@ -1413,6 +1413,20 @@ export default function getConfigFileMigrationsFactory(homeDir, defaultConfigs) const isLocal = options.network === NETWORK_LOCAL || name === 'local'; const isTestnet = options.network === NETWORK_TESTNET || name === 'testnet'; + // Flip `core.compactFilters` to true for every config — + // pre-3.1.0 configs predate the field entirely (template + // emitted nothing, dashcore left the cfilter index off), + // so a missing-or-false value here always means + // "inherited the old implicit-off default" rather than + // "user explicitly opted out". The base config now + // ships with this flag on; this backfill brings every + // already-set-up cluster up to that line so the iOS + // BIP157 SPV flow against `local_seed` (and any other + // dashmate node) works without manual editing. + if (options.core) { + options.core.compactFilters = true; + } + if (options.platform?.drive?.tenderdash?.docker && defaultConfig.has('platform.drive.tenderdash.docker.image')) { options.platform.drive.tenderdash.docker.image = defaultConfig diff --git a/packages/dashmate/src/config/configJsonSchema.js b/packages/dashmate/src/config/configJsonSchema.js index 3b53f61a5b2..ecf969bde64 100644 --- a/packages/dashmate/src/config/configJsonSchema.js +++ b/packages/dashmate/src/config/configJsonSchema.js @@ -487,6 +487,14 @@ export default { description: 'List of core indexes to enable. `platform.enable`, ' + ' `core.masternode.enable`, and `core.insight.enabled` add indexes dynamically', }, + compactFilters: { + type: 'boolean', + description: 'Build the BIP158 cfilter index and advertise ' + + 'NODE_COMPACT_FILTERS to peers, so BIP157 SPV clients can sync ' + + 'filter headers + filters from this node. Defaults to true on ' + + 'every preset; flip to false to skip the cfilter index ' + + '(~10% chain-size disk overhead on mainnet).', + }, }, required: ['docker', 'p2p', 'rpc', 'zmq', 'spork', 'masternode', 'miner', 'devnet', 'log', 'indexes', 'insight'], diff --git a/packages/dashmate/templates/core/dash.conf.dot b/packages/dashmate/templates/core/dash.conf.dot index c07f8f18cba..c86b84bcccd 100644 --- a/packages/dashmate/templates/core/dash.conf.dot +++ b/packages/dashmate/templates/core/dash.conf.dot @@ -69,6 +69,17 @@ spentindex=1 {{~}} {{?}} +# BIP157/158 compact block filters. Building the cfilter index plus +# advertising NODE_COMPACT_FILTERS lets BIP157 SPV clients sync +# headers + filters from this node. Off by default (mainnet/testnet +# usage doesn't justify the disk + CPU overhead); enabled on the +# `local` preset where the chain is tiny and the iOS dev flow needs +# filter sync against dashmate's `local_seed` to test the wallet. +{{? it.core.compactFilters }} +blockfilterindex=basic +peerblockfilters=1 +{{?}} + # ZeroMQ notifications zmqpubrawtx=tcp://0.0.0.0:{{=it.core.zmq.port}} zmqpubrawtxlock=tcp://0.0.0.0:{{=it.core.zmq.port}}