From 2c596914aaf32ce5cf1610aa28c558039744503c Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Fri, 4 Jun 2021 09:50:51 +0200 Subject: [PATCH 01/10] Merge bitcoin/bitcoin#15545: [doc] explain why CheckBlock() is called before AcceptBlock 3d552b0d788a7d3102396b32d0de08e57cbfd297 [doc] explain why CheckBlock() is called before AcceptBlock() (Sjors Provoost) Pull request description: Based on https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2019-February/016697.html and its PDF attachment. ACKs for top commit: MarcoFalke: cr ACK 3d552b0d788a7d3102396b32d0de08e57cbfd297 Tree-SHA512: d1ef39855317853e0e7e051ec6015054d0d227fcdf20281c2c1921056537f1f79044aa1bdd35f46475edd17596fbcae79aeb338c4865b1269a01b158f6cb2ac4 --- src/validation.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index 5bc1e91996a24..fea61f68921fe 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -4259,8 +4259,11 @@ bool ChainstateManager::ProcessNewBlock(const CChainParams& chainparams, const s // Therefore, the following critical section must include the CheckBlock() call as well. LOCK(cs_main); - // Ensure that CheckBlock() passes before calling AcceptBlock, as - // belt-and-suspenders. + // Skipping AcceptBlock() for CheckBlock() failures means that we will never mark a block as invalid if + // CheckBlock() fails. This is protective against consensus failure if there are any unknown forms of block + // malleability that cause CheckBlock() to fail; see e.g. CVE-2012-2459 and + // https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2019-February/016697.html. Because CheckBlock() is + // not very expensive, the anti-DoS benefits of caching failure (of a definitely-invalid block) are not substantial. bool ret = CheckBlock(*pblock, state, chainparams.GetConsensus()); if (ret) { // Store to disk From 283c5592c884f425e4a555777b0c0697c5b5139a Mon Sep 17 00:00:00 2001 From: fanquake Date: Wed, 26 May 2021 19:32:38 +0800 Subject: [PATCH 02/10] Merge bitcoin/bitcoin#18418: wallet: Increase OUTPUT_GROUP_MAX_ENTRIES to 100 e6fe1c37d0a2f8037996dd80619d6c23ec028729 rpc: Improve avoidpartialspends and avoid_reuse documentation (Fabian Jahr) 8f073076b102b77897e5a025ae555baae3d1f671 wallet: Increase OUTPUT_GROUP_MAX_ENTRIES to 100 (Fabian Jahr) Pull request description: Follow-up to #17824. This increases OUTPUT_GROUP_MAX_ENTRIES to 100 which means that OutputGroups will now be up to 100 outputs large, up from previously 10. The main motivation for this change is that during the PR review club on #17824 [several participants signaled](https://bitcoincore.reviews/17824.html#l-339) that 100 might be a better value here. I think fees should be manageable for users but more importantly, users should know what they can expect when using the wallet with this configuration, so I also tried to clarify the documentation on `-avoidpartialspends` and `avoid_reuse` a bit. If there are other additional ways how or docs where users can be made aware of the potential consequences of using these parameters, please let me know. Another small upside is that [there seem to be a high number of batching transactions with 100 and 200 inputs](https://miro.medium.com/max/3628/1*sZ5eaBSbsJsHx-J9iztq2g.png)([source](https://medium.com/@hasufly/an-analysis-of-batching-in-bitcoin-9bdf81a394e0)) giving these transactions a bit of a larger anonymity set, although that is probably a very weak argument. ACKs for top commit: jnewbery: ACK e6fe1c37d0 Xekyo: retACK e6fe1c37d0a2f8037996dd80619d6c23ec028729 rajarshimaitra: tACK `e6fe1c3` achow101: ACK e6fe1c37d0a2f8037996dd80619d6c23ec028729 glozow: code review ACK https://github.com/bitcoin/bitcoin/pull/18418/commits/e6fe1c37d0a2f8037996dd80619d6c23ec028729 Tree-SHA512: 79685c58bafa64ed8303b0ecd616fce50fc9a2b758aa79833e4ad9f15760e09ab60c007bc16ab4cbc4222e644cfd154f1fa494b0f3a5d86faede7af33a6f2826 --- src/wallet/init.cpp | 2 +- src/wallet/rpcwallet.cpp | 2 +- src/wallet/wallet.cpp | 4 +-- test/functional/wallet_avoidreuse.py | 46 ++++++++++++++-------------- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp index 87a8747fbf380..83c160b3ee42c 100644 --- a/src/wallet/init.cpp +++ b/src/wallet/init.cpp @@ -54,7 +54,7 @@ const WalletInitInterface& g_wallet_init_interface = WalletInit(); void WalletInit::AddWalletOptions(ArgsManager& argsman) const { - argsman.AddArg("-avoidpartialspends", strprintf("Group outputs by address, selecting all or none, instead of selecting on a per-output basis. Privacy is improved as an address is only used once (unless someone sends to it after spending from it), but may result in slightly higher fees as suboptimal coin selection may result due to the added limitation (default: %u (always enabled for wallets with \"avoid_reuse\" enabled))", DEFAULT_AVOIDPARTIALSPENDS), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET); + argsman.AddArg("-avoidpartialspends", strprintf("Group outputs by address, selecting many (possibly all) or none, instead of selecting on a per-output basis. Privacy is improved as addresses are mostly swept with fewer transactions and outputs are aggregated in clean change addresses. It may result in higher fees due to less optimal coin selection caused by this added limitation and possibly a larger-than-necessary number of inputs being used. Always enabled for wallets with \"avoid_reuse\" enabled, otherwise default: %u.", DEFAULT_AVOIDPARTIALSPENDS), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET); argsman.AddArg("-createwalletbackups=", strprintf("Number of automatic wallet backups (default: %u)", nWalletBackups), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET); argsman.AddArg("-disablewallet", "Do not load the wallet and disable wallet RPC calls", ArgsManager::ALLOW_ANY, OptionsCategory::WALLET); #if HAVE_SYSTEM diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 9b663d3f2c6dd..e8602e3248031 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -789,7 +789,7 @@ static UniValue getbalance(const JSONRPCRequest& request) {"minconf", RPCArg::Type::NUM, /* default */ "0", "Only include transactions confirmed at least this many times."}, {"addlocked", RPCArg::Type::BOOL, /* default */ "false", "Whether to include transactions locked via InstantSend in the wallet's balance."}, {"include_watchonly", RPCArg::Type::BOOL, /* default */ "true for watch-only wallets, otherwise false", "Also include balance in watch-only addresses (see 'importaddress')"}, - {"avoid_reuse", RPCArg::Type::BOOL, /* default */ "true", "(only available if avoid_reuse wallet flag is set) Do not include balance in dirty outputs; addresses are considered dirty if they have previously been used in a transaction."}, + {"avoid_reuse", RPCArg::Type::BOOL, /* default */ "true", "(only available if avoid_reuse wallet flag is set) Do not include balance in dirty outputs; addresses are considered dirty if they have previously been used in a transaction. If true, this also activates avoidpartialspends, grouping outputs by their addresses."}, }, RPCResult{ RPCResult::Type::STR_AMOUNT, "amount", "The total amount in " + CURRENCY_UNIT + " received for this wallet." diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index bb9520d58cb87..74a4080191668 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -66,7 +66,7 @@ const std::map WALLET_FLAG_CAVEATS{ }, }; -static const size_t OUTPUT_GROUP_MAX_ENTRIES = 10; +static constexpr size_t OUTPUT_GROUP_MAX_ENTRIES{100}; RecursiveMutex cs_wallets; static std::vector> vpwallets GUARDED_BY(cs_wallets); @@ -2871,7 +2871,7 @@ bool CWallet::SelectCoins(const std::vector& vAvailableCoins, const CAm // form groups from remaining coins; note that preset coins will not // automatically have their associated (same address) coins included if (coin_control.m_avoid_partial_spends && vCoins.size() > OUTPUT_GROUP_MAX_ENTRIES) { - // Cases where we have 11+ outputs all pointing to the same destination may result in + // Cases where we have 101+ outputs all pointing to the same destination may result in // privacy leaks as they will potentially be deterministically sorted. We solve that by // explicitly shuffling the outputs before processing Shuffle(vCoins.begin(), vCoins.end(), FastRandomContext()); diff --git a/test/functional/wallet_avoidreuse.py b/test/functional/wallet_avoidreuse.py index bff24f772d0d9..4f4078b747018 100755 --- a/test/functional/wallet_avoidreuse.py +++ b/test/functional/wallet_avoidreuse.py @@ -48,25 +48,25 @@ def count_unspent(node): r["reused"]["supported"] = supports_reused return r -def assert_unspent(node, total_count=None, total_sum=None, reused_supported=None, reused_count=None, reused_sum=None): +def assert_unspent(node, total_count=None, total_sum=None, reused_supported=None, reused_count=None, reused_sum=None, margin=0.001): '''Make assertions about a node's unspent output statistics''' stats = count_unspent(node) if total_count is not None: assert_equal(stats["total"]["count"], total_count) if total_sum is not None: - assert_approx(stats["total"]["sum"], total_sum, 0.001) + assert_approx(stats["total"]["sum"], total_sum, margin) if reused_supported is not None: assert_equal(stats["reused"]["supported"], reused_supported) if reused_count is not None: assert_equal(stats["reused"]["count"], reused_count) if reused_sum is not None: - assert_approx(stats["reused"]["sum"], reused_sum, 0.001) + assert_approx(stats["reused"]["sum"], reused_sum, margin) -def assert_balances(node, mine): +def assert_balances(node, mine, margin=0.001): '''Make assertions about a node's getbalances output''' got = node.getbalances()["mine"] for k,v in mine.items(): - assert_approx(got[k], v, 0.001) + assert_approx(got[k], v, margin) class AvoidReuseTest(BitcoinTestFramework): @@ -290,7 +290,7 @@ def test_getbalances_used(self): ret_addr = self.nodes[0].getnewaddress() # send multiple transactions, reusing one address - for _ in range(11): + for _ in range(101): self.nodes[0].sendtoaddress(new_addr, 1) self.nodes[0].generate(1) @@ -302,14 +302,14 @@ def test_getbalances_used(self): # getbalances and listunspent should show the remaining outputs # in the reused address as used/reused - assert_unspent(self.nodes[1], total_count=2, total_sum=6, reused_count=1, reused_sum=1) - assert_balances(self.nodes[1], mine={"used": 1, "trusted": 5}) + assert_unspent(self.nodes[1], total_count=2, total_sum=96, reused_count=1, reused_sum=1, margin=0.01) + assert_balances(self.nodes[1], mine={"used": 1, "trusted": 95}, margin=0.01) def test_full_destination_group_is_preferred(self): ''' - Test the case where [1] only has 11 outputs of 1 BTC in the same reused + Test the case where [1] only has 101 outputs of 1 BTC in the same reused address and tries to send a small payment of 0.5 BTC. The wallet - should use 10 outputs from the reused address as inputs and not a + should use 100 outputs from the reused address as inputs and not a single 1 BTC input, in order to join several outputs from the reused address. ''' @@ -321,8 +321,8 @@ def test_full_destination_group_is_preferred(self): new_addr = self.nodes[1].getnewaddress() ret_addr = self.nodes[0].getnewaddress() - # Send 11 outputs of 1 BTC to the same, reused address in the wallet - for _ in range(11): + # Send 101 outputs of 1 BTC to the same, reused address in the wallet + for _ in range(101): self.nodes[0].sendtoaddress(new_addr, 1) self.nodes[0].generate(1) @@ -333,14 +333,14 @@ def test_full_destination_group_is_preferred(self): txid = self.nodes[1].sendtoaddress(address=ret_addr, amount=0.5) inputs = self.nodes[1].getrawtransaction(txid, 1)["vin"] - # The transaction should use 10 inputs exactly - assert_equal(len(inputs), 10) + # The transaction should use 100 inputs exactly + assert_equal(len(inputs), 100) def test_all_destination_groups_are_used(self): ''' - Test the case where [1] only has 22 outputs of 1 BTC in the same reused - address and tries to send a payment of 20.5 BTC. The wallet - should use all 22 outputs from the reused address as inputs. + Test the case where [1] only has 202 outputs of 1 BTC in the same reused + address and tries to send a payment of 200.5 BTC. The wallet + should use all 202 outputs from the reused address as inputs. ''' self.log.info("Test that all destination groups are used") @@ -350,20 +350,20 @@ def test_all_destination_groups_are_used(self): new_addr = self.nodes[1].getnewaddress() ret_addr = self.nodes[0].getnewaddress() - # Send 22 outputs of 1 BTC to the same, reused address in the wallet - for _ in range(22): + # Send 202 outputs of 1 BTC to the same, reused address in the wallet + for _ in range(202): self.nodes[0].sendtoaddress(new_addr, 1) self.nodes[0].generate(1) self.sync_all() # Sending a transaction that needs to use the full groups - # of 10 inputs but also the incomplete group of 2 inputs. - txid = self.nodes[1].sendtoaddress(address=ret_addr, amount=20.5) + # of 100 inputs but also the incomplete group of 2 inputs. + txid = self.nodes[1].sendtoaddress(address=ret_addr, amount=200.5) inputs = self.nodes[1].getrawtransaction(txid, 1)["vin"] - # The transaction should use 22 inputs exactly - assert_equal(len(inputs), 22) + # The transaction should use 202 inputs exactly + assert_equal(len(inputs), 202) if __name__ == '__main__': From 637cbc6a00d73c032104d60047effddd209b058e Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Thu, 17 Dec 2020 18:45:40 +0100 Subject: [PATCH 03/10] Merge #20681: doc: Convert depends options list from html to markdown 7b6887e75aec7e0d5c25682c26943073b7a728e5 doc: Convert depends options list from html to markdown (Wladimir J. van der Laan) Pull request description: This makes it easier to read in `less`, which is important for install instructions. Rendered: [before](https://github.com/bitcoin/bitcoin/tree/7ef6b1c51d4a00511a74f6d08abb942a7e433f0b/depends#dependency-options) - [after](https://github.com/bitcoin/bitcoin/blob/d97042406f9123a295e79893839b03b24d228c95/depends/README.md#dependency-options) ACKs for top commit: jonatack: Code review re-ACK 7b6887e75aec7e0d5c25682c26943073b7a728e5 per `git diff d970424 7b6887e` hebasto: re-ACK 7b6887e75aec7e0d5c25682c26943073b7a728e5 Tree-SHA512: 02970b2bb97d2e8fb2d66470f6d70662653fda176bf6f4861742823b361fdc7ab6a2b44143480ac1a525b8d7808b6a068e8b3677dbba16cd783b4cab90470af5 --- depends/README.md | 56 +++++++++++++++++------------------------------ 1 file changed, 20 insertions(+), 36 deletions(-) diff --git a/depends/README.md b/depends/README.md index d60166634ff0e..a2a7b749c25e3 100644 --- a/depends/README.md +++ b/depends/README.md @@ -89,44 +89,28 @@ For linux S390X cross compilation: pkg_add bash gtar ### Dependency Options + The following can be set when running make: `make FOO=bar` -
-
SOURCES_PATH
-
downloaded sources will be placed here
-
BASE_CACHE
-
built packages will be placed here
-
SDK_PATH
-
Path where sdk's can be found (used by macOS)
-
FALLBACK_DOWNLOAD_PATH
-
If a source file can't be fetched, try here before giving up
-
NO_QT
-
Don't download/build/cache qt and its dependencies
-
NO_QR
-
Don't download/build/cache packages needed for enabling qrencode
-
NO_ZMQ
-
Don't download/build/cache packages needed for enabling zeromq
-
NO_WALLET
-
Don't download/build/cache libs needed to enable the wallet
-
NO_BDB
-
Don't download/build/cache BerkeleyDB
-
NO_SQLITE
-
Don't download/build/cache SQLite
-
NO_UPNP
-
Don't download/build/cache packages needed for enabling upnp
-
NO_NATPMP
-
Don't download/build/cache packages needed for enabling NAT-PMP
-
DEBUG
-
disable some optimizations and enable more runtime checking
-
HOST_ID_SALT
-
Optional salt to use when generating host package ids
-
BUILD_ID_SALT
-
Optional salt to use when generating build package ids
-
FORCE_USE_SYSTEM_CLANG
-
(EXPERTS ONLY) When cross-compiling for macOS, use Clang found in the -system's $PATH rather than the default prebuilt release of Clang -from llvm.org. Clang 8 or later is required.
-
+- `SOURCES_PATH`: Downloaded sources will be placed here +- `BASE_CACHE`: Built packages will be placed here +- `SDK_PATH`: Path where SDKs can be found (used by macOS) +- `FALLBACK_DOWNLOAD_PATH`: If a source file can't be fetched, try here before giving up +- `NO_QT`: Don't download/build/cache Qt and its dependencies +- `NO_QR`: Don't download/build/cache packages needed for enabling qrencode +- `NO_ZMQ`: Don't download/build/cache packages needed for enabling ZeroMQ +- `NO_WALLET`: Don't download/build/cache libs needed to enable the wallet +- `NO_BDB`: Don't download/build/cache BerkeleyDB +- `NO_SQLITE`: Don't download/build/cache SQLite +- `NO_UPNP`: Don't download/build/cache packages needed for enabling UPnP +- `NO_NATPMP`: Don't download/build/cache packages needed for enabling NAT-PMP +- `DEBUG`: Disable some optimizations and enable more runtime checking +- `HOST_ID_SALT`: Optional salt to use when generating host package ids +- `BUILD_ID_SALT`: Optional salt to use when generating build package ids +- `FORCE_USE_SYSTEM_CLANG`: (EXPERTS ONLY) When cross-compiling for macOS, use Clang found in the + system's `$PATH` rather than the default prebuilt release of Clang + from llvm.org. Clang 8 or later is required. + If some packages are not built, for example `make NO_WALLET=1`, the appropriate options will be passed to Dash Core's configure. In this case, `--disable-wallet`. From ebcfa7c0ec340fc4213766a9e36e3e808d01a556 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Wed, 6 Jan 2021 16:10:39 +0100 Subject: [PATCH 04/10] Merge #20829: doc: add -netinfo help 6f2c4fd0775a9c45eacc4bab8f138528852fdf44 netinfo: add user help documentation (Jon Atack) Pull request description: This is the help doc commit of #20764 without the rest of the PR or anything new since the 0.21.0 branch-off in order to target giving users a -netinfo help doc for 0.21. - to test the new help ``` $ ./src/bitcoin-cli -netinfo help ``` - to see the updated short help ``` $ ./src/bitcoin-cli -help | grep -A4 netinfo ```
-netinfo help doc

