Skip to content

p2p: Reconsider package transactions that are immediately trimmed - #36328

Open
instagibbs wants to merge 3 commits into
bitcoin:masterfrom
instagibbs:package-trim-reconsiderable
Open

instagibbs wants to merge 3 commits into
bitcoin:masterfrom
instagibbs:package-trim-reconsiderable

Conversation

@instagibbs

@instagibbs instagibbs commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

In-master, if a package is entered into mempool at the lowerst chunk feerate, pushing the mempool oversize, this causes that transaction (package) to be trimmed immediately. This is fine and expected, but the returned validation result TX_MEMPOOL_POLICY precludes the now-evicted parent from being considered again (i.e. fetched / processed as package) until after another block is found.

This is not a major issue, but would result in unneeded censorship of someone low-balling package feerates.

The already-in-mempool case needs a bit more logic due to the FeeFailure's requirement of package feerate knowledge, so I opted to defer it for now.

Related to finding made by Loupe, and subsequently Red Team.

…iderable

A transaction evicted by LimitMempoolSize() right after being accepted
by itself is TX_RECONSIDERABLE: a package with a higher feerate may
still get it in. Transactions submitted together as a package and
evicted by the final trim in AcceptPackage() were TX_MEMPOOL_POLICY
instead, as that code predates TX_RECONSIDERABLE.

For 1p1c relay this put an evicted parent and child in the reject
filter until the next block, so a new child could not bump the parent
back in.
@DrahtBot

DrahtBot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

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, ismaelsadeeq

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

Conflicts

No conflicts as of last run.

@instagibbs
instagibbs force-pushed the package-trim-reconsiderable branch from 0a3ab2c to 3c6cd0c Compare September 24, 2026 16:38
@DrahtBot

Copy link
Copy Markdown
Contributor

🚧 At least one of the CI tasks failed.
Task ASan + LSan + UBSan + integer: https://github.com/bitcoin/bitcoin/actions/runs/36027432164/job/107727417441
LLM reason (✨ experimental): CI failed to compile test_bitcoin because Clang -Wthread-safety (treated as -Werror) reported an exclusive cs_main lock is missing when calling ProcessNewPackage in txpackage_tests.cpp.

Hints

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.

@instagibbs

Copy link
Copy Markdown
Member Author

@instagibbs instagibbs changed the title Reconsider package transactions that are immediately trimmed p2p: Reconsider package transactions that are immediately trimmed Sep 28, 2026
@DrahtBot DrahtBot added the P2P label Sep 28, 2026
@fanquake fanquake added this to the 33.0 milestone Sep 29, 2026

@mzumsande mzumsande left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK
Seems to me that the first part is much more important because it could be encountered via p2p 1p1c.
The second part seems less urgent, and I think it could wait until after removing the fee information from FeeFailure, as suggested in the OP.
As far as I understand, the second part would mostly be encountered via rpc anyway, where it makes no observable difference (same error string). By delaying it we wouldn't need to introduce deduplicated_feerates.

@instagibbs
instagibbs force-pushed the package-trim-reconsiderable branch from 3c6cd0c to f19e4bf Compare November 4, 2026 18:44
@instagibbs

Copy link
Copy Markdown
Member Author

@mzumsande split it up, thanks

@mzumsande mzumsande left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review ACK f19e4bf

@sedited
sedited requested a review from ismaelsadeeq November 6, 2026 12:18

@ismaelsadeeq ismaelsadeeq left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK f19e4bf

I also went through the other TX_MEMPOOL_POLICY reasons. The "max feerate exceeded" one is a local only guard that can't be triggered over p2p, others are legitimate except one left deliberately by the OP. For that, I think a user who hits it can workaround the rejection by e.g. running with a larger -maxmempool, or starting from an empty mempool and not accepting incoming txs (-blocksonly). larger -maxmempool is optimistic but better because a blocksonly node relays only its own transactions and accepts none from peers, so it could be a source leak.
This should be fixed too.

Comment on lines +1276 to +1277
BOOST_CHECK(tx_result.m_effective_feerate == package_feerate);
BOOST_CHECK(tx_result.m_wtxids_fee_calculations == std::vector<Wtxid>({tx_parent->GetWitnessHash(), tx_child->GetWitnessHash()}));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can be boost check equal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants