fuzz: check GetStale() returns exactly the stale private broadcast txs #36670

pull frankomosh wants to merge 1 commits into bitcoin:master from frankomosh:2026-10-fuzz-private-broadcast-stale-check changing 1 files +27 −0
  1. frankomosh commented at 6:38 PM on October 26, 2026: contributor

    The private_broadcast fuzz test checks each tx that GetStale() returns. This adds to it by checking that all stale txs are returned. ReattemptPrivateBroadcast() only retries what GetStale() returns, and a stale tx left out is never retried.

    This partly came up during review in #35129#pullrequestreview-4427536924, and recently also surfaced in https://mutanthub.space/mutants/3752 , where changing continue to break in GetStale() passes all current tests.

    This PR records when each tx is added and when each node confirms it. Then it checks that GetStale() returns exactly the expected txs.

  2. DrahtBot added the label Fuzzing on Oct 26, 2026
  3. DrahtBot commented at 6:38 PM on October 26, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

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

    Type Reviewers
    ACK andrewtoth

    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.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. fanquake added the label Private Broadcast on Oct 26, 2026
  5. fanquake commented at 7:29 PM on October 26, 2026: member
  6. fuzz: check GetStale() returns exactly the stale private broadcast txs
    Currently, the private_broadcast harness checks that each transaction
    returned by GetStale() is known, unresolved and below the attempt cap.
    This adds onto that by checking the timing rule, and that every stale
    transaction is returned.
    
    Track when each transaction is added and when each node confirms
    reception, and check that GetStale() returns exactly the expected set.
    4f3dcb76ab
  7. in src/test/fuzz/private_broadcast.cpp:257 in 986cdf27b4
     252 | +                    const bool is_stale{last_confirmed ? *last_confirmed < now - PrivateBroadcast::STALE_DURATION :
     253 | +                                                         time_added.at(tx) < now - PrivateBroadcast::INITIAL_STALE_DURATION};
     254 | +                    if (is_stale) expected.insert(tx);
     255 | +                }
     256 | +                Assert(stale.size() == expected.size());
     257 | +                for (const auto& stale_tx : stale) Assert(expected.contains(stale_tx));
    


    andrewtoth commented at 8:19 PM on October 31, 2026:

    We can also assert that stale does not return any duplicates.

                    for (const auto& stale_tx : stale) Assert(expected.erase(stale_tx) == 1);
    

    frankomosh commented at 6:18 AM on November 2, 2026:

    Thanks, done in 4f3dcb7.

  8. frankomosh force-pushed on Nov 2, 2026
  9. in src/test/fuzz/private_broadcast.cpp:57 in 4f3dcb76ab
      50 | @@ -50,6 +51,10 @@ FUZZ_TARGET(private_broadcast)
      51 |      // The values are the number of times a transaction is planned to be sent.
      52 |      std::unordered_map<CTransactionRef, size_t, CTransactionRefHash, CTransactionRefComp> planned_sends;
      53 |      std::unordered_set<CTransactionRef, CTransactionRefHash, CTransactionRefComp> resolved_transactions;
      54 | +    // When each transaction was added, or reset by adding it again.
      55 | +    std::unordered_map<CTransactionRef, NodeClock::time_point, CTransactionRefHash, CTransactionRefComp> time_added;
      56 | +    // When each node confirmed reception. Only looked up through nodes_sent_to.
      57 | +    std::unordered_map<NodeId, NodeClock::time_point> confirmed_at;
    


    andrewtoth commented at 4:48 AM on November 4, 2026:

    I think a worthwhile refactor would be to collect all these individual maps and sets into two maps of structs for CTransactionRef and NodeId.


    frankomosh commented at 5:57 AM on November 5, 2026:

    I agree. Probably worth a follow-up at some point.

  10. andrewtoth commented at 4:49 AM on November 4, 2026: contributor

    ACK 4f3dcb76ab35ed6fe7d81e4997d36333efff12b9

    Fuzzed this PR for an hour on 4 CPUs, with no issues.

  11. sedited approved
  12. sedited commented at 7:30 PM on November 4, 2026: contributor

    ACK 4f3dcb76ab35ed6fe7d81e4997d36333efff12b9

  13. sedited merged this on Nov 4, 2026
  14. sedited closed this on Nov 4, 2026

  15. frankomosh deleted the branch on Nov 5, 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-11-16 01:51 UTC

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