Review report

core: PR #36015

Design and approach

Avoid decoding every orphan for the ID-only RPC (src/node/txorphanage.cpp:783, head)

GetOrphanTransactions() calls MakeTxRef() for every unique orphan. The RPC caller fetches the full vector before parsing verbosity, even though default verbosity returns only txids. A default getorphantxs call can therefore temporarily expand all retained witness-heavy orphans into much larger deserialized transactions; the PR's 199,000-element example uses about 11 MB when deserialized. Building the vector also holds m_tx_download_mutex, delaying transaction-download work. Parse verbosity first and provide an ID-only enumeration path for verbosity 0. This preserves the txid-only result without materializing unused transactions.

💡 Suggestion

Reuse the weight computed during admission (src/node/txorphanage.cpp:57, head)

AddTx() computes GetTransactionWeight(*tx) before constructing OrphanTxData, but this initializer calls GetOrphanUsage(tx), which computes the weight again. That adds another transaction-sized serialization-size traversal for each stored orphan, linear in witness elements, including for the many-small-element transactions motivating this change. Pass the precomputed usage into OrphanTxData; with the current GetOrphanUsage() implementation, this preserves both the weight-limit check and accounted usage.

Review coverage was incomplete. The adversarial review did not complete. The adversarial_glm review did not complete.