3 minor findings · 5 suggestions
Earlier concerns neither republished nor resolved: 1 suggestion. See the Run archive for their assessments.
Findings
[minor] · Missing-input children can be repeatedly deserialized before cheap rejection
Distinct low-fee parent witness variants can repeatedly rebuild a retained witness-heavy child under cs_main and m_tx_download_mutex without requiring valid signatures.
Location: src/node/txdownloadman_impl.cpp:328 (head).
Details and suggested fix
A peer can store a standard-weight, witness-heavy child C spending T:0 and another nonexistent outpoint, then send low-fee versions of T with distinct witnesses. For example, T can spend a mature confirmed P2TR output with a garbage key-path signature that passes the pre-script checks. Each variant reaches TX_RECONSIDERABLE at the fee check and gives {T, C} a new package hash, so Find1P1CPackage decodes C again. Validation then stops at C's missing input before script verification, and the missing-input result leaves C stored for the next variant. A child with roughly 199,000 tiny witness elements therefore incurs roughly that many additional element allocations and frees, plus hashing, per variant. Base reused the stored reference, although it already performed linear witness-size passes. The latency increase is unmeasured. GetTxToReconsider has the same decode-and-retain pattern after new accepted-parent events, but that path requires valid, fee-paying parents and processes one orphan per ProcessOrphanTx call. Before materializing an orphan, check its cached prevouts against the mempool and coins tip, accounting for the proposed parent's outputs during 1p1c selection, and skip those certain to remain missing inputs. This needs coins-view access in TxDownloadManagerImpl. Also correct the comment claiming full revalidation always dwarfs decoding.
[minor] · getorphantxs decodes every orphan under the download mutex
An authorized getorphantxs call reconstructs every unique orphan while holding m_tx_download_mutex, even when the default response only needs cached txids.
Location: src/node/txorphanage.cpp:783 (head).
Details and suggested fix
GetOrphanTransactions calls MakeTxRef for every unique orphan and retains all decoded results until the RPC finishes formatting its response. The RPC fetches this vector before parsing verbosity. With many tiny witness elements, this temporarily recreates the expanded stacks removed from steady-state storage and adds allocation work while transaction handling, orphan processing and chain notifications wait on the same mutex. Base snapshots shared already-stored transaction bodies; head reconstructs them on each call, and overlapping results can own separate expanded copies. Exact latency and transient memory usage are unmeasured. Have OrphanInfo carry cached txid, wtxid, serialized size, weight and announcers, together with shared immutable encoded bytes. Those values suffice for all verbosity levels, including hex, while preserving the current snapshot ordering and witness-distinct entries.
[minor] · Candidate cleanup can invalidate the later Assume(child_tx)
Cleaning up an in-mempool child can evict a later candidate from the ID snapshot, causing Assume-enforcing builds to abort; ordinary release builds skip it.
Location: src/node/txdownloadman_impl.cpp:329 (head).
Details and suggested fix
With default limits, let Q first supply a small child A of T. Let P then supply an older child C of T and an unrelated orphan F, each about 300 kWU, before becoming an announcer of A. The roughly 600 kWU total fits the two-peer allowance of 808 kWU. After A enters the mempool via RPC, retry T using a different-witness version already in the reconsiderable filter. P's candidate snapshot contains A before C. EraseTx(A) removes Q's last announcement, reduces MaxGlobalUsage to 404 kWU and invokes LimitOrphans, which evicts P's oldest non-reconsiderable orphan C. C's ID remains in the snapshot and can pass both reject filters, but GetTx(C) now returns nullptr. Base held owning transaction references and did not make this assumption. Use a plain if (!child_tx) continue;, documenting that earlier cleanup can trim later candidates, and add a selection test covering the peer-count reduction and eviction.
Optional improvements
[suggestion] · The witness-heavy test misses retention of the incoming transaction
Pointer inequality proves that GetTx returns a fresh object, but would not detect the orphanage retaining the original deserialized transaction as well.
Location: src/test/orphanage_tests.cpp:759 (head).
Details and suggested fix
If OrphanTxData kept the incoming CTransactionRef alongside its encoded bytes while continuing to decode on GetTx, the usage, IDs, witness-size and pointer-inequality assertions would all still pass. Current storage correctly keeps only serialized bytes and metadata, so ptx is the sole owner of that CTransaction after AddTx returns. Add BOOST_CHECK_EQUAL(ptx.use_count(), 1) immediately after AddTx. This catches retention of the incoming reference without relying on allocator-dependent memory measurements.
[suggestion] · EraseTx fuzz accounting still depends directly on weight
The txorphan accounting assertion bypasses GetOrphanUsage, leaving one usage expectation coupled to weight after the other targets adopt the new helper.
Location: src/test/fuzz/txorphan.cpp:183 (head).
Details and suggested fix
The EraseTx assertion subtracts tx_weight, computed with GetTransactionWeight, from UsageByPeer. That is correct today because GetOrphanUsage returns weight, but it leaves this target behind if the accounting metric changes. Use node::GetOrphanUsage(tx) for the accounting subtraction. Keep tx_weight for the separate MAX_STANDARD_TX_WEIGHT admission assertion.
[suggestion] · The usage comment incorrectly suggests platform-dependent accounting
GetOrphanUsage currently returns platform-independent transaction weight, contrary to the test comment's rationale for computing TX_USAGE.
Location: src/test/orphanage_tests.cpp:113 (head).
Details and suggested fix
The test already checks every transaction's weight against the hardcoded value 469, and GetOrphanUsage returns that same weight. Computing TX_USAGE through the helper is useful because the test should follow the orphanage's accounting metric, not because the current value varies by platform. Reword the comment to give that abstraction rationale.
[suggestion] · GetParentTxids lacks direct sorted-unique coverage
Late-announcement handling relies on the new getter's deduplicated parent IDs, but the existing duplicate-parent test exercises GetUniqueParents through initial admission.
Location: src/node/txorphanage.cpp:665 (head).
Details and suggested fix
GetParentTxids rebuilds the sorted unique parent list from cached prevouts. If deduplication regresses, MaybeAddOrphanResolutionCandidate can count repeated parents against MAX_PEER_TX_ANNOUNCEMENTS and refuse an otherwise eligible announcer near the limit. Extend get_children to assert that child_p1n0_p1n1 returns parent1 once and that child_p1n0_p2n0 returns the two IDs in sorted order. Also assert that an unknown wtxid returns std::nullopt. These directly test the new getter rather than the separate initial-admission helper.
[suggestion] · The new 1p1c selection tests mine a chain they never use
Both new selection tests only need an empty mempool, but TestChain100Setup additionally mines COINBASE_MATURITY blocks for each test.
Location: src/test/txdownload_tests.cpp:356 (head).
Details and suggested fix
find_1p1c_selection_order and find_1p1c_reject_filters add synthetic children directly to the orphanage, set rejection filters and call Find1P1CPackage. They never validate transactions or use coinbases or chain height. Use RegTestingSetup to retain the initialized regtest environment and mempool without the extra mining loop. The existing tx_rejection_types case follows the same heavier-fixture convention, so this optional simplification could also apply there.
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