fuzz: Add and use NodeClockContext #34479

pull maflcko wants to merge 3 commits into bitcoin:master from maflcko:2602-fuzz-clock-ctx changing 26 files +97 −46
  1. maflcko commented at 12:36 pm on February 2, 2026: member

    Iterating over fuzz inputs will usually be done in the same process. As the mocktime is global, it can theoretically leak from one fuzz input run into the next run, making it less deterministic.

    Fix this issue, by adding and using a context manager to handle the mocktime and reset it before the end.

    This refactor should not change any behavior.

  2. DrahtBot renamed this:
    fuzz: Add and use NodeClockContext
    fuzz: Add and use NodeClockContext
    on Feb 2, 2026
  3. DrahtBot added the label Fuzzing on Feb 2, 2026
  4. DrahtBot commented at 12:36 pm on February 2, 2026: contributor

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

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #33421 (node: add BlockTemplateCache by ismaelsadeeq)

    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.

  5. brunoerg commented at 11:52 pm on February 3, 2026: contributor
    Wouldn’t it need to change the warning (replacing SetMockTime to NodeClockContext) in CheckGlobalsImpl for when the target accesses system time?
  6. test: Add NodeClockContext
    This makes it easier to use mock-time in tests. Also, it resets the
    global mocktime, so that no state is leaked between test cases.
    fa0db768e5
  7. fuzz: Use NodeClockContext
    This refactor does not change any behavior.
    
    However, it is nice to know that no global mocktime leaks from the fuzz
    init step to the first fuzz input, or from one fuzz input execution to
    the next.
    With the clock context, the global is re-set at the end of the context.
    fa89e8de0c
  8. test: Fixup docs for NodeClockContext and SteadyClockContext 666643be8f
  9. maflcko force-pushed on Feb 9, 2026
  10. maflcko force-pushed on Feb 9, 2026
  11. maflcko force-pushed on Feb 9, 2026
  12. maflcko force-pushed on Feb 9, 2026
  13. maflcko force-pushed on Feb 9, 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-02-10 21:13 UTC

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