Merge bitcoin/bitcoin#36734: net: Do not add transaction reported as TX_CONSENSUS to the extrapool
What changed, and why it matters
This change stops one specific category of clearly invalid Bitcoin transactions from being kept in a small helper pool used to reconstruct compact blocks. The helper pool (extrapool) stores transactions that did not fit in the normal mempool so they can still be used if a peer later announces a block containing them. The patch says: if a transaction was rejected specifically because it breaks consensus rules, do not bother keeping it, because a valid block can never contain it. The author and reviewers explicitly state this is a minor cleanup, not a security fix or vulnerability.
No urgent action. Treat as a minor code-quality/efficiency improvement. If monitoring, confirm the test change matches intended behavior and that no downstream logic assumes TX_CONSENSUS transactions are always kept in the extrapool.
Security signals we found
Behavioral change in transaction rejection handling
Explicitly described by author as not a vulnerability or regression
Partial mitigation only: does not prevent all consensus-invalid transactions from entering extrapool
No validation logic change; only changes default of a boolean flag based on existing rejection reason
Evidence from the diff
In TxDownloadManagerImpl::MempoolRejectedTx, the flag add_extra_compact_tx previously defaulted to first_time_failure. It now also requires state.GetResult() != TxValidationResult::TX_CONSENSUS. This prevents transactions whose initial rejection reason is TX_CONSENSUS from being passed to AddToCompactExtraTransactions. The unit test is updated so the expected keep count for TX_CONSENSUS drops from 1 to 0. The PR description and ACKs note this is only a partial improvement: other consensus-invalid transactions reported under different validation results (e.g., TX_NOT_STANDARD for a bad signature, or orphans with unknown inputs) are still added to the extrapool. The change is framed as increasing extrapool utility, not fixing a DoS or consensus bug.
Changed components
src/node/txdownloadman_impl.cppsrc/test/txdownload_tests.cppCompact block reconstruction / extra transaction poolInspect captured patch +3 / −2
### src/node/txdownloadman_impl.cpp
@@ -362,7 +362,8 @@ node::RejectedTxTodo TxDownloadManagerImpl::MempoolRejectedTx(const CTransaction
const CTransaction& tx{*ptx};
// Results returned to caller
// Whether we should call AddToCompactExtraTransactions at the end
- bool add_extra_compact_tx{first_time_failure};
+ // Consensus-invalid transactions cannot help reconstruct a valid block.
+ bool add_extra_compact_tx{first_time_failure && state.GetResult() != TxValidationResult::TX_CONSENSUS};
// Hashes to pass to AddKnownTx later
std::vector<Txid> unique_parents;
// Populated if failure is reconsiderable and eligible package is found.
### src/test/txdownload_tests.cpp
@@ -58,7 +58,7 @@ struct Behaviors {
// Map from failure reason to expected behavior for a segwit tx that fails
// Txid and Wtxid are assumed to be different here. For a nonsegwit transaction, use the wtxid results.
static std::map<TxValidationResult, Behaviors> expected_behaviors{
- {TxValidationResult::TX_CONSENSUS, {/*txid_rejects*/0,/*wtxid_rejects*/1,/*txid_recon*/0,/*wtxid_recon*/0,/*keep*/1,/*txid_inv*/0,/*wtxid_inv*/1}},
+ {TxValidationResult::TX_CONSENSUS, {/*txid_rejects*/0,/*wtxid_rejects*/1,/*txid_recon*/0,/*wtxid_recon*/0,/*keep*/0,/*txid_inv*/0,/*wtxid_inv*/1}},
{TxValidationResult::TX_INPUTS_NOT_STANDARD, { 1, 1, 0, 0, 1, 1, 1}},
{TxValidationResult::TX_NOT_STANDARD, { 0, 1, 0, 0, 1, 0, 1}},
{TxValidationResult::TX_MISSING_INPUTS, { 0, 0, 0, 0, 1, 0, 1}},Why this scored 21/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.