fuzz: add more coverage for ScriptPubKeyMan #30134

pull brunoerg wants to merge 1 commits into bitcoin:master from brunoerg:2024-04-fuzz-spkm-improvements changing 1 files +16 −0
  1. brunoerg commented at 8:39 pm on May 17, 2024: 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.
  2. fuzz: add more coverage for `ScriptPubKeyMan` e3249f2111
  3. DrahtBot commented at 8:39 pm on May 17, 2024: 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.

  4. DrahtBot added the label Tests on May 17, 2024
  5. in src/wallet/test/fuzz/scriptpubkeyman.cpp:35 in e6f89cc982 outdated
    30-#include <map>
    31-#include <memory>
    32-#include <optional>
    33-#include <string>
    34-#include <utility>
    35-#include <variant>
    


    maflcko commented at 8:31 am on May 18, 2024:

    Can you explain this change?

     0wallet/test/fuzz/scriptpubkeyman.cpp should add these lines:
     1#include <assert.h>                        // for assert
     2#include <functional>                      // for function
     3#include <map>                             // for map
     4#include <memory>                          // for unique_ptr, shared_ptr, make_unique, __shared_ptr_access
     5#include <optional>                        // for optional, nullopt, nullopt_t
     6#include <unordered_set>                   // for unordered_set, _Node_iterator
     7#include <utility>                         // for pair, make_pair, move
     8#include <variant>                         // for get_if
     9#include "addresstype.h"                   // for PKHash, ExtractDestination, IsValidDestination, CTxDestination
    10#include "chain.h"                         // for CChain, CBlockIndex
    11#include "chainparams.h"                   // for SelectParams
    12#include "coins.h"                         // for Coin
    13#include "key.h"                           // for CKey, operator==
    14#include "primitives/transaction.h"        // for CMutableTransaction, TransactionSerParams, TX_WITH_WITNESS, COutPoint
    15#include "psbt.h"                          // for PartiallySignedTransaction, PrecomputePSBTData
    16#include "pubkey.h"                        // for CPubKey
    17#include "script/descriptor.h"             // for Descriptor, Parse
    18#include "script/interpreter.h"            // for PrecomputedTransactionData
    19#include "script/script.h"                 // for CScript
    20#include "script/signingprovider.h"        // for FlatSigningProvider
    21#include "sync.h"                          // for MaybeCheckNotHeld, LOCK, UniqueLock
    22#include "util/hasher.h"                   // for SaltedSipHasher
    23#include "util/result.h"                   // for Result
    24#include "util/strencodings.h"             // for string, char_traits, string_view
    25#include "util/translation.h"              // for bilingual_str
    26#include "wallet/types.h"                  // for isminetype
    

    https://api.cirrus-ci.com/v1/task/5472392502312960/logs/ci.log


    brunoerg commented at 9:02 am on May 18, 2024:
    Nevermind, just dropped this change.
  6. brunoerg force-pushed on May 18, 2024
  7. marcofleon commented at 2:21 pm on May 19, 2024: contributor

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

    Before:

    After:

    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?

  8. brunoerg commented at 7:51 pm on May 19, 2024: contributor

    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)?

  9. marcofleon commented at 1:43 pm on May 20, 2024: 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.
  10. marcofleon commented at 2:58 pm on May 31, 2024: contributor
    Tested ACK e3249f21111f1dd4beb66f10af933c34a36c30ac. 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.
  11. murchandamus commented at 8:16 pm on May 31, 2024: contributor

    Tested ACK e3249f21111f1dd4beb66f10af933c34a36c30ac

    I also fuzzed a bit: I ran a recent commit of the master branch and this PR’s e3249f21111f1dd4beb66f10af933c34a36c30ac 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: e3249f21111f1dd4beb66f10af933c34a36c30ac cov: 17095 ft: 83926 cov: 17699 ft: 98966

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

  12. fanquake merged this on Jun 3, 2024
  13. fanquake closed this on Jun 3, 2024


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-09-28 22:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me