diff --git a/.gitignore b/.gitignore index 023edd5f3498..ca8ffafefcfc 100644 --- a/.gitignore +++ b/.gitignore @@ -168,3 +168,7 @@ test/lint/.cppcheck/* # flake8 cache location .cache/* + +# Editor and tooling +.vscode/ +compile_commands.json diff --git a/ci/README.md b/ci/README.md index 3c5f04c39e34..19228ffbaaf0 100644 --- a/ci/README.md +++ b/ci/README.md @@ -15,10 +15,10 @@ testing compared to other parts of the codebase. If you want to keep the work tr system in a virtual machine with a Linux operating system of your choice. To allow for a wide range of tested environments, but also ensure reproducibility to some extent, the test stage -requires `docker` to be installed. To install all requirements on Ubuntu, run +requires `docker` to be installed. To run on different architectures than the host `qemu` is also required. To install all requirements on Ubuntu, run ``` -sudo apt install docker.io bash +sudo apt install docker.io bash qemu-user-static ``` To run the default test stage, diff --git a/ci/test/00_setup_env_s390x.sh b/ci/test/00_setup_env_s390x.sh index 05c062cb56de..5d95535daf92 100755 --- a/ci/test/00_setup_env_s390x.sh +++ b/ci/test/00_setup_env_s390x.sh @@ -22,4 +22,4 @@ export RUN_UNIT_TESTS=true export TEST_RUNNER_EXTRA="--exclude rpc_bind,feature_bind_extra" # Excluded for now, see https://github.com/bitcoin/bitcoin/issues/17765#issuecomment-602068547 export RUN_FUNCTIONAL_TESTS=true export GOAL="install" -export BITCOIN_CONFIG="--enable-reduce-exports --disable-gui-tests --with-boost-process" # GUI tests disabled for now, see https://github.com/bitcoin/bitcoin/issues/23730 +export BITCOIN_CONFIG="--enable-reduce-exports --with-boost-process" diff --git a/configure.ac b/configure.ac index 11f4fe2c215b..6bf3a3205718 100644 --- a/configure.ac +++ b/configure.ac @@ -378,6 +378,9 @@ if test "$enable_debug" = "yes"; then AX_CHECK_PREPROC_FLAG([-DABORT_ON_FAILED_ASSUME], [DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -DABORT_ON_FAILED_ASSUME"], [], [$CXXFLAG_WERROR]) AX_CHECK_COMPILE_FLAG([-ftrapv], [DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -ftrapv"], [], [$CXXFLAG_WERROR]) else + dnl If not debugging, enable more aggressive optimizations for sphlib sources + AX_CHECK_COMPILE_FLAG([-O3], [SPHLIB_CFLAGS="$SPHLIB_CFLAGS -O3"], [], [$CXXFLAG_WERROR]) + # We always enable at at least -g1 debug info to support proper stacktraces in crash infos # Stacktraces will be suboptimal due to optimization, but better than nothing. Also, -fno-omit-frame-pointer # mitigates this a little bit @@ -1874,6 +1877,7 @@ AC_SUBST(PIC_FLAGS) AC_SUBST(PIE_FLAGS) AC_SUBST(SANITIZER_CXXFLAGS) AC_SUBST(SANITIZER_LDFLAGS) +AC_SUBST(SPHLIB_CFLAGS) AC_SUBST(SSE42_CXXFLAGS) AC_SUBST(SSE41_CXXFLAGS) AC_SUBST(CLMUL_CXXFLAGS) diff --git a/contrib/debian/copyright b/contrib/debian/copyright index 10a68e74ac75..af24c9c258e5 100644 --- a/contrib/debian/copyright +++ b/contrib/debian/copyright @@ -7,10 +7,10 @@ Files: * Copyright: 2009-2025, Bitcoin Core Developers, 2019-2025, Dash Core Developers License: Expat -Comment: The Bitcoin Core Developers encompasses the current developers listed on bitcoin.org, - as well as the numerous contributors to the project. The Dash Core Developers - encompasses the current developers listed on https://www.dash.org/team/, as well as - the numerous contributors to the project. +Comment: The Bitcoin Core Developers encompasses all contributors to the + project, listed in the release notes or the git log. The Dash Core + Developers encompasses all contributors to the project, listed in the + release notes or the git log. Files: debian/* Copyright: 2010-2011, Jonas Smedegaard diff --git a/contrib/devtools/copyright_header.py b/contrib/devtools/copyright_header.py index 540e0fd5713c..c18c156d5f5e 100755 --- a/contrib/devtools/copyright_header.py +++ b/contrib/devtools/copyright_header.py @@ -25,7 +25,6 @@ 'src/ctpl_stl.h', 'src/test/fuzz/FuzzedDataProvider.h', 'src/tinyformat.h', - 'src/util/expected.h', 'src/wallet/bip39.cpp', 'src/wallet/bip39.h', 'src/wallet/bip39_english.h', diff --git a/depends/funcs.mk b/depends/funcs.mk index aeaff2288b1b..3c0dc7a7fcab 100644 --- a/depends/funcs.mk +++ b/depends/funcs.mk @@ -138,9 +138,9 @@ $(1)_config_env+=PKG_CONFIG_LIBDIR=$($($(1)_type)_prefix)/lib/pkgconfig $(1)_config_env+=PKG_CONFIG_PATH=$($($(1)_type)_prefix)/share/pkgconfig $(1)_config_env+=PKG_CONFIG_SYSROOT_DIR=/ $(1)_config_env+=CMAKE_MODULE_PATH=$($($(1)_type)_prefix)/lib/cmake -$(1)_config_env+=PATH=$(build_prefix)/bin:$(PATH) -$(1)_build_env+=PATH=$(build_prefix)/bin:$(PATH) -$(1)_stage_env+=PATH=$(build_prefix)/bin:$(PATH) +$(1)_config_env+=PATH="$(build_prefix)/bin:$(PATH)" +$(1)_build_env+=PATH="$(build_prefix)/bin:$(PATH)" +$(1)_stage_env+=PATH="$(build_prefix)/bin:$(PATH)" # Setting a --build type that differs from --host will explicitly enable # cross-compilation mode. Note that --build defaults to the output of diff --git a/doc/build-openbsd.md b/doc/build-openbsd.md index c80ecdaf83fd..afcc43355dd5 100644 --- a/doc/build-openbsd.md +++ b/doc/build-openbsd.md @@ -1,6 +1,6 @@ OpenBSD build guide ====================== -(updated for OpenBSD 6.7) +**Updated for OpenBSD [7.4](https://www.openbsd.org/74.html)** This guide describes how to build dashd, dash-qt, and command-line utilities on OpenBSD. @@ -40,6 +40,8 @@ from ports, for the same reason as boost above (g++/libstd++ incompatibility). If you have to build it yourself, you can use [the installation script included in contrib/](/contrib/install_db4.sh) like so: +Refer to [depends/README.md](/depends/README.md) for detailed instructions. + ```bash ./contrib/install_db4.sh `pwd` CC=cc CXX=c++ ``` diff --git a/doc/build-unix.md b/doc/build-unix.md index a5208103b2fb..5c81e83dfc94 100644 --- a/doc/build-unix.md +++ b/doc/build-unix.md @@ -250,52 +250,6 @@ Otherwise, you can build Dash Core from self-compiled [depends](/depends/README. **Note**: You only need Berkeley DB if the wallet is enabled (see [*Disable-wallet mode*](#disable-wallet-mode)). -Security --------- -To help make your Dash Core installation more secure by making certain attacks impossible to -exploit even if a vulnerability is found, binaries are hardened by default. -This can be disabled with: - -Hardening Flags: - - ./configure --enable-hardening - ./configure --disable-hardening - - -Hardening enables the following features: -* _Position Independent Executable_: Build position independent code to take advantage of Address Space Layout Randomization - offered by some kernels. Attackers who can cause execution of code at an arbitrary memory - location are thwarted if they don't know where anything useful is located. - The stack and heap are randomly located by default, but this allows the code section to be - randomly located as well. - - On an AMD64 processor where a library was not compiled with -fPIC, this will cause an error - such as: "relocation R_X86_64_32 against `......' can not be used when making a shared object;" - - To test that you have built PIE executable, install scanelf, part of paxutils, and use: - - scanelf -e ./dashd - - The output should contain: - - TYPE - ET_DYN - -* _Non-executable Stack_: If the stack is executable then trivial stack-based buffer overflow exploits are possible if - vulnerable buffers are found. By default, Dash Core should be built with a non-executable stack, - but if one of the libraries it uses asks for an executable stack or someone makes a mistake - and uses a compiler extension which requires an executable stack, it will silently build an - executable without the non-executable stack protection. - - To verify that the stack is non-executable after compiling use: - `scanelf -e ./dashd` - - The output should contain: - STK/REL/PTL - RW- R-- RW- - - The STK RW- means that the stack is readable and writeable but not executable. - Disable-wallet mode -------------------- When the intention is to run only a P2P node without a wallet, Dash Core may be compiled in diff --git a/doc/developer-notes.md b/doc/developer-notes.md index 9824956fe908..67f377b200e1 100644 --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -110,6 +110,8 @@ code. - `nullptr` is preferred over `NULL` or `(void*)0`. - `static_assert` is preferred over `assert` where possible. Generally; compile-time checking is preferred over run-time checking. - Align pointers and references to the left i.e. use `type& var` and not `type &var`. + - Prefer [`list initialization ({})`](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-list) where possible. + For example `int x{0};` instead of `int x = 0;` or `int x(0);` For function calls a namespace should be specified explicitly, unless such functions have been declared within it. Otherwise, [argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl), also known as ADL, could be @@ -135,7 +137,7 @@ int main() Block style example: ```c++ -int g_count = 0; +int g_count{0}; namespace foo { class Class @@ -147,7 +149,7 @@ public: { // Comment summarising what this section of code does for (int i = 0; i < n; ++i) { - int total_sum = 0; + int total_sum{0}; // When something fails, return early if (!Something()) return false; ... @@ -946,7 +948,9 @@ Threads and synchronization - Consistently use [Clang Thread Safety Analysis](https://clang.llvm.org/docs/ThreadSafetyAnalysis.html) annotations to get compile-time warnings about potential race conditions in code. Combine annotations in function declarations with - run-time asserts in function definitions: + run-time asserts in function definitions (`AssertLockNotHeld()` can be omitted if `LOCK()` is + called unconditionally after it because `LOCK()` does the same check as + `AssertLockNotHeld()` internally, for non-recursive mutexes): ```C++ // txmempool.h diff --git a/doc/policy/README.md b/doc/policy/README.md index a24298616d1a..1aa4f3847cd4 100644 --- a/doc/policy/README.md +++ b/doc/policy/README.md @@ -2,8 +2,8 @@ **Policy** (Mempool or Transaction Relay Policy) is the node's set of validation rules, in addition to consensus, enforced for unconfirmed transactions before submitting them to the mempool. These -rules are local to the node and configurable (e.g. `-minrelaytxfee`, `-limitancestorsize`, -`-incrementalRelayFee`). Policy may include restrictions on the transaction itself, the transaction +rules are local to the node and configurable, see "Node relay options" when running `-help`. +Policy may include restrictions on the transaction itself, the transaction in relation to the current chain tip, and the transaction in relation to the node's mempool contents. Policy is *not* applied to transactions in blocks. diff --git a/doc/reduce-memory.md b/doc/reduce-memory.md index 980c2b06ab9a..f966eb65e245 100644 --- a/doc/reduce-memory.md +++ b/doc/reduce-memory.md @@ -43,7 +43,7 @@ threads take up 8MiB for the thread stack on a 64-bit system, and 4MiB in a ## Linux specific -By default, glibc's implementation of `malloc` may use more than one arena. This is known to cause excessive memory usage in some scenarios. To avoid this, make a script that sets `MALLOC_ARENA_MAX` before starting dashd: +By default, glibc will create up to two heap arenas per core. This is known to cause excessive memory usage in some scenarios. To avoid this make a script that sets `MALLOC_ARENA_MAX` before starting dashd: ```bash #!/usr/bin/env bash diff --git a/doc/release-notes-6711.md b/doc/release-notes-6711.md new file mode 100644 index 000000000000..b25545e2a84d --- /dev/null +++ b/doc/release-notes-6711.md @@ -0,0 +1,9 @@ +Updated settings +---------------- + +- BIP157 compact block filters are now automatically enabled for masternodes. This improves privacy for light clients + connecting to masternodes and enables better support for pruned nodes. When a node is configured as a masternode + (via `-masternodeblsprivkey`), both `-peerblockfilters` and `-blockfilterindex=basic` are automatically enabled. + Note that this feature requires approximately 1GB+ of additional disk space for the block filter index. + Regular nodes keep the previous defaults (disabled). Masternodes can still explicitly disable these features + if needed by setting `-peerblockfilters=0` or `-blockfilterindex=0` (#6711). diff --git a/doc/release-notes-6813.md b/doc/release-notes-6813.md new file mode 100644 index 000000000000..c8697813e73d --- /dev/null +++ b/doc/release-notes-6813.md @@ -0,0 +1,4 @@ +EvoDB migration +--------------- + +This release introduces a new internal format for masternode state data to support extended addresses and make future updates of this data seamless. Nodes will automatically migrate to the new format. Downgrading to an earlier version would require a full reindex. #6813 diff --git a/doc/release-notes-6825.md b/doc/release-notes-6825.md new file mode 100644 index 000000000000..a21eb6cc35fa --- /dev/null +++ b/doc/release-notes-6825.md @@ -0,0 +1,19 @@ +# Breaking Change: Block Filter Index Format Update + +## Summary +The compact block filter index format has been updated to include Dash special transaction data, providing feature parity with bloom filters for SPV client support. This change is **incompatible** with existing blockfilter indexes. Existing blockfilter indexes will automatically be re-created with the new version. + +## Technical Details +- The blockfilter index now includes fields from Dash special transactions: + - ProRegTx (masternode registration) + - ProUpServTx (masternode service updates) + - ProUpRegTx (masternode operator updates) + - ProUpRevTx (masternode revocation) + - AssetLockTx (platform credit outputs) +- A versioning system has been added to detect incompatible indexes on startup +- The index version is now 2 (previously unversioned) + +## Benefits +- SPV clients can now detect and track Dash-specific transactions +- Feature parity between bloom filters and compact block filters +- Protection against serving incorrect filter data to light clients diff --git a/src/Makefile.am b/src/Makefile.am index fff2e0bbba19..009f91437a96 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -73,6 +73,8 @@ LIBBITCOIN_WALLET_TOOL=libbitcoin_wallet_tool.a endif LIBBITCOIN_CRYPTO = $(LIBBITCOIN_CRYPTO_BASE) +LIBBITCOIN_CRYPTO_SPH = crypto/libbitcoin_crypto_sph.la +LIBBITCOIN_CRYPTO += $(LIBBITCOIN_CRYPTO_SPH) if ENABLE_SSE41 LIBBITCOIN_CRYPTO_SSE41 = crypto/libbitcoin_crypto_sse41.la LIBBITCOIN_CRYPTO += $(LIBBITCOIN_CRYPTO_SSE41) @@ -200,6 +202,7 @@ BITCOIN_CORE_H = \ evo/simplifiedmns.h \ evo/smldiff.h \ evo/specialtx.h \ + evo/specialtx_filter.h \ evo/specialtxman.h \ dsnotificationinterface.h \ governance/governance.h \ @@ -357,7 +360,6 @@ BITCOIN_CORE_H = \ util/enumerate.h \ util/epochguard.h \ util/error.h \ - util/expected.h \ util/fastrange.h \ util/fees.h \ util/golombrice.h \ @@ -480,6 +482,7 @@ libbitcoin_node_a_SOURCES = \ evo/simplifiedmns.cpp \ evo/smldiff.cpp \ evo/specialtx.cpp \ + evo/specialtx_filter.cpp \ evo/specialtxman.cpp \ flatfile.cpp \ governance/classes.cpp \ @@ -718,8 +721,16 @@ crypto_libbitcoin_crypto_avx2_la_CXXFLAGS += $(AVX2_CXXFLAGS) crypto_libbitcoin_crypto_avx2_la_CPPFLAGS += -DENABLE_AVX2 crypto_libbitcoin_crypto_avx2_la_SOURCES = crypto/sha256_avx2.cpp -# x11 -crypto_libbitcoin_crypto_base_la_SOURCES += \ +# See explanation for -static in crypto_libbitcoin_crypto_base_la's LDFLAGS and +# CXXFLAGS above +crypto_libbitcoin_crypto_sph_la_LDFLAGS = $(AM_LDFLAGS) -static +crypto_libbitcoin_crypto_sph_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -static +crypto_libbitcoin_crypto_sph_la_CPPFLAGS = $(AM_CPPFLAGS) +crypto_libbitcoin_crypto_sph_la_CFLAGS = $(SPHLIB_CFLAGS) +crypto_libbitcoin_crypto_sph_la_CPPFLAGS += \ + -DSPH_SMALL_FOOTPRINT_CUBEHASH=1 \ + -DSPH_SMALL_FOOTPRINT_JH=1 +crypto_libbitcoin_crypto_sph_la_SOURCES = \ crypto/x11/aes_helper.c \ crypto/x11/blake.c \ crypto/x11/bmw.c \ @@ -1009,7 +1020,7 @@ endif # dashconsensus library # if BUILD_BITCOIN_LIBS include_HEADERS = script/bitcoinconsensus.h -libdashconsensus_la_SOURCES = support/cleanse.cpp $(crypto_libbitcoin_crypto_base_la_SOURCES) $(libbitcoin_consensus_a_SOURCES) +libdashconsensus_la_SOURCES = support/cleanse.cpp $(crypto_libbitcoin_crypto_base_la_SOURCES) $(crypto_libbitcoin_crypto_sph_la_SOURCES) $(libbitcoin_consensus_a_SOURCES) libdashconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS) libdashconsensus_la_LIBADD = $(LIBDASHBLS) $(LIBSECP256K1) $(GMP_LIBS) diff --git a/src/Makefile.bench.include b/src/Makefile.bench.include index a6ffeb1c2107..1169d922984c 100644 --- a/src/Makefile.bench.include +++ b/src/Makefile.bench.include @@ -43,6 +43,7 @@ bench_bench_dash_SOURCES = \ bench/nanobench.cpp \ bench/peer_eviction.cpp \ bench/pool.cpp \ + bench/pow_hash.cpp \ bench/rpc_blockchain.cpp \ bench/rpc_mempool.cpp \ bench/strencodings.cpp \ diff --git a/src/Makefile.test.include b/src/Makefile.test.include index 8d91aa3e548e..b05116eaee52 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -120,6 +120,10 @@ BITCOIN_TESTS =\ test/fs_tests.cpp \ test/getarg_tests.cpp \ test/governance_validators_tests.cpp \ + test/coinjoin_inouts_tests.cpp \ + test/coinjoin_dstxmanager_tests.cpp \ + test/coinjoin_basemanager_tests.cpp \ + test/coinjoin_queue_tests.cpp \ test/hash_tests.cpp \ test/httpserver_tests.cpp \ test/i2p_tests.cpp \ @@ -158,6 +162,7 @@ BITCOIN_TESTS =\ test/random_tests.cpp \ test/ratecheck_tests.cpp \ test/rest_tests.cpp \ + test/result_tests.cpp \ test/reverselock_tests.cpp \ test/rpc_tests.cpp \ test/sanity_tests.cpp \ @@ -210,6 +215,7 @@ BITCOIN_TESTS += \ wallet/test/wallet_crypto_tests.cpp \ wallet/test/wallet_transaction_tests.cpp \ wallet/test/coinselector_tests.cpp \ + wallet/test/availablecoins_tests.cpp \ wallet/test/init_tests.cpp \ wallet/test/ismine_tests.cpp \ wallet/test/scriptpubkeyman_tests.cpp diff --git a/src/bench/coin_selection.cpp b/src/bench/coin_selection.cpp index 689524a716ea..7b44f5425bdc 100644 --- a/src/bench/coin_selection.cpp +++ b/src/bench/coin_selection.cpp @@ -54,10 +54,10 @@ static void CoinSelection(benchmark::Bench& bench) addCoin(3 * COIN, wallet, wtxs); // Create coins - std::vector coins; + wallet::CoinsResult available_coins; for (const auto& wtx : wtxs) { const auto txout = wtx->tx->vout.at(0); - coins.emplace_back(COutPoint(wtx->GetHash(), 0), txout, /*depth=*/6 * 24, CalculateMaximumSignedInputSize(txout, &wallet, /*coin_control=*/nullptr), /*spendable=*/true, /*solvable=*/true, /*safe=*/true, wtx->GetTxTime(), /*from_me=*/true, /*fees=*/ 0); + available_coins.legacy.emplace_back(COutPoint(wtx->GetHash(), 0), txout, /*depth=*/6 * 24, CalculateMaximumSignedInputSize(txout, &wallet, /*coin_control=*/nullptr), /*spendable=*/true, /*solvable=*/true, /*safe=*/true, wtx->GetTxTime(), /*from_me=*/true, /*fees=*/ 0); } const CoinEligibilityFilter filter_standard(1, 6, 0); FastRandomContext rand{}; @@ -73,7 +73,7 @@ static void CoinSelection(benchmark::Bench& bench) /*avoid_partial=*/ false, }; bench.run([&] { - auto result = AttemptSelection(wallet, 1003 * COIN, filter_standard, coins, coin_selection_params); + auto result = AttemptSelection(wallet, 1003 * COIN, filter_standard, available_coins, coin_selection_params, /*allow_mixed_output_types=*/true); assert(result); assert(result->GetSelectedValue() == 1003 * COIN); assert(result->GetInputSet().size() == 2); diff --git a/src/bench/crypto_hash.cpp b/src/bench/crypto_hash.cpp index d184bdc8bf8b..9db0703c6d1e 100644 --- a/src/bench/crypto_hash.cpp +++ b/src/bench/crypto_hash.cpp @@ -295,15 +295,6 @@ static void DSHA256_1M(benchmark::Bench& bench) }); } -static void X11_1M(benchmark::Bench& bench) -{ - uint256 hash; - std::vector in(BUFFER_SIZE,0); - bench.batch(in.size()).unit("byte").run([&] { - hash = HashX11(in.begin(), in.end()); - }); -} - /* Hash different number of bytes via DSHA256 */ static void DSHA256_0032b_single(benchmark::Bench& bench) { @@ -359,63 +350,7 @@ static void DSHA256_2048b_single(benchmark::Bench& bench) }); } -/* Hash different number of bytes via X11 */ -static void X11_0032b_single(benchmark::Bench& bench) -{ - uint256 hash; - std::vector in(32,0); - bench.batch(in.size()).unit("byte").run([&] { - hash = HashX11(in.begin(), in.end()); - }); -} - -static void X11_0080b_single(benchmark::Bench& bench) -{ - uint256 hash; - std::vector in(80,0); - bench.batch(in.size()).unit("byte").run([&] { - hash = HashX11(in.begin(), in.end()); - }); -} - -static void X11_0128b_single(benchmark::Bench& bench) -{ - uint256 hash; - std::vector in(128,0); - bench.batch(in.size()).unit("byte").run([&] { - hash = HashX11(in.begin(), in.end()); - }); -} - -static void X11_0512b_single(benchmark::Bench& bench) -{ - uint256 hash; - std::vector in(512,0); - bench.batch(in.size()).unit("byte").run([&] { - hash = HashX11(in.begin(), in.end()); - }); -} - -static void X11_1024b_single(benchmark::Bench& bench) -{ - uint256 hash; - std::vector in(1024,0); - bench.batch(in.size()).unit("byte").run([&] { - hash = HashX11(in.begin(), in.end()); - }); -} - -static void X11_2048b_single(benchmark::Bench& bench) -{ - uint256 hash; - std::vector in(2048,0); - bench.batch(in.size()).unit("byte").run([&] { - hash = HashX11(in.begin(), in.end()); - }); -} - BENCHMARK(DSHA256_1M); -BENCHMARK(X11_1M); BENCHMARK(DSHA256_0032b_single); BENCHMARK(DSHA256_0080b_single); @@ -423,10 +358,3 @@ BENCHMARK(DSHA256_0128b_single); BENCHMARK(DSHA256_0512b_single); BENCHMARK(DSHA256_1024b_single); BENCHMARK(DSHA256_2048b_single); - -BENCHMARK(X11_0032b_single); -BENCHMARK(X11_0080b_single); -BENCHMARK(X11_0128b_single); -BENCHMARK(X11_0512b_single); -BENCHMARK(X11_1024b_single); -BENCHMARK(X11_2048b_single); diff --git a/src/bench/pow_hash.cpp b/src/bench/pow_hash.cpp new file mode 100644 index 000000000000..d5f9c17f9808 --- /dev/null +++ b/src/bench/pow_hash.cpp @@ -0,0 +1,359 @@ +// Copyright (c) 2025 The Dash Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { +//! Bytes to hash per iteration +static constexpr size_t BUFFER_SIZE{1000*1000}; +//! Bytes required to represent 512-bit unsigned integers (uint512) +static constexpr size_t OUTPUT_SIZE{64}; + +inline void Pow_X11(benchmark::Bench& bench, const size_t bytes) +{ + uint256 hash{}; + std::vector in(bytes, 0); + bench.batch(in.size()).unit("byte").run([&] { + hash = HashX11(in.begin(), in.end()); + }); +} + +inline void Pow_Blake512(benchmark::Bench& bench, const size_t bytes) +{ + sph_blake512_context ctx; + uint8_t hash[OUTPUT_SIZE]; + std::vector in(bytes, 0); + bench.batch(in.size()).unit("byte").run([&] { + sph_blake512_init(&ctx); + sph_blake512(&ctx, in.data(), in.size()); + sph_blake512_close(&ctx, &hash); + }); +} + +inline void Pow_Bmw512(benchmark::Bench& bench, const size_t bytes) +{ + sph_bmw512_context ctx; + uint8_t hash[OUTPUT_SIZE]; + std::vector in(bytes, 0); + bench.batch(in.size()).unit("byte").run([&] { + sph_bmw512_init(&ctx); + sph_bmw512(&ctx, in.data(), in.size()); + sph_bmw512_close(&ctx, &hash); + }); +} + +inline void Pow_Cubehash512(benchmark::Bench& bench, const size_t bytes) +{ + sph_cubehash512_context ctx; + uint8_t hash[OUTPUT_SIZE]; + std::vector in(bytes, 0); + bench.batch(in.size()).unit("byte").run([&] { + sph_cubehash512_init(&ctx); + sph_cubehash512(&ctx, in.data(), in.size()); + sph_cubehash512_close(&ctx, &hash); + }); +} + +inline void Pow_Echo512(benchmark::Bench& bench, const size_t bytes) +{ + sph_echo512_context ctx; + uint8_t hash[OUTPUT_SIZE]; + std::vector in(bytes, 0); + bench.batch(in.size()).unit("byte").run([&] { + sph_echo512_init(&ctx); + sph_echo512(&ctx, in.data(), in.size()); + sph_echo512_close(&ctx, &hash); + }); +} + +inline void Pow_Groestl512(benchmark::Bench& bench, const size_t bytes) +{ + sph_groestl512_context ctx; + uint8_t hash[OUTPUT_SIZE]; + std::vector in(bytes, 0); + bench.batch(in.size()).unit("byte").run([&] { + sph_groestl512_init(&ctx); + sph_groestl512(&ctx, in.data(), in.size()); + sph_groestl512_close(&ctx, &hash); + }); +} + +inline void Pow_Jh512(benchmark::Bench& bench, const size_t bytes) +{ + sph_jh512_context ctx; + uint8_t hash[OUTPUT_SIZE]; + std::vector in(bytes, 0); + bench.batch(in.size()).unit("byte").run([&] { + sph_jh512_init(&ctx); + sph_jh512(&ctx, in.data(), in.size()); + sph_jh512_close(&ctx, &hash); + }); +} + +inline void Pow_Keccak512(benchmark::Bench& bench, const size_t bytes) +{ + sph_keccak512_context ctx; + uint8_t hash[OUTPUT_SIZE]; + std::vector in(bytes, 0); + bench.batch(in.size()).unit("byte").run([&] { + sph_keccak512_init(&ctx); + sph_keccak512(&ctx, in.data(), in.size()); + sph_keccak512_close(&ctx, &hash); + }); +} + +inline void Pow_Luffa512(benchmark::Bench& bench, const size_t bytes) +{ + sph_luffa512_context ctx; + uint8_t hash[OUTPUT_SIZE]; + std::vector in(bytes, 0); + bench.batch(in.size()).unit("byte").run([&] { + sph_luffa512_init(&ctx); + sph_luffa512(&ctx, in.data(), in.size()); + sph_luffa512_close(&ctx, &hash); + }); +} + +inline void Pow_Shavite512(benchmark::Bench& bench, const size_t bytes) +{ + sph_shavite512_context ctx; + uint8_t hash[OUTPUT_SIZE]; + std::vector in(bytes, 0); + bench.batch(in.size()).unit("byte").run([&] { + sph_shavite512_init(&ctx); + sph_shavite512(&ctx, in.data(), in.size()); + sph_shavite512_close(&ctx, &hash); + }); +} + +inline void Pow_Simd512(benchmark::Bench& bench, const size_t bytes) +{ + sph_simd512_context ctx; + uint8_t hash[OUTPUT_SIZE]; + std::vector in(bytes, 0); + bench.batch(in.size()).unit("byte").run([&] { + sph_simd512_init(&ctx); + sph_simd512(&ctx, in.data(), in.size()); + sph_simd512_close(&ctx, &hash); + }); +} + +inline void Pow_Skein512(benchmark::Bench& bench, const size_t bytes) +{ + sph_skein512_context ctx; + uint8_t hash[OUTPUT_SIZE]; + std::vector in(bytes, 0); + bench.batch(in.size()).unit("byte").run([&] { + sph_skein512_init(&ctx); + sph_skein512(&ctx, in.data(), in.size()); + sph_skein512_close(&ctx, &hash); + }); +} +} // anonymous namespace + +static void Pow_X11_0032b(benchmark::Bench& bench) { return Pow_X11(bench, 32); } +static void Pow_X11_0080b(benchmark::Bench& bench) { return Pow_X11(bench, 80); } +static void Pow_X11_0128b(benchmark::Bench& bench) { return Pow_X11(bench, 128); } +static void Pow_X11_0512b(benchmark::Bench& bench) { return Pow_X11(bench, 512); } +static void Pow_X11_1024b(benchmark::Bench& bench) { return Pow_X11(bench, 1024); } +static void Pow_X11_2048b(benchmark::Bench& bench) { return Pow_X11(bench, 2048); } +static void Pow_X11_1M(benchmark::Bench& bench) { return Pow_X11(bench, BUFFER_SIZE); } + +static void Pow_Blake512_0032b(benchmark::Bench& bench) { return Pow_Blake512(bench, 32); } +static void Pow_Blake512_0080b(benchmark::Bench& bench) { return Pow_Blake512(bench, 80); } +static void Pow_Blake512_0128b(benchmark::Bench& bench) { return Pow_Blake512(bench, 128); } +static void Pow_Blake512_0512b(benchmark::Bench& bench) { return Pow_Blake512(bench, 512); } +static void Pow_Blake512_1024b(benchmark::Bench& bench) { return Pow_Blake512(bench, 1024); } +static void Pow_Blake512_2048b(benchmark::Bench& bench) { return Pow_Blake512(bench, 2048); } +static void Pow_Blake512_1M(benchmark::Bench& bench) { return Pow_Blake512(bench, BUFFER_SIZE); } + +static void Pow_Bmw512_0032b(benchmark::Bench& bench) { return Pow_Bmw512(bench, 32); } +static void Pow_Bmw512_0080b(benchmark::Bench& bench) { return Pow_Bmw512(bench, 80); } +static void Pow_Bmw512_0128b(benchmark::Bench& bench) { return Pow_Bmw512(bench, 128); } +static void Pow_Bmw512_0512b(benchmark::Bench& bench) { return Pow_Bmw512(bench, 512); } +static void Pow_Bmw512_1024b(benchmark::Bench& bench) { return Pow_Bmw512(bench, 1024); } +static void Pow_Bmw512_2048b(benchmark::Bench& bench) { return Pow_Bmw512(bench, 2048); } +static void Pow_Bmw512_1M(benchmark::Bench& bench) { return Pow_Bmw512(bench, BUFFER_SIZE); } + +static void Pow_Cubehash512_0032b(benchmark::Bench& bench) { return Pow_Cubehash512(bench, 32); } +static void Pow_Cubehash512_0080b(benchmark::Bench& bench) { return Pow_Cubehash512(bench, 80); } +static void Pow_Cubehash512_0128b(benchmark::Bench& bench) { return Pow_Cubehash512(bench, 128); } +static void Pow_Cubehash512_0512b(benchmark::Bench& bench) { return Pow_Cubehash512(bench, 512); } +static void Pow_Cubehash512_1024b(benchmark::Bench& bench) { return Pow_Cubehash512(bench, 1024); } +static void Pow_Cubehash512_2048b(benchmark::Bench& bench) { return Pow_Cubehash512(bench, 2048); } +static void Pow_Cubehash512_1M(benchmark::Bench& bench) { return Pow_Cubehash512(bench, BUFFER_SIZE); } + +static void Pow_Echo512_0032b(benchmark::Bench& bench) { return Pow_Echo512(bench, 32); } +static void Pow_Echo512_0080b(benchmark::Bench& bench) { return Pow_Echo512(bench, 80); } +static void Pow_Echo512_0128b(benchmark::Bench& bench) { return Pow_Echo512(bench, 128); } +static void Pow_Echo512_0512b(benchmark::Bench& bench) { return Pow_Echo512(bench, 512); } +static void Pow_Echo512_1024b(benchmark::Bench& bench) { return Pow_Echo512(bench, 1024); } +static void Pow_Echo512_2048b(benchmark::Bench& bench) { return Pow_Echo512(bench, 2048); } +static void Pow_Echo512_1M(benchmark::Bench& bench) { return Pow_Echo512(bench, BUFFER_SIZE); } + +static void Pow_Groestl512_0032b(benchmark::Bench& bench) { return Pow_Groestl512(bench, 32); } +static void Pow_Groestl512_0080b(benchmark::Bench& bench) { return Pow_Groestl512(bench, 80); } +static void Pow_Groestl512_0128b(benchmark::Bench& bench) { return Pow_Groestl512(bench, 128); } +static void Pow_Groestl512_0512b(benchmark::Bench& bench) { return Pow_Groestl512(bench, 512); } +static void Pow_Groestl512_1024b(benchmark::Bench& bench) { return Pow_Groestl512(bench, 1024); } +static void Pow_Groestl512_2048b(benchmark::Bench& bench) { return Pow_Groestl512(bench, 2048); } +static void Pow_Groestl512_1M(benchmark::Bench& bench) { return Pow_Groestl512(bench, BUFFER_SIZE); } + +static void Pow_Jh512_0032b(benchmark::Bench& bench) { return Pow_Jh512(bench, 32); } +static void Pow_Jh512_0080b(benchmark::Bench& bench) { return Pow_Jh512(bench, 80); } +static void Pow_Jh512_0128b(benchmark::Bench& bench) { return Pow_Jh512(bench, 128); } +static void Pow_Jh512_0512b(benchmark::Bench& bench) { return Pow_Jh512(bench, 512); } +static void Pow_Jh512_1024b(benchmark::Bench& bench) { return Pow_Jh512(bench, 1024); } +static void Pow_Jh512_2048b(benchmark::Bench& bench) { return Pow_Jh512(bench, 2048); } +static void Pow_Jh512_1M(benchmark::Bench& bench) { return Pow_Jh512(bench, BUFFER_SIZE); } + +static void Pow_Keccak512_0032b(benchmark::Bench& bench) { return Pow_Keccak512(bench, 32); } +static void Pow_Keccak512_0080b(benchmark::Bench& bench) { return Pow_Keccak512(bench, 80); } +static void Pow_Keccak512_0128b(benchmark::Bench& bench) { return Pow_Keccak512(bench, 128); } +static void Pow_Keccak512_0512b(benchmark::Bench& bench) { return Pow_Keccak512(bench, 512); } +static void Pow_Keccak512_1024b(benchmark::Bench& bench) { return Pow_Keccak512(bench, 1024); } +static void Pow_Keccak512_2048b(benchmark::Bench& bench) { return Pow_Keccak512(bench, 2048); } +static void Pow_Keccak512_1M(benchmark::Bench& bench) { return Pow_Keccak512(bench, BUFFER_SIZE); } + +static void Pow_Luffa512_0032b(benchmark::Bench& bench) { return Pow_Luffa512(bench, 32); } +static void Pow_Luffa512_0080b(benchmark::Bench& bench) { return Pow_Luffa512(bench, 80); } +static void Pow_Luffa512_0128b(benchmark::Bench& bench) { return Pow_Luffa512(bench, 128); } +static void Pow_Luffa512_0512b(benchmark::Bench& bench) { return Pow_Luffa512(bench, 512); } +static void Pow_Luffa512_1024b(benchmark::Bench& bench) { return Pow_Luffa512(bench, 1024); } +static void Pow_Luffa512_2048b(benchmark::Bench& bench) { return Pow_Luffa512(bench, 2048); } +static void Pow_Luffa512_1M(benchmark::Bench& bench) { return Pow_Luffa512(bench, BUFFER_SIZE); } + +static void Pow_Shavite512_0032b(benchmark::Bench& bench) { return Pow_Shavite512(bench, 32); } +static void Pow_Shavite512_0080b(benchmark::Bench& bench) { return Pow_Shavite512(bench, 80); } +static void Pow_Shavite512_0128b(benchmark::Bench& bench) { return Pow_Shavite512(bench, 128); } +static void Pow_Shavite512_0512b(benchmark::Bench& bench) { return Pow_Shavite512(bench, 512); } +static void Pow_Shavite512_1024b(benchmark::Bench& bench) { return Pow_Shavite512(bench, 1024); } +static void Pow_Shavite512_2048b(benchmark::Bench& bench) { return Pow_Shavite512(bench, 2048); } +static void Pow_Shavite512_1M(benchmark::Bench& bench) { return Pow_Shavite512(bench, BUFFER_SIZE); } + +static void Pow_Simd512_0032b(benchmark::Bench& bench) { return Pow_Simd512(bench, 32); } +static void Pow_Simd512_0080b(benchmark::Bench& bench) { return Pow_Simd512(bench, 80); } +static void Pow_Simd512_0128b(benchmark::Bench& bench) { return Pow_Simd512(bench, 128); } +static void Pow_Simd512_0512b(benchmark::Bench& bench) { return Pow_Simd512(bench, 512); } +static void Pow_Simd512_1024b(benchmark::Bench& bench) { return Pow_Simd512(bench, 1024); } +static void Pow_Simd512_2048b(benchmark::Bench& bench) { return Pow_Simd512(bench, 2048); } +static void Pow_Simd512_1M(benchmark::Bench& bench) { return Pow_Simd512(bench, BUFFER_SIZE); } + +static void Pow_Skein512_0032b(benchmark::Bench& bench) { return Pow_Skein512(bench, 32); } +static void Pow_Skein512_0080b(benchmark::Bench& bench) { return Pow_Skein512(bench, 80); } +static void Pow_Skein512_0128b(benchmark::Bench& bench) { return Pow_Skein512(bench, 128); } +static void Pow_Skein512_0512b(benchmark::Bench& bench) { return Pow_Skein512(bench, 512); } +static void Pow_Skein512_1024b(benchmark::Bench& bench) { return Pow_Skein512(bench, 1024); } +static void Pow_Skein512_2048b(benchmark::Bench& bench) { return Pow_Skein512(bench, 2048); } +static void Pow_Skein512_1M(benchmark::Bench& bench) { return Pow_Skein512(bench, BUFFER_SIZE); } + +BENCHMARK(Pow_X11_0032b); +BENCHMARK(Pow_X11_0080b); +BENCHMARK(Pow_X11_0128b); +BENCHMARK(Pow_X11_0512b); +BENCHMARK(Pow_X11_1024b); +BENCHMARK(Pow_X11_2048b); +BENCHMARK(Pow_X11_1M); + +BENCHMARK(Pow_Blake512_0032b); +BENCHMARK(Pow_Blake512_0080b); +BENCHMARK(Pow_Blake512_0128b); +BENCHMARK(Pow_Blake512_0512b); +BENCHMARK(Pow_Blake512_1024b); +BENCHMARK(Pow_Blake512_2048b); +BENCHMARK(Pow_Blake512_1M); + +BENCHMARK(Pow_Bmw512_0032b); +BENCHMARK(Pow_Bmw512_0080b); +BENCHMARK(Pow_Bmw512_0128b); +BENCHMARK(Pow_Bmw512_0512b); +BENCHMARK(Pow_Bmw512_1024b); +BENCHMARK(Pow_Bmw512_2048b); +BENCHMARK(Pow_Bmw512_1M); + +BENCHMARK(Pow_Cubehash512_0032b); +BENCHMARK(Pow_Cubehash512_0080b); +BENCHMARK(Pow_Cubehash512_0128b); +BENCHMARK(Pow_Cubehash512_0512b); +BENCHMARK(Pow_Cubehash512_1024b); +BENCHMARK(Pow_Cubehash512_2048b); +BENCHMARK(Pow_Cubehash512_1M); + +BENCHMARK(Pow_Echo512_0032b); +BENCHMARK(Pow_Echo512_0080b); +BENCHMARK(Pow_Echo512_0128b); +BENCHMARK(Pow_Echo512_0512b); +BENCHMARK(Pow_Echo512_1024b); +BENCHMARK(Pow_Echo512_2048b); +BENCHMARK(Pow_Echo512_1M); + +BENCHMARK(Pow_Groestl512_0032b); +BENCHMARK(Pow_Groestl512_0080b); +BENCHMARK(Pow_Groestl512_0128b); +BENCHMARK(Pow_Groestl512_0512b); +BENCHMARK(Pow_Groestl512_1024b); +BENCHMARK(Pow_Groestl512_2048b); +BENCHMARK(Pow_Groestl512_1M); + +BENCHMARK(Pow_Jh512_0032b); +BENCHMARK(Pow_Jh512_0080b); +BENCHMARK(Pow_Jh512_0128b); +BENCHMARK(Pow_Jh512_0512b); +BENCHMARK(Pow_Jh512_1024b); +BENCHMARK(Pow_Jh512_2048b); +BENCHMARK(Pow_Jh512_1M); + +BENCHMARK(Pow_Keccak512_0032b); +BENCHMARK(Pow_Keccak512_0080b); +BENCHMARK(Pow_Keccak512_0128b); +BENCHMARK(Pow_Keccak512_0512b); +BENCHMARK(Pow_Keccak512_1024b); +BENCHMARK(Pow_Keccak512_2048b); +BENCHMARK(Pow_Keccak512_1M); + +BENCHMARK(Pow_Luffa512_0032b); +BENCHMARK(Pow_Luffa512_0080b); +BENCHMARK(Pow_Luffa512_0128b); +BENCHMARK(Pow_Luffa512_0512b); +BENCHMARK(Pow_Luffa512_1024b); +BENCHMARK(Pow_Luffa512_2048b); +BENCHMARK(Pow_Luffa512_1M); + +BENCHMARK(Pow_Shavite512_0032b); +BENCHMARK(Pow_Shavite512_0080b); +BENCHMARK(Pow_Shavite512_0128b); +BENCHMARK(Pow_Shavite512_0512b); +BENCHMARK(Pow_Shavite512_1024b); +BENCHMARK(Pow_Shavite512_2048b); +BENCHMARK(Pow_Shavite512_1M); + +BENCHMARK(Pow_Simd512_0032b); +BENCHMARK(Pow_Simd512_0080b); +BENCHMARK(Pow_Simd512_0128b); +BENCHMARK(Pow_Simd512_0512b); +BENCHMARK(Pow_Simd512_1024b); +BENCHMARK(Pow_Simd512_2048b); +BENCHMARK(Pow_Simd512_1M); + +BENCHMARK(Pow_Skein512_0032b); +BENCHMARK(Pow_Skein512_0080b); +BENCHMARK(Pow_Skein512_0128b); +BENCHMARK(Pow_Skein512_0512b); +BENCHMARK(Pow_Skein512_1024b); +BENCHMARK(Pow_Skein512_2048b); +BENCHMARK(Pow_Skein512_1M); diff --git a/src/bench/wallet_loading.cpp b/src/bench/wallet_loading.cpp index 7fdacc24529a..b01732b615a1 100644 --- a/src/bench/wallet_loading.cpp +++ b/src/bench/wallet_loading.cpp @@ -47,12 +47,8 @@ static void BenchUnloadWallet(std::shared_ptr&& wallet) static void AddTx(CWallet& wallet) { - bilingual_str error; - CTxDestination dest; - wallet.GetNewDestination("", dest, error); - CMutableTransaction mtx; - mtx.vout.push_back({COIN, GetScriptForDestination(dest)}); + mtx.vout.push_back({COIN, GetScriptForDestination(*Assert(wallet.GetNewDestination("")))}); mtx.vin.push_back(CTxIn()); wallet.AddToWallet(MakeTransactionRef(mtx), TxStateInactive{}); diff --git a/src/blockfilter.cpp b/src/blockfilter.cpp index e58c4c2110ed..f4638dabcc0d 100644 --- a/src/blockfilter.cpp +++ b/src/blockfilter.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include