``` $ ./src/bitcoin-cli -netinfo help -netinfo level "help" Returns a network peer connections dashboard with information from the remote server. Under the hood, -netinfo fetches the data by calling getpeerinfo and getnetworkinfo. An optional integer argument from 0 to 4 can be passed for different peers listings. Pass "help" to see this detailed help documentation. If more than one argument is passed, only the first one is read and parsed. Suggestion: use with the Linux watch(1) command for a live dashboard; see example below. Arguments: 1. level (integer 0-4, optional) Specify the info level of the peers dashboard (default 0): 0 - Connection counts and local addresses 1 - Like 0 but with a peers listing (without address or version columns) 2 - Like 1 but with an address column 3 - Like 1 but with a version column 4 - Like 1 but with both address and version columns 2. help (string "help", optional) Print this help documentation instead of the dashboard. Result: * The peers listing in levels 1-4 displays all of the peers sorted by direction and minimum ping time: Column Description ------ ----------- <-> Direction "in" - inbound connections are those initiated by the peer "out" - outbound connections are those initiated by us type Type of peer connection "full" - full relay, the default "block" - block relay; like full relay but does not relay transactions or addresses net Network the peer connected through ("ipv4", "ipv6", "onion", "i2p", or "cjdns") mping Minimum observed ping time, in milliseconds (ms) ping Last observed ping time, in milliseconds (ms) send Time since last message sent to the peer, in seconds recv Time since last message received from the peer, in seconds txn Time since last novel transaction received from the peer and accepted into our mempool, in minutes blk Time since last novel block passing initial validity checks received from the peer, in minutes age Duration of connection to the peer, in minutes asmap Mapped AS (Autonomous System) number in the BGP route to the peer, used for diversifying peer selection (only displayed if the -asmap config option is set) id Peer index, in increasing order of peer connections since node startup address IP address and port of the peer version Peer version and subversion concatenated, e.g. "70016/Satoshi:21.0.0/" * The connection counts table displays the number of peers by direction, network, and the totals for each, as well as a column for block relay peers. * The local addresses table lists each local address broadcast by the node, the port, and the score. Examples: Connection counts and local addresses only > bitcoin-cli -netinfo Compact peers listing > bitcoin-cli -netinfo 1 Full dashboard > bitcoin-cli -netinfo 4 Full live dashboard, adjust --interval or --no-title as needed (Linux) > watch --interval 1 --no-title ./src/bitcoin-cli -netinfo 4 See this help > bitcoin-cli -netinfo help ```

