p2p: plug "tier 1" 1p1c liveness holes #36506

Open
instagibbs wants to merge 4 commits from 2026-10-1p1c-liveness-fixes into master AGit
instagibbs commented 2026-10-12 21:20:18 +00:00 (Migrated from github.com)
Resolves a few key weaknesses in 1p1c relay, focusing on issues that can be easily achieved on average cpfp behavior. Deferred fuzz harness for the holes: https://github.com/instagibbs/bitcoin/tree/2026-11-1p1c-liveness-fuzz Known issues doc: https://gist.github.com/instagibbs/880a76535fd802fced9f9a5253cdbb40
DrahtBot commented 2026-10-12 21:20:29 +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 mzumsande
Concept ACK ismaelsadeeq
Stale ACK fametrano

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36946 (scripted-diff: [test] Add util/check.h includes for assertions by maflcko)

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 places where comparison-specific test macros should replace generic comparisons:

  • test/functional/p2p_opportunistic_1p1c.py: assert package_fee / honest_vsize * 1000 > mempoolminfee → Prefer assert_greater_than(package_fee / honest_vsize * 1000, mempoolminfee).

2026-11-30 20:30:50

<!--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/36506 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36506.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36506#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 | [mzumsande](https://github.com/bitcoin/bitcoin/pull/36506#pullrequestreview-6133857190) | | Concept ACK | [ismaelsadeeq](https://github.com/bitcoin/bitcoin/pull/36506#issuecomment-7383187852) | | Stale ACK | [fametrano](https://github.com/bitcoin/bitcoin/pull/36506#issuecomment-6183724291) | 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. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#36946](https://github.com/bitcoin/bitcoin/pull/36946) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36946.svg"></sub> (scripted-diff: [test] Add util/check.h includes for assertions by maflcko) 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. <!--5faf32d7da4f0f540f40219e4f7537a3--> ### LLM Linter (✨ experimental) Possible places where comparison-specific test macros should replace generic comparisons: - `test/functional/p2p_opportunistic_1p1c.py`: `assert package_fee / honest_vsize * 1000 > mempoolminfee` → Prefer `assert_greater_than(package_fee / honest_vsize * 1000, mempoolminfee)`. <sup>2026-11-30 20:30:50</sup>
First-time contributor

Earlier concerns neither republished nor resolved: 1 suggestion. See the Run archive linked from the Review report for their assessments.

🔵 Suggestion · A retained low-feerate child can delay its acceptable sibling after a tip change

After a tip change clears the pair cache, a retained low-feerate child can consume another parent delivery before an acceptable sibling is tried; no production occurrence of this sequence has been identified.

Location: src/net_processing.cpp:3466 (head).

🔵 Suggestion · A failed BOOST_REQUIRE leaves connman with a destroyed PeerManager

If a fatal assertion fails after the test nodes are registered, stack unwinding destroys peerman before connman, whose destructor then finalizes those nodes through a dangling m_msgproc.

Location: src/test/txdownload_tests.cpp:482 (head).

🔵 Suggestion · The new functional test misses repeated evaluation of the failed padded pair

The test checks child retention and honest-parent recovery, but would not detect repeated package evaluation when the attacker resends the same padded parent.

Location: test/functional/p2p_opportunistic_1p1c.py:395 (head).

🔵 Suggestion · d8c1eb7 couples tracker-state changes to relay-policy changes

The new TxRequestTracker operation has independently testable completion and deletion semantics that are easier to validate separately from its witness-sensitive relay-policy use.

Location: src/txrequest.cpp:566 (commit).


