1 minor finding · 4 suggestions
Earlier concerns neither republished nor resolved: 1 minor finding · 1 suggestion. See the Run archive for their assessments.
Findings
[minor] · A readable stale copy hides the pruned active-chain block
When a transaction's active-chain copy is pruned but a stale copy remains readable, implicit RPC lookups lose the active-block hint and can report zero confirmations or return a proof that verifytxoutproof rejects.
Location: src/index/txindex.cpp:247 (head).
Details and suggested fix
With -txindex and pruning, index a transaction in A, reorg it into B, then reorg back to A. Once file-order pruning removes A's older file but leaves B readable, FindTx collects A in pruned_block_hashes and discards that set when B matches. Verbose getrawtransaction without a block hash consequently returns B with confirmations: 0. If the transaction is fully spent, implicit gettxoutproof has no UTXO shortcut and builds a proof for B, which verifytxoutproof rejects with "Block not found in chain". Preserve pruned active-chain candidates alongside a stale TxFound and let chain-sensitive callers surface a fetch-and-retry hint. This retains readable data for raw-transaction and PSBT callers and preserves explicit stale-block requests. Keep the hints qualified as candidates because hash prefixes can collide. No production instance of this reorg-and-back plus file-order pruning scenario was identified.
Optional improvements
[suggestion] · Fetched blocks have no 288-block retention guarantee
With automatic pruning and a historical-only file rollover, fetched blocks can disappear before the advised retry; the 288-block retention claim in the rationale is not guaranteed.
Location: src/rpc/rawtransaction.cpp:264 (head).
Details and suggested fix
AcceptBlock stores fetched blocks with their historical heights, which also populate the file metadata. The current file and files containing recent blocks are protected, but a batch can fill a historical-only file and roll over to the next file. Under automatic pruning pressure, that completed file can then be pruned during the receive-time FlushStateToDisk(NONE), without another tip block. Earlier downloads may disappear before the advised retry. Repeat getblockfrompeer's existing immediate-re-pruning warning beside the new getrawtransaction and gettxoutproof advice, and remove the unconditional 288-block claim from the rationale. If that retention guarantee is intended instead, it needs explicit protection and an automatic-pruning rollover test. The current manual-pruning, single-fetch test does not exercise this case.
[suggestion] · The prune-mode test omits rebuilding over retained history
Starting with txindex enabled on a clean chain exercises notification-driven indexing, not the successful disk-backed rebuild in prune mode recommended to legacy-index users.
Location: test/functional/feature_txindex_prune.py:42 (head).
Details and suggested fix
setup_clean_chain=True and the empty-datadir latch in BaseIndex::Init make this fixture index generated blocks through BlockConnected. The temporary -txindex=0 restart advances no blocks, so re-enabling the index also skips historical sync. Keep this case, but add a chain built with txindex disabled and all block data retained, then restart with a fresh txindex and pruning enabled. Wait for sync, prune and check the historical-block hints, then restart to check that the saved index position is reused. Exercise the prune lock's protection before the initial PruneAndFlush and the successful BLOCK_HAVE_DATA startup check in this scenario. The new legacy-index recovery advice relies on that workflow, while the existing rejection tests do not cover its success path.
[suggestion] · The PSBT test misses the SegWit UTXO fallback
The only tested PSBT input is P2PKH, so the assertions would still pass if pruned-block lookup misses stopped feeding the SegWit witness_utxo fallback.
Location: test/functional/feature_txindex_prune.py:80 (head).
Details and suggested fix
ProcessPSBT currently queues every TxMiss for FindCoins, then fills witness_utxo for SegWit outputs. Here tx["sent_vout"] is the legacy destination, so before fetching the block the test only checks that non_witness_utxo is absent. Skipping the coins entry specifically for misses carrying pruned hashes would leave that assertion passing, and the post-fetch check uses the found-transaction path. Add the same transaction's unspent P2TR change output at vout 0 as a second PSBT input. Before fetching, assert that it has no non_witness_utxo and that its witness_utxo contains the expected amount and script. MiniWallet already creates that output, so this needs no extra mining or restarts.
[suggestion] · Prune-race recovery lacks deterministic test coverage
The tests prune before lookup, so they do not protect the failed-open recheck that returns a block hint when pruning occurs during FindTx.
Location: src/index/txindex.cpp:229 (head).
Details and suggested fix
FindTx copies candidate positions under cs_main, then opens their files after releasing the lock. If pruning clears availability and unlinks a file in that interval, the failed-open recheck records the active-chain hash instead of throwing. The unit helper clears status before lookup, the functional test completes manual pruning first, and the I/O test removes a file while leaving its status intact. None forces this recovery path. Add a deterministic test that pauses after candidate collection without holding cs_main, prunes and unlinks an eligible candidate file on another thread, then resumes and checks that TxMiss contains the active block hash. It would detect removal of the recheck, which would restore a "Failed to open block file" error without a fetch hint. This requires a test-only synchronization seam, so weigh its maintenance cost against the narrow race coverage.
Earlier concerns
Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.
- [minor]: Check all requested txids for pruned-block candidates
- [suggestion]: Fetch-and-retry advice omits the peer privacy caveat (earlier report)