From c2014e447b58b1fdbb5c6658f91976fb89ae28e4 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kittywhiskers@users.noreply.github.com> Date: Thu, 24 Aug 2023 13:40:24 +0530 Subject: [PATCH 01/11] merge bitcoin#23842: Rename interfaces::WalletClient to interfaces::WalletLoader --- src/interfaces/node.h | 6 +++--- src/interfaces/wallet.h | 6 +++--- src/node/context.h | 4 ++-- src/node/interfaces.cpp | 6 +++--- src/qt/bitcoingui.cpp | 4 ++-- src/qt/optionsdialog.cpp | 2 +- src/qt/splashscreen.cpp | 2 +- src/qt/walletcontroller.cpp | 10 +++++----- src/qt/walletmodel.cpp | 2 +- src/wallet/init.cpp | 6 +++--- src/wallet/interfaces.cpp | 14 +++++++------- src/wallet/test/init_test_fixture.cpp | 2 +- src/wallet/test/init_test_fixture.h | 2 +- src/wallet/test/init_tests.cpp | 14 +++++++------- src/wallet/test/wallet_test_fixture.cpp | 2 +- src/wallet/test/wallet_test_fixture.h | 2 +- src/wallet/wallet.h | 2 +- 17 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/interfaces/node.h b/src/interfaces/node.h index f6eb8d6fb8bc..cd50480b0708 100644 --- a/src/interfaces/node.h +++ b/src/interfaces/node.h @@ -37,7 +37,7 @@ struct NodeContext; namespace interfaces { class Handler; -class WalletClient; +class WalletLoader; struct BlockTip; //! Interface for the src/evo part of a dash node (dashd process). @@ -284,8 +284,8 @@ class Node //! Get unspent outputs associated with a transaction. virtual bool getUnspentOutput(const COutPoint& output, Coin& coin) = 0; - //! Get wallet client. - virtual WalletClient& walletClient() = 0; + //! Get wallet loader. + virtual WalletLoader& walletLoader() = 0; //! Return interface for accessing evo related handler. virtual EVO& evo() = 0; diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h index 049b17769000..7232bc79f6bd 100644 --- a/src/interfaces/wallet.h +++ b/src/interfaces/wallet.h @@ -349,7 +349,7 @@ class Wallet //! Wallet chain client that in addition to having chain client methods for //! starting up, shutting down, and registering RPCs, also has additional //! methods (called by the GUI) to load and create wallets. -class WalletClient : public ChainClient +class WalletLoader : public ChainClient { public: //! Create new wallet. @@ -456,9 +456,9 @@ struct WalletTxOut //! dummywallet.cpp and throws if the wallet component is not compiled. std::unique_ptr MakeWallet(const std::shared_ptr& wallet); -//! Return implementation of ChainClient interface for a wallet client. This +//! Return implementation of ChainClient interface for a wallet loader. This //! function will be undefined in builds where ENABLE_WALLET is false. -std::unique_ptr MakeWalletClient(Chain& chain, ArgsManager& args); +std::unique_ptr MakeWalletLoader(Chain& chain, ArgsManager& args); } // namespace interfaces diff --git a/src/node/context.h b/src/node/context.h index 32f2b511bbc9..f44cc8d51b54 100644 --- a/src/node/context.h +++ b/src/node/context.h @@ -25,7 +25,7 @@ class CEvoDB; namespace interfaces { class Chain; class ChainClient; -class WalletClient; +class WalletLoader; } // namespace interfaces //! NodeContext struct containing references to chain state and connection @@ -52,7 +52,7 @@ struct NodeContext { std::vector> chain_clients; //! Reference to chain client that should used to load or create wallets //! opened by the gui. - interfaces::WalletClient* wallet_client{nullptr}; + interfaces::WalletLoader* wallet_loader{nullptr}; std::unique_ptr scheduler; std::function rpc_interruption_point = [] {}; //! Dash diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index c74e20d016df..036187e53802 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -71,7 +71,7 @@ using interfaces::Handler; using interfaces::LLMQ; using interfaces::MakeHandler; using interfaces::Node; -using interfaces::WalletClient; +using interfaces::WalletLoader; namespace node { namespace { @@ -431,9 +431,9 @@ class NodeImpl : public Node assert(std::addressof(::ChainstateActive()) == std::addressof(chainman().ActiveChainstate())); return chainman().ActiveChainstate().CoinsTip().GetCoin(output, coin); } - WalletClient& walletClient() override + WalletLoader& walletLoader() override { - return *Assert(m_context->wallet_client); + return *Assert(m_context->wallet_loader); } EVO& evo() override { return m_evo; } diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 00bab9460a58..03ef6acbc087 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -1357,7 +1357,7 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, const QStri bool disableAppNap = !m_node.masternodeSync().isSynced(); #ifdef ENABLE_WALLET if (enableWallet) { - for (const auto& wallet : m_node.walletClient().getWallets()) { + for (const auto& wallet : m_node.walletLoader().getWallets()) { disableAppNap |= wallet->coinJoin().isMixing(); } } @@ -1725,7 +1725,7 @@ void BitcoinGUI::showIncomingTransactions() // On new transaction, make an info balloon QString msg = tr("Date: %1\n").arg(itx.date) + tr("Amount: %1\n").arg(BitcoinUnits::formatWithUnit(itx.unit, itx.amount, true)); - if (m_node.walletClient().getWallets().size() > 1 && !itx.walletName.isEmpty()) { + if (m_node.walletLoader().getWallets().size() > 1 && !itx.walletName.isEmpty()) { msg += tr("Wallet: %1\n").arg(itx.walletName); } msg += tr("Type: %1\n").arg(itx.type); diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index 0af071c11c2f..b74646a95ead 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -404,7 +404,7 @@ void OptionsDialog::on_okButton_clicked() appearance->accept(); #ifdef ENABLE_WALLET if (m_enable_wallet) { - for (auto& wallet : model->node().walletClient().getWallets()) { + for (auto& wallet : model->node().walletLoader().getWallets()) { wallet->coinJoin().resetCachedBlocks(); wallet->markDirty(); } diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp index 01c8df2ddb94..1e56981a08ce 100644 --- a/src/qt/splashscreen.cpp +++ b/src/qt/splashscreen.cpp @@ -189,7 +189,7 @@ void SplashScreen::handleLoadWallet() { #ifdef ENABLE_WALLET if (!WalletModel::isWalletEnabled()) return; - m_handler_load_wallet = m_node.walletClient().handleLoadWallet([this](std::unique_ptr wallet) { + m_handler_load_wallet = m_node.walletLoader().handleLoadWallet([this](std::unique_ptr wallet) { m_connected_wallet_handlers.emplace_back(wallet->handleShowProgress(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2, false))); m_connected_wallets.emplace_back(std::move(wallet)); }); diff --git a/src/qt/walletcontroller.cpp b/src/qt/walletcontroller.cpp index 51eab2d652fc..ddd2fd346a7f 100644 --- a/src/qt/walletcontroller.cpp +++ b/src/qt/walletcontroller.cpp @@ -34,11 +34,11 @@ WalletController::WalletController(ClientModel& client_model, QObject* parent) , m_node(client_model.node()) , m_options_model(client_model.getOptionsModel()) { - m_handler_load_wallet = m_node.walletClient().handleLoadWallet([this](std::unique_ptr wallet) { + m_handler_load_wallet = m_node.walletLoader().handleLoadWallet([this](std::unique_ptr wallet) { getOrCreateWallet(std::move(wallet)); }); - for (std::unique_ptr& wallet : m_node.walletClient().getWallets()) { + for (std::unique_ptr& wallet : m_node.walletLoader().getWallets()) { getOrCreateWallet(std::move(wallet)); } @@ -65,7 +65,7 @@ std::map WalletController::listWalletDir() const { QMutexLocker locker(&m_mutex); std::map wallets; - for (const std::string& name : m_node.walletClient().listWalletDir()) { + for (const std::string& name : m_node.walletLoader().listWalletDir()) { wallets[name] = false; } for (WalletModel* wallet_model : m_wallets) { @@ -228,7 +228,7 @@ void CreateWalletActivity::createWallet() } QTimer::singleShot(500, worker(), [this, name, flags] { - std::unique_ptr wallet = node().walletClient().createWallet(name, m_passphrase, flags, m_error_message, m_warning_message); + std::unique_ptr wallet = node().walletLoader().createWallet(name, m_passphrase, flags, m_error_message, m_warning_message); if (wallet) m_wallet_model = m_wallet_controller->getOrCreateWallet(std::move(wallet)); @@ -299,7 +299,7 @@ void OpenWalletActivity::open(const std::string& path) showProgressDialog(tr("Opening Wallet %1...").arg(name.toHtmlEscaped())); QTimer::singleShot(0, worker(), [this, path] { - std::unique_ptr wallet = node().walletClient().loadWallet(path, m_error_message, m_warning_message); + std::unique_ptr wallet = node().walletLoader().loadWallet(path, m_error_message, m_warning_message); if (wallet) m_wallet_model = m_wallet_controller->getOrCreateWallet(std::move(wallet)); diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 53900aa06eaf..8a27a6719dd9 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -606,7 +606,7 @@ QString WalletModel::getDisplayName() const bool WalletModel::isMultiwallet() { - return m_node.walletClient().getWallets().size() > 1; + return m_node.walletLoader().getWallets().size() > 1; } uint256 WalletModel::getLastBlockProcessed() const diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp index f6c9a5132802..4956d92c8a56 100644 --- a/src/wallet/init.cpp +++ b/src/wallet/init.cpp @@ -185,9 +185,9 @@ void WalletInit::Construct(NodeContext& node) const LogPrintf("Wallet disabled!\n"); return; } - auto wallet_client = interfaces::MakeWalletClient(*node.chain, args); - node.wallet_client = wallet_client.get(); - node.chain_clients.emplace_back(std::move(wallet_client)); + auto wallet_loader = interfaces::MakeWalletLoader(*node.chain, args); + node.wallet_loader = wallet_loader.get(); + node.chain_clients.emplace_back(std::move(wallet_loader)); } diff --git a/src/wallet/interfaces.cpp b/src/wallet/interfaces.cpp index 2ddaccd7cb69..69be72a8ab4f 100644 --- a/src/wallet/interfaces.cpp +++ b/src/wallet/interfaces.cpp @@ -38,7 +38,7 @@ using interfaces::MakeHandler; using interfaces::Wallet; using interfaces::WalletAddress; using interfaces::WalletBalances; -using interfaces::WalletClient; +using interfaces::WalletLoader; using interfaces::WalletOrderForm; using interfaces::WalletTx; using interfaces::WalletTxOut; @@ -601,15 +601,15 @@ class WalletImpl : public Wallet CoinJoinImpl m_coinjoin; }; -class WalletClientImpl : public WalletClient +class WalletLoaderImpl : public WalletLoader { public: - WalletClientImpl(Chain& chain, ArgsManager& args) + WalletLoaderImpl(Chain& chain, ArgsManager& args) { m_context.chain = &chain; m_context.args = &args; } - ~WalletClientImpl() override { UnloadWallets(); } + ~WalletLoaderImpl() override { UnloadWallets(); } //! ChainClient methods void registerRpcs() override @@ -628,7 +628,7 @@ class WalletClientImpl : public WalletClient void stop() override { return StopWallets(); } void setMockTime(int64_t time) override { return SetMockTime(time); } - //! WalletClient methods + //! WalletLoader methods std::unique_ptr createWallet(const std::string& name, const SecureString& passphrase, uint64_t wallet_creation_flags, bilingual_str& error, std::vector& warnings) override { std::shared_ptr wallet; @@ -681,7 +681,7 @@ class WalletClientImpl : public WalletClient namespace interfaces { std::unique_ptr MakeWallet(const std::shared_ptr& wallet) { return wallet ? std::make_unique(wallet) : nullptr; } -std::unique_ptr MakeWalletClient(Chain& chain, ArgsManager& args) { - return std::make_unique(chain, args); +std::unique_ptr MakeWalletLoader(Chain& chain, ArgsManager& args) { + return std::make_unique(chain, args); } } // namespace interfaces diff --git a/src/wallet/test/init_test_fixture.cpp b/src/wallet/test/init_test_fixture.cpp index 59fc162ee7cb..6242af1f3279 100644 --- a/src/wallet/test/init_test_fixture.cpp +++ b/src/wallet/test/init_test_fixture.cpp @@ -10,7 +10,7 @@ InitWalletDirTestingSetup::InitWalletDirTestingSetup(const std::string& chainName) : BasicTestingSetup(chainName) { - m_wallet_client = MakeWalletClient(*m_node.chain, *Assert(m_node.args)); + m_wallet_loader = MakeWalletLoader(*m_node.chain, *Assert(m_node.args)); std::string sep; sep += fs::path::preferred_separator; diff --git a/src/wallet/test/init_test_fixture.h b/src/wallet/test/init_test_fixture.h index acf8789fe8ef..0dfc5767b444 100644 --- a/src/wallet/test/init_test_fixture.h +++ b/src/wallet/test/init_test_fixture.h @@ -19,7 +19,7 @@ struct InitWalletDirTestingSetup: public BasicTestingSetup { fs::path m_datadir; fs::path m_cwd; std::map m_walletdir_path_cases; - std::unique_ptr m_wallet_client; + std::unique_ptr m_wallet_loader; }; #endif // BITCOIN_WALLET_TEST_INIT_TEST_FIXTURE_H diff --git a/src/wallet/test/init_tests.cpp b/src/wallet/test/init_tests.cpp index 811708e06af3..0fba357252da 100644 --- a/src/wallet/test/init_tests.cpp +++ b/src/wallet/test/init_tests.cpp @@ -16,7 +16,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_default) SetWalletDir(m_walletdir_path_cases["default"]); { ASSERT_DEBUG_LOG(""); - bool result = m_wallet_client->verify(); + bool result = m_wallet_loader->verify(); BOOST_CHECK(result == true); } fs::path walletdir = gArgs.GetArg("-walletdir", ""); @@ -29,7 +29,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_custom) SetWalletDir(m_walletdir_path_cases["custom"]); { ASSERT_DEBUG_LOG(""); - bool result = m_wallet_client->verify(); + bool result = m_wallet_loader->verify(); BOOST_CHECK(result == true); } fs::path walletdir = gArgs.GetArg("-walletdir", ""); @@ -42,7 +42,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_does_not_exist) SetWalletDir(m_walletdir_path_cases["nonexistent"]); { ASSERT_DEBUG_LOG("does not exist"); - bool result = m_wallet_client->verify(); + bool result = m_wallet_loader->verify(); BOOST_CHECK(result == false); } } @@ -52,7 +52,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_is_not_directory) SetWalletDir(m_walletdir_path_cases["file"]); { ASSERT_DEBUG_LOG("is not a directory"); - bool result = m_wallet_client->verify(); + bool result = m_wallet_loader->verify(); BOOST_CHECK(result == false); } } @@ -62,7 +62,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_is_not_relative) SetWalletDir(m_walletdir_path_cases["relative"]); { ASSERT_DEBUG_LOG("is a relative path"); - bool result = m_wallet_client->verify(); + bool result = m_wallet_loader->verify(); BOOST_CHECK(result == false); } } @@ -72,7 +72,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing) SetWalletDir(m_walletdir_path_cases["trailing"]); { ASSERT_DEBUG_LOG(""); - bool result = m_wallet_client->verify(); + bool result = m_wallet_loader->verify(); BOOST_CHECK(result == true); } fs::path walletdir = gArgs.GetArg("-walletdir", ""); @@ -85,7 +85,7 @@ BOOST_AUTO_TEST_CASE(walletinit_verify_walletdir_no_trailing2) SetWalletDir(m_walletdir_path_cases["trailing2"]); { ASSERT_DEBUG_LOG(""); - bool result = m_wallet_client->verify(); + bool result = m_wallet_loader->verify(); BOOST_CHECK(result == true); } fs::path walletdir = gArgs.GetArg("-walletdir", ""); diff --git a/src/wallet/test/wallet_test_fixture.cpp b/src/wallet/test/wallet_test_fixture.cpp index 27c01c47f465..fc6100557d77 100644 --- a/src/wallet/test/wallet_test_fixture.cpp +++ b/src/wallet/test/wallet_test_fixture.cpp @@ -12,5 +12,5 @@ WalletTestingSetup::WalletTestingSetup(const std::string& chainName) bool fFirstRun; m_wallet.LoadWallet(fFirstRun); m_chain_notifications_handler = m_node.chain->handleNotifications({ &m_wallet, [](CWallet*) {} }); - m_wallet_client->registerRpcs(); + m_wallet_loader->registerRpcs(); } diff --git a/src/wallet/test/wallet_test_fixture.h b/src/wallet/test/wallet_test_fixture.h index ab7fb8c42b06..4f034489f141 100644 --- a/src/wallet/test/wallet_test_fixture.h +++ b/src/wallet/test/wallet_test_fixture.h @@ -20,7 +20,7 @@ struct WalletTestingSetup : public TestingSetup { explicit WalletTestingSetup(const std::string& chainName = CBaseChainParams::MAIN); - std::unique_ptr m_wallet_client = interfaces::MakeWalletClient(*m_node.chain, *Assert(m_node.args)); + std::unique_ptr m_wallet_loader = interfaces::MakeWalletLoader(*m_node.chain, *Assert(m_node.args)); CWallet m_wallet; std::unique_ptr m_chain_notifications_handler; }; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index b6f796db29e1..83eaff9fbbc3 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -49,7 +49,7 @@ using LoadWalletFn = std::function wall //! Explicitly unload and delete the wallet. // Blocks the current thread after signaling the unload intent so that all -// wallet clients release the wallet. +// wallet pointer owners release the wallet. // Note that, when blocking is not required, the wallet is implicitly unloaded // by the shared pointer deleter. void UnloadWallet(std::shared_ptr&& wallet); From 0761496ce4364097ededc59013696f79a83b4d27 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kittywhiskers@users.noreply.github.com> Date: Thu, 24 Aug 2023 13:59:24 +0530 Subject: [PATCH 02/11] merge bitcoin#24714: Don't use a lambda for Assert/Assume Co-authored-by: Konstantin Akimov --- src/Makefile.am | 1 + src/test/util_tests.cpp | 33 +++++++++++++++++++++++++ src/util/check.cpp | 14 +++++++++++ src/util/check.h | 24 ++++++++++++------ src/wallet/test/wallet_test_fixture.cpp | 1 + src/wallet/test/wallet_test_fixture.h | 2 +- 6 files changed, 66 insertions(+), 9 deletions(-) create mode 100644 src/util/check.cpp diff --git a/src/Makefile.am b/src/Makefile.am index b8d268b41967..3b642102e292 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -735,6 +735,7 @@ libbitcoin_util_a_SOURCES = \ util/asmap.cpp \ util/bip32.cpp \ util/bytevectorhash.cpp \ + util/check.cpp \ util/error.cpp \ util/fees.cpp \ util/getuniquepath.cpp \ diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index b01af9f00103..bdac17981681 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -51,6 +51,31 @@ namespace BCLog { BOOST_FIXTURE_TEST_SUITE(util_tests, BasicTestingSetup) +namespace { +class NoCopyOrMove +{ +public: + int i; + explicit NoCopyOrMove(int i) : i{i} { } + + NoCopyOrMove() = delete; + NoCopyOrMove(const NoCopyOrMove&) = delete; + NoCopyOrMove(NoCopyOrMove&&) = delete; + NoCopyOrMove& operator=(const NoCopyOrMove&) = delete; + NoCopyOrMove& operator=(NoCopyOrMove&&) = delete; + + operator bool() const { return i != 0; } + + int get_ip1() { return i + 1; } + bool test() + { + // Check that Assume can be used within a lambda and still call methods + [&]() { Assume(get_ip1()); }(); + return Assume(get_ip1() != 5); + } +}; +} // namespace + BOOST_AUTO_TEST_CASE(util_check) { // Check that Assert can forward @@ -62,6 +87,14 @@ BOOST_AUTO_TEST_CASE(util_check) // Check that Assume can be used as unary expression const bool result{Assume(two == 2)}; Assert(result); + + // Check that Assert doesn't require copy/move + NoCopyOrMove x{9}; + Assert(x).i += 3; + Assert(x).test(); + + // Check nested Asserts + BOOST_CHECK_EQUAL(Assert((Assert(x).test() ? 3 : 0)), 3); } BOOST_AUTO_TEST_CASE(util_criticalsection) diff --git a/src/util/check.cpp b/src/util/check.cpp new file mode 100644 index 000000000000..2a9f885560d0 --- /dev/null +++ b/src/util/check.cpp @@ -0,0 +1,14 @@ +// 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. + +#include + +#include + +void assertion_fail(const char* file, int line, const char* func, const char* assertion) +{ + auto str = strprintf("%s:%s %s: Assertion `%s' failed.\n", file, line, func, assertion); + fwrite(str.data(), 1, str.size(), stderr); + std::abort(); +} diff --git a/src/util/check.h b/src/util/check.h index 9dab06acd5c9..c871f6fe9cd9 100644 --- a/src/util/check.h +++ b/src/util/check.h @@ -47,14 +47,26 @@ class NonFatalCheckError : public std::runtime_error #endif /** Helper for Assert() */ -template -T get_pure_r_value(T&& val) +void assertion_fail(const char* file, int line, const char* func, const char* assertion); + +/** Helper for Assert()/Assume() */ +template +T&& inline_assertion_check(T&& val, const char* file, int line, const char* func, const char* assertion) { + if constexpr (IS_ASSERT +#ifdef ABORT_ON_FAILED_ASSUME + || true +#endif + ) { + if (!val) { + assertion_fail(file, line, func, assertion); + } + } return std::forward(val); } /** Identity function. Abort if the value compares equal to zero */ -#define Assert(val) ([&]() -> decltype(get_pure_r_value(val)) { auto&& check = (val); assert(#val && check); return std::forward(check); }()) +#define Assert(val) inline_assertion_check(val, __FILE__, __LINE__, __func__, #val) /** * Assume is the identity function. @@ -66,10 +78,6 @@ T get_pure_r_value(T&& val) * - For non-fatal errors in interactive sessions (e.g. RPC or command line * interfaces), CHECK_NONFATAL() might be more appropriate. */ -#ifdef ABORT_ON_FAILED_ASSUME -#define Assume(val) Assert(val) -#else -#define Assume(val) ([&]() -> decltype(get_pure_r_value(val)) { auto&& check = (val); return std::forward(check); }()) -#endif +#define Assume(val) inline_assertion_check(val, __FILE__, __LINE__, __func__, #val) #endif // BITCOIN_UTIL_CHECK_H diff --git a/src/wallet/test/wallet_test_fixture.cpp b/src/wallet/test/wallet_test_fixture.cpp index fc6100557d77..18fbfa1a113c 100644 --- a/src/wallet/test/wallet_test_fixture.cpp +++ b/src/wallet/test/wallet_test_fixture.cpp @@ -7,6 +7,7 @@ WalletTestingSetup::WalletTestingSetup(const std::string& chainName) : TestingSetup(chainName), + m_wallet_loader{interfaces::MakeWalletLoader(*m_node.chain, *Assert(m_node.args))}, m_wallet(m_node.chain.get(), "", CreateMockWalletDatabase()) { bool fFirstRun; diff --git a/src/wallet/test/wallet_test_fixture.h b/src/wallet/test/wallet_test_fixture.h index 4f034489f141..44f6c210598f 100644 --- a/src/wallet/test/wallet_test_fixture.h +++ b/src/wallet/test/wallet_test_fixture.h @@ -20,7 +20,7 @@ struct WalletTestingSetup : public TestingSetup { explicit WalletTestingSetup(const std::string& chainName = CBaseChainParams::MAIN); - std::unique_ptr m_wallet_loader = interfaces::MakeWalletLoader(*m_node.chain, *Assert(m_node.args)); + std::unique_ptr m_wallet_loader; CWallet m_wallet; std::unique_ptr m_chain_notifications_handler; }; From 1cf996ac8cbd4f38f5888427303a96b50c2378e0 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kittywhiskers@users.noreply.github.com> Date: Mon, 1 Feb 2021 22:19:59 +0200 Subject: [PATCH 03/11] merge bitcoin#21059: Drop boost/preprocessor dependencies --- src/bench/bench.h | 8 ++++---- src/clientversion.h | 9 ++------- src/util/macros.h | 7 +++++++ test/lint/lint-includes.sh | 2 -- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/bench/bench.h b/src/bench/bench.h index bafc7f8716a1..22f06d8cb8bc 100644 --- a/src/bench/bench.h +++ b/src/bench/bench.h @@ -5,6 +5,8 @@ #ifndef BITCOIN_BENCH_BENCH_H #define BITCOIN_BENCH_BENCH_H +#include + #include #include #include @@ -12,8 +14,6 @@ #include #include -#include -#include /* * Usage: @@ -56,8 +56,8 @@ class BenchRunner static void RunAll(const Args& args); }; } -// BENCHMARK(foo) expands to: benchmark::BenchRunner bench_11foo("foo"); +// BENCHMARK(foo) expands to: benchmark::BenchRunner bench_11foo("foo", foo); #define BENCHMARK(n) \ - benchmark::BenchRunner BOOST_PP_CAT(bench_, BOOST_PP_CAT(__LINE__, n))(BOOST_PP_STRINGIZE(n), n); + benchmark::BenchRunner PASTE2(bench_, PASTE2(__LINE__, n))(STRINGIZE(n), n); #endif // BITCOIN_BENCH_BENCH_H diff --git a/src/clientversion.h b/src/clientversion.h index 245688ecae4f..13115693a207 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -5,6 +5,8 @@ #ifndef BITCOIN_CLIENTVERSION_H #define BITCOIN_CLIENTVERSION_H +#include + #if defined(HAVE_CONFIG_H) #include #endif //HAVE_CONFIG_H @@ -14,13 +16,6 @@ #error Client version information missing: version is not defined by bitcoin-config.h or in any other way #endif -/** - * Converts the parameter X to a string after macro replacement on X has been performed. - * Don't merge these into one macro! - */ -#define STRINGIZE(X) DO_STRINGIZE(X) -#define DO_STRINGIZE(X) #X - //! Copyright string used in Windows .rc files #define COPYRIGHT_STR "2009-" STRINGIZE(COPYRIGHT_YEAR) " The Bitcoin Core Developers, 2014-" STRINGIZE(COPYRIGHT_YEAR) " " COPYRIGHT_HOLDERS_FINAL diff --git a/src/util/macros.h b/src/util/macros.h index 36ea87c0fe7e..0887c80fd7f1 100644 --- a/src/util/macros.h +++ b/src/util/macros.h @@ -8,4 +8,11 @@ #define PASTE(x, y) x ## y #define PASTE2(x, y) PASTE(x, y) +/** + * Converts the parameter X to a string after macro replacement on X has been performed. + * Don't merge these into one macro! + */ +#define STRINGIZE(X) DO_STRINGIZE(X) +#define DO_STRINGIZE(X) #X + #endif // BITCOIN_UTIL_MACROS_H diff --git a/test/lint/lint-includes.sh b/test/lint/lint-includes.sh index ef28cee4209c..7265dcc26ec9 100755 --- a/test/lint/lint-includes.sh +++ b/test/lint/lint-includes.sh @@ -61,8 +61,6 @@ EXPECTED_BOOST_INCLUDES=( boost/multi_index_container.hpp boost/optional.hpp boost/pool/pool_alloc.hpp - boost/preprocessor/cat.hpp - boost/preprocessor/stringize.hpp boost/signals2/connection.hpp boost/signals2/optional_last_value.hpp boost/signals2/signal.hpp From 772a3affce619cc43565440aaa5a50cf2ed19017 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kittywhiskers@users.noreply.github.com> Date: Thu, 6 Jan 2022 11:27:06 -0500 Subject: [PATCH 04/11] merge bitcoin#23994: Consolidate all uses of the fast range mapping technique in util/fastrange.h --- src/Makefile.am | 1 + src/blockfilter.cpp | 2 +- src/bloom.cpp | 13 +++------ src/cuckoocache.h | 27 +++++++++---------- src/test/fuzz/golomb_rice.cpp | 2 +- src/util/fastrange.h | 51 +++++++++++++++++++++++++++++++++++ src/util/golombrice.h | 33 ++--------------------- 7 files changed, 71 insertions(+), 58 deletions(-) create mode 100644 src/util/fastrange.h diff --git a/src/Makefile.am b/src/Makefile.am index 3b642102e292..d27f3bf59b96 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -310,6 +310,7 @@ BITCOIN_CORE_H = \ util/check.h \ util/enumerate.h \ util/error.h \ + util/fastrange.h \ util/fees.h \ util/golombrice.h \ util/hash_type.h \ diff --git a/src/blockfilter.cpp b/src/blockfilter.cpp index 109784137950..551486fb782c 100644 --- a/src/blockfilter.cpp +++ b/src/blockfilter.cpp @@ -29,7 +29,7 @@ uint64_t GCSFilter::HashToRange(const Element& element) const uint64_t hash = CSipHasher(m_params.m_siphash_k0, m_params.m_siphash_k1) .Write(element.data(), element.size()) .Finalize(); - return MapIntoRange(hash, m_F); + return FastRange64(hash, m_F); } std::vector GCSFilter::BuildHashedSet(const ElementSet& elements) const diff --git a/src/bloom.cpp b/src/bloom.cpp index 4003c95c5a25..b9508b3da124 100644 --- a/src/bloom.cpp +++ b/src/bloom.cpp @@ -14,6 +14,7 @@ #include