Detect transaction problems early during deserialization

bitcoin/bitcoin: PR #36906

3 suggestions

Optional improvements

Link

[suggestion] · TX_WITH_WITNESS_P2P lacks a differential fuzz assertion

The parser modes agree today, but transaction fuzzing never checks that TX_WITH_WITNESS_P2P accepts exactly the TX_WITH_WITNESS parses with nonempty inputs and outputs.

Location: src/primitives/transaction.h:234 (head).

Details and suggested fix

The transaction target only compares CTransaction and CMutableTransaction under TX_WITH_WITNESS; the new unit cases do not provide an arbitrary-buffer comparison of modes. Before the if (!valid_tx) early return, parse buffer again from a fresh SpanReader using TX_WITH_WITNESS_P2P. Assert that it succeeds exactly when valid_tx && !tx.vin.empty() && !tx.vout.empty(), and compare GetWitnessHash() values on success. This adds a direct oracle for mode-specific acceptance or decoding differences in the parser now used for P2P messages.


Link

[suggestion] · RPC transaction-count limits lack a release note

A 24,391-input transaction now makes testmempoolaccept raise a request-wide -22 instead of returning a per-transaction bad-txns-oversize result; it cannot be valid, but the RPC-visible change has no release note.

Location: src/primitives/transaction.h:233 (head).

Details and suggested fix

The count caps are unconditional, so both TX_WITH_WITNESS and TX_NO_WITNESS reject transactions claiming more than 24,390 inputs or 111,111 outputs. testmempoolaccept throws on DecodeHexTx failure before producing any results, so one such transaction also aborts a multi-transaction rawtxs request. Add a short release note explaining the new decode-time limits and changed error shape, following the API-change convention in doc/developer-notes.md.


Link

[suggestion] · Empty-transaction block tests no longer reach consensus validation

The updated InputMissing and OutputMissing cases stop at P2P deserialization, so feature_block.py no longer verifies their unchanged block-validation rejection reasons.

Location: test/functional/feature_block.py:199 (head).

Details and suggested fix

p2p_deserialization_error now takes priority over bad-txns-vin-empty and bad-txns-vout-empty, so these cases fail before CheckBlock can call CheckTransaction. The input-empty unit test and output-empty mempool test still exercise the shared checks, but not their block-validation integration. For templates with p2p_deserialization_error, also submit the same badblock through node.submitblock(badblock.serialize().hex()) and assert that the result equals template.block_reject_reason or template.reject_reason. submitblock decodes with ordinary TX_WITH_WITNESS, allowing this assertion to restore the original consensus-rejection coverage alongside the new P2P checks.


Coverage details