Repository navigation
p2p: plug "tier 1" 1p1c liveness holes - #36506
instagibbs wants to merge 4 commits into
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
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:
2026-11-30 20:30:50 |
077fd92 to
9972cd9
Compare
9972cd9 to
8746d5a
Compare
|
@marcofleon @mzumsande this will be the ultimate target PR to fuzz |
8746d5a to
c8abd9e
Compare
|
Tested c8abd9e: 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 |
|
ACK c8abd9e. 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 |
c8abd9e to
8d44ac8
Compare
|
reACK 8d44ac8. The new |
|
@fametrano fuzzer hit it, which is a good sign |
There was a problem hiding this comment.
Concept ACK
I reviewed the production code fixes/non-fuzz test 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.
If that makes it easier, can do. Would you prefer just to have me close #36437 , split out the fuzz target commits, and get this one merged ASAP? |
8d44ac8 to
a30665c
Compare
|
Rabased on master, deferring the fuzz harness as future PR work at https://github.com/instagibbs/bitcoin/tree/2026-11-1p1c-liveness-fuzz |
| * announcement is a request for the transaction with any witness, so a verdict about one witness (recorded | ||
| * under a wtxid that equals the txid because that copy had no witness) should not cancel it. | ||
| */ | ||
| void ForgetTxHash(const GenTxid& gtxid); |
There was a problem hiding this comment.
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.
|
|
||
| /** Like GetCandidatePeers(txhash, result_peers), but only for announcements whose type (txid or wtxid) | ||
| * matches that of gtxid. */ | ||
| void GetCandidatePeers(const GenTxid& gtxid, std::vector<NodeId>& result_peers) const; |
There was a problem hiding this comment.
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.
a30665c to
44842fc
Compare
A child that arrives before its parent is kept as an orphan. Once the parent is accepted on its own, the orphan is put in one randomly chosen announcer's work set to be retried. If that announcer disconnects or is evicted first, the orphan is never retried, and re-announcements by the other announcers don't fetch it again since it is already held. This keeps e.g. a CPFP child of a parent that pays for itself out of the mempool until the orphan is evicted, and an announcer can cause it on purpose. Hand reconsideration over to the remaining announcer with the lowest NodeId instead.
TX_CONFLICT means the transaction is already known, in the mempool or confirmed, not that it is invalid. Its wtxid still went into the reject filter. For a witnessless copy that is also the txid, so if the known parent then left the mempool before the next block, a child arriving afterwards was dropped as having a rejected parent. For the honest version of a parent whose other-witness version is in the mempool, the honest parent itself was ignored once that version left. Don't add TX_CONFLICT results to the reject filter. The entry only saved re-downloading and re-checking a transaction we already have. Do the same for a DIFFERENT_WITNESS result in 1p1c package evaluation, which ProcessPackageResult passed to ProcessInvalidTx with a valid state and so reached the filter by another path. This also keeps a witnessless copy of a confirmed transaction out of the filter, as it is rejected as already known when one of its outputs is in the coins cache, so children spending that transaction are no longer dropped. A copy of a coinbase is rejected as TX_CONSENSUS instead, before any input lookup, and still poisons the coinbase's txid. Update the rejection-type table for TX_CONFLICT.
When a 1p1c package fails the package feerate check, the child gets a TX_RECONSIDERABLE result, and ProcessPackageResult passed it to ProcessInvalidTx, which erased the child from the orphanage for all of its announcers. The failure is a property of that pair of wtxids, which MempoolRejectedPackage already caches, not of the child. The child can still succeed with another version of the parent, such as the one an honest announcer holds, so it should stay available. Skip ProcessInvalidTx for package members with a TX_RECONSIDERABLE result. A child that is too low feerate on its own is still rejected when its parent's work set is processed.
A reconsiderable rejection of a witnessless copy of a transaction forgot its wtxid in TxRequestTracker regardless of announcement type, and since that wtxid equals the txid, it also cancelled every peer's txid-typed request for the transaction, including orphan resolution requests for a missing parent. Now only wtxid-typed announcements of that hash are forgotten, so witnessless parents are treated like witnessed ones, which were never affected since their wtxid differs from the txid.
44842fc to
d8c1eb7
Compare
|
Concept ACK |

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