ACKs for top commit: laanwj: ACK 6f2c4fd0775a9c45eacc4bab8f138528852fdf44 Tree-SHA512: dd49b1ce65546dacfb8ba9f9d57de0eae55560fd05533cf26c0b5d6ec65bf1de789c3287e90a0e2f47707532fab2fe62919a4192a7ffd58ac8eec18293e9aaeb --- src/bitcoin-cli.cpp | 70 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index bd3ef610dfc59..d237006c8b965 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -56,7 +56,7 @@ static void SetupCliArgs(ArgsManager& argsman) argsman.AddArg("-datadir=", "Specify data directory", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); argsman.AddArg("-generate", strprintf("Generate blocks immediately, equivalent to RPC generatenewaddress followed by RPC generatetoaddress. Optional positional integer arguments are number of blocks to generate (default: %s) and maximum iterations to try (default: %s), equivalent to RPC generatetoaddress nblocks and maxtries arguments. Example: dash-cli -generate 4 1000", DEFAULT_NBLOCKS, DEFAULT_MAX_TRIES), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); argsman.AddArg("-getinfo", "Get general information from the remote server. Note that unlike server-side RPC calls, the results of -getinfo is the result of multiple non-atomic requests. Some entries in the result may represent results from different states (e.g. wallet balance may be as of a different block from the chain state reported)", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); - argsman.AddArg("-netinfo", "Get network peer connection information from the remote server. An optional integer argument from 0 to 4 can be passed for different peers listings (default: 0).", ArgsManager::ALLOW_INT, OptionsCategory::OPTIONS); + argsman.AddArg("-netinfo", "Get network peer connection information from the remote server. An optional integer argument from 0 to 4 can be passed for different peers listings (default: 0). Pass \"help\" for detailed help documentation.", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); argsman.AddArg("-named", strprintf("Pass named instead of positional arguments (default: %s)", DEFAULT_NAMED), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); argsman.AddArg("-rpcclienttimeout=", strprintf("Timeout in seconds during HTTP requests, or 0 for no timeout. (default: %d)", DEFAULT_HTTP_CLIENT_TIMEOUT), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); argsman.AddArg("-rpcconnect=", strprintf("Send commands to node running on (default: %s)", DEFAULT_RPCCONNECT), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); @@ -312,7 +312,8 @@ class NetinfoRequestHandler : public BaseRequestHandler } return UNKNOWN_NETWORK; } - uint8_t m_details_level{0}; //!< Optional user-supplied arg to set dashboard details level + uint8_t m_details_level{0}; //!< Optional user-supplied arg to set dashboard details level + bool m_is_help_requested{false}; //!< Optional user-supplied arg to print help documentation bool DetailsRequested() const { return m_details_level > 0 && m_details_level < 5; } bool IsAddressSelected() const { return m_details_level == 2 || m_details_level == 4; } bool IsVersionSelected() const { return m_details_level == 3 || m_details_level == 4; } @@ -344,6 +345,62 @@ class NetinfoRequestHandler : public BaseRequestHandler if (gArgs.GetChainName() == CBaseChainParams::REGTEST) return " regtest"; return ""; } + const UniValue NetinfoHelp() + { + return std::string{ + "-netinfo level|\"help\" \n\n" + "Returns a network peer connections dashboard with information from the remote server.\n" + "Under the hood, -netinfo fetches the data by calling getpeerinfo and getnetworkinfo.\n" + "An optional integer argument from 0 to 4 can be passed for different peers listings.\n" + "Pass \"help\" to see this detailed help documentation.\n" + "If more than one argument is passed, only the first one is read and parsed.\n" + "Suggestion: use with the Linux watch(1) command for a live dashboard; see example below.\n\n" + "Arguments:\n" + "1. level (integer 0-4, optional) Specify the info level of the peers dashboard (default 0):\n" + " 0 - Connection counts and local addresses\n" + " 1 - Like 0 but with a peers listing (without address or version columns)\n" + " 2 - Like 1 but with an address column\n" + " 3 - Like 1 but with a version column\n" + " 4 - Like 1 but with both address and version columns\n" + "2. help (string \"help\", optional) Print this help documentation instead of the dashboard.\n\n" + "Result:\n\n" + "* The peers listing in levels 1-4 displays all of the peers sorted by direction and minimum ping time:\n\n" + " Column Description\n" + " ------ -----------\n" + " <-> Direction\n" + " \"in\" - inbound connections are those initiated by the peer\n" + " \"out\" - outbound connections are those initiated by us\n" + " type Type of peer connection\n" + " \"full\" - full relay, the default\n" + " \"block\" - block relay; like full relay but does not relay transactions or addresses\n" + " net Network the peer connected through (\"ipv4\", \"ipv6\", \"onion\", \"i2p\", or \"cjdns\")\n" + " mping Minimum observed ping time, in milliseconds (ms)\n" + " ping Last observed ping time, in milliseconds (ms)\n" + " send Time since last message sent to the peer, in seconds\n" + " recv Time since last message received from the peer, in seconds\n" + " txn Time since last novel transaction received from the peer and accepted into our mempool, in minutes\n" + " blk Time since last novel block passing initial validity checks received from the peer, in minutes\n" + " age Duration of connection to the peer, in minutes\n" + " asmap Mapped AS (Autonomous System) number in the BGP route to the peer, used for diversifying\n" + " peer selection (only displayed if the -asmap config option is set)\n" + " id Peer index, in increasing order of peer connections since node startup\n" + " address IP address and port of the peer\n" + " version Peer version and subversion concatenated, e.g. \"70016/Satoshi:21.0.0/\"\n\n" + "* The connection counts table displays the number of peers by direction, network, and the totals\n" + " for each, as well as a column for block relay peers.\n\n" + "* The local addresses table lists each local address broadcast by the node, the port, and the score.\n\n" + "Examples:\n\n" + "Connection counts and local addresses only\n" + "> dash-cli -netinfo\n\n" + "Compact peers listing\n" + "> dash-cli -netinfo 1\n\n" + "Full dashboard\n" + "> dash-cli -netinfo 4\n\n" + "Full live dashboard, adjust --interval or --no-title as needed (Linux)\n" + "> watch --interval 1 --no-title dash-cli -netinfo 4\n\n" + "See this help\n" + "> dash-cli -netinfo help\n"}; + } const int64_t m_time_now{GetSystemTimeInSeconds()}; public: @@ -356,6 +413,10 @@ class NetinfoRequestHandler : public BaseRequestHandler uint8_t n{0}; if (ParseUInt8(args.at(0), &n)) { m_details_level = n; + } else if (args.at(0) == "help") { + m_is_help_requested = true; + } else { + throw std::runtime_error(strprintf("invalid -netinfo argument: %s", args.at(0))); } } UniValue result(UniValue::VARR); @@ -366,6 +427,9 @@ class NetinfoRequestHandler : public BaseRequestHandler UniValue ProcessReply(const UniValue& batch_in) override { + if (m_is_help_requested) { + return JSONRPCReplyObj(NetinfoHelp(), NullUniValue, 1); + } const std::vector batch{JSONRPCProcessBatchReply(batch_in)}; if (!batch[ID_PEERINFO]["error"].isNull()) return batch[ID_PEERINFO]; if (!batch[ID_NETWORKINFO]["error"].isNull()) return batch[ID_NETWORKINFO]; @@ -417,7 +481,7 @@ class NetinfoRequestHandler : public BaseRequestHandler // Report detailed peer connections list sorted by direction and minimum ping time. if (DetailsRequested() && !m_peers.empty()) { std::sort(m_peers.begin(), m_peers.end()); - result += "Peer connections sorted by direction and min ping\n<-> relay net mping ping send recv txn blk uptime "; + result += "<-> relay net mping ping send recv txn blk uptime "; if (m_is_asmap_on) result += " asmap "; result += strprintf("%*s %-*s%s\n", m_max_id_length, "id", IsAddressSelected() ? m_max_addr_length : 0, IsAddressSelected() ? "address" : "", IsVersionSelected() ? "version" : ""); for (const Peer& peer : m_peers) { From 00d2d7fac3abd959fd2b84521582af9a08eab51b Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Thu, 4 Feb 2021 10:27:54 +0100 Subject: [PATCH 05/10] Merge #21042: doc, test: Improve setup_clean_chain documentation 590bda79e876d9b959083105b8c7c41dd87706eb scripted-diff: Remove setup_clean_chain if default is not changed (Fabian Jahr) 98892f39e3d079c73bff7f2a5d5420fa95270497 doc: Improve setup_clean_chain documentation (Fabian Jahr) Pull request description: The first commit improves documentation on setup_clean_chain which is misunderstood quite frequently. Most importantly it fixes the TestShell docs which are simply incorrect. The second commit removes the instances of `setup_clean_clain` in functional tests where it is not changing the default. This used to be part of #19168 which also sought to rename`setup_clean_chain`. ACKs for top commit: jonatack: ACK 590bda79e876d9b959083105b8c7c41dd87706eb Tree-SHA512: a7881186e65d31160b8f84107fb185973b37c6e50f190a85c6e2906a13a7472bb4efa9440bd37fe0a9ac5cd2d1e8559870a7e4380632d9a249eca8980b945f3e --- test/functional/README.md | 11 +++++++---- test/functional/example_test.py | 3 +++ test/functional/feature_asmap.py | 1 - test/functional/feature_dbcrash.py | 1 - test/functional/feature_includeconf.py | 1 - test/functional/p2p_addr_relay.py | 1 - test/functional/p2p_blocksonly.py | 1 - test/functional/p2p_filter.py | 1 - test/functional/p2p_getaddr_caching.py | 1 - test/functional/p2p_invalid_locator.py | 1 - test/functional/p2p_tx_download.py | 1 - test/functional/rpc_estimatefee.py | 1 - .../rpc_getaddressinfo_label_deprecation.py | 1 - .../rpc_getaddressinfo_labels_purpose_deprecation.py | 1 - test/functional/rpc_psbt.py | 1 - test/functional/test-shell.md | 2 +- test/functional/wallet_avoidreuse.py | 1 - test/functional/wallet_create_tx.py | 1 - test/functional/wallet_createwallet.py | 1 - test/functional/wallet_watchonly.py | 1 - 20 files changed, 11 insertions(+), 22 deletions(-) diff --git a/test/functional/README.md b/test/functional/README.md index 60867ac62cd94..11485ed03acd6 100644 --- a/test/functional/README.md +++ b/test/functional/README.md @@ -61,10 +61,13 @@ don't have test cases for. - Avoid stop-starting the nodes multiple times during the test if possible. A stop-start takes several seconds, so doing it several times blows up the runtime of the test. -- Set the `self.setup_clean_chain` variable in `set_test_params()` to control whether - or not to use the cached data directories. The cached data directories - contain a 200-block pre-mined blockchain and wallets for four nodes. Each node - has 25 mature blocks (25x500=12500 DASH) in its wallet. +- Set the `self.setup_clean_chain` variable in `set_test_params()` to `True` to + initialize an empty blockchain and start from the Genesis block, rather than + load a premined blockchain from cache with the default value of `False`. The + cached data directories contain a 200-block pre-mined blockchain with the + spendable mining rewards being split between four nodes. Each node has 25 + mature block subsidies (25x500=12500 DASH) in its wallet. Using them is much more + efficient than mining blocks in your test. - When calling RPCs with lots of arguments, consider using named keyword arguments instead of positional arguments to make the intent of the call clear to readers. diff --git a/test/functional/example_test.py b/test/functional/example_test.py index a9bda99198126..8a3e3d7f60799 100755 --- a/test/functional/example_test.py +++ b/test/functional/example_test.py @@ -77,6 +77,9 @@ def set_test_params(self): """Override test parameters for your individual test. This method must be overridden and num_nodes must be explicitly set.""" + # By default every test loads a pre-mined chain of 200 blocks from cache. + # Set setup_clean_chain to True to skip this and start from the Genesis + # block. self.setup_clean_chain = True self.num_nodes = 3 # Use self.extra_args to change command-line arguments for the nodes diff --git a/test/functional/feature_asmap.py b/test/functional/feature_asmap.py index 60c4dd16323b1..0eb998fab7469 100755 --- a/test/functional/feature_asmap.py +++ b/test/functional/feature_asmap.py @@ -36,7 +36,6 @@ def expected_messages(filename): class AsmapTest(BitcoinTestFramework): def set_test_params(self): - self.setup_clean_chain = False self.num_nodes = 1 def test_without_asmap_arg(self): diff --git a/test/functional/feature_dbcrash.py b/test/functional/feature_dbcrash.py index e80c8eae48f62..de35e4bcec35f 100755 --- a/test/functional/feature_dbcrash.py +++ b/test/functional/feature_dbcrash.py @@ -49,7 +49,6 @@ class ChainstateWriteCrashTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 4 - self.setup_clean_chain = False self.rpc_timeout = 480 self.supports_cli = False diff --git a/test/functional/feature_includeconf.py b/test/functional/feature_includeconf.py index 879bb54a94a6e..7e705516fbfb6 100755 --- a/test/functional/feature_includeconf.py +++ b/test/functional/feature_includeconf.py @@ -20,7 +20,6 @@ class IncludeConfTest(BitcoinTestFramework): def set_test_params(self): - self.setup_clean_chain = False self.num_nodes = 1 def setup_chain(self): diff --git a/test/functional/p2p_addr_relay.py b/test/functional/p2p_addr_relay.py index 1f0012d95f6c0..48c17fb7714a0 100755 --- a/test/functional/p2p_addr_relay.py +++ b/test/functional/p2p_addr_relay.py @@ -40,7 +40,6 @@ def on_addr(self, message): class AddrTest(BitcoinTestFramework): def set_test_params(self): - self.setup_clean_chain = False self.num_nodes = 1 def run_test(self): diff --git a/test/functional/p2p_blocksonly.py b/test/functional/p2p_blocksonly.py index f0e716e84f353..4bab19388142f 100755 --- a/test/functional/p2p_blocksonly.py +++ b/test/functional/p2p_blocksonly.py @@ -12,7 +12,6 @@ class P2PBlocksOnly(BitcoinTestFramework): def set_test_params(self): - self.setup_clean_chain = False self.num_nodes = 1 self.extra_args = [["-blocksonly"]] diff --git a/test/functional/p2p_filter.py b/test/functional/p2p_filter.py index f00e91f3cc37a..f5daa890922ac 100755 --- a/test/functional/p2p_filter.py +++ b/test/functional/p2p_filter.py @@ -54,7 +54,6 @@ def on_tx(self, message): class FilterTest(BitcoinTestFramework): def set_test_params(self): - self.setup_clean_chain = False self.num_nodes = 1 self.extra_args = [[ '-peerbloomfilters', diff --git a/test/functional/p2p_getaddr_caching.py b/test/functional/p2p_getaddr_caching.py index cad2e7550660e..a2cb488001adf 100755 --- a/test/functional/p2p_getaddr_caching.py +++ b/test/functional/p2p_getaddr_caching.py @@ -39,7 +39,6 @@ def addr_received(self): class AddrTest(BitcoinTestFramework): def set_test_params(self): - self.setup_clean_chain = False self.num_nodes = 1 def run_test(self): diff --git a/test/functional/p2p_invalid_locator.py b/test/functional/p2p_invalid_locator.py index 15770819c9f27..9229a62d46e0a 100755 --- a/test/functional/p2p_invalid_locator.py +++ b/test/functional/p2p_invalid_locator.py @@ -13,7 +13,6 @@ class InvalidLocatorTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 1 - self.setup_clean_chain = False def run_test(self): node = self.nodes[0] # convenience reference to the node diff --git a/test/functional/p2p_tx_download.py b/test/functional/p2p_tx_download.py index 8d2963f5293d3..bd0ce10622a5b 100755 --- a/test/functional/p2p_tx_download.py +++ b/test/functional/p2p_tx_download.py @@ -52,7 +52,6 @@ def on_getdata(self, message): class TxDownloadTest(BitcoinTestFramework): def set_test_params(self): - self.setup_clean_chain = False self.num_nodes = 2 def test_tx_requests(self): diff --git a/test/functional/rpc_estimatefee.py b/test/functional/rpc_estimatefee.py index 14a04aa1cff56..faba579e5729b 100755 --- a/test/functional/rpc_estimatefee.py +++ b/test/functional/rpc_estimatefee.py @@ -14,7 +14,6 @@ class EstimateFeeTest(BitcoinTestFramework): def set_test_params(self): - self.setup_clean_chain = False self.num_nodes = 1 def run_test(self): diff --git a/test/functional/rpc_getaddressinfo_label_deprecation.py b/test/functional/rpc_getaddressinfo_label_deprecation.py index 5e739ebede51a..a173771940418 100755 --- a/test/functional/rpc_getaddressinfo_label_deprecation.py +++ b/test/functional/rpc_getaddressinfo_label_deprecation.py @@ -12,7 +12,6 @@ class GetAddressInfoLabelDeprecationTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 2 - self.setup_clean_chain = False # Start node[0] with -deprecatedrpc=label, and node[1] without. self.extra_args = [["-deprecatedrpc=label"], []] diff --git a/test/functional/rpc_getaddressinfo_labels_purpose_deprecation.py b/test/functional/rpc_getaddressinfo_labels_purpose_deprecation.py index 903f5536b91cc..3c1eea7fbeb81 100755 --- a/test/functional/rpc_getaddressinfo_labels_purpose_deprecation.py +++ b/test/functional/rpc_getaddressinfo_labels_purpose_deprecation.py @@ -16,7 +16,6 @@ class GetAddressInfoLabelsPurposeDeprecationTest(BitcoinTestFramework): def set_test_params(self): self.num_nodes = 2 - self.setup_clean_chain = False # Start node[0] with -deprecatedrpc=labelspurpose and node[1] without. self.extra_args = [["-deprecatedrpc=labelspurpose"], []] diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py index d0037580bb2e8..24e9b0dbe7cfd 100755 --- a/test/functional/rpc_psbt.py +++ b/test/functional/rpc_psbt.py @@ -21,7 +21,6 @@ class PSBTTest(BitcoinTestFramework): def set_test_params(self): - self.setup_clean_chain = False self.num_nodes = 3 # TODO: remove -txindex. Currently required for getrawtransaction call. self.extra_args = [ diff --git a/test/functional/test-shell.md b/test/functional/test-shell.md index f6ea9ef68277f..b8e899d6758f7 100644 --- a/test/functional/test-shell.md +++ b/test/functional/test-shell.md @@ -178,7 +178,7 @@ can be called after the TestShell is shut down. | `num_nodes` | `1` | Sets the number of initialized bitcoind processes. | | `perf` | False | Profiles running nodes with `perf` for the duration of the test if set to `True`. | | `rpc_timeout` | `60` | Sets the RPC server timeout for the underlying bitcoind processes. | -| `setup_clean_chain` | `False` | Initializes an empty blockchain by default. A 199-block-long chain is initialized if set to `True`. | +| `setup_clean_chain` | `False` | A 200-block-long chain is initialized from cache by default. Instead, `setup_clean_chain` initializes an empty blockchain if set to `True`. | | `randomseed` | Random Integer | `TestShell.options.randomseed` is a member of `TestShell` which can be accessed during a test to seed a random generator. User can override default with a constant value for reproducible test runs. | | `supports_cli` | `False` | Whether the bitcoin-cli utility is compiled and available for the test. | | `tmpdir` | `"/var/folders/.../"` | Sets directory for test logs. Will be deleted upon a successful test run unless `nocleanup` is set to `True` | diff --git a/test/functional/wallet_avoidreuse.py b/test/functional/wallet_avoidreuse.py index 4f4078b747018..b5fb557c5c29b 100755 --- a/test/functional/wallet_avoidreuse.py +++ b/test/functional/wallet_avoidreuse.py @@ -71,7 +71,6 @@ def assert_balances(node, mine, margin=0.001): class AvoidReuseTest(BitcoinTestFramework): def set_test_params(self): - self.setup_clean_chain = False self.num_nodes = 2 # This test isn't testing txn relay/timing, so set whitelist on the # peers for instant txn relay. This speeds up the test run time 2-3x. diff --git a/test/functional/wallet_create_tx.py b/test/functional/wallet_create_tx.py index 834dfc2ec4bb0..29693bf81d7f1 100755 --- a/test/functional/wallet_create_tx.py +++ b/test/functional/wallet_create_tx.py @@ -12,7 +12,6 @@ class CreateTxWalletTest(BitcoinTestFramework): def set_test_params(self): - self.setup_clean_chain = False self.num_nodes = 1 def skip_test_if_missing_module(self): diff --git a/test/functional/wallet_createwallet.py b/test/functional/wallet_createwallet.py index df1d9082e22ca..54dac62bfae1d 100755 --- a/test/functional/wallet_createwallet.py +++ b/test/functional/wallet_createwallet.py @@ -13,7 +13,6 @@ class CreateWalletTest(BitcoinTestFramework): def set_test_params(self): - self.setup_clean_chain = False self.num_nodes = 1 def skip_test_if_missing_module(self): diff --git a/test/functional/wallet_watchonly.py b/test/functional/wallet_watchonly.py index 36d9118749f5c..2b91edf22fcfd 100755 --- a/test/functional/wallet_watchonly.py +++ b/test/functional/wallet_watchonly.py @@ -15,7 +15,6 @@ class CreateWalletWatchonlyTest(BitcoinTestFramework): def set_test_params(self): - self.setup_clean_chain = False self.num_nodes = 1 self.supports_cli = True From 7a2d07c6831f521f8fc3e0fb9f766d7dad570330 Mon Sep 17 00:00:00 2001 From: fanquake Date: Fri, 12 Mar 2021 12:50:22 +0800 Subject: [PATCH 06/10] Merge #21394: [doc] Improve comment about protected peers ebde946a527e50630df180c6565ea5bf8d2ab5aa [doc] Improve comment about protected peers (Amiti Uttarwar) Pull request description: The comment currently suggests a long-standing node would infrequently protect peers under normal circumstances. Clarify that we also protect peers that are synced to the same work as our chain tip. [Relevant check here](https://github.com/bitcoin/bitcoin/blob/ee0dc02c6f93de2a366bbff490eb4d37bca6a24f/src/net_processing.cpp#L1997). ACKs for top commit: Empact: ACK https://github.com/bitcoin/bitcoin/pull/21394/commits/ebde946a527e50630df180c6565ea5bf8d2ab5aa jnewbery: ACK ebde946a527e50630df180c6565ea5bf8d2ab5aa Tree-SHA512: 3692f4098e95f935d801e0ee6bbd3a7c9480e66ca070a7c68ba79c4fc2e62377f5d37080c7b6a7d15ab617aaf4d3df9b26abc4f1b090d572ba46fdd092a6a64a --- src/net_processing.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index a1c6d24db6c7b..865c75ad7b3fb 100755 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -574,7 +574,7 @@ struct CNodeState { * - its connection type is IsBlockOnlyConn() == false * - it gave us a valid connecting header * - we haven't reached MAX_OUTBOUND_PEERS_TO_PROTECT_FROM_DISCONNECT yet - * - it has a better chain than we have + * - its chain tip has at least as much work as ours * * CHAIN_SYNC_TIMEOUT: if a peer's best known block has less work than our tip, * set a timeout CHAIN_SYNC_TIMEOUT seconds in the future: From aebc28725b591c9db511aa08a78aea51d5bbde17 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Mon, 15 Mar 2021 18:52:55 +0100 Subject: [PATCH 07/10] Merge #21398: doc: Update fuzzing docs for afl-clang-lto fab633d2dbfed1efcc3a02061685d56327ae51fd doc: Update fuzzing docs for afl-clang-lto (MarcoFalke) Pull request description: Update the docs to default to `afl-clang-lto`. The afl-gcc (and other afl legacy fuzz engines) are still supported, though discouraged. ACKs for top commit: fanquake: ACK fab633d2dbfed1efcc3a02061685d56327ae51fd - seems to work for me. Compiled and ran some fuzzers using Clang 11 on Bionic. Set `llvm-config` so that `clang-11` would be used over `clang` (10). jarolrod: ACK fab633d2dbfed1efcc3a02061685d56327ae51fd, tested on Ubuntu Focal Tree-SHA512: 3d1969c167bea45a9d691f3b757f51213d550c9c1b895bed1fcf3c2f7345791787cfb13c376291b94eb3181caf4ae3126f4d01c7cebda7b2bb1c40a1294e9a68 --- doc/fuzzing.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/doc/fuzzing.md b/doc/fuzzing.md index 4ebbbdc934d38..859c3c04b77dd 100644 --- a/doc/fuzzing.md +++ b/doc/fuzzing.md @@ -128,33 +128,32 @@ Full configure that was tested on macOS Catalina with `brew` installed `llvm`: Read the [libFuzzer documentation](https://llvm.org/docs/LibFuzzer.html) for more information. This [libFuzzer tutorial](https://github.com/google/fuzzing/blob/master/tutorial/libFuzzerTutorial.md) might also be of interest. -# Fuzzing Dash Core using american fuzzy lop (`afl-fuzz`) +# Fuzzing Dash Core using afl++ ## Quickstart guide -To quickly get started fuzzing Dash Core using [`afl-fuzz`](https://github.com/google/afl): +To quickly get started fuzzing Dash Core using [afl++](https://github.com/AFLplusplus/AFLplusplus): ```sh $ git clone https://github.com/dashpay/dash $ cd dash/ -$ git clone https://github.com/google/afl -$ make -C afl/ -$ make -C afl/llvm_mode/ +$ git clone https://github.com/AFLplusplus/AFLplusplus +$ make -C AFLplusplus/ source-only $ ./autogen.sh -# It is possible to compile with afl-gcc and afl-g++ instead of afl-clang. However, running afl-fuzz -# may require more memory via the -m flag. -$ CC=$(pwd)/afl/afl-clang-fast CXX=$(pwd)/afl/afl-clang-fast++ ./configure --enable-fuzz --enable-c++17 +# If afl-clang-lto is not available, see +# https://github.com/AFLplusplus/AFLplusplus#a-selecting-the-best-afl-compiler-for-instrumenting-the-target +$ CC=$(pwd)/AFLplusplus/afl-clang-lto CXX=$(pwd)/AFLplusplus/afl-clang-lto++ ./configure --enable-fuzz --enable-c++17 $ make # For macOS you may need to ignore x86 compilation checks when running "make". If so, # try compiling using: AFL_NO_X86=1 make $ mkdir -p inputs/ outputs/ $ echo A > inputs/thin-air-input -$ FUZZ=bech32 afl/afl-fuzz -i inputs/ -o outputs/ -- src/test/fuzz/fuzz +$ FUZZ=bech32 AFLplusplus/afl-fuzz -i inputs/ -o outputs/ -- src/test/fuzz/fuzz # You may have to change a few kernel parameters to test optimally - afl-fuzz # will print an error and suggestion if so. ``` -Read the [`afl-fuzz` documentation](https://github.com/google/afl) for more information. +Read the [afl++ documentation](https://github.com/AFLplusplus/AFLplusplus) for more information. # Fuzzing Dash Core using Honggfuzz From 65313727264f70dfc474b08b36d69d292e50e7a0 Mon Sep 17 00:00:00 2001 From: "W. J. van der Laan" Date: Thu, 1 Apr 2021 19:00:34 +0200 Subject: [PATCH 08/10] Merge #21567: docs: fix various misleading comments 4eca20d6f7d850492d331d89d1cdd77abb3c70c1 [doc] correct comment about ATMPW (glozow) 8fa74aeb5b96419c7d40b40f8e1e1269509278e2 [doc] correct comment in chainparams (glozow) 2f8272c2a4b6fa84c04dfeb4d751bb218f2d4c78 [doc] GetBestBlock() doesn't do nothing (gzhao408) Pull request description: Came across a few misleading comments, wanted to fix them ACKs for top commit: jnewbery: ACK 4eca20d6f7 MarcoFalke: ACK 4eca20d6f7d850492d331d89d1cdd77abb3c70c1 laanwj: Code review ACK 4eca20d6f7d850492d331d89d1cdd77abb3c70c1 Tree-SHA512: 5bef1f1e7703f304128cf0eb8945e139e031580c99062bbbe15bf4db8443c2ba5a8c65844833132e6646c8980c678fc1d2ab0c63e17105585d583570ee350fd0 --- src/chainparams.cpp | 9 +++++---- src/chainparams.h | 5 +---- src/validation.cpp | 9 +++++---- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 03058e6498934..fd5677efe59cb 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -129,7 +129,7 @@ std::optional CChainParams::GetLLMQ(Consensus::LLMQType l } /** - * Main network + * Main network on which people trade goods and services. */ class CMainParams : public CChainParams { public: @@ -325,7 +325,7 @@ class CMainParams : public CChainParams { }; /** - * Testnet (v3) + * Testnet (v3): public test network which is reset from time to time. */ class CTestNetParams : public CChainParams { public: @@ -496,7 +496,7 @@ class CTestNetParams : public CChainParams { }; /** - * Devnet + * Devnet: The Development network intended for developers use. */ class CDevNetParams : public CChainParams { public: @@ -731,7 +731,8 @@ class CDevNetParams : public CChainParams { }; /** - * Regression test + * Regression test: intended for private networks only. Has minimal difficulty to ensure that + * blocks can be found instantly. */ class CRegTestParams : public CChainParams { public: diff --git a/src/chainparams.h b/src/chainparams.h index e5e6ec0347508..7e2d93586ad2d 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -65,10 +65,7 @@ struct ChainTxData { /** * CChainParams defines various tweakable parameters of a given instance of the - * Dash system. There are three: the main network on which people trade goods - * and services, the public test network which gets reset from time to time and - * a regression test mode which is intended for private networks only. It has - * minimal difficulty to ensure that blocks can be found instantly. + * Dash system. */ class CChainParams { diff --git a/src/validation.cpp b/src/validation.cpp index fea61f68921fe..f1090856aeee6 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -740,7 +740,8 @@ bool MemPoolAccept::PreChecks(ATMPArgs& args, Workspace& ws) } } - // Bring the best block into scope + // This is const, but calls into the back end CoinsViews. The CCoinsViewDB at the bottom of the + // hierarchy brings the best block into scope. See CCoinsViewDB::GetBestBlock(). m_view.GetBestBlock(); // we have all inputs cached now, so switch back to dummy (to protect @@ -990,9 +991,9 @@ static bool AcceptToMemoryPoolWithTime(const CChainParams& chainparams, CTxMemPo if (!res || test_accept) { if (!res) LogPrint(BCLog::MEMPOOL, "%s: %s %s (%s)\n", __func__, tx->GetHash().ToString(), state.GetRejectReason(), state.GetDebugMessage()); - // Remove coins that were not present in the coins cache before calling ATMPW; - // this is to prevent memory DoS in case we receive a large number of - // invalid transactions that attempt to overrun the in-memory coins cache + // Remove coins that were not present in the coins cache before calling; + // AcceptSingleTransaction(); this is to prevent memory DoS in case we receive a large + // number of invalid transactions that attempt to overrun the in-memory coins cache // (`CCoinsViewCache::cacheCoins`). for (const COutPoint& hashTx : coins_to_uncache) From 37fdef82782e25b07b488007bf50f7168665a689 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Tue, 20 Apr 2021 10:40:28 +0200 Subject: [PATCH 09/10] Merge bitcoin/bitcoin#21736: doc: Fix doxygen comment silent merge conflict in descriptor.cpp e5faec65bd06a3b14175aca3040290f343bd6e9c doc: Fix doxygen comment silent merge conflict in descriptor.cpp (W. J. van der Laan) Pull request description: It looks like #21238 introduced a silent merge conflict in the documentation, which fails with `-Wdocumentation` in the CI. (please merge only if CI passes) ACKs for top commit: ajtowns: ACK e5faec65bd06a3b14175aca3040290f343bd6e9c -- fixed it for me meshcollider: ACK e5faec65bd06a3b14175aca3040290f343bd6e9c modulo CI Tree-SHA512: b07d50fd12aa7c239a92aad8ef29f4e88583c3ce701ebedba7c426aac4981c79113adc4670b7d055ab9535a28bdc3f9a30e6ca1b1ed0d7b9a333a3d9c4b40d8a --- src/script/descriptor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/script/descriptor.cpp b/src/script/descriptor.cpp index ae540d66b5dc5..57ea467642548 100644 --- a/src/script/descriptor.cpp +++ b/src/script/descriptor.cpp @@ -421,7 +421,7 @@ class DescriptorImpl : public Descriptor * m_subdescriptor_arg, or just once in case m_subdescriptor_arg is nullptr. * @param pubkeys The evaluations of the m_pubkey_args field. - * @param script The evaluation of m_subdescriptor_arg (or nullptr when m_subdescriptor_arg is nullptr). + * @param scripts The evaluation of m_subdescriptor_arg (or nullptr when m_subdescriptor_arg is nullptr). * @param out A FlatSigningProvider to put scripts or public keys in that are necessary to the solver. * The script arguments to this function are automatically added, as is the origin info of the provided pubkeys. * @return A vector with scriptPubKeys for this descriptor. From 22122ba5438c23372d08caefbb387061170b3b0c Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Thu, 19 Nov 2020 16:39:27 +0100 Subject: [PATCH 10/10] Merge #20054: Remove confusing and useless "unexpected version" warning 0000a0c7e9e4e7c1afafe6ef75b7624f4c573190 Remove confusing and almost useless "unexpected version" warning (MarcoFalke) Pull request description: It is useless because it isn't displayed for most users: * It isn't displayed in normal operation (because the validation debug category is disabled by default) * It isn't displayed for users that sync up their nodes intermittently, e.g. once a day or once a week (because it is disabled for IBD) * It is only displayed in the debug log (as opposed to the versionbits warning, which is displayed more prominently) It is confusing because it doesn't have a use case: Despite the above, if a user *did* see the warning, it would most likely be a false positive (like it has been in the past). Even if it wasn't, there is nothing they can do about it. The only thing they could do is to check for updates and hope that a fixed version is available. But why would the user be so scrupulously precise in enabling the warning and reading the log, but then fail to regularly check update channels for updated software? ACKs for top commit: practicalswift: ACK 0000a0c7e9e4e7c1afafe6ef75b7624f4c573190 decryp2kanon: ACK 0000a0c LarryRuane: ACK 0000a0c7e9e4e7c1afafe6ef75b7624f4c573190 Tree-SHA512: 16e069c84be6ab6034baeefdc515d0e5cdf560b2005d2faec5f989d45494bd16cfcb4ffca6a17211d9556ae44f9737a60a476c08b5c2bb5e1bd29724ecd6d5c1 --- src/validation.cpp | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/validation.cpp b/src/validation.cpp index f1090856aeee6..be691495ed31f 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2717,7 +2717,6 @@ void CChainState::UpdateTip(const CBlockIndex* pindexNew) assert(std::addressof(::ChainstateActive()) == std::addressof(*this)); if (!this->IsInitialBlockDownload()) { - int nUpgraded = 0; const CBlockIndex* pindex = pindexNew; for (int bit = 0; bit < VERSIONBITS_NUM_BITS; bit++) { WarningBitsConditionChecker checker(bit); @@ -2731,16 +2730,6 @@ void CChainState::UpdateTip(const CBlockIndex* pindexNew) } } } - // Check the version of the last 100 blocks to see if we need to upgrade: - for (int i = 0; i < 100 && pindex != nullptr; i++) - { - int32_t nExpectedVersion = ComputeBlockVersion(pindex->pprev, m_params.GetConsensus()); - if (pindex->nVersion > VERSIONBITS_LAST_OLD_BLOCK_VERSION && (pindex->nVersion & ~nExpectedVersion) != 0) - ++nUpgraded; - pindex = pindex->pprev; - } - if (nUpgraded > 0) - AppendWarning(warningMessages, strprintf(_("%d of last 100 blocks have unexpected version").translated, nUpgraded)); } assert(std::addressof(::ChainstateActive()) == std::addressof(*this)); LogPrintf("%s: new best=%s height=%d version=0x%08x log2_work=%.8g tx=%lu date='%s' progress=%f cache=%.1fMiB(%utxo) evodb_cache=%.1fMiB%s\n", __func__,