mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 15:04:44 +01:00
Merge bitcoin/bitcoin#24626: init: disallow reindex-chainstate when pruning
b2813980b8
init: disallow reindex-chainstate when pruning (Martin Zumsande) Pull request description: The combination of `-reindex-chainstate` and `-prune` currently makes the node stuck in an endless loop: - `LoadChainstate()` will wipe the existing chainstate (so we have no genesis block anymore). It won't clean up unusable block files by calling `CleanupBlockRevFiles()` as for full `-reindex`. - `ThreadImport()` has [logic](91d12344b1/src/node/blockstorage.cpp (L855)
) of reloading Genesis after reindexing. This is what makes full `-reindex` work with `-prune` but it's not executed for `-reindex-chainstate`. - Since we still don't have a genesis block, init will wait for it forever in an endless loop ([code](91d12344b1/src/init.cpp (L1630-L1640)
)). Fix this by disallowing `-reindex-chainstate` together with `-prune`. This is discouraged in the help for `-reindex-chainstate` anyway ("When in pruning mode or if blocks on disk might be corrupted, use full -reindex instead.") but wasn't enforced. Fixes #24242 ACKs for top commit: MarcoFalke: cr ACKb2813980b8
Tree-SHA512: 7220842daaf9a4f972d82b13b81fdeac2833bf5e665c5b0f8eaf6a4bcd0725c8e97d19ec956ca4b730065a983475bb3a2732713d338f4caf8666ccbf63d4d988
This commit is contained in:
commit
4a0ab355b3
2 changed files with 7 additions and 1 deletions
|
@ -853,12 +853,14 @@ bool AppInitParameterInteraction(const ArgsManager& args)
|
||||||
nLocalServices = ServiceFlags(nLocalServices | NODE_COMPACT_FILTERS);
|
nLocalServices = ServiceFlags(nLocalServices | NODE_COMPACT_FILTERS);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if using block pruning, then disallow txindex and coinstatsindex
|
|
||||||
if (args.GetIntArg("-prune", 0)) {
|
if (args.GetIntArg("-prune", 0)) {
|
||||||
if (args.GetBoolArg("-txindex", DEFAULT_TXINDEX))
|
if (args.GetBoolArg("-txindex", DEFAULT_TXINDEX))
|
||||||
return InitError(_("Prune mode is incompatible with -txindex."));
|
return InitError(_("Prune mode is incompatible with -txindex."));
|
||||||
if (args.GetBoolArg("-coinstatsindex", DEFAULT_COINSTATSINDEX))
|
if (args.GetBoolArg("-coinstatsindex", DEFAULT_COINSTATSINDEX))
|
||||||
return InitError(_("Prune mode is incompatible with -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
|
// If -forcednsseed is set to true, ensure -dnsseed has not been set to false
|
||||||
|
|
|
@ -141,6 +141,10 @@ class PruneTest(BitcoinTestFramework):
|
||||||
expected_msg='Error: Prune mode is incompatible with -coinstatsindex.',
|
expected_msg='Error: Prune mode is incompatible with -coinstatsindex.',
|
||||||
extra_args=['-prune=550', '-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):
|
def test_height_min(self):
|
||||||
assert os.path.isfile(os.path.join(self.prunedir, "blk00000.dat")), "blk00000.dat is missing, pruning too early"
|
assert os.path.isfile(os.path.join(self.prunedir, "blk00000.dat")), "blk00000.dat is missing, pruning too early"
|
||||||
|
|
Loading…
Add table
Reference in a new issue