Merge cbfbf46e57 into merged_master (Bitcoin PR bitcoin/bitcoin#25781)

This commit is contained in:
Byron Hambly 2025-04-10 08:56:13 +02:00
commit 59a4dcb178
17 changed files with 142 additions and 66 deletions

View file

@ -38,6 +38,7 @@
#include <net_processing.h>
#include <netbase.h>
#include <netgroup.h>
#include <node/blockmanager_args.h>
#include <node/blockstorage.h>
#include <node/caches.h>
#include <node/chainstate.h>
@ -126,9 +127,7 @@ using node::ShouldPersistMempool;
using node::NodeContext;
using node::ThreadImport;
using node::VerifyLoadedChainstate;
using node::fPruneMode;
using node::fReindex;
using node::nPruneTarget;
static constexpr bool DEFAULT_PROXYRANDOMIZE{true};
static constexpr bool DEFAULT_REST_ENABLE{false};
@ -991,22 +990,7 @@ bool AppInitParameterInteraction(const ArgsManager& args, bool use_syscall_sandb
init::SetLoggingCategories(args);
init::SetLoggingLevel(args);
// block pruning; get the amount of disk space (in MiB) to allot for block & undo files
int64_t nPruneArg = args.GetIntArg("-prune", 0);
if (nPruneArg < 0) {
return InitError(_("Prune cannot be configured with a negative value."));
}
nPruneTarget = (uint64_t) nPruneArg * 1024 * 1024;
if (nPruneArg == 1) { // manual pruning: -prune=1
nPruneTarget = std::numeric_limits<uint64_t>::max();
fPruneMode = true;
} else if (nPruneTarget) {
if (nPruneTarget < MIN_DISK_SPACE_FOR_BLOCK_FILES) {
return InitError(strprintf(_("Prune configured below the minimum of %d MiB. Please use a higher number."), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024));
}
fPruneMode = true;
}
// ELEMENTS: epoch length and trim headers
uint32_t epoch_length = chainparams.GetConsensus().dynamic_epoch_length;
if (epoch_length == std::numeric_limits<uint32_t>::max()) {
// That's the default value, for non-dynafed chains and some tests. Pick a more sensible default here.
@ -1126,6 +1110,10 @@ bool AppInitParameterInteraction(const ArgsManager& args, bool use_syscall_sandb
if (const auto error{ApplyArgsManOptions(args, chainman_opts_dummy)}) {
return InitError(*error);
}
node::BlockManager::Options blockman_opts_dummy{};
if (const auto error{ApplyArgsManOptions(args, blockman_opts_dummy)}) {
return InitError(*error);
}
}
return true;
@ -1591,6 +1579,9 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
};
Assert(!ApplyArgsManOptions(args, chainman_opts)); // no error can happen, already checked in AppInitParameterInteraction
node::BlockManager::Options blockman_opts{};
Assert(!ApplyArgsManOptions(args, blockman_opts)); // no error can happen, already checked in AppInitParameterInteraction
// cache size calculations
CacheSizes cache_sizes = CalculateCacheSizes(args, g_enabled_filter_types.size());
@ -1626,7 +1617,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
for (bool fLoaded = false; !fLoaded && !ShutdownRequested();) {
node.mempool = std::make_unique<CTxMemPool>(mempool_opts);
node.chainman = std::make_unique<ChainstateManager>(chainman_opts);
node.chainman = std::make_unique<ChainstateManager>(chainman_opts, blockman_opts);
ChainstateManager& chainman = *node.chainman;
node::ChainstateLoadOptions options;