Reviewed: d8c1eb7e8d3a · Review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:312ddb2095238aa2ca395a9cc39b05ab5a38a7177afbdb0d69098df9c3e0bef9:9a7f127b15c6116c267953d38288a9f17ec7c7bcd3a975fb71a2db8bfd974dbf --> <!-- ralph-base:1ea904d983f8841c28cb8240c576e46ac2efe529 --> <!-- ralph-head:d8c1eb7e8d3a1bc99313c4e70b36d874ce865f5f --> <!-- ralph-case:3249b4434a5dda436697e7aa3f7e52b147a1b2e33cbcc0da98b8aa7e615a6956 --> Earlier concerns neither republished nor resolved: 1 suggestion. See the Run archive linked from the Review report for their assessments. **🔵 Suggestion · A retained low-feerate child can delay its acceptable sibling after a tip change** After a tip change clears the pair cache, a retained low-feerate child can consume another parent delivery before an acceptable sibling is tried; no production occurrence of this sequence has been identified. Location: [`src/net_processing.cpp:3466`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/d8c1eb7e8d3a1bc99313c4e70b36d874ce865f5f/src/net_processing.cpp#L3466>) (head). **🔵 Suggestion · A failed `BOOST_REQUIRE` leaves `connman` with a destroyed `PeerManager`** If a fatal assertion fails after the test nodes are registered, stack unwinding destroys `peerman` before `connman`, whose destructor then finalizes those nodes through a dangling `m_msgproc`. Location: [`src/test/txdownload_tests.cpp:482`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/d8c1eb7e8d3a1bc99313c4e70b36d874ce865f5f/src/test/txdownload_tests.cpp#L482>) (head). **🔵 Suggestion · The new functional test misses repeated evaluation of the failed padded pair** The test checks child retention and honest-parent recovery, but would not detect repeated package evaluation when the attacker resends the same padded parent. Location: [`test/functional/p2p_opportunistic_1p1c.py:395`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/d8c1eb7e8d3a1bc99313c4e70b36d874ce865f5f/test/functional/p2p_opportunistic_1p1c.py#L395>) (head). **🔵 Suggestion · `d8c1eb7` couples tracker-state changes to relay-policy changes** The new `TxRequestTracker` operation has independently testable completion and deletion semantics that are easier to validate separately from its witness-sensitive relay-policy use. Location: src/txrequest.cpp:566 (commit). <!-- Review tier: sensitive --> --- Reviewed: [`d8c1eb7e8d3a`](<https://git.fish.foo/bitcoin/bitcoin/commit/d8c1eb7e8d3a1bc99313c4e70b36d874ce865f5f>) · [Review report](<https://review.fish.foo/report/36506-d8c1eb7e8d3a1bc99313c4e70b36d874ce865f5f-3362-8.html>) · [Previous reports](<https://review.fish.foo/traces/36506/>) [permalink](<https://review.fish.foo/report/36506-d8c1eb7e8d3a1bc99313c4e70b36d874ce865f5f-3362-8.html>)
instagibbs commented 2026-10-14 02:07:31 +00:00 (Migrated from github.com)

@marcofleon @mzumsande this will be the ultimate target PR to fuzz

@marcofleon @mzumsande this will be the ultimate target PR to fuzz
fametrano commented 2026-10-14 14:43:10 +00:00 (Migrated from github.com)

Tested c8abd9ee41: each of the four fixes is caught by a test this PR adds or extends. I reverted each fix on its own, keeping the tests, and each revert made txdownload_tests, orphanage_tests or p2p_opportunistic_1p1c.py fail, while the unchanged branch passes them all. I did not review the C++ changes. Details on request.

Tested c8abd9ee41: each of the four fixes is caught by a test this PR adds or extends. I reverted each fix on its own, keeping the tests, and each revert made `txdownload_tests`, `orphanage_tests` or `p2p_opportunistic_1p1c.py` fail, while the unchanged branch passes them all. I did not review the C++ changes. Details on request.
fametrano commented 2026-10-14 15:31:55 +00:00 (Migrated from github.com)

ACK c8abd9ee41. I have now reviewed the four fixes commit by commit and found nothing blocking. One gap remains for a follow-up: in the 1p1c package path, a DIFFERENT_WITNESS result still goes through ProcessInvalidTx, so a witness-stripped copy of a mempool parent puts the parent's txid in the reject filter, as TX_CONFLICT did before 3a2b5539a1. A functional test shows it end to end: an attacker peer re-sends the stripped copy with an orphan of its own, and after the parent leaves the mempool, an honest child is dropped as having a rejected parent. Test on request.

ACK c8abd9ee41. I have now reviewed the four fixes commit by commit and found nothing blocking. One gap remains for a follow-up: in the 1p1c package path, a `DIFFERENT_WITNESS` result still goes through `ProcessInvalidTx`, so a witness-stripped copy of a mempool parent puts the parent's txid in the reject filter, as `TX_CONFLICT` did before 3a2b5539a1. A functional test shows it end to end: an attacker peer re-sends the stripped copy with an orphan of its own, and after the parent leaves the mempool, an honest child is dropped as having a rejected parent. Test on request.
fametrano commented 2026-10-15 03:28:09 +00:00 (Migrated from github.com)

reACK 8d44ac8909. The new DIFFERENT_WITNESS case closes the 1p1c gap I noted at c8abd9ee41, and the only other code change is its test, known_parent_in_package_does_not_poison_after_eviction. I built test_bitcoin and ran txdownload_tests, orphanage_tests and txpackage_tests: the new test passes, and fails with that case moved back next to INVALID.

reACK 8d44ac8909. The new `DIFFERENT_WITNESS` case closes the 1p1c gap I noted at c8abd9ee41, and the only other code change is its test, `known_parent_in_package_does_not_poison_after_eviction`. I built `test_bitcoin` and ran `txdownload_tests`, `orphanage_tests` and `txpackage_tests`: the new test passes, and fails with that case moved back next to `INVALID`.
instagibbs commented 2026-10-15 04:04:24 +00:00 (Migrated from github.com)

@fametrano fuzzer hit it, which is a good sign

@fametrano fuzzer hit it, which is a good sign
mzumsande (Migrated from github.com) reviewed 2026-11-24 18:05:40 +00:00
mzumsande (Migrated from github.com) left a comment

Concept ACK

I reviewed the net_processing fixes/non-fuzz changes and they are all quite small and reviewable, and they all look good to me.

Personally, it would help me to ACK quicker if the large p2p_1p1c_liveness fuzz target was added in a separate PR, especially since all the changes covered by other tests as well, and a lot of code gets added first and then removed again in later commits - but up to you of course.

Concept ACK I reviewed the `net_processing` fixes/non-fuzz changes and they are all quite small and reviewable, and they all look good to me. Personally, it would help me to ACK quicker if the large `p2p_1p1c_liveness` fuzz target was added in a separate PR, especially since all the changes covered by other tests as well, and a lot of code gets added first and then removed again in later commits - but up to you of course.
instagibbs commented 2026-11-24 19:19:59 +00:00 (Migrated from github.com)

Personally, it would help me to ACK quicker if the large p2p_1p1c_liveness fuzz target was added in a separate PR, especially since all the changes covered by other tests as well, and a lot of code gets added first and then removed again in later commits - but up to you of course.

If that makes it easier, can do. Would you prefer just to have me close https://github.com/bitcoin/bitcoin/pull/36437 , split out the fuzz target commits, and get this one merged ASAP?

> Personally, it would help me to ACK quicker if the large p2p_1p1c_liveness fuzz target was added in a separate PR, especially since all the changes covered by other tests as well, and a lot of code gets added first and then removed again in later commits - but up to you of course. If that makes it easier, can do. Would you prefer just to have me close https://github.com/bitcoin/bitcoin/pull/36437 , split out the fuzz target commits, and get this one merged ASAP?
instagibbs commented 2026-11-25 15:51:29 +00:00 (Migrated from github.com)
Rabased on master, deferring the fuzz harness as future PR work at https://github.com/instagibbs/bitcoin/tree/2026-11-1p1c-liveness-fuzz
mzumsande (Migrated from github.com) reviewed 2026-11-30 18:09:30 +00:00
mzumsande (Migrated from github.com) left a comment

Code Review ACK a30665c3c6

I reviewed the entire code changes after the new fuzz test was deferred, the comments are minor.

Code Review ACK a30665c3c66f90f9130e43bcd231f26ddd89f73e I reviewed the entire code changes after the new fuzz test was deferred, the comments are minor.
mzumsande (Migrated from github.com) commented 2026-11-30 17:48:48 +00:00

I think I'd prefer a different name, such as ForgetTxHashOfType or similar to avoid confusion with the existing method (e.g. ForgetTxHash(ptx->GetHash()) used to be a compile error, now it compiles and has different behavior from ForgetTxHash(ptx->GetHash().ToUint256())) which may not be intended by future callers.

I think I'd prefer a different name, such as `ForgetTxHashOfType` or similar to avoid confusion with the existing method (e.g. `ForgetTxHash(ptx->GetHash())` used to be a compile error, now it compiles and has different behavior from `ForgetTxHash(ptx->GetHash().ToUint256())`) which may not be intended by future callers.
mzumsande (Migrated from github.com) commented 2026-11-30 17:54:22 +00:00

nit: Maybe we don't really need this? It's only called from tests, and it seems that existing checks already covers the behavior pretty well, so not sure if its adds enough additional coverage.

nit: Maybe we don't really need this? It's only called from tests, and it seems that existing checks already covers the behavior pretty well, so not sure if its adds enough additional coverage.
instagibbs (Migrated from github.com) reviewed 2026-11-30 20:07:04 +00:00
instagibbs (Migrated from github.com) commented 2026-11-30 20:07:04 +00:00

suggestion taken

suggestion taken
instagibbs (Migrated from github.com) reviewed 2026-11-30 20:07:11 +00:00
instagibbs (Migrated from github.com) commented 2026-11-30 20:07:11 +00:00

removed

removed
mzumsande (Migrated from github.com) reviewed 2026-12-01 15:00:23 +00:00
mzumsande (Migrated from github.com) left a comment

Code Review ACK d8c1eb7e8d

Code Review ACK d8c1eb7e8d3a1bc99313c4e70b36d874ce865f5f
ismaelsadeeq commented 2026-12-03 15:27:58 +00:00 (Migrated from github.com)

Concept ACK

Concept ACK
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!36506
No description provided.