2 minor findings · 1 suggestion
Earlier concerns neither republished nor resolved: 1 suggestion. See the Run archive for their assessments.
Findings
[minor] · The orphan RPC rebuilds every transaction while holding the download mutex
Each call deserializes every orphan even though the RPC fields are cached, increasing peak memory and delaying transaction and inventory processing while the mutex is held.
Location: src/node/txorphanage.cpp:783 (head).
Details and suggested fix
getorphantxs fetches all orphan transactions before parsing verbosity. PeerManagerImpl::GetOrphanTransactions() holds m_tx_download_mutex while GetOrphanTransactions() calls MakeTxRef() for each unique orphan. For orphans with many small witness elements, this temporarily recreates the expanded witness stacks that the change otherwise stops retaining. The PR description estimates about 11 MB for a 199,000-element orphan. This allocation work also delays transaction and inventory processing that needs the same mutex. The base implementation copied shared references instead. The RPC output can use cached values in OrphanTxData: txid, wtxid, encoded size, weight, vsize, and announcers. Its verbosity-2 hex is the encoded transaction with witness. Have OrphanInfo carry these cached values, or a shared pointer to OrphanTxData, and build the response from them.
[minor] · Cheap parent variants repeatedly deserialize the same missing-input orphan
An inbound peer can trigger another orphan deserialization under cs_main and m_tx_download_mutex with each small, fee-free parent variant; the time per message was not measured.
Location: src/node/txdownloadman_impl.cpp:321 (head).
Details and suggested fix
A peer can store an orphan with many small witness elements that spends T:0 and an unavailable outpoint, then send transactions with txid T and different witnesses, each below the minimum fee. Each new wtxid passes AlreadyHaveTx(). PreChecks returns TX_RECONSIDERABLE at the fee-rate check before script checks, so MempoolRejectedTx() calls Find1P1CPackage(). The new package hash avoids the reject filters, and GetTx() deserializes the same orphan. Package validation then stops because the child has a missing input, so the orphan remains available for the next variant. The base revision reused a shared CTransactionRef; now each roughly 150-byte message causes about 199,000 allocations and frees plus a roughly 400 kB wtxid hash under cs_main and m_tx_download_mutex. Commit 0557bc8 estimates about 0.9 seconds for roughly 40 MB of such orphans, suggesting milliseconds per message, but this review did not measure the time. ProcessOrphanTx() has a fee-gated version of the same behavior: when a parent becomes available, GetTxToReconsider() deserializes each marked orphan, and the loop continues for orphans still missing another input. Both paths conflict with the comment at txorphanage.cpp:37 that these paths feed into full validation. Check an orphan's cached prevouts against the mempool, UTXO set, and 1p1c parent before deserializing it; skip orphans that would fail with missing inputs, and correct the comment. The repeated deserialization is established, but its production impact on block and peer processing was not measured.
Optional improvements
[suggestion] · The test comment misstates the orphanage usage metric
GetOrphanUsage() returns transaction weight, not a platform-dependent memory estimate.
Location: src/test/orphanage_tests.cpp:113 (head).
Details and suggested fix
The comment says TX_USAGE should not be hardcoded because it may differ across platforms. GetOrphanUsage() returns GetTransactionWeight(*tx), which is platform-independent, and the test already hardcodes that weight as 469. Replace the platform claim with a note that the value comes from GetOrphanUsage(), so the test follows the metric the orphanage uses.
Earlier concerns
Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.
- [suggestion]: Reuse the weight computed during admission