diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -319,7 +319,7 @@ std::vector hidden_args = { "-rpcssl", "-benchmark", "-h", "-help", "-socks", "-tor", "-debugnet", "-whitelistalwaysrelay", "-blockminsize", "-dbcrashratio", - "-forcecompactdb", "-usehd", "-parkdeepreorg", + "-forcecompactdb", "-usehd", "-parkdeepreorg", "-automaticunparking", "-replayprotectionactivationtime", // GUI args. These will be overwritten by SetupUIArgs for the GUI "-allowselfsignedrootcertificates", "-choosedatadir", "-lang=", diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2571,7 +2571,7 @@ // If this is a parked chain, but it has enough PoW, clear the park // state. bool fParkedChain = pindexTest->nStatus.isOnParkedChain(); - if (fParkedChain && gArgs.GetBoolArg("-parkdeepreorg", true)) { + if (fParkedChain && gArgs.GetBoolArg("-automaticunparking", true)) { const CBlockIndex *pindexTip = chainActive.Tip(); // During initialization, pindexTip and/or pindexFork may be @@ -2645,6 +2645,13 @@ pindexBestParked = pindexNew; } + LogPrintf("Considered switching to better tip %s but that chain " + "contains a%s%s%s block.\n", + pindexNew->GetBlockHash().ToString(), + fInvalidChain ? "n invalid" : "", + fParkedChain ? " parked" : "", + fMissingData ? " missing-data" : ""); + CBlockIndex *pindexFailed = pindexNew; // Remove the entire chain from the set. while (pindexTest != pindexFailed) { diff --git a/test/functional/abc-parkedchain.py b/test/functional/abc-parkedchain.py --- a/test/functional/abc-parkedchain.py +++ b/test/functional/abc-parkedchain.py @@ -5,13 +5,14 @@ """Test the parckblock and unparkblock RPC calls.""" from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, wait_until +from test_framework.util import assert_equal, connect_nodes_bi, wait_until class ParkedChainTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 2 - self.extra_args = [["-noparkdeepreorg"], ["-maxreorgdepth=-1"]] + self.extra_args = [["-noparkdeepreorg", + "-noautomaticunparking"], ["-maxreorgdepth=-1"]] # There should only be one chaintip, which is expected_tip def only_valid_tip(self, expected_tip, other_tip_status=None): @@ -188,6 +189,30 @@ check_reorg_protection(6, 6) check_reorg_protection(100, 100) + self.log.info("Test that unparking works when -parkdeepreorg=0") + # Set up parking node height = fork + 4, node height = fork + 5 + node.invalidateblock(node.getbestblockhash()) + parking_node.generate(3) + node.generate(5) + wait_for_parked_block(node.getbestblockhash()) + # Restart the parking node without parkdeepreorg. + self.restart_node(1, ["-parkdeepreorg=0"]) + parking_node = self.nodes[1] + connect_nodes_bi(node, parking_node) + # The other chain should still be marked 'parked'. + wait_for_parked_block(node.getbestblockhash()) + # Three more blocks is not enough to unpark. Even though its PoW is + # larger, we are still following the delayed-unparking rules. + node.generate(3) + wait_for_parked_block(node.getbestblockhash()) + # Final block pushes over the edge, and should unpark. + node.generate(1) + wait_until(lambda: parking_node.getbestblockhash() == + node.getbestblockhash(), timeout=5) + + # Do not append tests after this point without restarting node again. + # Parking node is no longer parking. + if __name__ == '__main__': ParkedChainTest().main() diff --git a/test/lint/check-doc.py b/test/lint/check-doc.py --- a/test/lint/check-doc.py +++ b/test/lint/check-doc.py @@ -37,6 +37,7 @@ '-debugnet', '-forcecompactdb', '-parkdeepreorg', + '-automaticunparking', # Remove after May 2020 upgrade '-phononactivationtime', '-replayprotectionactivationtime',