net: keep finished private broadcast txs in memory, rebroadcast if evicted from mempool #34707

pull andrewtoth wants to merge 5 commits into bitcoin:master from andrewtoth:private_broadcast_store changing 6 files +277 −45
  1. andrewtoth commented at 1:46 am on March 2, 2026: contributor

    Follow up from #34329.

    Private broadcast transaction data is removed from memory when either 1) the tx is received back from another peer and inserted into our mempool or 2) the tx is no longer acceptable to our mempool.

    We want to persist this data for a number of reasons. See #30471.

    This PR changes the behavior of the private broadcast queue to keep received and mempool-rejected txs in memory. The peer’s address we received the tx from and the time, or the mempool rejection reason is now also returned via getprivatebroadcastinfo RPC.

    Any tx that has been received back or is not acceptable to our mempool will not be picked by a private broadcast connection and will not be counted as pending. This maintains the current behavior of stopping broadcasting when these conditions are met.

    When reattempting to broadcast stale private broadcast txs, every tx whether pending or not is checked for mempool acceptance. This has the added benefit of rebroadcasting previously received txs that have since been evicted from the mempool.

    This is designed to facilitate follow up work including:

    • rebroadcasting txs that are in our mempool but have not been confirmed after a while. This can obviate rebroadcasting wallet txs if private broadcast is enabled (see #34533 (comment)).
    • adding a delay when submitting private broadcast txs so they will be broadcast at a later time (see #34118).
    • persisting private broadcast state to disk for resuming after restart or crash (see #34322).
    • expiring txs after a while so they are removed from the queue without having to manually abort.
  2. refactor: wrap sent_to in TxState struct
    This is a non-functional change.
    Wrapping the sent_to vector in a struct lets us add more fields to each tx.
    4233ce72ce
  3. DrahtBot added the label P2P on Mar 2, 2026
  4. DrahtBot commented at 1:47 am on March 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:

    • #34389 (net/log: standardize peer+addr log formatting via LogPeer by l0rinc)
    • #34271 (net_processing: make m_tx_for_private_broadcast optional by vasild)

    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.

    LLM Linter (✨ experimental)

    Possible typos and grammar issues:

    • already in -> already in the mempool or mined) [The added comment line “Skip stale transactions that are no longer relevant (e.g. already in” is incomplete by itself; replace with the full phrase “already in the mempool or mined)” so the comment is a complete, comprehensible sentence.]

    • rejection reason -> rejection_reason [The documentation refers to the function parameter; using rejection_reason (with the underscore) matches the actual parameter name and avoids confusion.]

    2026-03-02 02:04:10

  5. net: track received peer and mempool status in private broadcast
    Introduce Received and UpdateMempoolState methods in PrivateBroadcast.
    
    Add fields to track received data and mempool state in TxState.
    
    Don't remove txs when received back from peer or not accepted to mempool in stale check. Only pick or return pending txs that do not have received data or mempool state set.
    
    Reset state if previously received tx is evicted from mempool without confirming, or if Add is called again with the same tx.
    fa857a980c
  6. test: extract find_tx_info to static helper
    Non-functional refactor.
    16480cbf08
  7. net: return received data and mempool rejection reason in pb info d48cf8bc3d
  8. rpc,net: return received data or mempool rejection info afca84489c
  9. andrewtoth force-pushed on Mar 2, 2026
  10. DrahtBot added the label CI failed on Mar 2, 2026
  11. DrahtBot commented at 2:04 am on March 2, 2026: contributor

    🚧 At least one of the CI tasks failed. Task macOS native: https://github.com/bitcoin/bitcoin/actions/runs/22558096885/job/65339168667 LLM reason (✨ experimental): private_broadcast_tests failed with an assertion error in netaddress.cpp (ToStringAddr), causing the test subprocess to abort.

    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.

  12. DrahtBot removed the label CI failed on Mar 2, 2026


andrewtoth DrahtBot

Labels
P2P


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-03-03 03:13 UTC

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