diff --git a/backend/mempool-config.sample.json b/backend/mempool-config.sample.json index f0d447582..b11616b2a 100644 --- a/backend/mempool-config.sample.json +++ b/backend/mempool-config.sample.json @@ -32,6 +32,7 @@ "RUST_GBT": true, "LIMIT_GBT": false, "CLUSTER_MEMPOOL": false, + "CLUSTER_MEMPOOL_INDEXING": false, "CPFP_INDEXING": false, "DISK_CACHE_BLOCK_INTERVAL": 6, "MAX_PUSH_TX_SIZE_WEIGHT": 4000000, diff --git a/backend/mempool-config.test.json b/backend/mempool-config.test.json index b0ca4cd04..c309099b9 100644 --- a/backend/mempool-config.test.json +++ b/backend/mempool-config.test.json @@ -32,6 +32,7 @@ "RUST_GBT": true, "LIMIT_GBT": false, "CLUSTER_MEMPOOL": false, + "CLUSTER_MEMPOOL_INDEXING": false, "CPFP_INDEXING": false, "DISK_CACHE_BLOCK_INTERVAL": 6, "MAX_PUSH_TX_SIZE_WEIGHT": 4000000, diff --git a/backend/src/__fixtures__/mempool-config.template.json b/backend/src/__fixtures__/mempool-config.template.json index 56feefa67..688a9ba37 100644 --- a/backend/src/__fixtures__/mempool-config.template.json +++ b/backend/src/__fixtures__/mempool-config.template.json @@ -33,6 +33,7 @@ "RUST_GBT": false, "LIMIT_GBT": false, "CLUSTER_MEMPOOL": false, + "CLUSTER_MEMPOOL_INDEXING": false, "CPFP_INDEXING": true, "MAX_BLOCKS_BULK_QUERY": 999, "DISK_CACHE_BLOCK_INTERVAL": 999, diff --git a/backend/src/__tests__/config.test.ts b/backend/src/__tests__/config.test.ts index ec44eeeff..42a0b3fc8 100644 --- a/backend/src/__tests__/config.test.ts +++ b/backend/src/__tests__/config.test.ts @@ -46,6 +46,7 @@ describe('Mempool Backend Config', () => { RUST_GBT: true, LIMIT_GBT: false, CLUSTER_MEMPOOL: false, + CLUSTER_MEMPOOL_INDEXING: false, CPFP_INDEXING: false, MAX_BLOCKS_BULK_QUERY: 0, DISK_CACHE_BLOCK_INTERVAL: 6, diff --git a/backend/src/api/block-processor.ts b/backend/src/api/block-processor.ts index eb0eaaeaf..6556e907e 100644 --- a/backend/src/api/block-processor.ts +++ b/backend/src/api/block-processor.ts @@ -205,9 +205,6 @@ export function detectTemplateAlgorithm( fast: boolean = false ): { templateAlgorithm: TemplateAlgorithm; cpfpSummary: CpfpSummary } { - const network = config.MEMPOOL.NETWORK || 'mainnet'; - const activationHeight = CM_ACTIVATION_HEIGHT[network] ?? Infinity; - const legacyCpfpData = fast ? calculateFastBlockCpfp( height, blockTransactions, @@ -217,6 +214,16 @@ export function detectTemplateAlgorithm( poolAccelerations ); + if (!config.MEMPOOL.CLUSTER_MEMPOOL_INDEXING) { + return { + templateAlgorithm: TemplateAlgorithm.legacy, + cpfpSummary: saveCpfpDataToCpfpSummary(blockTransactions, legacyCpfpData), + }; + } + + const network = config.MEMPOOL.NETWORK || 'mainnet'; + const activationHeight = CM_ACTIVATION_HEIGHT[network] ?? Infinity; + if (height < activationHeight) { return { templateAlgorithm: TemplateAlgorithm.legacy, diff --git a/backend/src/api/websocket-handler.ts b/backend/src/api/websocket-handler.ts index 4fbe3aa09..92b3d909e 100644 --- a/backend/src/api/websocket-handler.ts +++ b/backend/src/api/websocket-handler.ts @@ -777,6 +777,8 @@ class WebsocketHandler { removed: websocketAccelerationDelta.filter(txid => !accelerations[txid]), }; + const cpfpUpdatesSent = new Set(); + // TODO - Fix indentation after PR is merged for (const server of this.webSocketServers) { server.clients.forEach(async (client) => { @@ -961,6 +963,7 @@ class WebsocketHandler { } } positionData['cpfp'] = cpfp; + cpfpUpdatesSent.add(trackTxid); } response['txPosition'] = JSON.stringify(positionData); } @@ -1009,6 +1012,7 @@ class WebsocketHandler { (txInfo.cpfp as CpfpInfo).cluster = cluster; } } + cpfpUpdatesSent.add(txid); } txHasInfo = true; } @@ -1059,6 +1063,12 @@ class WebsocketHandler { } }); } + + for (const txid of cpfpUpdatesSent) { + if (newMempool[txid]) { + newMempool[txid].cpfpDirty = false; + } + } } /** @asyncSafe */ diff --git a/backend/src/config.ts b/backend/src/config.ts index 6850d8de6..6ac08a2f1 100644 --- a/backend/src/config.ts +++ b/backend/src/config.ts @@ -35,6 +35,7 @@ interface IConfig { POOLS_UPDATE_DELAY: number, AUDIT: boolean; CLUSTER_MEMPOOL: boolean; + CLUSTER_MEMPOOL_INDEXING: boolean; RUST_GBT: boolean; LIMIT_GBT: boolean; CPFP_INDEXING: boolean; @@ -207,6 +208,7 @@ const defaults: IConfig = { 'POOLS_UPDATE_DELAY': 604800, // in seconds, default is one week 'AUDIT': false, 'CLUSTER_MEMPOOL': false, + 'CLUSTER_MEMPOOL_INDEXING': false, 'RUST_GBT': true, 'LIMIT_GBT': false, 'CPFP_INDEXING': false, diff --git a/docker/backend/mempool-config.json b/docker/backend/mempool-config.json index 4dcb45cd2..4c3e075ce 100644 --- a/docker/backend/mempool-config.json +++ b/docker/backend/mempool-config.json @@ -30,6 +30,7 @@ "RUST_GBT": __MEMPOOL_RUST_GBT__, "LIMIT_GBT": __MEMPOOL_LIMIT_GBT__, "CLUSTER_MEMPOOL": __MEMPOOL_CLUSTER_MEMPOOL__, + "CLUSTER_MEMPOOL_INDEXING": __MEMPOOL_CLUSTER_MEMPOOL_INDEXING__, "CPFP_INDEXING": __MEMPOOL_CPFP_INDEXING__, "MAX_BLOCKS_BULK_QUERY": __MEMPOOL_MAX_BLOCKS_BULK_QUERY__, "DISK_CACHE_BLOCK_INTERVAL": __MEMPOOL_DISK_CACHE_BLOCK_INTERVAL__, diff --git a/docker/backend/start.sh b/docker/backend/start.sh index d5ea316bb..bb1351b05 100755 --- a/docker/backend/start.sh +++ b/docker/backend/start.sh @@ -34,6 +34,7 @@ __MEMPOOL_AUDIT__=${MEMPOOL_AUDIT:=false} __MEMPOOL_RUST_GBT__=${MEMPOOL_RUST_GBT:=true} __MEMPOOL_LIMIT_GBT__=${MEMPOOL_LIMIT_GBT:=false} __MEMPOOL_CLUSTER_MEMPOOL__=${MEMPOOL_CLUSTER_MEMPOOL:=false} +__MEMPOOL_CLUSTER_MEMPOOL_INDEXING__=${MEMPOOL_CLUSTER_MEMPOOL_INDEXING:=false} __MEMPOOL_CPFP_INDEXING__=${MEMPOOL_CPFP_INDEXING:=false} __MEMPOOL_MAX_BLOCKS_BULK_QUERY__=${MEMPOOL_MAX_BLOCKS_BULK_QUERY:=0} __MEMPOOL_DISK_CACHE_BLOCK_INTERVAL__=${MEMPOOL_DISK_CACHE_BLOCK_INTERVAL:=6} @@ -199,6 +200,7 @@ sed -i "s!__MEMPOOL_AUDIT__!${__MEMPOOL_AUDIT__}!g" mempool-config.json sed -i "s!__MEMPOOL_RUST_GBT__!${__MEMPOOL_RUST_GBT__}!g" mempool-config.json sed -i "s!__MEMPOOL_LIMIT_GBT__!${__MEMPOOL_LIMIT_GBT__}!g" mempool-config.json sed -i "s!__MEMPOOL_CLUSTER_MEMPOOL__!${__MEMPOOL_CLUSTER_MEMPOOL__}!g" mempool-config.json +sed -i "s!__MEMPOOL_CLUSTER_MEMPOOL_INDEXING__!${__MEMPOOL_CLUSTER_MEMPOOL_INDEXING__}!g" mempool-config.json sed -i "s!__MEMPOOL_CPFP_INDEXING__!${__MEMPOOL_CPFP_INDEXING__}!g" mempool-config.json sed -i "s!__MEMPOOL_MAX_BLOCKS_BULK_QUERY__!${__MEMPOOL_MAX_BLOCKS_BULK_QUERY__}!g" mempool-config.json sed -i "s!__MEMPOOL_DISK_CACHE_BLOCK_INTERVAL__!${__MEMPOOL_DISK_CACHE_BLOCK_INTERVAL__}!g" mempool-config.json