From be7f51a27d51026001376821b9900f47f43532cd Mon Sep 17 00:00:00 2001 From: fanquake Date: Tue, 23 May 2023 13:06:02 +0100 Subject: [PATCH 01/10] Merge bitcoin/bitcoin#27717: test: Make `util/test_runner.py` honor `BITCOINUTIL` and `BITCOINTX` 4f2f615d1362afe92cabe9eab50087f8bfe454fd test: Make `util/test_runner.py` honor `BITCOINUTIL` and `BITCOINTX` (Hennadii Stepanov) Pull request description: This PR is a continuation of changes to our testing frameworks (https://github.com/bitcoin/bitcoin/pull/27554, https://github.com/bitcoin/bitcoin/pull/27561) that allow them to work correctly in a multi-config build environment that is possible for [upcoming](https://github.com/bitcoin/bitcoin/pull/25797) CMake-based build system. That means that built for different configurations binaries (e.g., "Debug" and "Release") can coexist in separated directories. The commit has been pulled from https://github.com/hebasto/bitcoin/pull/15 and it seems [useful](https://github.com/hebasto/bitcoin/pull/15#discussion_r1200251404) by itself as: > I believe the rationale for allowing to drop in the executables via env var is to allow to test the guix-produced, or other third-party-produced executables... The current implementation of the `test/functional/test_framework/test_framework.py` script uses the same approach: https://github.com/bitcoin/bitcoin/blob/09351f51d279612973ecd76811dc075dff08209f/test/functional/test_framework/test_framework.py#L231-L246 ACKs for top commit: MarcoFalke: lgtm ACK 4f2f615d1362afe92cabe9eab50087f8bfe454fd TheCharlatan: ACK 4f2f615d1362afe92cabe9eab50087f8bfe454fd stickies-v: ACK 4f2f615d1362afe92cabe9eab50087f8bfe454fd Tree-SHA512: 99ee9a727b266700649d8f2ec528dfaeb04a1e48f0cb1d4eeaece65917165be647c10c4548429a9e8b30d094597f67e860c1db03ac689ebb409b223ce1b63aa9 --- test/util/test_runner.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/util/test_runner.py b/test/util/test_runner.py index d12f8cec31bd..f96a74629b1f 100755 --- a/test/util/test_runner.py +++ b/test/util/test_runner.py @@ -74,6 +74,11 @@ def bctest(testDir, testObj, buildenv): """ # Get the exec names and arguments execprog = os.path.join(buildenv["BUILDDIR"], "src", testObj["exec"] + buildenv["EXEEXT"]) + if testObj["exec"] == "./dash-util": + execprog = os.getenv("DASHUTIL", default=execprog) + elif testObj["exec"] == "./dash-tx": + execprog = os.getenv("DASHTX", default=execprog) + execargs = testObj['args'] execrun = [execprog] + execargs From 5ee733eb3d23af710551a1dd3416a0cb2f970561 Mon Sep 17 00:00:00 2001 From: fanquake Date: Wed, 26 Jul 2023 09:42:42 +0100 Subject: [PATCH 02/10] Merge bitcoin/bitcoin#28147: suppressions: note that `type:ClassName::MethodName` should be used d0c6cc4abe42163aaf081a969d2c449785563ba2 suppressions: note that 'type:ClassName::MethodName' should be used (fanquake) Pull request description: Now that the symbolizer is back in play, suppressions can once-again be targeted to functions, rather than file-wide. ACKs for top commit: MarcoFalke: lgtm ACK d0c6cc4abe42163aaf081a969d2c449785563ba2 hebasto: ACK d0c6cc4abe42163aaf081a969d2c449785563ba2 Tree-SHA512: fb65398eae18a6ebc5f8414275c568cf2664ab5357c2b3160f3bf285b67bc3af788225c5dba3c824c0e098627789450bec775375f52529d71c6ef700a9632d65 --- test/sanitizer_suppressions/ubsan | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/test/sanitizer_suppressions/ubsan b/test/sanitizer_suppressions/ubsan index 79507945434f..1d1f2ad352b5 100644 --- a/test/sanitizer_suppressions/ubsan +++ b/test/sanitizer_suppressions/ubsan @@ -1,9 +1,7 @@ +# Suppressions should use `sanitize-type:ClassName::MethodName`. + # -fsanitize=undefined suppressions # ================================= -# The suppressions would be `sanitize-type:ClassName::MethodName`, -# however due to a bug in clang the symbolizer is disabled and thus no symbol -# names can be used. -# See https://github.com/google/sanitizers/issues/1364 # -fsanitize=integer suppressions # =============================== @@ -11,8 +9,7 @@ # ------------ # Suppressions in dependencies that are developed outside this repository. unsigned-integer-overflow:*/include/c++/ -# unsigned-integer-overflow in FuzzedDataProvider's ConsumeIntegralInRange -unsigned-integer-overflow:FuzzedDataProvider.h +unsigned-integer-overflow:FuzzedDataProvider::ConsumeIntegralInRange unsigned-integer-overflow:leveldb/ unsigned-integer-overflow:minisketch/ unsigned-integer-overflow:secp256k1/ From 0029e6f5402c29871824aa5ea97c225c8bb3554e Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Fri, 1 Sep 2023 13:17:42 -0400 Subject: [PATCH 03/10] Merge bitcoin/bitcoin#28350: Log explicit error message when coindb is found in inconsistent state df60de770d8e27c00eced29d8a4a4bce7c6e4b30 log: Print error message when coindb is in inconsistent state (Fabian Jahr) Pull request description: While doing manual testing on assumeutxo this week I managed to put the coindb into an inconsistent state twice. For a normal user, this can also happen if their computer crashes during a flush or if they try to stop their node during a flush and then get tired of waiting and just shut their computer down or kill the process. It's an edge case but I wouldn't be surprised if this does happen more often when assumeutxo gets used more widely because there might be multiple flushes happening during loading of the UTXO set in the beginning and users may think something is going wrong because of the unexpected wait or they forgot some configs and want to start over quickly. The problem is, when this happens at first the node starts up normally until it's time to flush again and then it hits an assert that the user can not understand. ``` 2023-08-25T16:31:09Z [httpworker.0] [snapshot] 52000000 coins loaded (43.30%, 6768 MB) 2023-08-25T16:31:16Z [httpworker.0] Cache size (7272532192) exceeds total space (7256510300) 2023-08-25T16:31:16Z [httpworker.0] FlushSnapshotToDisk: flushing coins cache (7272 MB) started Assertion failed: (old_heads[0] == hashBlock), function BatchWrite, file txdb.cpp, line 126. Abort trap: 6 ``` We should at least log an error message that gives users a hint of what the problem is and what they can do to resolve it. I am keeping this separate from the assumeutxo project since this issue can also happen during any regular flush. ACKs for top commit: jonatack: ACK df60de770d8e27c00eced29d8a4a4bce7c6e4b30 achow101: ACK df60de770d8e27c00eced29d8a4a4bce7c6e4b30 ryanofsky: Code review ACK df60de770d8e27c00eced29d8a4a4bce7c6e4b30 jamesob: Code review ACK df60de770d8e27c00eced29d8a4a4bce7c6e4b30 Tree-SHA512: b546aa0b0323ece2962867a29c38e014ac83ae8f1ded090da2894b4ff2450c05229629c7e8892f7b550cf7def4038a0b4119812e548e11b00c60b1dc3d4276d2 --- src/txdb.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/txdb.cpp b/src/txdb.cpp index 6237b26a707a..73827a9a3e5f 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -114,6 +114,9 @@ bool CCoinsViewDB::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock, boo // We may be in the middle of replaying. std::vector old_heads = GetHeadBlocks(); if (old_heads.size() == 2) { + if (old_heads[0] != hashBlock) { + LogPrintLevel(BCLog::COINDB, BCLog::Level::Error, "The coins database detected an inconsistent state, likely due to a previous crash or shutdown. You will need to restart bitcoind with the -reindex-chainstate or -reindex configuration option.\n"); + } assert(old_heads[0] == hashBlock); old_tip = old_heads[1]; } From 404230ca7634baa3e06cef050e257c9a043ba44c Mon Sep 17 00:00:00 2001 From: fanquake Date: Tue, 5 Sep 2023 11:45:27 +0300 Subject: [PATCH 04/10] Merge bitcoin/bitcoin#28396: test: p2p: check that `getaddr` msgs are only responded once per connection 668aa6af8d5fbf047d43cf6f85f3335565637fb9 test: p2p: check that `getaddr` msgs are only responded once per connection (Sebastian Falbesoner) Pull request description: This simple PR adds missing test coverage for ignoring repeated `getaddr` requests (introduced in #7856, commit 66b07247a7a9e48e082502338176cc06edf61474): https://github.com/bitcoin/bitcoin/blob/6f03c45f6bb5a6edaa3051968b6a1ca4f84d2ccb/src/net_processing.cpp#L4642-L4648 ACKs for top commit: MarcoFalke: lgtm ACK 668aa6af8d5fbf047d43cf6f85f3335565637fb9 brunoerg: crACK 668aa6af8d5fbf047d43cf6f85f3335565637fb9 Tree-SHA512: edcdc6501c684fb41911e393f55ded9b044cd2f92918877eca152edd5a4287d1a9d57ae999f1cb42185eae00c3a0af411fcb9bcd5b990ef48849c3834b141584 --- test/functional/p2p_addr_relay.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/functional/p2p_addr_relay.py b/test/functional/p2p_addr_relay.py index da8d8e1895c2..978bf5e655ec 100755 --- a/test/functional/p2p_addr_relay.py +++ b/test/functional/p2p_addr_relay.py @@ -296,6 +296,15 @@ def getaddr_tests(self): assert_equal(block_relay_peer.num_ipv4_received, 0) assert inbound_peer.num_ipv4_received > 100 + self.log.info('Check that we answer getaddr messages only once per connection') + received_addrs_before = inbound_peer.num_ipv4_received + with self.nodes[0].assert_debug_log(['Ignoring repeated "getaddr".']): + inbound_peer.send_and_ping(msg_getaddr()) + self.bump_mocktime(10 * 60) + inbound_peer.sync_with_ping() + received_addrs_after = inbound_peer.num_ipv4_received + assert_equal(received_addrs_before, received_addrs_after) + self.nodes[0].disconnect_p2ps() def blocksonly_mode_tests(self): From 40f088814f221685d57f8adca642e19bc3463eb4 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Tue, 17 Oct 2023 15:21:49 -0400 Subject: [PATCH 05/10] Merge bitcoin/bitcoin#28544: wallet: Add TxStateString function for debugging and logging 8a553c94098c96cb3679468c2b460be145a0eabf wallet: Add TxStateString function for debugging and logging (Ryan Ofsky) Pull request description: I found this useful while debugging silent conflict between #10102 and #27469 recently ACKs for top commit: ishaanam: utACK 8a553c94098c96cb3679468c2b460be145a0eabf achow101: ACK 8a553c94098c96cb3679468c2b460be145a0eabf furszy: Code ACK 8a553c9 Tree-SHA512: 87965c66bcb59a21e7639878bb567e583a0e624735721ff7ad1104eed6bb9fba60607d0e3de7be3304232b3a55f48bab7039ea9c26b0e81963e59f9acd94f666 --- src/wallet/transaction.h | 11 +++++++++++ src/wallet/wallet.cpp | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/wallet/transaction.h b/src/wallet/transaction.h index 0e7830b59e31..bac89c2f633f 100644 --- a/src/wallet/transaction.h +++ b/src/wallet/transaction.h @@ -28,10 +28,12 @@ struct TxStateConfirmed { int position_in_block; explicit TxStateConfirmed(const uint256& block_hash, int height, int index) : confirmed_block_hash(block_hash), confirmed_block_height(height), position_in_block(index) {} + std::string toString() const { return strprintf("Confirmed (block=%s, height=%i, index=%i)", confirmed_block_hash.ToString(), confirmed_block_height, position_in_block); } }; //! State of transaction added to mempool. struct TxStateInMempool { + std::string toString() const { return strprintf("InMempool"); } }; //! State of rejected transaction that conflicts with a confirmed block. @@ -40,6 +42,7 @@ struct TxStateConflicted { int conflicting_block_height; explicit TxStateConflicted(const uint256& block_hash, int height) : conflicting_block_hash(block_hash), conflicting_block_height(height) {} + std::string toString() const { return strprintf("Conflicted (block=%s, height=%i)", conflicting_block_hash.ToString(), conflicting_block_height); } }; //! State of transaction not confirmed or conflicting with a known block and @@ -50,6 +53,7 @@ struct TxStateInactive { bool abandoned; explicit TxStateInactive(bool abandoned = false) : abandoned(abandoned) {} + std::string toString() const { return strprintf("Inactive (abandoned=%i)", abandoned); } }; //! State of transaction loaded in an unrecognized state with unexpected hash or @@ -61,6 +65,7 @@ struct TxStateUnrecognized { int index; TxStateUnrecognized(const uint256& block_hash, int index) : block_hash(block_hash), index(index) {} + std::string toString() const { return strprintf("Unrecognized (block=%s, index=%i)", block_hash.ToString(), index); } }; //! All possible CWalletTx states @@ -108,6 +113,12 @@ static inline int TxStateSerializedIndex(const TxState& state) }, state); } +//! Return TxState or SyncTxState as a string for logging or debugging. +template +std::string TxStateString(const T& state) +{ + return std::visit([](const auto& s) { return s.toString(); }, state); +} typedef std::map mapValue_t; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 1caf30747a3b..24c4a2e5ff1d 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -965,7 +965,7 @@ CWalletTx* CWallet::AddToWallet(CTransactionRef tx, const TxState& state, const LockProTxCoins(candidates, &batch); //// debug print - WalletLogPrintf("AddToWallet %s %s%s\n", hash.ToString(), (fInsertedNew ? "new" : ""), (fUpdated ? "update" : "")); + WalletLogPrintf("AddToWallet %s %s%s %s\n", hash.ToString(), (fInsertedNew ? "new" : ""), (fUpdated ? "update" : ""), TxStateString(state)); // Write to disk if (fInsertedNew || fUpdated) From 59bb09989f6398debddc10e57730cd0d0fc2a2d7 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Thu, 2 Nov 2023 15:19:26 -0400 Subject: [PATCH 06/10] Merge bitcoin/bitcoin#27852: test: add coverage to rpc_blockchain.py 376dc2cfb32806a8aa450589effe4d384e648398 test: add coverage to rpc_blockchain.py (kevkevin) Pull request description: Included a test that checks the functionality of setting the first param of getnetworkhashps to negative value returns the average network hashes per second from the last difficulty change. ACKs for top commit: jlopp: tACK https://github.com/bitcoin/bitcoin/commit/376dc2cfb32806a8aa450589effe4d384e648398 achow101: ACK 376dc2cfb32806a8aa450589effe4d384e648398 ismaelsadeeq: Tested ACK 376dc2cfb32806a8aa450589effe4d384e648398 pablomartin4btc: tACK 376dc2cfb32806a8aa450589effe4d384e648398 Tree-SHA512: 02d52f622e9cb7a1240c5d124510dd75d03f696f119b2625b0befd60b004ec50ff1a2d5515e0e227601adeecd837e0778ed131ee2a8c5f75f1b824be711213a7 --- test/functional/rpc_blockchain.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/functional/rpc_blockchain.py b/test/functional/rpc_blockchain.py index ba74f84980f5..0f1381d47385 100755 --- a/test/functional/rpc_blockchain.py +++ b/test/functional/rpc_blockchain.py @@ -59,6 +59,7 @@ TIME_RANGE_MTP = TIME_GENESIS_BLOCK + (HEIGHT - 6) * TIME_RANGE_STEP TIME_RANGE_TIP = TIME_GENESIS_BLOCK + (HEIGHT - 1) * TIME_RANGE_STEP TIME_RANGE_END = TIME_GENESIS_BLOCK + HEIGHT * TIME_RANGE_STEP +DIFFICULTY_ADJUSTMENT_INTERVAL = 2016 class BlockchainTest(BitcoinTestFramework): @@ -431,6 +432,15 @@ def _test_getnetworkhashps(self): # This should be 2 hashes every 2.6 minutes (156 seconds) or 1/78 assert abs(hashes_per_second * 78 - 1) < 0.0001 + # Test setting the first param of getnetworkhashps to negative value returns the average network + # hashes per second from the last difficulty change. + current_block_height = self.nodes[0].getmininginfo()['blocks'] + blocks_since_last_diff_change = current_block_height % DIFFICULTY_ADJUSTMENT_INTERVAL + 1 + expected_hashes_per_second_since_diff_change = self.nodes[0].getnetworkhashps(blocks_since_last_diff_change) + + assert_equal(self.nodes[0].getnetworkhashps(-1), expected_hashes_per_second_since_diff_change) + assert_equal(self.nodes[0].getnetworkhashps(-2), expected_hashes_per_second_since_diff_change) + def _test_stopatheight(self): assert_equal(self.nodes[0].getblockcount(), HEIGHT) self.generate(self.wallet, 6) From 7a3df4ed14f347c8ad855391c13f23ffbd013d3e Mon Sep 17 00:00:00 2001 From: fanquake Date: Mon, 18 Dec 2023 13:46:39 +0000 Subject: [PATCH 07/10] Merge bitcoin/bitcoin#29064: fuzz: Improve fuzzing stability for minisketch harness b2fc7a2eda103724ac8cbeaf99df3ce6f5b7d974 [fuzz] Improve fuzzing stability for minisketch harness (dergoegge) Pull request description: The `minisketch` harness has low stability due to: * Rng internal to minisketch * Benchmarkning for the best minisketch impl Fix this by seeding the rng and letting the fuzzer choose the impl. Also see #29018. ACKs for top commit: maflcko: review ACK b2fc7a2eda103724ac8cbeaf99df3ce6f5b7d974 Tree-SHA512: 3d81414299c6803c34e928a53bcf843722fa8c38e1d3676cde7fa80923f9058b1ad4b9a2941f718303a6641b17eeb28b4a22eda09678102e9fb7c4e31d06f8f2 --- src/test/fuzz/minisketch.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/test/fuzz/minisketch.cpp b/src/test/fuzz/minisketch.cpp index a17be73f6c80..698cb15fc94b 100644 --- a/src/test/fuzz/minisketch.cpp +++ b/src/test/fuzz/minisketch.cpp @@ -12,14 +12,27 @@ #include #include -using node::MakeMinisketch32; +namespace { + +Minisketch MakeFuzzMinisketch32(size_t capacity, uint32_t impl) +{ + return Assert(Minisketch(32, impl, capacity)); +} + +} // namespace FUZZ_TARGET(minisketch) { FuzzedDataProvider fuzzed_data_provider{buffer.data(), buffer.size()}; + const auto capacity{fuzzed_data_provider.ConsumeIntegralInRange(1, 200)}; - Minisketch sketch_a{Assert(MakeMinisketch32(capacity))}; - Minisketch sketch_b{Assert(MakeMinisketch32(capacity))}; + const uint32_t impl{fuzzed_data_provider.ConsumeIntegralInRange(0, Minisketch::MaxImplementation())}; + if (!Minisketch::ImplementationSupported(32, impl)) return; + + Minisketch sketch_a{MakeFuzzMinisketch32(capacity, impl)}; + Minisketch sketch_b{MakeFuzzMinisketch32(capacity, impl)}; + sketch_a.SetSeed(fuzzed_data_provider.ConsumeIntegral()); + sketch_b.SetSeed(fuzzed_data_provider.ConsumeIntegral()); // Fill two sets and keep the difference in a map std::map diff; @@ -47,8 +60,11 @@ FUZZ_TARGET(minisketch) } const auto num_diff{std::accumulate(diff.begin(), diff.end(), size_t{0}, [](auto n, const auto& e) { return n + e.second; })}; - Minisketch sketch_ar{MakeMinisketch32(capacity)}; - Minisketch sketch_br{MakeMinisketch32(capacity)}; + Minisketch sketch_ar{MakeFuzzMinisketch32(capacity, impl)}; + Minisketch sketch_br{MakeFuzzMinisketch32(capacity, impl)}; + sketch_ar.SetSeed(fuzzed_data_provider.ConsumeIntegral()); + sketch_br.SetSeed(fuzzed_data_provider.ConsumeIntegral()); + sketch_ar.Deserialize(sketch_a.Serialize()); sketch_br.Deserialize(sketch_b.Serialize()); From 0fac60f23cd9da80e886df61347d548cd2131521 Mon Sep 17 00:00:00 2001 From: fanquake Date: Tue, 16 Jan 2024 10:51:45 +0000 Subject: [PATCH 08/10] Merge bitcoin/bitcoin#29230: doc: update -loglevel help to add `info` to the always logged levels ec779a2b8e4fcc00596ee8833be35ae9b326552c doc: add unconditional info loglevel following merge of PR 28318 (Jon Atack) Pull request description: Commit ab34dc6012351e7b8aab871dd9d2b38ade1cd9b of #28318 was an incomplete version of [`118c756` (#25203)](https://github.com/bitcoin/bitcoin/pull/25203/commits/118c7567f62df2b882877590f232242d7c627a05) from the `Severity-based logging` parent PR. Add the missing text to update the `-loglevel` help doc. While here, make the help text a little easier to understand. Can be tested by running: ``` ./src/bitcoind -regtest -help-debug | grep -A12 loglevel= ``` before ``` -loglevel=|: Set the global or per-category severity level for logging categories enabled with the -debug configuration option or the logging RPC: info, debug, trace (default=debug); warning and error levels are always logged. ``` after ``` -loglevel=|: Set the global or per-category severity level for logging categories enabled with the -debug configuration option or the logging RPC. Possible values are info, debug, trace (default=debug). The following levels are always logged: error, warning, info. ``` ACKs for top commit: stickies-v: ACK ec779a2b8e4fcc00596ee8833be35ae9b326552c Tree-SHA512: 0c375e30a5a4c168ca7d97720e8c287f598216767afedae329824e09a480830faf8537b792c5c4bb647c68681c287fe3005c62093708ce85624e9a71c8245e42 --- src/init/common.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/init/common.cpp b/src/init/common.cpp index 0a1bff80d48d..d04764d0c73e 100644 --- a/src/init/common.cpp +++ b/src/init/common.cpp @@ -65,7 +65,7 @@ void AddLoggingArgs(ArgsManager& argsman) ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST); argsman.AddArg("-debugexclude=", "Exclude debug and trace logging for a category. Can be used in conjunction with -debug=1 to output debug and trace logging for all categories except the specified category. This option can be specified multiple times to exclude multiple categories.", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST); argsman.AddArg("-logips", strprintf("Include IP addresses in debug output (default: %u)", DEFAULT_LOGIPS), ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST); - argsman.AddArg("-loglevel=|:", strprintf("Set the global or per-category severity level for logging categories enabled with the -debug configuration option or the logging RPC: %s (default=%s); warning and error levels are always logged. If : is supplied, the setting will override the global one and may be specified multiple times to set multiple category-specific levels. can be: %s.", LogInstance().LogLevelsString(), LogInstance().LogLevelToStr(BCLog::DEFAULT_LOG_LEVEL), LogInstance().LogCategoriesString()), ArgsManager::DISALLOW_NEGATION | ArgsManager::DISALLOW_ELISION | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST); + argsman.AddArg("-loglevel=|:", strprintf("Set the global or per-category severity level for logging categories enabled with the -debug configuration option or the logging RPC. Possible values are %s (default=%s). The following levels are always logged: error, warning, info. If : is supplied, the setting will override the global one and may be specified multiple times to set multiple category-specific levels. can be: %s.", LogInstance().LogLevelsString(), LogInstance().LogLevelToStr(BCLog::DEFAULT_LOG_LEVEL), LogInstance().LogCategoriesString()), ArgsManager::DISALLOW_NEGATION | ArgsManager::DISALLOW_ELISION | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST); argsman.AddArg("-logtimestamps", strprintf("Prepend debug output with timestamp (default: %u)", DEFAULT_LOGTIMESTAMPS), ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST); argsman.AddArg("-logthreadnames", strprintf("Prepend debug output with name of the originating thread (only available on platforms supporting thread_local) (default: %u)", DEFAULT_LOGTHREADNAMES), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST); argsman.AddArg("-logsourcelocations", strprintf("Prepend debug output with name of the originating source location (source file, line number and function name) (default: %u)", DEFAULT_LOGSOURCELOCATIONS), ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST); From 39baa2388aec6aebef36207f39d241f129a6532b Mon Sep 17 00:00:00 2001 From: fanquake Date: Mon, 26 Feb 2024 12:26:03 +0000 Subject: [PATCH 09/10] Merge bitcoin/bitcoin#29467: test: Fix intermittent issue in interface_rest.py faeed91c0be6e5dda4790522d0dc999afd869d11 test: Fix intermittent issue in interface_rest.py (MarcoFalke) Pull request description: Fixes: ``` test 2024-02-22T16:15:37.465000Z TestFramework (ERROR): Assertion failed Traceback (most recent call last): File "/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/test_framework/test_framework.py", line 131, in main self.run_test() File "/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/interface_rest.py", line 340, in run_test assert_equal(json_obj, mempool_info) File "/ci_container_base/ci/scratch/build/bitcoin-x86_64-pc-linux-gnu/test/functional/test_framework/util.py", line 57, in assert_equal raise AssertionError("not(%s)" % " == ".join(str(arg) for arg in (thing1, thing2) + args)) AssertionError: not({'loaded': True, 'size': 3, 'bytes': 312, 'usage': 3600, 'total_fee': Decimal('0.00093600'), 'maxmempool': 300000000, 'mempoolminfee': Decimal('0.00001000'), 'minrelaytxfee': Decimal('0.00001000'), 'incrementalrelayfee': Decimal('0.00001000'), 'unbroadcastcount': 1, 'fullrbf': False} == {'loaded': True, 'size': 3, 'bytes': 312, 'usage': 3600, 'total_fee': Decimal('0.00093600'), 'maxmempool': 300000000, 'mempoolminfee': Decimal('0.00001000'), 'minrelaytxfee': Decimal('0.00001000'), 'incrementalrelayfee': Decimal('0.00001000'), 'unbroadcastcount': 0, 'fullrbf': False}) ``` https://cirrus-ci.com/task/4852944378527744?logs=ci#L4436 ACKs for top commit: m3dwards: ACK https://github.com/bitcoin/bitcoin/pull/29467/commits/faeed91c0be6e5dda4790522d0dc999afd869d11 mzumsande: ACK faeed91c0be6e5dda4790522d0dc999afd869d11 Tree-SHA512: 513422229db45d2586c554b9a466e86848bfcf5280b0f000718cbfc44d93dd1af69e19a56f6ac578f5d7aada74ab0c90d4a9e09a324062b6f9ed239e5e34f540 --- test/functional/interface_rest.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/functional/interface_rest.py b/test/functional/interface_rest.py index 5f63718c4bba..9ec1fe9bbece 100755 --- a/test/functional/interface_rest.py +++ b/test/functional/interface_rest.py @@ -336,6 +336,9 @@ def run_test(self): assert_greater_than(json_obj['bytes'], 240) mempool_info = self.nodes[0].getmempoolinfo() + # pop unstable unbroadcastcount before check + for obj in [json_obj, mempool_info]: + obj.pop("unbroadcastcount") assert_equal(json_obj, mempool_info) # Check that there are our submitted transactions in the TX memory pool From b84939e03545b2613f0d17d2960c83b1892b2896 Mon Sep 17 00:00:00 2001 From: fanquake Date: Fri, 1 Mar 2024 10:07:35 -0500 Subject: [PATCH 10/10] Merge bitcoin/bitcoin#29495: fuzz: add target for local address stuff 25eab523897e790f4f4d7b49cdbf19d13e3b0fcc fuzz: add target for local addresses (brunoerg) Pull request description: This PR adds fuzz target for local address functions - (`AddLocal`, `RemoveLocal`, `SeenLocal`, `IsLocal`) ACKs for top commit: dergoegge: ACK 25eab523897e790f4f4d7b49cdbf19d13e3b0fcc vasild: ACK 25eab523897e790f4f4d7b49cdbf19d13e3b0fcc Tree-SHA512: 24faaab86dcd8835ba0e2d81fb6322a39a9266c7edf66415dbc4421754054f47efb6e0de4efdc7ea026b0686792658e86a526f7cf27cbc6cf9ed0c4aed376f97 --- src/test/fuzz/net.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/test/fuzz/net.cpp b/src/test/fuzz/net.cpp index 1de4877f94ae..0089d0f2e8a2 100644 --- a/src/test/fuzz/net.cpp +++ b/src/test/fuzz/net.cpp @@ -94,3 +94,40 @@ FUZZ_TARGET(net, .init = initialize_net) (void)node.HasPermission(net_permission_flags); (void)node.ConnectedThroughNetwork(); } + +FUZZ_TARGET(local_address, .init = initialize_net) +{ + FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size()); + CService service{ConsumeService(fuzzed_data_provider)}; + CNode node{ConsumeNode(fuzzed_data_provider)}; + { + LOCK(g_maplocalhost_mutex); + mapLocalHost.clear(); + } + LIMITED_WHILE(fuzzed_data_provider.ConsumeBool(), 10000) { + CallOneOf( + fuzzed_data_provider, + [&] { + service = ConsumeService(fuzzed_data_provider); + }, + [&] { + const bool added{AddLocal(service, fuzzed_data_provider.ConsumeIntegralInRange(0, LOCAL_MAX - 1))}; + if (!added) return; + assert(service.IsRoutable()); + assert(IsLocal(service)); + assert(SeenLocal(service)); + }, + [&] { + (void)RemoveLocal(service); + }, + [&] { + (void)SeenLocal(service); + }, + [&] { + (void)IsLocal(service); + }, + [&] { + (void)GetLocalAddress(node); + }); + } +}