Skip to content

fuzz: add more coverage for ScriptPubKeyMan - #30134

Merged
fanquake merged 1 commit into
bitcoin:masterfrom
brunoerg:2024-04-fuzz-spkm-improvements
Jun 3, 2024
Merged

fanquake merged 1 commit into
bitcoin:masterfrom
brunoerg:2024-04-fuzz-spkm-improvements

Conversation

@brunoerg

@brunoerg brunoerg commented May 17, 2024 •

Copy link
Copy Markdown
Contributor

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

DrahtBot commented May 17, 2024 •

Copy link
Copy Markdown
Contributor

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
11 of 14 tasks
@brunoerg
brunoerg force-pushed the 2024-04-fuzz-spkm-improvements branch from e6f89cc to e3249f2 Compare May 18, 2024 09:00

@marcofleon marcofleon left a comment •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
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.

@marcofleon marcofleon left a comment

Copy link
Copy Markdown
Contributor

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.

@murchandamus murchandamus left a comment •

Copy link
Copy Markdown
Member

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.

@fanquake
fanquake merged commit c065ae8 into bitcoin:master Jun 3, 2024
@bitcoin bitcoin locked and limited conversation to collaborators Jun 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants