From 8f675c70629dae0c0bb0185a0955ce5b5e3b23da Mon Sep 17 00:00:00 2001 From: Mononaut Date: Sun, 25 Jun 2023 20:35:41 -0400 Subject: [PATCH] Add Rust GBT config flag --- backend/mempool-config.sample.json | 1 + .../__fixtures__/mempool-config.template.json | 1 + backend/src/__tests__/config.test.ts | 1 + backend/src/api/websocket-handler.ts | 18 +++++++++++++++--- backend/src/config.ts | 2 ++ docker/backend/mempool-config.json | 1 + docker/backend/start.sh | 2 ++ production/mempool-config.mainnet.json | 1 + production/mempool-config.signet.json | 1 + production/mempool-config.testnet.json | 1 + 10 files changed, 26 insertions(+), 3 deletions(-) diff --git a/backend/mempool-config.sample.json b/backend/mempool-config.sample.json index 32becd00d..3371a8587 100644 --- a/backend/mempool-config.sample.json +++ b/backend/mempool-config.sample.json @@ -27,6 +27,7 @@ "AUDIT": false, "ADVANCED_GBT_AUDIT": false, "ADVANCED_GBT_MEMPOOL": false, + "RUST_GBT": false, "CPFP_INDEXING": false, "DISK_CACHE_BLOCK_INTERVAL": 6 }, diff --git a/backend/src/__fixtures__/mempool-config.template.json b/backend/src/__fixtures__/mempool-config.template.json index 919784464..62b2e5f45 100644 --- a/backend/src/__fixtures__/mempool-config.template.json +++ b/backend/src/__fixtures__/mempool-config.template.json @@ -27,6 +27,7 @@ "AUDIT": true, "ADVANCED_GBT_AUDIT": true, "ADVANCED_GBT_MEMPOOL": true, + "RUST_GBT": 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 278d83f50..937011ba2 100644 --- a/backend/src/__tests__/config.test.ts +++ b/backend/src/__tests__/config.test.ts @@ -40,6 +40,7 @@ describe('Mempool Backend Config', () => { AUDIT: false, ADVANCED_GBT_AUDIT: false, ADVANCED_GBT_MEMPOOL: false, + RUST_GBT: false, CPFP_INDEXING: false, MAX_BLOCKS_BULK_QUERY: 0, DISK_CACHE_BLOCK_INTERVAL: 6, diff --git a/backend/src/api/websocket-handler.ts b/backend/src/api/websocket-handler.ts index c32aee4cd..1bc594a83 100644 --- a/backend/src/api/websocket-handler.ts +++ b/backend/src/api/websocket-handler.ts @@ -342,7 +342,11 @@ class WebsocketHandler { this.printLogs(); if (config.MEMPOOL.ADVANCED_GBT_MEMPOOL) { - await mempoolBlocks.$rustUpdateBlockTemplates(newMempool, newTransactions, deletedTransactions, true); + if (config.MEMPOOL.RUST_GBT) { + await mempoolBlocks.$rustUpdateBlockTemplates(newMempool, newTransactions, deletedTransactions, true); + } else { + await mempoolBlocks.$updateBlockTemplates(newMempool, newTransactions, deletedTransactions, true); + } } else { mempoolBlocks.updateMempoolBlocks(newMempool, true); } @@ -588,7 +592,11 @@ class WebsocketHandler { if (separateAudit) { auditMempool = deepClone(_memPool); if (config.MEMPOOL.ADVANCED_GBT_AUDIT) { - projectedBlocks = await mempoolBlocks.$rustMakeBlockTemplates(auditMempool, false); + if (config.MEMPOOL.RUST_GBT) { + projectedBlocks = await mempoolBlocks.$rustMakeBlockTemplates(auditMempool, false); + } else { + projectedBlocks = await mempoolBlocks.$makeBlockTemplates(auditMempool, false); + } } else { projectedBlocks = mempoolBlocks.updateMempoolBlocks(auditMempool, false); } @@ -655,7 +663,11 @@ class WebsocketHandler { } if (config.MEMPOOL.ADVANCED_GBT_MEMPOOL) { - await mempoolBlocks.$rustMakeBlockTemplates(_memPool, true); + if (config.MEMPOOL.RUST_GBT) { + await mempoolBlocks.$rustMakeBlockTemplates(_memPool, true); + } else { + await mempoolBlocks.$makeBlockTemplates(_memPool, true); + } } else { mempoolBlocks.updateMempoolBlocks(_memPool, true); } diff --git a/backend/src/config.ts b/backend/src/config.ts index ff5ea4f9f..fd7d7bc28 100644 --- a/backend/src/config.ts +++ b/backend/src/config.ts @@ -31,6 +31,7 @@ interface IConfig { AUDIT: boolean; ADVANCED_GBT_AUDIT: boolean; ADVANCED_GBT_MEMPOOL: boolean; + RUST_GBT: boolean; CPFP_INDEXING: boolean; MAX_BLOCKS_BULK_QUERY: number; DISK_CACHE_BLOCK_INTERVAL: number; @@ -160,6 +161,7 @@ const defaults: IConfig = { 'AUDIT': false, 'ADVANCED_GBT_AUDIT': false, 'ADVANCED_GBT_MEMPOOL': false, + 'RUST_GBT': false, 'CPFP_INDEXING': false, 'MAX_BLOCKS_BULK_QUERY': 0, 'DISK_CACHE_BLOCK_INTERVAL': 6, diff --git a/docker/backend/mempool-config.json b/docker/backend/mempool-config.json index 06ed51f41..45f95a53e 100644 --- a/docker/backend/mempool-config.json +++ b/docker/backend/mempool-config.json @@ -25,6 +25,7 @@ "AUDIT": __MEMPOOL_AUDIT__, "ADVANCED_GBT_AUDIT": __MEMPOOL_ADVANCED_GBT_AUDIT__, "ADVANCED_GBT_MEMPOOL": __MEMPOOL_ADVANCED_GBT_MEMPOOL__, + "RUST_GBT": __MEMPOOL_RUST_GBT__, "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 cb1108a05..b746512a9 100755 --- a/docker/backend/start.sh +++ b/docker/backend/start.sh @@ -28,6 +28,7 @@ __MEMPOOL_POOLS_JSON_TREE_URL__=${MEMPOOL_POOLS_JSON_TREE_URL:=https://api.githu __MEMPOOL_AUDIT__=${MEMPOOL_AUDIT:=false} __MEMPOOL_ADVANCED_GBT_AUDIT__=${MEMPOOL_ADVANCED_GBT_AUDIT:=false} __MEMPOOL_ADVANCED_GBT_MEMPOOL__=${MEMPOOL_ADVANCED_GBT_MEMPOOL:=false} +__MEMPOOL_RUST_GBT__=${MEMPOOL_RUST_GBT:=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} @@ -155,6 +156,7 @@ sed -i "s!__MEMPOOL_POOLS_JSON_URL__!${__MEMPOOL_POOLS_JSON_URL__}!g" mempool-co sed -i "s!__MEMPOOL_POOLS_JSON_TREE_URL__!${__MEMPOOL_POOLS_JSON_TREE_URL__}!g" mempool-config.json sed -i "s!__MEMPOOL_AUDIT__!${__MEMPOOL_AUDIT__}!g" mempool-config.json sed -i "s!__MEMPOOL_ADVANCED_GBT_MEMPOOL__!${__MEMPOOL_ADVANCED_GBT_MEMPOOL__}!g" mempool-config.json +sed -i "s!__MEMPOOL_RUST_GBT__!${__MEMPOOL_GBT__}!g" mempool-config.json sed -i "s!__MEMPOOL_ADVANCED_GBT_AUDIT__!${__MEMPOOL_ADVANCED_GBT_AUDIT__}!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 diff --git a/production/mempool-config.mainnet.json b/production/mempool-config.mainnet.json index 1cbed5119..8630f1fcd 100644 --- a/production/mempool-config.mainnet.json +++ b/production/mempool-config.mainnet.json @@ -14,6 +14,7 @@ "CPFP_INDEXING": true, "ADVANCED_GBT_AUDIT": true, "ADVANCED_GBT_MEMPOOL": true, + "RUST_GBT": true, "USE_SECOND_NODE_FOR_MINFEE": true, "DISK_CACHE_BLOCK_INTERVAL": 1 }, diff --git a/production/mempool-config.signet.json b/production/mempool-config.signet.json index 8cd21047d..e216ed216 100644 --- a/production/mempool-config.signet.json +++ b/production/mempool-config.signet.json @@ -10,6 +10,7 @@ "AUDIT": true, "ADVANCED_GBT_AUDIT": true, "ADVANCED_GBT_MEMPOOL": true, + "RUST_GBT": true, "POLL_RATE_MS": 1000, "DISK_CACHE_BLOCK_INTERVAL": 1 }, diff --git a/production/mempool-config.testnet.json b/production/mempool-config.testnet.json index 9f33e7aa7..02bf892c1 100644 --- a/production/mempool-config.testnet.json +++ b/production/mempool-config.testnet.json @@ -10,6 +10,7 @@ "AUDIT": true, "ADVANCED_GBT_AUDIT": true, "ADVANCED_GBT_MEMPOOL": true, + "RUST_GBT": true, "POLL_RATE_MS": 1000, "DISK_CACHE_BLOCK_INTERVAL": 1 },