This is unused and avoids a clang warning.
Can be tested via: git grep --count '\<g_setup' | grep ':2'
Before: Prints files names. After: No output.
This is unused and avoids a clang warning.
Can be tested via: git grep --count '\<g_setup' | grep ':2'
Before: Prints files names. After: No output.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
See the guideline for information on the review process.
| Type | Reviewers |
|---|---|
| ACK | hebasto, hodlinator |
| Stale ACK | sedited |
If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.
g_setup).
42-const BasicTestingSetup* g_setup;
43-} // namespace
44-
45 void initialize_deserialize()
46 {
47 static const auto testing_setup = MakeNoLogFileContext<>();
Only the snapshotmetadata_deserialize-target needs this. Moreover, it only needs SelectParams(ChainType::MAIN); to be called.
0diff --git a/src/test/fuzz/deserialize.cpp b/src/test/fuzz/deserialize.cpp
1index 1329f471c7..23e5e0dfbc 100644
2--- a/src/test/fuzz/deserialize.cpp
3+++ b/src/test/fuzz/deserialize.cpp
4@@ -8,6 +8,7 @@
5 #include <blockencodings.h>
6 #include <blockfilter.h>
7 #include <chain.h>
8+#include <chainparams.h>
9 #include <coins.h>
10 #include <common/args.h>
11 #include <compressor.h>
12@@ -27,7 +28,6 @@
13 #include <streams.h>
14 #include <test/fuzz/fuzz.h>
15 #include <test/fuzz/util.h>
16-#include <test/util/setup_common.h>
17 #include <undo.h>
18
19 #include <cstdint>
20@@ -38,13 +38,13 @@
21 using kernel::CBlockFileInfo;
22 using node::SnapshotMetadata;
23
24-void initialize_deserialize()
25+static void InitializeParams()
26 {
27- static const auto testing_setup = MakeNoLogFileContext<>();
28+ SelectParams(ChainType::MAIN);
29 }
30
31 #define FUZZ_TARGET_DESERIALIZE(name, code) \
32- FUZZ_TARGET(name, .init = initialize_deserialize) \
33+ FUZZ_TARGET(name) \
34 { \
35 try { \
36 code \
37@@ -128,7 +128,7 @@ FUZZ_TARGET_DESERIALIZE(block_filter_deserialize, {
38 BlockFilter block_filter;
39 DeserializeFromFuzzingInput(buffer, block_filter);
40 })
41-FUZZ_TARGET(addr_info_deserialize, .init = initialize_deserialize)
42+FUZZ_TARGET(addr_info_deserialize)
43 {
44 FuzzedDataProvider fdp{buffer.data(), buffer.size()};
45 (void)ConsumeDeserializable<AddrInfo>(fdp, ConsumeDeserializationParams<CAddress::SerParams>(fdp));
46@@ -229,7 +229,7 @@ FUZZ_TARGET_DESERIALIZE(coins_deserialize, {
47 Coin coin;
48 DeserializeFromFuzzingInput(buffer, coin);
49 })
50-FUZZ_TARGET(netaddr_deserialize, .init = initialize_deserialize)
51+FUZZ_TARGET(netaddr_deserialize)
52 {
53 FuzzedDataProvider fdp{buffer.data(), buffer.size()};
54 const auto maybe_na{ConsumeDeserializable<CNetAddr>(fdp, ConsumeDeserializationParams<CNetAddr::SerParams>(fdp))};
55@@ -240,7 +240,7 @@ FUZZ_TARGET(netaddr_deserialize, .init = initialize_deserialize)
56 }
57 AssertEqualAfterSerializeDeserialize(na, CNetAddr::V2);
58 }
59-FUZZ_TARGET(service_deserialize, .init = initialize_deserialize)
60+FUZZ_TARGET(service_deserialize)
61 {
62 FuzzedDataProvider fdp{buffer.data(), buffer.size()};
63 const auto ser_params{ConsumeDeserializationParams<CNetAddr::SerParams>(fdp)};
64@@ -260,7 +260,7 @@ FUZZ_TARGET_DESERIALIZE(messageheader_deserialize, {
65 DeserializeFromFuzzingInput(buffer, mh);
66 (void)mh.IsMessageTypeValid();
67 })
68-FUZZ_TARGET(address_deserialize, .init = initialize_deserialize)
69+FUZZ_TARGET(address_deserialize)
70 {
71 FuzzedDataProvider fdp{buffer.data(), buffer.size()};
72 const auto ser_enc{ConsumeDeserializationParams<CAddress::SerParams>(fdp)};
73@@ -310,11 +310,15 @@ FUZZ_TARGET_DESERIALIZE(blocktransactionsrequest_deserialize, {
74 BlockTransactionsRequest btr;
75 DeserializeFromFuzzingInput(buffer, btr);
76 })
77-FUZZ_TARGET_DESERIALIZE(snapshotmetadata_deserialize, {
78+FUZZ_TARGET(snapshotmetadata_deserialize, .init = InitializeParams)
79+{
80 auto msg_start = Params().MessageStart();
81 SnapshotMetadata snapshot_metadata{msg_start};
82- DeserializeFromFuzzingInput(buffer, snapshot_metadata);
83-})
84+ try {
85+ DeserializeFromFuzzingInput(buffer, snapshot_metadata);
86+ } catch (const invalid_fuzzing_input_exception&) {
87+ }
88+}
89 FUZZ_TARGET_DESERIALIZE(uint160_deserialize, {
90 uint160 u160;
91 DeserializeFromFuzzingInput(buffer, u160);
this suggested diff is hard to review.
It’s not a one-liner, but I wouldn’t characterize the diff as hard to review?
The targets barely contain any branches. Running ./build_fuzz/test/fuzz/test_runner.py deserialize helps give some assurance of correctness.
See #34562 (comment) for a similar diff.
I’ve been working on an isolated PR for the change discussed in that thread for the last week. Hope to get it up for review tomorrow. That’s part of why I felt comfortable about suggesting the diff I guess, and also motivated to minimize dependencies on BasicTestingSetup.
That’s part of why I felt comfortable about suggesting the diff I guess
Ok, I see. Though, my preference would be to just wait until tomorrow and then review the unrelated changes separately, so that all reviewers can be equally comfortable about them.
The goal here is just to remove a clearly unused pointer. Restructuring the logging, or the testing context should ideally be done in a separate pull.
The goal here is just to remove a clearly unused pointer. Restructuring the logging, or the testing context should ideally be done in a separate pull.
These fuzz targets we’re already running under MakeNoLogFileContext on master, so my diff doesn’t materially change that aspect.
I guess I can tack on a version of my diff above to my upcoming PR… but it would feel more tangential there, while here it’s more off a thorough change instead of doing the absolute minimal to silence the compiler.
Is there another semi-urgent PR depending on this one?
The goal here is just to remove a clearly unused pointer. Restructuring the logging, or the testing context should ideally be done in a separate pull.
These fuzz targets we’re already running under
MakeNoLogFileContexton master, so my diff doesn’t materially change that aspect.
It literally changes that by removing (-) it. At least I see in the diff:
0- static const auto testing_setup = MakeNoLogFileContext<>();
Is there another semi-urgent PR depending on this one?
Nothing urgent. Happy to close this one, if you think it is too controversial, no strong opinion.
Yes, on master MakeNoLogFileContext prevents logging to a file, and in my diff the removal of the testing_setup prevents logging to a file.
I don’t think the PR is controversial in it’s current state, just half-baked, leaving detritus behind.
Is logging to the console important for these fuzz tests? Or is there some other context I’m missing?
I don’t think the PR is controversial in it’s current state, just half-baked, leaving detritus behind.
Is logging to the console important for these fuzz tests? Or is there some other context I’m missing?
I don’t like mixing behavior changes with refactors. If you want to remove the logging feature, it may be fine, but this is unrelated to this pull request, whose aim is to not change any behavior.
This is just what i’ve already said previously in #34562 (review):
Seems a bit odd to hide those changes without any mention in a commit called “test: move and simplify BOOST_CHECK ostream helpers”.
This will break DEBUG_LOG_OUT for all of those tests, which makes failures harder to debug.
I think this should be reverted, or at a minimum put into a different commit, to explain that this is a breaking change.
I don’t like mixing behavior changes with refactors. If you want to remove the logging feature, it may be fine, but this is unrelated to this pull request, whose aim is to not change any behavior.
Okay, it boils down to wanting to make it a strict refactoring. I can respect that.
Seems a bit odd to hide those changes without any mention in a commit called “test: move and simplify BOOST_CHECK ostream helpers”.
It was good you called it out, it was a combination of that PR authors change and a patch I had posted earlier. At that time I didn’t see the integration of our logging system into the unit test execution to be an important feature, but you changed my mind.
This will break DEBUG_LOG_OUT for all of those tests, which makes failures harder to debug.
As I said in that thread, I hadn’t been aware of DEBUG_LOG_OUT.
My upcoming PR takes care to preserve DEBUG_LOG_OUT support for all unit tests using a *TestingSetup.
My upcoming PR
DEBUG_LOG_OUT, but using the bitcoind option: FUZZ=block_deserialize ./bld-cmake/bin/fuzz -- --printtoconsole=1
-printtoconsole=1 and drop DEBUG_LOG_OUT?
I think that requires a NodeContext::ArgsManager, whereas DEBUG_LOG_OUT works on the global logger context.
I guess it is a bit unclear which direction to go:
-printtoconsole=1)DEBUG_LOG_OUT to the fuzz testsI minimally tend toward the second option, but no strong opinion.
DEBUG_LOG_OUT is implemented within G_TEST_LOG_FUN which is only added as a logging callback inside of BasicTestingSetup which also calls InitLogging() which calls SetLoggingOptions() which reads -printtoconsole=1.
During destruction of BasicTestingSetup it calls LogInstance().DisconnectTestLogger() which removes the G_TEST_LOG_FUN callback. DisableLogging() is not called, so Logger::m_print_to_console would be left on.
So it doesn’t seem like DEBUG_LOG_OUT leads to increased logging over -printtoconsole=1.
Ah, I didn’t read the code, and just went from memory. Thanks for correcting me.
Though, I guess I still don’t know which direction to go:
Either change seems large-ish, so should come with a strong rationale.
DEBUG_LOG_OUT and replacing it with the equivalent -- --printtoconsole=1 seems fine for now. If there is need for it in the future, it can trivially be added back.
Maybe just removing
DEBUG_LOG_OUTand replacing it with the equivalent-- --printtoconsole=1seems fine for now. If there is need for it in the future, it can trivially be added back.
Done now in #34926.
Running hebasto/bitcoin-core-nightly#221.
There is another instance:
0/home/runner/work/bitcoin-core-nightly/bitcoin-core-nightly/src/test/fuzz/mini_miner.cpp:30:21: error: variable 'g_setup' set but not used [-Werror,-Wunused-but-set-variable]
1 30 | const TestingSetup* g_setup;
2 | ^
31 error generated.
There is another instance:
Thx, updated pull description with git grep command to find all.
Tested fa55562d841f593f87fd2a04fe188c77184d6b36.
https://github.com/hebasto/bitcoin-core-nightly/actions/runs/23540222699:
0/home/runner/work/bitcoin-core-nightly/bitcoin-core-nightly/src/wallet/test/fuzz/crypter.cpp:14:21: error: variable 'g_setup' set but not used [-Werror,-Wunused-but-set-variable]
1 14 | const TestingSetup* g_setup;
2 | ^
31 error generated.
These are unused and removing them avoids clang warnings like:
src/test/fuzz/deserialize.cpp:42:26: error: variable g_setup set but not used [-Werror,-Wunused-but-set-variable]
In your description, you mention that the grep command will output two file names, but I get three.
On master branch 2fe76ed8324af44c985b96455a05c3e8bec0a03e
0$ git grep --count '\<g_setup' | grep ':2'
1src/test/fuzz/deserialize.cpp:2
2src/test/fuzz/mini_miner.cpp:2
3src/wallet/test/fuzz/crypter.cpp:2
I do in fact get none after fabbfec
In your description, you mention that the grep command will output two file names, but I get three.
thx, removed outdated “two”
ACK fabbfec3b00c138a28034a4f5594305d2220b9bb
Could clean more stuff away (https://github.com/bitcoin/bitcoin/pull/34918#discussion_r2987687080), but it’s okay to keep it a strict refactor.