diff --git a/src/init.cpp b/src/init.cpp index b4427b10be0e..ea87f729ac0e 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -493,7 +493,7 @@ std::string HelpMessage(HelpMessageMode mode) #ifndef WIN32 strUsage += HelpMessageOpt("-pid=", strprintf(_("Specify pid file. Relative paths will be prefixed by a net-specific datadir location. (default: %s)"), BITCOIN_PID_FILENAME)); #endif - strUsage += HelpMessageOpt("-prune=", strprintf(_("Reduce storage requirements by enabling pruning (deleting) of old blocks. This allows the pruneblockchain RPC to be called to delete specific blocks, and enables automatic pruning of old blocks if a target size in MiB is provided. This mode is incompatible with -txindex and -rescan. " + strUsage += HelpMessageOpt("-prune=", strprintf(_("Reduce storage requirements by enabling pruning (deleting) of old blocks. This allows the pruneblockchain RPC to be called to delete specific blocks, and enables automatic pruning of old blocks if a target size in MiB is provided. This mode is incompatible with -txindex, -rescan and -disablegovernance=false. " "Warning: Reverting this setting requires re-downloading the entire blockchain. " "(default: 0 = disable pruning blocks, 1 = allow manual pruning via RPC, >%u = automatically prune block files to stay under the specified target size in MiB)"), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024)); strUsage += HelpMessageOpt("-reindex-chainstate", _("Rebuild chain state from the currently indexed blocks")); @@ -981,6 +981,23 @@ void InitParameterInteraction() LogPrintf("%s: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1\n", __func__); } + if (gArgs.GetBoolArg("-litemode", false)) { + InitWarning(_("Warning: -litemode is deprecated, please use -disablegovernance.\n")); + if (gArgs.SoftSetBoolArg("-disablegovernance", true)) { + LogPrintf("%s: parameter interaction: -litemode=true -> setting -disablegovernance=true\n", __func__); + } + gArgs.ForceRemoveArg("-litemode"); + } + + if (gArgs.GetArg("-prune", 0) > 0) { + if (gArgs.SoftSetBoolArg("-disablegovernance", true)) { + LogPrintf("%s: parameter interaction: -prune=%d -> setting -disablegovernance=true\n", __func__); + } + if (gArgs.SoftSetBoolArg("-txindex", false)) { + LogPrintf("%s: parameter interaction: -prune=%d -> setting -txindex=false\n", __func__); + } + } + // Make sure additional indexes are recalculated correctly in VerifyDB // (we must reconnect blocks whenever we disconnect them for these indexes to work) bool fAdditionalIndexes = @@ -1103,10 +1120,13 @@ bool AppInitParameterInteraction() // also see: InitParameterInteraction() - // if using block pruning, then disallow txindex + // if using block pruning, then disallow txindex and require disabling governance validation if (gArgs.GetArg("-prune", 0)) { if (gArgs.GetBoolArg("-txindex", DEFAULT_TXINDEX)) return InitError(_("Prune mode is incompatible with -txindex.")); + if (!gArgs.GetBoolArg("-disablegovernance", false)) { + return InitError(_("Prune mode is incompatible with -disablegovernance=false.")); + } } if (gArgs.IsArgSet("-devnet")) { @@ -1196,14 +1216,6 @@ bool AppInitParameterInteraction() if (gArgs.IsArgSet("-blockminsize")) InitWarning("Unsupported argument -blockminsize ignored."); - if (gArgs.GetBoolArg("-litemode", false)) { - InitWarning(_("Warning: -litemode is deprecated, please use -disablegovernance.\n")); - if (gArgs.SoftSetBoolArg("-disablegovernance", true)) { - LogPrintf("%s: parameter interaction: -litemode=true -> setting -disablegovernance=true\n", __func__); - } - gArgs.ForceRemoveArg("-litemode"); - } - // Checkmempool and checkblockindex default to true in regtest mode int ratio = std::min(std::max(gArgs.GetArg("-checkmempool", chainparams.DefaultConsistencyChecks() ? 1 : 0), 0), 1000000); if (ratio != 0) { @@ -1515,6 +1527,13 @@ bool AppInitParameterInteraction() } } + fDisableGovernance = gArgs.GetBoolArg("-disablegovernance", false); + LogPrintf("fDisableGovernance %d\n", fDisableGovernance); + + if (fDisableGovernance) { + InitWarning(_("You are starting with governance validation disabled.") + (fPruneMode ? " " + _("This is expected because you are running a pruned node.") : "")); + } + return true; } @@ -1784,15 +1803,7 @@ bool AppInitMain() nMaxOutboundLimit = gArgs.GetArg("-maxuploadtarget", DEFAULT_MAX_UPLOAD_TARGET)*1024*1024; } - // ********************************************************* Step 7a: check lite mode and load sporks - - // lite mode disables governance validation - fDisableGovernance = gArgs.GetBoolArg("-disablegovernance", false); - LogPrintf("fDisableGovernance %d\n", fDisableGovernance); - - if(fDisableGovernance) { - InitWarning(_("You are starting with governance validation disabled.")); - } + // ********************************************************* Step 7a: Load sporks uiInterface.InitMessage(_("Loading sporks cache...")); CFlatDB flatdb6("sporks.dat", "magicSporkCache"); diff --git a/test/functional/blockchain.py b/test/functional/blockchain.py index 0b94c2018b8d..460c7f2d3100 100755 --- a/test/functional/blockchain.py +++ b/test/functional/blockchain.py @@ -21,6 +21,7 @@ from decimal import Decimal import http.client import subprocess +import sys from test_framework.test_framework import BitcoinTestFramework from test_framework.util import ( @@ -49,6 +50,7 @@ class BlockchainTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 1 self.setup_clean_chain = True + self.stderr = sys.stdout self.extra_args = [['-stopatheight=207', '-prune=1', '-txindex=0']] def run_test(self): diff --git a/test/functional/import-rescan.py b/test/functional/import-rescan.py index ef6e1fa74a2f..bd33daa7f3e9 100755 --- a/test/functional/import-rescan.py +++ b/test/functional/import-rescan.py @@ -25,6 +25,7 @@ import collections import enum import itertools +import sys Call = enum.Enum("Call", "single multi") Data = enum.Enum("Data", "address pub priv") @@ -125,7 +126,7 @@ def setup_network(self): # txindex is enabled by default in Dash and needs to be disabled for import-rescan.py extra_args[i] += ["-prune=1", "-txindex=0", "-reindex"] - self.add_nodes(self.num_nodes, extra_args) + self.add_nodes(self.num_nodes, extra_args, stderr=sys.stdout) self.start_nodes() for i in range(1, self.num_nodes): connect_nodes(self.nodes[i], 0) diff --git a/test/functional/node_network_limited.py b/test/functional/node_network_limited.py index 99e6d8254fdc..94f7722bf90d 100755 --- a/test/functional/node_network_limited.py +++ b/test/functional/node_network_limited.py @@ -13,6 +13,8 @@ from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, disconnect_nodes, connect_nodes_bi, sync_blocks +import sys + class P2PIgnoreInv(P2PInterface): firstAddrnServices = 0 def on_inv(self, message): @@ -32,6 +34,7 @@ class NodeNetworkLimitedTest(BitcoinTestFramework): def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 3 + self.stderr = sys.stdout self.extra_args = [['-prune=550', '-txindex=0', '-addrmantest'], [], []] def disconnect_all(self):