diff --git a/src/init.cpp b/src/init.cpp index 0c368d8bac8..22940181258 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -935,7 +935,6 @@ bool AppInitParameterInteraction(const ArgsManager& args, bool use_syscall_sandb init::SetLoggingLevel(args); fCheckBlockIndex = args.GetBoolArg("-checkblockindex", chainparams.DefaultConsistencyChecks()); - fCheckpointsEnabled = args.GetBoolArg("-checkpoints", DEFAULT_CHECKPOINTS_ENABLED); // block pruning; get the amount of disk space (in MiB) to allot for block & undo files int64_t nPruneArg = args.GetIntArg("-prune", 0); diff --git a/src/kernel/chainstatemanager_opts.h b/src/kernel/chainstatemanager_opts.h index 90acfab63a9..25e0a5c0b87 100644 --- a/src/kernel/chainstatemanager_opts.h +++ b/src/kernel/chainstatemanager_opts.h @@ -15,6 +15,7 @@ class CChainParams; +static constexpr bool DEFAULT_CHECKPOINTS_ENABLED{true}; static constexpr auto DEFAULT_MAX_TIP_AGE{24h}; namespace kernel { @@ -27,6 +28,7 @@ namespace kernel { struct ChainstateManagerOpts { const CChainParams& chainparams; const std::function adjusted_time_callback{nullptr}; + bool checkpoints_enabled{DEFAULT_CHECKPOINTS_ENABLED}; //! If set, it will override the minimum work we will assume exists on some valid chain. std::optional minimum_chain_work; //! If set, it will override the block hash whose ancestors we will assume to have valid scripts without checking them. diff --git a/src/node/chainstatemanager_args.cpp b/src/node/chainstatemanager_args.cpp index 4716be46b56..b9960eafdb3 100644 --- a/src/node/chainstatemanager_args.cpp +++ b/src/node/chainstatemanager_args.cpp @@ -19,6 +19,8 @@ namespace node { std::optional ApplyArgsManOptions(const ArgsManager& args, ChainstateManager::Options& opts) { + if (auto value{args.GetBoolArg("-checkpoints")}) opts.checkpoints_enabled = *value; + if (auto value{args.GetArg("-minimumchainwork")}) { if (!IsHexNumber(*value)) { return strprintf(Untranslated("Invalid non-hex (%s) minimum chain work value specified"), *value); diff --git a/src/validation.cpp b/src/validation.cpp index 3df4bfb0d01..d649e129f09 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -122,7 +122,6 @@ std::condition_variable g_best_block_cv; uint256 g_best_block; bool g_parallel_script_checks{false}; bool fCheckBlockIndex = false; -bool fCheckpointsEnabled = DEFAULT_CHECKPOINTS_ENABLED; const CBlockIndex* Chainstate::FindForkInGlobalIndex(const CBlockLocator& locator) const { @@ -3528,7 +3527,7 @@ static bool ContextualCheckBlockHeader(const CBlockHeader& block, BlockValidatio return state.Invalid(BlockValidationResult::BLOCK_INVALID_HEADER, "bad-diffbits", "incorrect proof of work"); // Check against checkpoints - if (fCheckpointsEnabled) { + if (chainman.m_options.checkpoints_enabled) { // Don't accept any forks from the main chain prior to last checkpoint. // GetLastCheckpoint finds the last checkpoint in MapCheckpoints that's in our // BlockIndex(). diff --git a/src/validation.h b/src/validation.h index 495618549a2..da5dc89482b 100644 --- a/src/validation.h +++ b/src/validation.h @@ -63,7 +63,6 @@ struct Params; static const int MAX_SCRIPTCHECK_THREADS = 15; /** -par default (number of script-checking threads, 0 = auto) */ static const int DEFAULT_SCRIPTCHECK_THREADS = 0; -static const bool DEFAULT_CHECKPOINTS_ENABLED = true; /** Default for -stopatheight */ static const int DEFAULT_STOPATHEIGHT = 0; /** Block files containing a block-height within MIN_BLOCKS_TO_KEEP of ActiveChain().Tip() will not be pruned. */ @@ -97,7 +96,6 @@ extern uint256 g_best_block; */ extern bool g_parallel_script_checks; extern bool fCheckBlockIndex; -extern bool fCheckpointsEnabled; /** Documentation for argument 'checklevel'. */ extern const std::vector CHECKLEVEL_DOC;