fuzz: Add utxo_snapshot target #21953

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:2104-assumeutxoCrash02 changing 6 files +132 −6
  1. MarcoFalke commented at 10:07 AM on May 15, 2021: member

    No description provided.

  2. fanquake added the label Tests on May 15, 2021
  3. practicalswift commented at 11:31 AM on May 15, 2021: contributor

    Concept ACK

    Very nice! :)

  4. fuzz: Add utxo_snapshot target fa91994b1b
  5. MarcoFalke force-pushed on May 16, 2021
  6. in src/test/fuzz/utxo_snapshot.cpp:72 in fa91994b1b
      67 | +        Assert(*chainman.ActiveChainstate().m_from_snapshot_blockhash ==
      68 | +               *chainman.SnapshotBlockhash());
      69 | +        const auto& coinscache{chainman.ActiveChainstate().CoinsTip()};
      70 | +        int64_t chain_tx{};
      71 | +        for (const auto& block : *g_chain) {
      72 | +            Assert(coinscache.HaveCoin(COutPoint{block->vtx.at(0)->GetHash(), 0}));
    


    jamesob commented at 3:19 PM on May 20, 2021:

    Just out of curiosity - if we've gotten here, that means that the fuzzer has provided random input that has happened to correspond to a utxo snapshot that matches the chain we've generated in setup. This seems extraordinarily unlikely to me; how often do we expect this to actually happen? Am I missing some mechanic about how the fuzzer works that makes this a more frequent thing?


    MarcoFalke commented at 6:53 PM on May 21, 2021:

    Right, I expect this to be impossible unless one of the initial seed inputs is a valid snapshot.


  7. adamjonas commented at 10:30 PM on May 20, 2021: member

    Fuzzed utxo_snapshot with fa91994 and did see modest coverage gains. Naively wondering whether if it'd be possible to improve the execution speed.

    <details> <summary>Log</summary>

    [#2](/bitcoin-bitcoin/2/)	pulse  ft: 36401 exec/s: 0 rss: 547Mb
    [#4](/bitcoin-bitcoin/4/)	pulse  cov: 36733 ft: 36457 corp: 2/2b exec/s: 0 rss: 561Mb
    [#8](/bitcoin-bitcoin/8/)	pulse  cov: 36749 ft: 36458 corp: 3/3b exec/s: 0 rss: 582Mb
    [#16](/bitcoin-bitcoin/16/)	pulse  cov: 36750 ft: 36460 corp: 4/4b exec/s: 0 rss: 624Mb
    [#32](/bitcoin-bitcoin/32/)	pulse  cov: 36750 ft: 36461 corp: 6/6b exec/s: 1 rss: 695Mb
    [#64](/bitcoin-bitcoin/64/)	pulse  cov: 36751 ft: 36472 corp: 10/10b exec/s: 2 rss: 789Mb
    [#128](/bitcoin-bitcoin/128/)	pulse  cov: 36751 ft: 36475 corp: 12/12b exec/s: 4 rss: 790Mb
    [#256](/bitcoin-bitcoin/256/)	pulse  cov: 36751 ft: 36475 corp: 12/12b exec/s: 6 rss: 790Mb
    [#512](/bitcoin-bitcoin/512/)	pulse  cov: 36751 ft: 36475 corp: 12/12b exec/s: 9 rss: 790Mb
    [#1024](/bitcoin-bitcoin/1024/)	pulse  cov: 36759 ft: 36511 corp: 18/24b exec/s: 13 rss: 790Mb
    [#2048](/bitcoin-bitcoin/2048/)	pulse  cov: 36761 ft: 36544 corp: 23/36b exec/s: 15 rss: 790Mb
    [#4096](/bitcoin-bitcoin/4096/)	pulse  cov: 37753 ft: 40612 corp: 56/151b exec/s: 16 rss: 790Mb
    [#8192](/bitcoin-bitcoin/8192/)	pulse  cov: 37754 ft: 40812 corp: 106/426b exec/s: 16 rss: 790Mb
    ...
    

    </details>

  8. MarcoFalke commented at 6:38 AM on May 21, 2021: member

    Naively wondering whether if it'd be possible to improve the execution speed.

    Sure, just set the tempdir to a ramdisk

  9. MarcoFalke commented at 6:48 AM on May 21, 2021: member

    For refrerence, I am getting

    [#3502](/bitcoin-bitcoin/3502/)	NEW    cov: 4861 ft: 5258 corp: 79/859b lim: 17 exec/s: 106 rss: 91Mb L: 17/17 MS: 1 CopyPart-
    
  10. jamesob approved
  11. jamesob commented at 1:32 PM on May 21, 2021: member

    ACK https://github.com/bitcoin/bitcoin/pull/21953/commits/fa91994b1b9b6da3bb2a2f722d9251d7d0f2167e

    I'm in the process of trying to get this to run locally, but have reviewed the code and it looks like a great start. We could maybe save some cycles by conditionally prepending valid snapshot metadata to the file we construct (in the same way that we conditionally have the background chainstate synced to the snapshot base), but in any case this is a good change.

    I'll report back with logs when I get this running.

  12. jamesob commented at 6:56 PM on May 21, 2021: member

    Tested ACK

    Ran it locally for a while: #9331 NEW cov: 18641 ft: 21159 corp: 162/2883b lim: 38 exec/s: 17 rss: 549Mb L: 25/36 MS: 2 InsertByte-PersAutoDict- DE: "debuglogf"-

  13. MarcoFalke merged this on May 22, 2021
  14. MarcoFalke closed this on May 22, 2021

  15. MarcoFalke deleted the branch on May 22, 2021
  16. practicalswift commented at 8:23 AM on May 22, 2021: contributor

    Post-merge tested ACK fa91994b1b9b6da3bb2a2f722d9251d7d0f2167e

    $ FUZZ=utxo_snapshot src/test/fuzz/fuzz utxo_snapshot/
    …
    INFO:      266 files found in utxo_snapshot/
    …
    [#16](/bitcoin-bitcoin/16/)     pulse  cov: 20394 ft: 20311 corp: 5/6b exec/s: 8 rss: 241Mb
    …
    [#267](/bitcoin-bitcoin/267/)    INITED cov: 22144 ft: 29197 corp: 145/5368b exec/s: 3 rss: 497Mb
    

    utxo_snapshot/ created from thin air during ~8 hours of fuzzing.

  17. sidhujag referenced this in commit 0ade921c40 on May 24, 2021
  18. gwillen referenced this in commit 2a2bbdaee3 on Jun 1, 2022
  19. DrahtBot locked this on Aug 18, 2022

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: 2026-04-17 06:14 UTC

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