test: make orphanage_dos_many fill the orphanage #36407

Manually merged
fametrano merged 1 commit from test-orphanage-dos-many-inv into master 2026-10-19 14:41:28 +00:00 AGit
fametrano commented 2026-10-01 21:28:41 +00:00 (Migrated from github.com)

test_orphanage_dos_many checks that a normal peer's orphan survives while DoS peers flood the orphanage. I found that the orphanage never fills: the 60 peers send the same 51 orphans as tx, and a tx already held as an orphan is dropped in ReceivedTx without recording its sender. The orphanage peaks at 152 announcements against a limit of 3000, so nothing is evicted.

Here the first peer sends the orphans and the other 59 announce them by inv, which does add them as announcers. The test now asserts that the orphanage holds 3000 announcements, instead of asserting on what it sends. It takes about as long as before.

If LimitOrphans is changed to evict the normal peer's orphan first, the test used to pass and now fails. (test_orphanage_dos_large already catches that change.)

Found while porting these tests to https://github.com/btclib-org/bitcoin-node-tests.

Made with my usual tools: a computer, the Internet and an LLM. The mistakes, as usual, are all mine.

`test_orphanage_dos_many` checks that a normal peer's orphan survives while DoS peers flood the orphanage. I found that the orphanage never fills: the 60 peers send the same 51 orphans as `tx`, and a `tx` already held as an orphan is dropped in `ReceivedTx` without recording its sender. The orphanage peaks at 152 announcements against a limit of 3000, so nothing is evicted. Here the first peer sends the orphans and the other 59 announce them by `inv`, which does add them as announcers. The test now asserts that the orphanage holds 3000 announcements, instead of asserting on what it sends. It takes about as long as before. If `LimitOrphans` is changed to evict the normal peer's orphan first, the test used to pass and now fails. (`test_orphanage_dos_large` already catches that change.) Found while porting these tests to https://github.com/btclib-org/bitcoin-node-tests. *Made with my usual tools: a computer, the Internet and an LLM. The mistakes, as usual, are all mine.*
DrahtBot commented 2026-10-01 21:28:50 +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 instagibbs, naiyoma

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/36407 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36407.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36407#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 | [instagibbs](https://github.com/bitcoin/bitcoin/pull/36407#issuecomment-5957638455), [naiyoma](https://github.com/bitcoin/bitcoin/pull/36407#pullrequestreview-5572757215) | 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

Base: 7988380da987c0b860885853ace8149b84ac2ee8
Head: 86ff13a0af0679ee0c725bac9c64c3e373cb0283

No verified findings are available from this partial review.

Review coverage was incomplete. The archaeology review had incomplete evidence. The adversarial review had incomplete evidence.

Full review report

<!-- forgejo-review-bot:bitcoin/bitcoin --> Base: `7988380da987c0b860885853ace8149b84ac2ee8` Head: `86ff13a0af0679ee0c725bac9c64c3e373cb0283` No verified findings are available from this partial review. Review coverage was incomplete. The archaeology review had incomplete evidence. The adversarial review had incomplete evidence. [Full review report](<https://review.fish.foo/traces/36407-86ff13a0af0679ee0c725bac9c64c3e373cb0283-218-1.html>)
instagibbs commented 2026-10-02 17:21:57 +00:00 (Migrated from github.com)

ACK 86ff13a0af

I remember writing/reviewing this slop, thanks for fixing it with something we didn't consider!

Test failure seems unrelated

ACK 86ff13a0af0679ee0c725bac9c64c3e373cb0283 I remember writing/reviewing this slop, thanks for fixing it with something we didn't consider! Test failure seems unrelated
naiyoma (Migrated from github.com) reviewed 2026-10-19 14:06:44 +00:00
naiyoma (Migrated from github.com) left a comment

tACK 86ff13a0af

Logged the total number of announcements right after peers are synced

self.log.info(f"announcements: {sum(len(o['from']) for o in node.getorphantxs(verbosity=1))}")

on master: 2026-10-19T12:56:46.099833Z TestFramework (INFO): announcements: 51
Duplicate txs dropped, so the orphanage never reaches its limit

this pr: 2026-10-19T13:03:07.679566Z TestFramework (INFO): announcements: 3000
Orphanage is full, limit is reached

tACK 86ff13a0af0679ee0c725bac9c64c3e373cb0283 Logged the total number of announcements right after peers are synced `self.log.info(f"announcements: {sum(len(o['from']) for o in node.getorphantxs(verbosity=1))}")` on master: `2026-10-19T12:56:46.099833Z TestFramework (INFO): announcements: 51` Duplicate txs dropped, so the orphanage never reaches its limit this pr: `2026-10-19T13:03:07.679566Z TestFramework (INFO): announcements: 3000` Orphanage is full, limit is reached
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!36407
No description provided.