mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-04 02:02:42 +02:00
Merge bitcoin/bitcoin#25487: [kernel 3b/n] Decouple {Dump,Load}Mempool from ArgsManager
cb3e9a1e3fMove {Load,Dump}Mempool to kernel namespace (Carl Dong)aa30676541Move DEFAULT_PERSIST_MEMPOOL out of libbitcoinkernel (Carl Dong)06b88ffb8aLoadMempool: Pass in load_path, stop using gArgs (Carl Dong)b857ac60d9test/fuzz: Invoke LoadMempool via CChainState (Carl Dong)b3267258b0Move FopenFn to fsbridge namespace (Carl Dong)ae1e8e3756mempool: Use NodeClock+friends for LoadMempool (Carl Dong)f9e8e5719fmempool: Improve comments for [GS]etLoadTried (Carl Dong)813962da0bscripted-diff: Rename m_is_loaded -> m_load_tried (Carl Dong)413f4bb52bDumpMempool: Pass in dump_path, stop using gArgs (Carl Dong)bd4407817eDumpMempool: Use std::chrono instead of weird int64_t arthmetics (Carl Dong)c84390b741test/mempool_persist: Test manual savemempool when -persistmempool=0 (Carl Dong) Pull request description: This is part of the `libbitcoinkernel` project: #24303, https://github.com/bitcoin/bitcoin/projects/18 ----- This PR moves `{Dump,Load}Mempool` into its own `kernel/mempool_persist` module and introduces `ArgsManager` `node::` helpers in `node/mempool_persist_args`to remove the scattered calls to `GetBoolArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)`. More context can be gleaned from the commit messages. ----- One thing I was reflecting on as I wrote this was that in the long run, I think we should probably invert the validation <-> mempool relationship. Instead of mempool not depending on validation, it might make more sense to have validation not depend on mempool. Not super urgent since `libbitcoinkernel` will include both validation and mempool, but perhaps something for the future. ACKs for top commit: glozow: re ACKcb3e9a1e3fvia `git range-diff 7ae032e...cb3e9a1` MarcoFalke: ACKcb3e9a1e3f🔒 ryanofsky: Code review ACKcb3e9a1e3fTree-SHA512: 979d7237c3abb5a1dd9b5ad3dbf3b954f906a6d8320ed7b923557f41a4472deccae3e8a6bca0018c8e7a3c4a93afecc502acd1e26756f2054f157f1c0edd939d
This commit is contained in:
19
src/test/fuzz/mempool_utils.h
Normal file
19
src/test/fuzz/mempool_utils.h
Normal file
@@ -0,0 +1,19 @@
|
||||
// Copyright (c) 2022 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef BITCOIN_TEST_FUZZ_MEMPOOL_UTILS_H
|
||||
#define BITCOIN_TEST_FUZZ_MEMPOOL_UTILS_H
|
||||
|
||||
#include <validation.h>
|
||||
|
||||
class DummyChainState final : public CChainState
|
||||
{
|
||||
public:
|
||||
void SetMempool(CTxMemPool* mempool)
|
||||
{
|
||||
m_mempool = mempool;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // BITCOIN_TEST_FUZZ_MEMPOOL_UTILS_H
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <node/miner.h>
|
||||
#include <test/fuzz/FuzzedDataProvider.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <test/fuzz/mempool_utils.h>
|
||||
#include <test/fuzz/util.h>
|
||||
#include <test/util/mining.h>
|
||||
#include <test/util/script.h>
|
||||
@@ -34,15 +35,6 @@ struct MockedTxPool : public CTxMemPool {
|
||||
}
|
||||
};
|
||||
|
||||
class DummyChainState final : public CChainState
|
||||
{
|
||||
public:
|
||||
void SetMempool(CTxMemPool* mempool)
|
||||
{
|
||||
m_mempool = mempool;
|
||||
}
|
||||
};
|
||||
|
||||
void initialize_tx_pool()
|
||||
{
|
||||
static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>();
|
||||
|
||||
@@ -2,10 +2,14 @@
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <kernel/mempool_persist.h>
|
||||
|
||||
#include <chainparamsbase.h>
|
||||
#include <mempool_args.h>
|
||||
#include <node/mempool_persist_args.h>
|
||||
#include <test/fuzz/FuzzedDataProvider.h>
|
||||
#include <test/fuzz/fuzz.h>
|
||||
#include <test/fuzz/mempool_utils.h>
|
||||
#include <test/fuzz/util.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <txmempool.h>
|
||||
@@ -15,6 +19,10 @@
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
using kernel::DumpMempool;
|
||||
|
||||
using node::MempoolPath;
|
||||
|
||||
namespace {
|
||||
const TestingSetup* g_setup;
|
||||
} // namespace
|
||||
@@ -33,9 +41,12 @@ FUZZ_TARGET_INIT(validation_load_mempool, initialize_validation_load_mempool)
|
||||
|
||||
CTxMemPool pool{MemPoolOptionsForTest(g_setup->m_node)};
|
||||
|
||||
auto& chainstate{static_cast<DummyChainState&>(g_setup->m_node.chainman->ActiveChainstate())};
|
||||
chainstate.SetMempool(&pool);
|
||||
|
||||
auto fuzzed_fopen = [&](const fs::path&, const char*) {
|
||||
return fuzzed_file_provider.open();
|
||||
};
|
||||
(void)LoadMempool(pool, g_setup->m_node.chainman->ActiveChainstate(), fuzzed_fopen);
|
||||
(void)DumpMempool(pool, fuzzed_fopen, true);
|
||||
(void)chainstate.LoadMempool(MempoolPath(g_setup->m_args), fuzzed_fopen);
|
||||
(void)DumpMempool(pool, MempoolPath(g_setup->m_args), fuzzed_fopen, true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user