net: make orphan reconsideration more granular #36594

pull darosior wants to merge 2 commits into bitcoin:master from darosior:2610_granular_orphan_reconsideration changing 2 files +32 −7
  1. darosior commented at 7:06 PM on October 21, 2026: member

    We currently concentrate the validation of all the assigned peer’s reconsiderable orphans that are still missing inputs in a single message-processing turn. This ties orphan processing to validation result, and adds latency to processing other peers' messages.

    Always process a single reconsiderable orphan per turn instead. This removes the need for an immediate validation result, and shifts the latency from other peers to the assigned peer.

  2. DrahtBot added the label P2P on Oct 21, 2026
  3. DrahtBot commented at 7:06 PM on October 21, 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 fametrano
    Concept ACK instagibbs, ViniciusCestarii

    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. in src/net_processing.cpp:715 in ed083094fa outdated
     712 | @@ -713,13 +713,12 @@ class PeerManagerImpl final : public PeerManager
     713 |      /**
     714 |       * Reconsider orphan transactions after a parent has been accepted to the mempool.
     715 |       *
    


    instagibbs commented at 7:44 PM on October 21, 2026:

    commit msg: citing the wrong hash, should be 866c8058a7 ?


    darosior commented at 9:04 PM on October 21, 2026:

    Yeah, looks like a copy paste mistake.


    darosior commented at 9:33 PM on October 21, 2026:

    Corrected commit message, thanks.

  5. instagibbs commented at 9:02 PM on October 21, 2026: member

    concept ACK

    probably slap on a unit test or smth and/or fuzz to cap the amount of reconsidered stuff in a step

  6. darosior force-pushed on Oct 21, 2026
  7. net: reconsider at most one orphan per call, whatever the validation result
    Orphan processing used to be uninterruptible, which could be exploited
    as a severe CPU DoS (see CVE-2024-52914). 866c8058a7 mitigated this by
    interrupting orphan processing after the first transaction validation
    that did not result in a missing input error.
    
    This commit moves the interruption point to after each transaction
    validation, whatever the result. This unties it from the validation
    result and reduces the latency before processing other peers' messages,
    at the cost of increasing it for the messages of the peer the orphans
    are assigned to.
    28a41e61ab
  8. qa: test a single orphan is processed per peer turn, regardless of its validation result 83003cafaa
  9. darosior commented at 9:47 PM on October 22, 2026: member

    Added a unit test that demonstrates the behaviour: the test will fail on master, as both child would be reconsidered there (since validation returns a missing-input error).

  10. ViniciusCestarii commented at 1:09 PM on October 23, 2026: contributor

    Concept ACK

    Was the missing-inputs exception in 866c8058a706931f025335b3e794ed2f4d287918 there because failing in PreChecks was considered cheap? The only hint I found is "after every actual transaction validation attempt" in the 866c8058a706931f025335b3e794ed2f4d287918 commit message.

  11. instagibbs commented at 1:13 PM on October 23, 2026: member

    It seems the focus was likely on avoiding too much script validation, and wiping from the orphanage eagerly to avoid a single announcer dominating the orphanage. The orphanage and how announcements are handled across peers has changed quite a bit since then.

  12. fametrano commented at 7:47 AM on October 25, 2026: contributor

    tACK 83003cafaa81bb116526419246608658ede824b6

    I measured the trade-off the description names with a scenario of my own. One peer sends four orphans that each spend a parent output and an outpoint that does not exist, then sends the parent and an unrelated valid transaction back to back. On master the unrelated transaction is processed on the peer's second turn, because all four orphans are retried in one turn. With this PR it takes six turns: the parent, one per orphan, then the transaction. So the wait moves onto the assigned peer, as described, and each turn validates at most one orphan.

    The new case in denialofservice_tests fails on master, at the ProcessMessagesOnce check in its loop, and passes here.

    I tested the head merged into master a773e1e33b, in a Debug build, with the denialofservice, orphanage, txdownload and txpackage unit tests and the p2p_orphan_handling and p2p_opportunistic_1p1c functional tests. I ran them again with #36437 and #36578 merged on top; the three PRs merge without conflicts. I can share the scenario, a Boost test case, as a gist.

  13. DrahtBot requested review from instagibbs on Oct 25, 2026
  14. DrahtBot requested review from ViniciusCestarii on Oct 25, 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-10-26 02:52 UTC

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