Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fuzz: add more coverage for ScriptPubKeyMan #30134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

brunoerg
Copy link
Contributor

@brunoerg brunoerg commented May 17, 2024

This PR adds more coverage for ScriptPubKeyMan:

  • Check GetKey and HasPrivKey after adding descriptor key.
  • Cover GetEndRange and GetKeyPoolSize.
  • Cover MarkUnusedAddresses with the scripts from ScriptPubKeys and GetMetadata with the destinations from them.

@DrahtBot
Copy link
Contributor

DrahtBot commented May 17, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK marcofleon, murchandamus

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #28333 (wallet: Construct ScriptPubKeyMans with all data rather than loaded progressively by achow101)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@DrahtBot DrahtBot added the Tests label May 17, 2024
@brunoerg brunoerg mentioned this pull request May 17, 2024
10 tasks
@brunoerg brunoerg force-pushed the 2024-04-fuzz-spkm-improvements branch from e6f89cc to e3249f2 Compare May 18, 2024 09:00
Copy link
Contributor

@marcofleon marcofleon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generated a coverage report for the current ScriptPubKeyMan harness and for the updated harness in this PR.

Before:
Screenshot 2024-05-19 at 6 18 27 AM
Screenshot 2024-05-19 at 6 18 37 AM

After:
Screenshot 2024-05-19 at 7 06 41 AM
Screenshot 2024-05-19 at 7 06 54 AM

So more coverage in scriptpubkeyman.cpp but it seems less total coverage when running the indivdual harness. My question here is do the totals matter when fuzzing a single target. Because there are probably other harnesses that would hit those other files (other than scriptpubkeyman.cpp).

Basically, does total coverage only matter when generating a report from fuzzing all the targets?

@brunoerg
Copy link
Contributor Author

I generated a coverage report for the current ScriptPubKeyMan harness and for the updated harness in this PR.

@marcofleon It's good to mention how you run it. How many hours? From seed corpus (note that changes can invalidate it)?

@marcofleon
Copy link
Contributor

Got it, thanks @brunoerg. I'll redo and get back to you then. I also realized I was looking at the wrong line in the coverage report. I should probably be looking at wallet/scriptpubkeyman.cpp not wallet/test/fuzz/scriptpubkeyman.cpp.

Copy link
Contributor

@marcofleon marcofleon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested ACK e3249f2. I ran the updated harness for ~9 hours on an empty corpus, generated a coverage report, and checked that the new functions mentioned were hit. Coverage of scriptpubkeyman.cpp increased.

Copy link
Contributor

@murchandamus murchandamus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested ACK e3249f2

I also fuzzed a bit: I ran a recent commit of the master branch and this PR’s e3249f2 against qa-assets:HEAD and then again after fuzzing about 12 CPU hours on top of qa-assets:HEAD.

qa-assets qa-assets + fuzzing
master cov: 16525 ft: 96185 cov: 16874 ft: 104431
#30134: e3249f2 cov: 17095 ft: 83926 cov: 17699 ft: 98966

This PR increases the coverage with the existing seeds and further improves even after light fuzzing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants