From dacf8592189883705538cb1764f21e6e3895209a Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Thu, 4 Jul 2024 13:26:27 +0000 Subject: [PATCH 1/7] refactor: make `pdsNotificationInterface` a `unique_ptr`, rename --- src/dsnotificationinterface.cpp | 2 ++ src/dsnotificationinterface.h | 2 ++ src/init.cpp | 16 +++++++--------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/dsnotificationinterface.cpp b/src/dsnotificationinterface.cpp index 880ada8a78..701f96ccaa 100644 --- a/src/dsnotificationinterface.cpp +++ b/src/dsnotificationinterface.cpp @@ -153,3 +153,5 @@ void CDSNotificationInterface::NotifyChainLock(const CBlockIndex* pindex, const m_llmq_ctx->isman->NotifyChainLock(pindex); m_cj_ctx->dstxman->NotifyChainLock(pindex, *m_llmq_ctx->clhandler, m_mn_sync); } + +std::unique_ptr g_ds_notification_interface; diff --git a/src/dsnotificationinterface.h b/src/dsnotificationinterface.h index c98f913880..d58d178a1b 100644 --- a/src/dsnotificationinterface.h +++ b/src/dsnotificationinterface.h @@ -60,4 +60,6 @@ private: const std::unique_ptr& m_cj_ctx; }; +extern std::unique_ptr g_ds_notification_interface; + #endif // BITCOIN_DSNOTIFICATIONINTERFACE_H diff --git a/src/init.cpp b/src/init.cpp index 18decacf04..81f05e48fd 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -141,8 +141,6 @@ static constexpr bool DEFAULT_PROXYRANDOMIZE{true}; static constexpr bool DEFAULT_REST_ENABLE{false}; static constexpr bool DEFAULT_I2P_ACCEPT_INCOMING{true}; -static CDSNotificationInterface* pdsNotificationInterface = nullptr; - #ifdef WIN32 // Win32 LevelDB doesn't use filedescriptors, and the ones used for // accessing block files don't count towards the fd_set size limit @@ -369,11 +367,11 @@ void PrepareShutdown(NodeContext& node) } #endif - if (pdsNotificationInterface) { - UnregisterValidationInterface(pdsNotificationInterface); - delete pdsNotificationInterface; - pdsNotificationInterface = nullptr; + if (g_ds_notification_interface) { + UnregisterValidationInterface(g_ds_notification_interface.get()); + g_ds_notification_interface.reset(); } + if (node.mn_activeman) { UnregisterValidationInterface(node.mn_activeman.get()); node.mn_activeman.reset(); @@ -2147,10 +2145,10 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) node.cj_ctx, node.llmq_ctx, ignores_incoming_txs); RegisterValidationInterface(node.peerman.get()); - pdsNotificationInterface = new CDSNotificationInterface( + g_ds_notification_interface = std::make_unique( *node.connman, *node.mn_sync, *node.govman, *node.peerman, chainman, node.mn_activeman.get(), node.dmnman, node.llmq_ctx, node.cj_ctx ); - RegisterValidationInterface(pdsNotificationInterface); + RegisterValidationInterface(g_ds_notification_interface.get()); // ********************************************************* Step 7c: Setup CoinJoin @@ -2327,7 +2325,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) } chainman.m_load_block = std::thread(&util::TraceThread, "loadblk", [=, &args, &chainman, &node] { - ThreadImport(chainman, *node.dmnman, *pdsNotificationInterface, vImportFiles, node.mn_activeman.get(), args); + ThreadImport(chainman, *node.dmnman, *g_ds_notification_interface, vImportFiles, node.mn_activeman.get(), args); }); // Wait for genesis block to be processed From cba650953af4a5ac12c495475457f1d30181b58e Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Wed, 18 Sep 2024 07:38:48 +0000 Subject: [PATCH 2/7] test: simplify `pow_test`'s `get_next_work` block index construction Co-authored-by: Konstantin Akimov --- src/test/pow_tests.cpp | 133 ++++++++++------------------------------- 1 file changed, 30 insertions(+), 103 deletions(-) diff --git a/src/test/pow_tests.cpp b/src/test/pow_tests.cpp index b85ab75ddd..dba5592e6d 100644 --- a/src/test/pow_tests.cpp +++ b/src/test/pow_tests.cpp @@ -16,107 +16,34 @@ BOOST_AUTO_TEST_CASE(get_next_work) { const auto chainParams = CreateChainParams(*m_node.args, CBaseChainParams::MAIN); - // build the chain of 24 blocks - CBlockIndex blockIndexLast; - blockIndexLast.nHeight = 123456; - blockIndexLast.nTime = 1408732489; - blockIndexLast.nBits = 0x1b1418d4; - CBlockIndex blockIndexPrev1 = CBlockIndex(); - blockIndexPrev1.nTime = 1408732257; // Block #123455 - blockIndexPrev1.nBits = 0x1b13b83f; - blockIndexLast.pprev = &blockIndexPrev1; - CBlockIndex blockIndexPrev2 = CBlockIndex(); - blockIndexPrev2.nTime = 1408732229; // Block #123454 - blockIndexPrev2.nBits = 0x1b10460b; - blockIndexPrev1.pprev = &blockIndexPrev2; - CBlockIndex blockIndexPrev3 = CBlockIndex(); - blockIndexPrev3.nTime = 1408731256; // Block #123453 - blockIndexPrev3.nBits = 0x1b113ff1; - blockIndexPrev2.pprev = &blockIndexPrev3; - CBlockIndex blockIndexPrev4 = CBlockIndex(); - blockIndexPrev4.nTime = 1408731242; // Block #123452 - blockIndexPrev4.nBits = 0x1b0fed89; - blockIndexPrev3.pprev = &blockIndexPrev4; - CBlockIndex blockIndexPrev5 = CBlockIndex(); - blockIndexPrev5.nTime = 1408730914; // Block #123451 - blockIndexPrev5.nBits = 0x1b10b864; - blockIndexPrev4.pprev = &blockIndexPrev5; - CBlockIndex blockIndexPrev6 = CBlockIndex(); - blockIndexPrev6.nTime = 1408730862; // Block #123450 - blockIndexPrev6.nBits = 0x1b0dd168; - blockIndexPrev5.pprev = &blockIndexPrev6; - CBlockIndex blockIndexPrev7 = CBlockIndex(); - blockIndexPrev7.nTime = 1408730179; // Block #123449 - blockIndexPrev7.nBits = 0x1b0c03d6; - blockIndexPrev6.pprev = &blockIndexPrev7; - CBlockIndex blockIndexPrev8 = CBlockIndex(); - blockIndexPrev8.nTime = 1408729678; // Block #123448 - blockIndexPrev8.nBits = 0x1b0c9ab8; - blockIndexPrev7.pprev = &blockIndexPrev8; - CBlockIndex blockIndexPrev9 = CBlockIndex(); - blockIndexPrev9.nTime = 1408729647; // Block #123447 - blockIndexPrev9.nBits = 0x1b0dfaff; - blockIndexPrev8.pprev = &blockIndexPrev9; - CBlockIndex blockIndexPrev10 = CBlockIndex(); - blockIndexPrev10.nTime = 1408729587; // Block #123446 - blockIndexPrev10.nBits = 0x1b10e878; - blockIndexPrev9.pprev = &blockIndexPrev10; - CBlockIndex blockIndexPrev11 = CBlockIndex(); - blockIndexPrev11.nTime = 1408729576; // Block #123445 - blockIndexPrev11.nBits = 0x1b1063d0; - blockIndexPrev10.pprev = &blockIndexPrev11; - CBlockIndex blockIndexPrev12 = CBlockIndex(); - blockIndexPrev12.nTime = 1408729474; // Block #123444 - blockIndexPrev12.nBits = 0x1b104297; - blockIndexPrev11.pprev = &blockIndexPrev12; - CBlockIndex blockIndexPrev13 = CBlockIndex(); - blockIndexPrev13.nTime = 1408729305; // Block #123443 - blockIndexPrev13.nBits = 0x1b107556; - blockIndexPrev12.pprev = &blockIndexPrev13; - CBlockIndex blockIndexPrev14 = CBlockIndex(); - blockIndexPrev14.nTime = 1408729179; // Block #123442 - blockIndexPrev14.nBits = 0x1b110764; - blockIndexPrev13.pprev = &blockIndexPrev14; - CBlockIndex blockIndexPrev15 = CBlockIndex(); - blockIndexPrev15.nTime = 1408729116; // Block #123441 - blockIndexPrev15.nBits = 0x1b1141bf; - blockIndexPrev14.pprev = &blockIndexPrev15; - CBlockIndex blockIndexPrev16 = CBlockIndex(); - blockIndexPrev16.nTime = 1408728950; // Block #123440 - blockIndexPrev16.nBits = 0x1b1123f9; - blockIndexPrev15.pprev = &blockIndexPrev16; - CBlockIndex blockIndexPrev17 = CBlockIndex(); - blockIndexPrev17.nTime = 1408728756; // Block #123439 - blockIndexPrev17.nBits = 0x1b118d9c; - blockIndexPrev16.pprev = &blockIndexPrev17; - CBlockIndex blockIndexPrev18 = CBlockIndex(); - blockIndexPrev18.nTime = 1408728744; // Block #123438 - blockIndexPrev18.nBits = 0x1b11abac; - blockIndexPrev17.pprev = &blockIndexPrev18; - CBlockIndex blockIndexPrev19 = CBlockIndex(); - blockIndexPrev19.nTime = 1408728608; // Block #123437 - blockIndexPrev19.nBits = 0x1b11951e; - blockIndexPrev18.pprev = &blockIndexPrev19; - CBlockIndex blockIndexPrev20 = CBlockIndex(); - blockIndexPrev20.nTime = 1408728495; // Block #123436 - blockIndexPrev20.nBits = 0x1b121cf3; - blockIndexPrev19.pprev = &blockIndexPrev20; - CBlockIndex blockIndexPrev21 = CBlockIndex(); - blockIndexPrev21.nTime = 1408728479; // Block #123435 - blockIndexPrev21.nBits = 0x1b11a33c; - blockIndexPrev20.pprev = &blockIndexPrev21; - CBlockIndex blockIndexPrev22 = CBlockIndex(); - blockIndexPrev22.nTime = 1408728332; // Block #123434 - blockIndexPrev22.nBits = 0x1b10e09e; - blockIndexPrev21.pprev = &blockIndexPrev22; - CBlockIndex blockIndexPrev23 = CBlockIndex(); - blockIndexPrev23.nTime = 1408728124; // Block #123433 - blockIndexPrev23.nBits = 0x1b104be1; - blockIndexPrev22.pprev = &blockIndexPrev23; + static const std::vector> mainnet_data = { + { 1408728124, 0x1b104be1U }, { 1408728332, 0x1b10e09eU }, { 1408728479, 0x1b11a33cU }, + { 1408728495, 0x1b121cf3U }, { 1408728608, 0x1b11951eU }, { 1408728744, 0x1b11abacU }, + { 1408728756, 0x1b118d9cU }, { 1408728950, 0x1b1123f9U }, { 1408729116, 0x1b1141bfU }, + { 1408729179, 0x1b110764U }, { 1408729305, 0x1b107556U }, { 1408729474, 0x1b104297U }, + { 1408729576, 0x1b1063d0U }, { 1408729587, 0x1b10e878U }, { 1408729647, 0x1b0dfaffU }, + { 1408729678, 0x1b0c9ab8U }, { 1408730179, 0x1b0c03d6U }, { 1408730862, 0x1b0dd168U }, + { 1408730914, 0x1b10b864U }, { 1408731242, 0x1b0fed89U }, { 1408731256, 0x1b113ff1U }, + { 1408732229, 0x1b10460bU }, { 1408732257, 0x1b13b83fU }, { 1408732489, 0x1b1418d4U } + }; + + // Construct a chain of block index entries + std::list blockidx; + CBlockIndex* blockIndexLast{nullptr}; + + for (const auto& [nTime, nBits] : mainnet_data) { + auto& entry = blockidx.emplace_back(); + entry.nTime = nTime; + entry.nBits = nBits; + entry.pprev = blockIndexLast; + blockIndexLast = &entry; + } + blockIndexLast->nHeight = 123456; + assert(mainnet_data.size() == blockidx.size()); CBlockHeader blockHeader; blockHeader.nTime = 1408732505; // Block #123457 - BOOST_CHECK_EQUAL(GetNextWorkRequired(&blockIndexLast, &blockHeader, chainParams->GetConsensus()), 0x1b1441deU); // Block #123457 has 0x1b1441de + BOOST_CHECK_EQUAL(GetNextWorkRequired(blockIndexLast, &blockHeader, chainParams->GetConsensus()), 0x1b1441deU); // Block #123457 has 0x1b1441de // test special rules for slow blocks on devnet/testnet gArgs.SoftSetBoolArg("-devnet", true); @@ -125,18 +52,18 @@ BOOST_AUTO_TEST_CASE(get_next_work) // make sure normal rules apply blockHeader.nTime = 1408732505; // Block #123457 - BOOST_CHECK_EQUAL(GetNextWorkRequired(&blockIndexLast, &blockHeader, chainParamsDev->GetConsensus()), 0x1b1441deU); // Block #123457 has 0x1b1441de + BOOST_CHECK_EQUAL(GetNextWorkRequired(blockIndexLast, &blockHeader, chainParamsDev->GetConsensus()), 0x1b1441deU); // Block #123457 has 0x1b1441de // 10x higher target blockHeader.nTime = 1408733090; // Block #123457 (10m+1sec) - BOOST_CHECK_EQUAL(GetNextWorkRequired(&blockIndexLast, &blockHeader, chainParamsDev->GetConsensus()), 0x1c00c8f8U); // Block #123457 has 0x1c00c8f8 + BOOST_CHECK_EQUAL(GetNextWorkRequired(blockIndexLast, &blockHeader, chainParamsDev->GetConsensus()), 0x1c00c8f8U); // Block #123457 has 0x1c00c8f8 blockHeader.nTime = 1408733689; // Block #123457 (20m) - BOOST_CHECK_EQUAL(GetNextWorkRequired(&blockIndexLast, &blockHeader, chainParamsDev->GetConsensus()), 0x1c00c8f8U); // Block #123457 has 0x1c00c8f8 + BOOST_CHECK_EQUAL(GetNextWorkRequired(blockIndexLast, &blockHeader, chainParamsDev->GetConsensus()), 0x1c00c8f8U); // Block #123457 has 0x1c00c8f8 // lowest diff possible blockHeader.nTime = 1408739690; // Block #123457 (2h+1sec) - BOOST_CHECK_EQUAL(GetNextWorkRequired(&blockIndexLast, &blockHeader, chainParamsDev->GetConsensus()), 0x207fffffU); // Block #123457 has 0x207fffff + BOOST_CHECK_EQUAL(GetNextWorkRequired(blockIndexLast, &blockHeader, chainParamsDev->GetConsensus()), 0x207fffffU); // Block #123457 has 0x207fffff blockHeader.nTime = 1408743289; // Block #123457 (3h) - BOOST_CHECK_EQUAL(GetNextWorkRequired(&blockIndexLast, &blockHeader, chainParamsDev->GetConsensus()), 0x207fffffU); // Block #123457 has 0x207fffff + BOOST_CHECK_EQUAL(GetNextWorkRequired(blockIndexLast, &blockHeader, chainParamsDev->GetConsensus()), 0x207fffffU); // Block #123457 has 0x207fffff } /* Test the constraint on the upper bound for next work */ From 3a1743fc7fe66c82a07f5c8643b68e1aa520a9f9 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Fri, 13 Sep 2024 13:40:26 +0000 Subject: [PATCH 3/7] trivial: avoid unneeded copy when iterating through `mapDenomCount` Caught by Clang 14 with `--enable-werror` --- src/coinjoin/client.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/coinjoin/client.cpp b/src/coinjoin/client.cpp index bf8e25ab0b..86dce7a10b 100644 --- a/src/coinjoin/client.cpp +++ b/src/coinjoin/client.cpp @@ -1727,7 +1727,7 @@ bool CCoinJoinClientSession::CreateDenominated(CAmount nBalanceToDenominate, con } bool finished = true; - for (const auto [denom, count] : mapDenomCount) { + for (const auto& [denom, count] : mapDenomCount) { // Check if this specific denom could use another loop, check that there aren't nCoinJoinDenomsGoal of this // denom and that our nValueLeft/nBalanceToDenominate is enough to create one of these denoms, if so, loop again. if (count < CCoinJoinClientOptions::GetDenomsGoal() && txBuilder.CouldAddOutput(denom) && nBalanceToDenominate > 0) { @@ -1807,7 +1807,7 @@ bool CCoinJoinClientSession::CreateDenominated(CAmount nBalanceToDenominate, con WalletCJLogPrint(m_wallet, "CCoinJoinClientSession::%s -- 3 - nBalanceToDenominate: %f, %s\n", __func__, (float) nBalanceToDenominate / COIN, txBuilder.ToString()); - for (const auto [denom, count] : mapDenomCount) { + for (const auto& [denom, count] : mapDenomCount) { WalletCJLogPrint(m_wallet, "CCoinJoinClientSession::%s -- 3 - DONE - nDenomValue: %f, count: %d\n", __func__, (float) denom / COIN, count); } From 438cb85eceaecc27c8913e2aa769bd76c5a74666 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Tue, 27 Aug 2024 20:05:31 +0000 Subject: [PATCH 4/7] ci: set UBSan to halt on error and provide more information --- ci/dash/matrix.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/dash/matrix.sh b/ci/dash/matrix.sh index 51a8c6e2e3..70d0a57abe 100755 --- a/ci/dash/matrix.sh +++ b/ci/dash/matrix.sh @@ -14,7 +14,7 @@ source ./ci/test/00_setup_env.sh export ASAN_OPTIONS="" export LSAN_OPTIONS="suppressions=${BASE_ROOT_DIR}/test/sanitizer_suppressions/lsan" export TSAN_OPTIONS="suppressions=${BASE_ROOT_DIR}/test/sanitizer_suppressions/tsan:halt_on_error=1" -export UBSAN_OPTIONS="suppressions=${BASE_ROOT_DIR}/test/sanitizer_suppressions/ubsan" +export UBSAN_OPTIONS="suppressions=${BASE_ROOT_DIR}/test/sanitizer_suppressions/ubsan:print_stacktrace=1:halt_on_error=1:report_error_type=1" if [ "$BUILD_TARGET" = "arm-linux" ]; then source ./ci/test/00_setup_env_arm.sh From 061aa05cf0961ca17f235e8bf4cb845db0356b61 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Fri, 13 Sep 2024 13:14:32 +0000 Subject: [PATCH 5/7] chore: remove old llmq db migration code The migration code was introduced as part of dash#4141 in v0.18. We've had a few major version releases since. --- src/llmq/context.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/llmq/context.cpp b/src/llmq/context.cpp index 68d3ea1cb2..f6db0af0f5 100644 --- a/src/llmq/context.cpp +++ b/src/llmq/context.cpp @@ -41,9 +41,6 @@ LLMQContext::LLMQContext(CChainState& chainstate, CConnman& connman, CDeterminis }()}, ehfSignalsHandler{std::make_unique(chainstate, mnhfman, *sigman, *shareman, mempool, *qman, sporkman, peerman)} { - // NOTE: we use this only to wipe the old db, do NOT use it for anything else - // TODO: remove it in some future version - auto llmqDbTmp = std::make_unique(unit_tests ? "" : (gArgs.GetDataDirNet() / "llmq"), 1 << 20, unit_tests, true); } LLMQContext::~LLMQContext() { From 77ce6af5c1f9518a22247be622389c72a195ec32 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Fri, 13 Sep 2024 13:21:43 +0000 Subject: [PATCH 6/7] chore: remove ancient setting migration logic This code in its original form was first introduced in 0.12 (bbbbdd81) and in its current form 0.17 (ae506bae6) and has survived rebrandings. Time to retire it. --- src/qt/optionsmodel.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index fb07fd662e..85c4cf4077 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -232,13 +232,8 @@ void OptionsModel::Init(bool resetSettings) if (!gArgs.SoftSetArg("-coinjoinrounds", settings.value("nCoinJoinRounds").toString().toStdString())) addOverriddenOption("-coinjoinrounds"); - if (!settings.contains("nCoinJoinAmount")) { - // for migration from old settings - if (!settings.contains("nAnonymizeDashAmount")) - settings.setValue("nCoinJoinAmount", DEFAULT_COINJOIN_AMOUNT); - else - settings.setValue("nCoinJoinAmount", settings.value("nAnonymizeDashAmount").toInt()); - } + if (!settings.contains("nCoinJoinAmount")) + settings.setValue("nCoinJoinAmount", DEFAULT_COINJOIN_AMOUNT); if (!gArgs.SoftSetArg("-coinjoinamount", settings.value("nCoinJoinAmount").toString().toStdString())) addOverriddenOption("-coinjoinamount"); From 4e621037c5553e24decbebefd3a68305b7063b72 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Fri, 20 Sep 2024 12:28:38 +0000 Subject: [PATCH 7/7] test: move `EXPECTED_STDERR_NO_GOV`{`_PRUNE`} and use it more --- test/functional/feature_blockfilterindex_prune.py | 9 +++++---- test/functional/feature_pruning.py | 7 ++++--- test/functional/interface_usdt_utxocache.py | 3 ++- test/functional/p2p_node_network_limited.py | 3 ++- test/functional/rpc_blockchain.py | 3 ++- test/functional/test_framework/governance.py | 3 +++ test/functional/wallet_import_rescan.py | 3 ++- 7 files changed, 20 insertions(+), 11 deletions(-) diff --git a/test/functional/feature_blockfilterindex_prune.py b/test/functional/feature_blockfilterindex_prune.py index fcefd43cd4..9cc2d16d91 100755 --- a/test/functional/feature_blockfilterindex_prune.py +++ b/test/functional/feature_blockfilterindex_prune.py @@ -9,6 +9,7 @@ from test_framework.util import ( assert_greater_than, assert_raises_rpc_error, ) +from test_framework.governance import EXPECTED_STDERR_NO_GOV_PRUNE class FeatureBlockfilterindexPruneTest(BitcoinTestFramework): @@ -42,7 +43,7 @@ class FeatureBlockfilterindexPruneTest(BitcoinTestFramework): assert_greater_than(len(self.nodes[0].getblockfilter(self.nodes[0].getblockhash(2))['filter']), 0) self.log.info("start node without blockfilterindex") - self.restart_node(0, extra_args=["-fastprune", "-prune=1"], expected_stderr='Warning: You are starting with governance validation disabled. This is expected because you are running a pruned node.') + self.restart_node(0, extra_args=["-fastprune", "-prune=1"], expected_stderr=EXPECTED_STDERR_NO_GOV_PRUNE) self.log.info("make sure accessing the blockfilters throws an error") assert_raises_rpc_error(-1, "Index is not enabled for filtertype basic", self.nodes[0].getblockfilter, self.nodes[0].getblockhash(2)) @@ -51,17 +52,17 @@ class FeatureBlockfilterindexPruneTest(BitcoinTestFramework): self.log.info("prune below the blockfilterindexes best block while blockfilters are disabled") pruneheight_new = self.nodes[0].pruneblockchain(1000) assert_greater_than(pruneheight_new, pruneheight) - self.stop_node(0, expected_stderr='Warning: You are starting with governance validation disabled. This is expected because you are running a pruned node.') + self.stop_node(0, expected_stderr=EXPECTED_STDERR_NO_GOV_PRUNE) self.log.info("make sure we get an init error when starting the node again with block filters") self.nodes[0].assert_start_raises_init_error( extra_args=["-fastprune", "-prune=1", "-blockfilterindex=1"], - expected_msg="Warning: You are starting with governance validation disabled. This is expected because you are running a pruned node.\nError: basic block filter index best block of the index goes beyond pruned data. Please disable the index or reindex (which will download the whole blockchain again)", + expected_msg=f"{EXPECTED_STDERR_NO_GOV_PRUNE}\nError: basic block filter index best block of the index goes beyond pruned data. Please disable the index or reindex (which will download the whole blockchain again)", ) self.log.info("make sure the node starts again with the -reindex arg") self.start_node(0, extra_args=["-fastprune", "-prune=1", "-blockfilterindex", "-reindex"]) - self.stop_nodes(expected_stderr='Warning: You are starting with governance validation disabled. This is expected because you are running a pruned node.') + self.stop_nodes(expected_stderr=EXPECTED_STDERR_NO_GOV_PRUNE) if __name__ == '__main__': diff --git a/test/functional/feature_pruning.py b/test/functional/feature_pruning.py index cf9e78ece3..e722c28226 100755 --- a/test/functional/feature_pruning.py +++ b/test/functional/feature_pruning.py @@ -11,6 +11,10 @@ This test takes 30 mins or more (up to 2 hours) import os from test_framework.blocktools import create_coinbase +from test_framework.governance import ( + EXPECTED_STDERR_NO_GOV, + EXPECTED_STDERR_NO_GOV_PRUNE, +) from test_framework.messages import CBlock from test_framework.script import ( CScript, @@ -29,9 +33,6 @@ from test_framework.util import ( # compatible with pruning based on key creation time. TIMESTAMP_WINDOW = 2 * 60 * 60 -EXPECTED_STDERR_NO_GOV = "Warning: You are starting with governance validation disabled." -EXPECTED_STDERR_NO_GOV_PRUNE = EXPECTED_STDERR_NO_GOV + " This is expected because you are running a pruned node." - def mine_large_blocks(node, n): # Make a large scriptPubKey for the coinbase transaction. This is OP_RETURN # followed by 950k of OP_NOP. This would be non-standard in a non-coinbase diff --git a/test/functional/interface_usdt_utxocache.py b/test/functional/interface_usdt_utxocache.py index e9f98de523..0098e9c98b 100755 --- a/test/functional/interface_usdt_utxocache.py +++ b/test/functional/interface_usdt_utxocache.py @@ -14,6 +14,7 @@ try: except ImportError: pass from test_framework.messages import COIN +from test_framework.governance import EXPECTED_STDERR_NO_GOV_PRUNE from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal from test_framework.wallet import MiniWallet @@ -402,7 +403,7 @@ class UTXOCacheTracepointTest(BitcoinTestFramework): assert_equal(0, len(possible_cache_sizes)) assert_equal(EXPECTED_HANDLE_FLUSH_SUCCESS, handle_flush_succeeds) - self.stop_node(0, expected_stderr='Warning: You are starting with governance validation disabled. This is expected because you are running a pruned node.') + self.stop_node(0, expected_stderr=EXPECTED_STDERR_NO_GOV_PRUNE) if __name__ == '__main__': UTXOCacheTracepointTest().main() diff --git a/test/functional/p2p_node_network_limited.py b/test/functional/p2p_node_network_limited.py index e176cc2e1e..16862fb918 100755 --- a/test/functional/p2p_node_network_limited.py +++ b/test/functional/p2p_node_network_limited.py @@ -9,6 +9,7 @@ and that it responds to getdata requests for blocks correctly: - send a block within 288 + 2 of the tip - disconnect peers who request blocks older than that.""" from test_framework.messages import CInv, MSG_BLOCK, msg_getdata, NODE_BLOOM, NODE_NETWORK_LIMITED, NODE_HEADERS_COMPRESSED +from test_framework.governance import EXPECTED_STDERR_NO_GOV_PRUNE from test_framework.p2p import P2PInterface from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal @@ -95,7 +96,7 @@ class NodeNetworkLimitedTest(BitcoinTestFramework): # sync must be possible, node 1 is no longer in IBD and should therefore connect to node 0 (NODE_NETWORK_LIMITED) self.sync_blocks([self.nodes[0], self.nodes[1]]) - self.stop_node(0, expected_stderr='Warning: You are starting with governance validation disabled. This is expected because you are running a pruned node.') + self.stop_node(0, expected_stderr=EXPECTED_STDERR_NO_GOV_PRUNE) if __name__ == '__main__': diff --git a/test/functional/rpc_blockchain.py b/test/functional/rpc_blockchain.py index fedeb1f3d8..9547f44624 100755 --- a/test/functional/rpc_blockchain.py +++ b/test/functional/rpc_blockchain.py @@ -31,6 +31,7 @@ from test_framework.blocktools import ( create_coinbase, TIME_GENESIS_BLOCK, ) +from test_framework.governance import EXPECTED_STDERR_NO_GOV_PRUNE from test_framework.messages import ( CBlockHeader, from_hex, @@ -125,7 +126,7 @@ class BlockchainTest(BitcoinTestFramework): assert res['pruned'] assert not res['automatic_pruning'] - self.restart_node(0, ['-stopatheight=207', '-txindex=0'], expected_stderr='Warning: You are starting with governance validation disabled. This is expected because you are running a pruned node.') + self.restart_node(0, ['-stopatheight=207', '-txindex=0'], expected_stderr=EXPECTED_STDERR_NO_GOV_PRUNE) res = self.nodes[0].getblockchaininfo() # should have exact keys assert_equal(sorted(res.keys()), keys) diff --git a/test/functional/test_framework/governance.py b/test/functional/test_framework/governance.py index 2132fb3a27..9eb46081fb 100644 --- a/test/functional/test_framework/governance.py +++ b/test/functional/test_framework/governance.py @@ -6,6 +6,9 @@ import json +EXPECTED_STDERR_NO_GOV = "Warning: You are starting with governance validation disabled." +EXPECTED_STDERR_NO_GOV_PRUNE = f"{EXPECTED_STDERR_NO_GOV} This is expected because you are running a pruned node." + def prepare_object(node, object_type, parent_hash, creation_time, revision, name, amount, payment_address): proposal_rev = revision proposal_time = int(creation_time) diff --git a/test/functional/wallet_import_rescan.py b/test/functional/wallet_import_rescan.py index 8f321c4b20..4b1969afb2 100755 --- a/test/functional/wallet_import_rescan.py +++ b/test/functional/wallet_import_rescan.py @@ -20,6 +20,7 @@ happened previously. """ from test_framework.test_framework import BitcoinTestFramework +from test_framework.governance import EXPECTED_STDERR_NO_GOV_PRUNE from test_framework.util import ( assert_equal, set_node_times, @@ -213,7 +214,7 @@ class ImportRescanTest(BitcoinTestFramework): variant.check(variant.sent_txid, variant.sent_amount, variant.confirmation_height) for i, import_node in enumerate(IMPORT_NODES, 2): if import_node.prune: - self.stop_node(i, expected_stderr='Warning: You are starting with governance validation disabled. This is expected because you are running a pruned node.') + self.stop_node(i, expected_stderr=EXPECTED_STDERR_NO_GOV_PRUNE)