aboutsummaryrefslogtreecommitdiff
path: root/src/bench
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2023-05-09 15:23:32 +0100
committerfanquake <fanquake@gmail.com>2023-05-09 15:42:21 +0100
commitfc06881f13495154c888a64a38c7d538baf00435 (patch)
tree9be742027b5debdbd7c70d03b6c67a9efde05b3a /src/bench
parentd5ff96f92008b12660007327aa8dc87bc5f63897 (diff)
parentd168458d1ff987e0d741c75ac1d4b63ae0cfb7e7 (diff)
Merge bitcoin/bitcoin#27491: refactor: Move chain constants to the util library
d168458d1ff987e0d741c75ac1d4b63ae0cfb7e7 scripted-diff: Remove unused chainparamsbase includes (TheCharlatan) e9ee8aaf3acdf6dce2b339916d4c602484570050 Add missing definitions in prep for scripted diff (TheCharlatan) ba8fc7d788932b25864fb260ca14983aa2398c23 refactor: Replace string chain name constants with ChainTypes (TheCharlatan) 401453df419af35957ec711423ac3d93ad512fe8 refactor: Introduce ChainType getters for ArgsManager (TheCharlatan) bfc21c31b2186f7d30fc9a9ca7d6887ab61c6fb9 refactor: Create chaintype files (TheCharlatan) Pull request description: This pull request is part of the `libbitcoinkernel` project https://github.com/bitcoin/bitcoin/issues/24303 https://github.com/bitcoin/bitcoin/projects/18 and more specifically its "Step 2: Decouple most non-consensus code from libbitcoinkernel". It is also a follow up to #26177. It replaces pull request https://github.com/bitcoin/bitcoin/pull/27294, which just moved the constants to a new file, but did not re-declare them as enums. The code move of the chain name constants out of the `chainparamsbase` to their own separate header allows the kernel `chainparams` to no longer include `chainparamsbase`. The `chainparamsbase` contain references to the `ArgsManager` and networking related options that should not belong to the kernel library. Besides this move, the constants are re-declared as enums with helper functions facilitating string conversions. ACKs for top commit: ryanofsky: Code review ACK d168458d1ff987e0d741c75ac1d4b63ae0cfb7e7. Just suggested changes since last review. Tree-SHA512: ac2fbe5cbbab4f52eae1e30af1f16700b6589eb4764c328a151a712adfc37f326cc94a65c385534c57d4bc92cc1a13bf1777d92bc924a20dbb30440e7380b316
Diffstat (limited to 'src/bench')
-rw-r--r--src/bench/checkblock.cpp3
-rw-r--r--src/bench/load_external.cpp3
-rw-r--r--src/bench/logging.cpp3
-rw-r--r--src/bench/mempool_stress.cpp5
-rw-r--r--src/bench/rpc_blockchain.cpp3
-rw-r--r--src/bench/rpc_mempool.cpp4
6 files changed, 13 insertions, 8 deletions
diff --git a/src/bench/checkblock.cpp b/src/bench/checkblock.cpp
index 260c8991ce..269ac847a5 100644
--- a/src/bench/checkblock.cpp
+++ b/src/bench/checkblock.cpp
@@ -9,6 +9,7 @@
#include <common/args.h>
#include <consensus/validation.h>
#include <streams.h>
+#include <util/chaintype.h>
#include <validation.h>
// These are the two major time-sinks which happen after we have fully received
@@ -36,7 +37,7 @@ static void DeserializeAndCheckBlockTest(benchmark::Bench& bench)
stream.write({&a, 1}); // Prevent compaction
ArgsManager bench_args;
- const auto chainParams = CreateChainParams(bench_args, CBaseChainParams::MAIN);
+ const auto chainParams = CreateChainParams(bench_args, ChainType::MAIN);
bench.unit("block").run([&] {
CBlock block; // Note that CBlock caches its checked state, so we need to recreate it here
diff --git a/src/bench/load_external.cpp b/src/bench/load_external.cpp
index 0fd842c7c3..2ff72a3012 100644
--- a/src/bench/load_external.cpp
+++ b/src/bench/load_external.cpp
@@ -6,6 +6,7 @@
#include <bench/data.h>
#include <chainparams.h>
#include <test/util/setup_common.h>
+#include <util/chaintype.h>
#include <validation.h>
/**
@@ -22,7 +23,7 @@
*/
static void LoadExternalBlockFile(benchmark::Bench& bench)
{
- const auto testing_setup{MakeNoLogFileContext<const TestingSetup>(CBaseChainParams::MAIN)};
+ const auto testing_setup{MakeNoLogFileContext<const TestingSetup>(ChainType::MAIN)};
// Create a single block as in the blocks files (magic bytes, block size,
// block data) as a stream object.
diff --git a/src/bench/logging.cpp b/src/bench/logging.cpp
index 9aedb26236..c97c4e151b 100644
--- a/src/bench/logging.cpp
+++ b/src/bench/logging.cpp
@@ -5,6 +5,7 @@
#include <bench/bench.h>
#include <logging.h>
#include <test/util/setup_common.h>
+#include <util/chaintype.h>
// All but 2 of the benchmarks should have roughly similar performance:
//
@@ -18,7 +19,7 @@ static void Logging(benchmark::Bench& bench, const std::vector<const char*>& ext
LogInstance().DisableCategory(BCLog::LogFlags::ALL);
TestingSetup test_setup{
- CBaseChainParams::REGTEST,
+ ChainType::REGTEST,
extra_args,
};
diff --git a/src/bench/mempool_stress.cpp b/src/bench/mempool_stress.cpp
index 80c959cdfb..826da73800 100644
--- a/src/bench/mempool_stress.cpp
+++ b/src/bench/mempool_stress.cpp
@@ -7,6 +7,7 @@
#include <policy/policy.h>
#include <test/util/setup_common.h>
#include <txmempool.h>
+#include <util/chaintype.h>
#include <validation.h>
#include <vector>
@@ -88,7 +89,7 @@ static void ComplexMemPool(benchmark::Bench& bench)
childTxs = static_cast<int>(bench.complexityN());
}
std::vector<CTransactionRef> ordered_coins = CreateOrderedCoins(det_rand, childTxs, /*min_ancestors=*/1);
- const auto testing_setup = MakeNoLogFileContext<const TestingSetup>(CBaseChainParams::MAIN);
+ const auto testing_setup = MakeNoLogFileContext<const TestingSetup>(ChainType::MAIN);
CTxMemPool& pool = *testing_setup.get()->m_node.mempool;
LOCK2(cs_main, pool.cs);
bench.run([&]() NO_THREAD_SAFETY_ANALYSIS {
@@ -103,7 +104,7 @@ static void ComplexMemPool(benchmark::Bench& bench)
static void MempoolCheck(benchmark::Bench& bench)
{
FastRandomContext det_rand{true};
- auto testing_setup = MakeNoLogFileContext<TestChain100Setup>(CBaseChainParams::REGTEST, {"-checkmempool=1"});
+ auto testing_setup = MakeNoLogFileContext<TestChain100Setup>(ChainType::REGTEST, {"-checkmempool=1"});
CTxMemPool& pool = *testing_setup.get()->m_node.mempool;
LOCK2(cs_main, pool.cs);
testing_setup->PopulateMempool(det_rand, 400, true);
diff --git a/src/bench/rpc_blockchain.cpp b/src/bench/rpc_blockchain.cpp
index f68b6acb5b..a9b197b190 100644
--- a/src/bench/rpc_blockchain.cpp
+++ b/src/bench/rpc_blockchain.cpp
@@ -8,6 +8,7 @@
#include <rpc/blockchain.h>
#include <streams.h>
#include <test/util/setup_common.h>
+#include <util/chaintype.h>
#include <validation.h>
#include <univalue.h>
@@ -15,7 +16,7 @@
namespace {
struct TestBlockAndIndex {
- const std::unique_ptr<const TestingSetup> testing_setup{MakeNoLogFileContext<const TestingSetup>(CBaseChainParams::MAIN)};
+ const std::unique_ptr<const TestingSetup> testing_setup{MakeNoLogFileContext<const TestingSetup>(ChainType::MAIN)};
CBlock block{};
uint256 blockHash{};
CBlockIndex blockindex{};
diff --git a/src/bench/rpc_mempool.cpp b/src/bench/rpc_mempool.cpp
index e3e1a07c83..7e274370e0 100644
--- a/src/bench/rpc_mempool.cpp
+++ b/src/bench/rpc_mempool.cpp
@@ -3,12 +3,12 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <bench/bench.h>
-#include <chainparamsbase.h>
#include <kernel/cs_main.h>
#include <kernel/mempool_entry.h>
#include <rpc/mempool.h>
#include <test/util/setup_common.h>
#include <txmempool.h>
+#include <util/chaintype.h>
#include <univalue.h>
@@ -21,7 +21,7 @@ static void AddTx(const CTransactionRef& tx, const CAmount& fee, CTxMemPool& poo
static void RpcMempool(benchmark::Bench& bench)
{
- const auto testing_setup = MakeNoLogFileContext<const ChainTestingSetup>(CBaseChainParams::MAIN);
+ const auto testing_setup = MakeNoLogFileContext<const ChainTestingSetup>(ChainType::MAIN);
CTxMemPool& pool = *Assert(testing_setup->m_node.mempool);
LOCK2(cs_main, pool.cs);