fuzz: Use FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION for pow checks#29305
Closed
dergoegge wants to merge 1 commit intobitcoin:masterfrom
Closed
fuzz: Use FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION for pow checks#29305dergoegge wants to merge 1 commit intobitcoin:masterfrom
dergoegge wants to merge 1 commit intobitcoin:masterfrom
Conversation
Unless we are fuzzing `CheckProofOfWork` itself, it makes little sense to have it be a blocker when fuzzing. We therefore use `FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION` (only defined for fuzz builds by e.g. clang with -fsanitize=fuzzer, afl-clang-lto, etc.) to replace the actual proof-of-work checks with checking if the first bit on `nNonce` is set. This allows the fuzzer to create PoW (in)valid blocks by controling that one bit instead of having to grind for actual PoW. Checking for a bit in `nNonce` is preferable over checking for a bit in the block hash as `nNonce` is chosen by the fuzzer and when whole chains of blocks are created during fuzzing a change in an old block won't invalidate the fake PoW on newer blocks.
Contributor
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process. |
Member
Author
|
Using clang with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Alternative to the mocking of
CheckProofOfWorkin #28043 for avoiding fuzzers to be blocked on proof-of-work checks.More on
FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION: https://llvm.org/docs/LibFuzzer.html#fuzzer-friendly-build-mode