fuzz: scope fake clocks to target phases #35956

pull HowHsu wants to merge 2 commits into bitcoin:master from HowHsu:fuzz-target-local-clock changing 8 files +23 −25
  1. HowHsu commented at 11:41 AM on August 12, 2026: contributor

    Follow-up to #35482 (https://github.com/bitcoin/bitcoin/pull/35482#discussion_r3612852792), addressing a remaining issue with the lifetime of the mock node clock.

    This replaces the process-wide FakeNodeClock accessor with scoped clocks in the affected fuzz target initialization and input-processing phases, following the existing FakeSteadyClock pattern. The active clock is passed to ResetChainmanAndMempool() by reference.

    Tested the affected fuzz targets with -runs=1:

    • cmpctblock
    • process_message
    • process_messages
    • utxo_snapshot
    • utxo_snapshot_invalid
  2. fuzz: document arbitrary mocktimes e33410d888
  3. DrahtBot added the label Fuzzing on Aug 12, 2026
  4. DrahtBot commented at 11:41 AM on August 12, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35956.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK maflcko, nervana21

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #24230 (indexes: Stop using node internal types and locking cs_main, improve sync logic by ryanofsky)

    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.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. in src/test/fuzz/cmpctblock.cpp:122 in 12e3c5b6b9
     118 | @@ -119,20 +119,21 @@ extern void MakeRandDeterministicDANGEROUS(const uint256& seed) noexcept;
     119 |  
     120 |  void initialize_cmpctblock()
     121 |  {
     122 | +    FakeNodeClock node_clock{1231006505s}; // Bitcoin genesis block timestamp
    


    nervana21 commented at 7:56 PM on August 13, 2026:

    12e3c5b6b940b43b52da6cb527969807310de722: fuzz: refactor: scope fake clocks to target phases

    Nit. There are 3 instances where 1231006505s is labeled "Bitcoin genesis", but these targets are REGTEST, and ResetChainmanAndMempool overwrites with GenesisBlock().Time() anyway.

        FakeNodeClock node_clock{1231006505s}; // dummy block timestamp until Reset
    

    maflcko commented at 2:58 PM on August 18, 2026:
        FakeNodeClock init_clock{}; // Uses the existing mock time
    

    Haven't tried this, but what about just clarifying that this is using the existing (global) fuzz init mock time?


    HowHsu commented at 12:17 PM on August 19, 2026:

    Haven't tried this, but what about just clarifying that this is using the existing (global) fuzz init mock time?

    Tested, it works with a little bit extra change.

  6. nervana21 commented at 7:56 PM on August 13, 2026: contributor

    tACK 12e3c5b6b940b43b52da6cb527969807310de722

  7. nervana21 commented at 12:42 PM on August 19, 2026: contributor

    Please apply this change to all three instances of 'node_clock' and squash the changes to be included along with the previous commit

  8. HowHsu force-pushed on Aug 19, 2026
  9. DrahtBot added the label CI failed on Aug 19, 2026
  10. DrahtBot commented at 12:45 PM on August 19, 2026: contributor

    <!--85328a0da195eb286784d51f73fa0af9-->

    🚧 At least one of the CI tasks failed. <sub>Task previous releases: https://github.com/bitcoin/bitcoin/actions/runs/32251840412/job/96064409693</sub> <sub>LLM reason (✨ experimental): CI failed due to a C++ compilation error in the fuzz test build (cmpctblock.cpp): node_clock was not declared (did you mean NodeClock?).</sub>

    <details><summary>Hints</summary>

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

    </details>

  11. fuzz: refactor: scope fake clocks to target phases
    Avoid exposing a process-wide FakeNodeClock accessor from the test
    utility module. Initialize separate scoped clocks for target setup and
    input processing, and pass the active clock to ResetChainmanAndMempool
    by reference.
    
    ResetChainmanAndMempool sets each scoped clock to the selected chain's
    genesis time. Avoid hard-coding the mainnet genesis timestamp when
    constructing these clocks, because the targets use REGTEST parameters
    and the value is overwritten during reset.
    
    Initialize each clock from the fuzz harness's existing mock time until
    ResetChainmanAndMempool sets the REGTEST genesis time.
    
    This commit does not change behavior.
    
    Co-authored-by: maflcko <6399679+maflcko@users.noreply.github.com>
    Co-authored-by: nervana21 <205626986+nervana21@users.noreply.github.com>
    4e5327bc98
  12. HowHsu force-pushed on Aug 19, 2026
  13. HowHsu commented at 12:49 PM on August 19, 2026: contributor

    Please apply this change to all three instances of 'node_clock' and squash the changes to be included along with the previous commit

    Done.

  14. DrahtBot removed the label CI failed on Aug 19, 2026
  15. maflcko commented at 2:19 PM on August 19, 2026: member

    review ACK 4e5327bc988b3928ab6c96d6407d28a91a347413 🚉

    <details><summary>Show signature</summary>

    Signature:

    untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
    RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
    trusted comment: review ACK 4e5327bc988b3928ab6c96d6407d28a91a347413 🚉
    PoCj1AuywccLURIc1w/UngKSGsjZlYvkDChzh0NOF9zgQuI75RhE/nSVW+n8XfHjWIAog4evNRpq6DXRp+31CA==
    

    </details>

  16. DrahtBot requested review from nervana21 on Aug 19, 2026
  17. nervana21 commented at 2:23 PM on August 19, 2026: contributor

    re-ACK 4e5327bc988b3928ab6c96d6407d28a91a347413

  18. fanquake merged this on Aug 19, 2026
  19. fanquake closed this on Aug 19, 2026


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-08-21 04:51 UTC

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