From b2813980b81034ff9b40bd45080fa67dea475d39 Mon Sep 17 00:00:00 2001 From: Martin Zumsande Date: Mon, 21 Mar 2022 13:13:49 +0100 Subject: [PATCH] init: disallow reindex-chainstate when pruning This fixes a bug where the node would be stuck in an endless loop when combining these parameters. --- src/init.cpp | 4 +++- test/functional/feature_pruning.py | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/init.cpp b/src/init.cpp index e181beab632..9e8d2ac4b7a 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -853,12 +853,14 @@ bool AppInitParameterInteraction(const ArgsManager& args) nLocalServices = ServiceFlags(nLocalServices | NODE_COMPACT_FILTERS); } - // if using block pruning, then disallow txindex and coinstatsindex if (args.GetIntArg("-prune", 0)) { if (args.GetBoolArg("-txindex", DEFAULT_TXINDEX)) return InitError(_("Prune mode is incompatible with -txindex.")); if (args.GetBoolArg("-coinstatsindex", DEFAULT_COINSTATSINDEX)) return InitError(_("Prune mode is incompatible with -coinstatsindex.")); + if (args.GetBoolArg("-reindex-chainstate", false)) { + return InitError(_("Prune mode is incompatible with -reindex-chainstate. Use full -reindex instead.")); + } } // If -forcednsseed is set to true, ensure -dnsseed has not been set to false diff --git a/test/functional/feature_pruning.py b/test/functional/feature_pruning.py index ba3c5053cb7..bf193842795 100755 --- a/test/functional/feature_pruning.py +++ b/test/functional/feature_pruning.py @@ -141,6 +141,10 @@ class PruneTest(BitcoinTestFramework): expected_msg='Error: Prune mode is incompatible with -coinstatsindex.', extra_args=['-prune=550', '-coinstatsindex'], ) + self.nodes[0].assert_start_raises_init_error( + expected_msg='Error: Prune mode is incompatible with -reindex-chainstate. Use full -reindex instead.', + extra_args=['-prune=550', '-reindex-chainstate'], + ) def test_height_min(self): assert os.path.isfile(os.path.join(self.prunedir, "blk00000.dat")), "blk00000.dat is missing, pruning too early"