From 34e3958ff33b62b05cbca6cc1fb3cdc6feee630a Mon Sep 17 00:00:00 2001 From: pasta Date: Sun, 28 Jun 2020 10:31:24 -0500 Subject: [PATCH 1/9] explicitly check that -disablegovernance is true for pruned mode. Signed-off-by: pasta --- src/init.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/init.cpp b/src/init.cpp index b4427b10be0e..1fb775df71cc 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1107,6 +1107,9 @@ bool AppInitParameterInteraction() 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")) { From bf6108d1b816b14bbdc3810a925d6218c0069f06 Mon Sep 17 00:00:00 2001 From: pasta Date: Sun, 28 Jun 2020 10:32:11 -0500 Subject: [PATCH 2/9] try to set -disablegovernance and -txindex if pruned mode is enabled Signed-off-by: pasta --- src/init.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/init.cpp b/src/init.cpp index 1fb775df71cc..0a8580126035 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -981,6 +981,15 @@ void InitParameterInteraction() LogPrintf("%s: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1\n", __func__); } + 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 = From 1591ffc80fbb7dc22040202a6a1050c0cdfb6ca9 Mon Sep 17 00:00:00 2001 From: pasta Date: Sun, 28 Jun 2020 12:20:34 -0500 Subject: [PATCH 3/9] Adjust InitWarning when governance validation is disabled Signed-off-by: pasta --- src/init.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 0a8580126035..c3ea67788f12 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1802,8 +1802,8 @@ bool AppInitMain() fDisableGovernance = gArgs.GetBoolArg("-disablegovernance", false); LogPrintf("fDisableGovernance %d\n", fDisableGovernance); - if(fDisableGovernance) { - InitWarning(_("You are starting with governance validation disabled.")); + if (fDisableGovernance) { + InitWarning(_("You are starting with governance validation disabled. This is expected if you are running a pruned node.")); } uiInterface.InitMessage(_("Loading sporks cache...")); From 2668baa9ffd325a05e78e888c21e3af278167f2e Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Mon, 6 Jul 2020 11:22:50 +0300 Subject: [PATCH 4/9] Check for deprecated -litemode earlier --- src/init.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index c3ea67788f12..35f8f8e00385 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -981,6 +981,14 @@ 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__); @@ -1208,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) { From fc04eb76dcda5d94f7c76cc2582ab5affd91a70e Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Mon, 6 Jul 2020 11:50:54 +0300 Subject: [PATCH 5/9] Move -disablegovernance warning into AppInitParameterInteraction --- src/init.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 35f8f8e00385..d6481a391995 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1527,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. This is expected if you are running a pruned node")); + } + return true; } @@ -1796,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. This is expected if you are running a pruned node.")); - } + // ********************************************************* Step 7a: Load sporks uiInterface.InitMessage(_("Loading sporks cache...")); CFlatDB flatdb6("sporks.dat", "magicSporkCache"); From 699a92292f0bd721b882842ddd1af22289253a8f Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Mon, 6 Jul 2020 11:53:50 +0300 Subject: [PATCH 6/9] Tweak -prune help text and a related comment in AppInitParameterInteraction --- src/init.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index d6481a391995..773fb3e3e14e 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")); @@ -1120,7 +1120,7 @@ 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.")); From 722f1051ddca37ba338f83bd43607c344387d43e Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Mon, 6 Jul 2020 21:26:05 +0300 Subject: [PATCH 7/9] Ignore init warnings in blockchain.py --- test/functional/blockchain.py | 2 ++ 1 file changed, 2 insertions(+) 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): From a68d91aada1b638f9d2fdd46d9ae1d67fb30efaf Mon Sep 17 00:00:00 2001 From: PastaPastaPasta <6443210+PastaPastaPasta@users.noreply.github.com> Date: Tue, 7 Jul 2020 17:00:26 +0000 Subject: [PATCH 8/9] Adjust "governance validation disabled" warning depending on if running a pruned node Co-authored-by: UdjinM6 --- src/init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/init.cpp b/src/init.cpp index 773fb3e3e14e..ea87f729ac0e 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1531,7 +1531,7 @@ bool AppInitParameterInteraction() LogPrintf("fDisableGovernance %d\n", fDisableGovernance); if (fDisableGovernance) { - InitWarning(_("You are starting with governance validation disabled. This is expected if you are running a pruned node")); + InitWarning(_("You are starting with governance validation disabled.") + (fPruneMode ? " " + _("This is expected because you are running a pruned node.") : "")); } return true; From f0779a01606933f6b070e8e3341be6fe2809ae5c Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Tue, 7 Jul 2020 01:34:31 +0300 Subject: [PATCH 9/9] Skip init warnings in import-rescan.py and node_network_limited.py --- test/functional/import-rescan.py | 3 ++- test/functional/node_network_limited.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) 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):