Add FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION in PoW check
To avoid PoW being a blocker for fuzz tests, `FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION` is used in fuzz builds to bypass the actual PoW validation in `CheckProofOfWork`. It's replaced with a check on the last byte of the hash, which allows the fuzzer to quickly generate (in)valid blocks by checking a single bit, rather than performing the full PoW computation. If PoW is the target of a fuzz test, then it should call `CheckProofOfWorkImpl`.
This commit is contained in:
1 parent
a3f6f5acd8
commit
a0eaa4749f
4 files changed
+14
-2
No files matched your search
@@ -80,7 +80,7 @@ FUZZ_TARGET(pow, .init = initialize_pow)
|
||||
{
|
||||
const std::optional<uint256> hash = ConsumeDeserializable<uint256>(fuzzed_data_provider);
|
||||
if (hash) {
|
||||
(void)CheckProofOfWork(*hash, fuzzed_data_provider.ConsumeIntegral<unsigned int>(), consensus_params);
|
||||
(void)CheckProofOfWorkImpl(*hash, fuzzed_data_provider.ConsumeIntegral<unsigned int>(), consensus_params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user