Skip to content
Merged
49 changes: 30 additions & 19 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ std::string HelpMessage(HelpMessageMode mode)
#ifndef WIN32
strUsage += HelpMessageOpt("-pid=<file>", strprintf(_("Specify pid file. Relative paths will be prefixed by a net-specific datadir location. (default: %s)"), BITCOIN_PID_FILENAME));
#endif
strUsage += HelpMessageOpt("-prune=<n>", 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=<n>", 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"));
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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")) {
Expand Down Expand Up @@ -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<int>(std::max<int>(gArgs.GetArg("-checkmempool", chainparams.DefaultConsistencyChecks() ? 1 : 0), 0), 1000000);
if (ratio != 0) {
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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<CSporkManager> flatdb6("sporks.dat", "magicSporkCache");
Expand Down
2 changes: 2 additions & 0 deletions test/functional/blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion test/functional/import-rescan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions test/functional/node_network_limited.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down