mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-12-13 06:03:54 +01:00
Merge bitcoin/bitcoin#30141: kernel: De-globalize validation caches
606a7ab862kernel: De-globalize signature cache (TheCharlatan)66d74bfc45Expose CSignatureCache class in header (TheCharlatan)021d38822ckernel: De-globalize script execution cache hasher (TheCharlatan)13a3661abakernel: De-globalize script execution cache (TheCharlatan)ab14d1d6a4validation: Don't error if maxsigcachesize exceeds uint32::max (TheCharlatan) Pull request description: The validation caches are currently setup independently from where the rest of the validation code is initialized. This makes their ownership semantics unclear. There is also no clear enforcement on when and in what order they need to be initialized. The caches are always initialized in the `BasicTestingSetup` although a number of tests don't actually need them. Solve this by moving the caches from global scope into the `ChainstateManager` class. This simplifies the usage of the kernel library by no longer requiring manual setup of the caches prior to using the `ChainstateManager`. Tests that need to access the caches can instantiate them independently. --- This pull request is part of the [libbitcoinkernel project](https://github.com/bitcoin/bitcoin/issues/27587). ACKs for top commit: stickies-v: re-ACK606a7ab862glozow: reACK606a7abryanofsky: Code review ACK606a7ab862. Just small formatting, include, and static_assert changes since last review. Tree-SHA512: e7f3ee41406e3b233832bb67dc3a63c4203b5367e5daeed383df9cb590f227fcc62eae31311029c077d5e81b273a37a88a364db3dee2efe91bb3b9c9ddc8a42e
This commit is contained in:
13
src/init.cpp
13
src/init.cpp
@@ -8,7 +8,6 @@
|
||||
#include <init.h>
|
||||
|
||||
#include <kernel/checks.h>
|
||||
#include <kernel/validation_cache_sizes.h>
|
||||
|
||||
#include <addrman.h>
|
||||
#include <banman.h>
|
||||
@@ -54,7 +53,6 @@
|
||||
#include <node/mempool_persist_args.h>
|
||||
#include <node/miner.h>
|
||||
#include <node/peerman_args.h>
|
||||
#include <node/validation_cache_args.h>
|
||||
#include <policy/feerate.h>
|
||||
#include <policy/fees.h>
|
||||
#include <policy/fees_args.h>
|
||||
@@ -119,7 +117,6 @@
|
||||
using common::AmountErrMsg;
|
||||
using common::InvalidPortErrMsg;
|
||||
using common::ResolveErrMsg;
|
||||
using kernel::ValidationCacheSizes;
|
||||
|
||||
using node::ApplyArgsManOptions;
|
||||
using node::BlockManager;
|
||||
@@ -619,7 +616,7 @@ void SetupServerArgs(ArgsManager& argsman)
|
||||
argsman.AddArg("-test=<option>", "Pass a test-only option. Options include : " + Join(TEST_OPTIONS_DOC, ", ") + ".", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
|
||||
argsman.AddArg("-capturemessages", "Capture all P2P messages to disk", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
|
||||
argsman.AddArg("-mocktime=<n>", "Replace actual time with " + UNIX_EPOCH_TIME + " (default: 0)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
|
||||
argsman.AddArg("-maxsigcachesize=<n>", strprintf("Limit sum of signature cache and script execution cache sizes to <n> MiB (default: %u)", DEFAULT_MAX_SIG_CACHE_BYTES >> 20), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
|
||||
argsman.AddArg("-maxsigcachesize=<n>", strprintf("Limit sum of signature cache and script execution cache sizes to <n> MiB (default: %u)", DEFAULT_VALIDATION_CACHE_BYTES >> 20), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
|
||||
argsman.AddArg("-maxtipage=<n>",
|
||||
strprintf("Maximum tip age in seconds to consider node in initial block download (default: %u)",
|
||||
Ticks<std::chrono::seconds>(DEFAULT_MAX_TIP_AGE)),
|
||||
@@ -1154,14 +1151,6 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
||||
args.GetArg("-datadir", ""), fs::PathToString(fs::current_path()));
|
||||
}
|
||||
|
||||
ValidationCacheSizes validation_cache_sizes{};
|
||||
ApplyArgsManOptions(args, validation_cache_sizes);
|
||||
if (!InitSignatureCache(validation_cache_sizes.signature_cache_bytes)
|
||||
|| !InitScriptExecutionCache(validation_cache_sizes.script_execution_cache_bytes))
|
||||
{
|
||||
return InitError(strprintf(_("Unable to allocate memory for -maxsigcachesize: '%s' MiB"), args.GetIntArg("-maxsigcachesize", DEFAULT_MAX_SIG_CACHE_BYTES >> 20)));
|
||||
}
|
||||
|
||||
assert(!node.scheduler);
|
||||
node.scheduler = std::make_unique<CScheduler>();
|
||||
auto& scheduler = *node.scheduler;
|
||||
|
||||
Reference in New Issue
Block a user