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

Manually merged
frankomosh merged 1 commit from 2026-10-fuzz-private-broadcast-stale-check into master 2026-11-04 19:36:19 +00:00 AGit
frankomosh commented 2026-10-26 18:38:27 +00:00 (Migrated from github.com)

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 https://github.com/bitcoin/bitcoin/pull/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.

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 https://github.com/bitcoin/bitcoin/pull/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.
DrahtBot commented 2026-10-26 18:38:37 +00:00 (Migrated from github.com)

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

External sites

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 <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36670 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36670.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36670#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | ACK | [andrewtoth](https://github.com/bitcoin/bitcoin/pull/36670#pullrequestreview-5763368524) | 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-->
First-time contributor

🔵 Suggestion · Erase timing entries when transactions leave the model

Neither Add() cleanup (lines 92-97) nor Remove() (lines 151-153) erases the PR-added time_added map, so departed CTransactionRefs pile up during an input of up to 10,000 operations. Lookups only touch live transactions, so this is a cleanup issue, not a correctness bug.

Location: src/test/fuzz/private_broadcast.cpp:92 (head).

Review coverage was incomplete.


Reviewed: 4f3dcb76ab35 · Full review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:965af1044d9e41839565702e4d9bd0a751eda81f6e8b6402747fa296ef84ebea:7efd3c3ba41667382004cfa7a7db56605da7d8f9b7ab69bc483f27117390ba48 --> <!-- ralph-base:6c01bd0b2dc201c21e80ac3635828abf854ee5a0 --> <!-- ralph-head:4f3dcb76ab35ed6fe7d81e4997d36333efff12b9 --> <!-- ralph-case:a3ee8ab6476f6a3e89b6f51936476ce24017bb08107f7e949dffdba88b7d638c --> **🔵 Suggestion · Erase timing entries when transactions leave the model** Neither Add() cleanup (lines 92-97) nor Remove() (lines 151-153) erases the PR-added `time_added` map, so departed CTransactionRefs pile up during an input of up to 10,000 operations. Lookups only touch live transactions, so this is a cleanup issue, not a correctness bug. Location: [`src/test/fuzz/private_broadcast.cpp:92`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/4f3dcb76ab35ed6fe7d81e4997d36333efff12b9/src/test/fuzz/private_broadcast.cpp#L92>) (head). Review coverage was incomplete. <!-- Review tier: routine --> --- Reviewed: [`4f3dcb76ab35`](<https://git.fish.foo/bitcoin/bitcoin/commit/4f3dcb76ab35ed6fe7d81e4997d36333efff12b9>) · [Full review report](<https://review.fish.foo/traces/36670-4f3dcb76ab35ed6fe7d81e4997d36333efff12b9-1965-5.html>) · [Previous reports](<https://review.fish.foo/traces/36670/>) [permalink](<https://review.fish.foo/traces/36670-4f3dcb76ab35ed6fe7d81e4997d36333efff12b9-1965-5.html>)
fanquake commented 2026-10-26 19:29:59 +00:00 (Migrated from github.com)

cc @vasild @andrewtoth

cc @vasild @andrewtoth
andrewtoth (Migrated from github.com) reviewed 2026-10-31 20:19:24 +00:00
andrewtoth (Migrated from github.com) commented 2026-10-31 20:19:24 +00:00

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

                for (const auto& stale_tx : stale) Assert(expected.erase(stale_tx) == 1);
We can also assert that stale does not return any duplicates. ```suggestion for (const auto& stale_tx : stale) Assert(expected.erase(stale_tx) == 1); ```
frankomosh (Migrated from github.com) reviewed 2026-11-02 06:18:03 +00:00
frankomosh (Migrated from github.com) commented 2026-11-02 06:18:03 +00:00

Thanks, done in 4f3dcb7.

Thanks, done in 4f3dcb7.
andrewtoth (Migrated from github.com) reviewed 2026-11-04 04:49:30 +00:00
andrewtoth (Migrated from github.com) left a comment

ACK 4f3dcb76ab

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

ACK 4f3dcb76ab35ed6fe7d81e4997d36333efff12b9 Fuzzed this PR for an hour on 4 CPUs, with no issues.
andrewtoth (Migrated from github.com) commented 2026-11-04 04:48:42 +00:00

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

I think a worthwhile refactor would be to collect all these individual maps and sets into two maps of structs for CTransactionRef and NodeId.
sedited (Migrated from github.com) approved these changes 2026-11-04 19:30:06 +00:00
sedited (Migrated from github.com) left a comment
ACK 4f3dcb76ab35ed6fe7d81e4997d36333efff12b9
frankomosh (Migrated from github.com) reviewed 2026-11-05 05:57:15 +00:00
frankomosh (Migrated from github.com) commented 2026-11-05 05:57:15 +00:00

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

I agree. Probably worth a follow-up at some point.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36670
No description provided.