Review report

core: PR #36480

1 minor finding · 4 suggestions

Earlier concerns neither republished nor resolved: 1 suggestion. See the Run archive for their assessments.

Findings

Link

[minor] · An unreadable spender becomes an ordinary unspent RPC result

When local block-storage damage makes the spender unreadable and neither format supplies a verified match, gettxspendingprevout now returns the normal unspent response instead of an error.

Location: src/index/txospenderindex.cpp:158 (head).

Details and suggested fix

When the RPC reaches the index after a mempool miss, a failed open or deserialization of the actual active-chain spender now logs and continues. The BLOCK_HAVE_DATA guard also skips without logging. If neither scan finds a verified match, std::nullopt becomes the bare outpoint. BlockUntilSyncedToCurrentChain checks indexing progress, not continued file readability. Keep scanning both formats so an unreadable false positive cannot hide a later match, but remember unchecked candidates across both scans. Retain util::Expected<std::optional<TxoSpender>, std::string> and propagate an RPC error if no match is found after such a skip. Also log the missing-data skip. Pruning is incompatible with -txospenderindex; no production occurrence was identified.


Optional improvements

Link

[suggestion] · The unreadable-candidate test misses the read-failure branch

Clearing BLOCK_HAVE_DATA skips the forged candidate before ReadTransaction runs, leaving continuation after an actual read failure untested.

Location: src/test/txospenderindex_tests.cpp:221 (head).

Details and suggested fix

The earlier candidate reaches the data-status guard at txospenderindex.cpp:154, not the failed-read branch. A regression that returns immediately only when ReadTransaction fails would still pass this test. Keep this case for the status guard and add one where the candidate retains BLOCK_HAVE_DATA but its transaction read fails deterministically. For example, temporarily change that block-index entry's nFile to a nonexistent file number without altering the real spender's file. Restore the field after lookup and assert that the later spender's txid and block hash are returned.


Link

[suggestion] · The persistent outpoint hash mapping lacks fixed-vector coverage

The tests do not pin the salt-and-outpoint mapping, so a wrapper-only change to the hash inputs could silently make existing hashed rows unreachable.

Location: src/test/txospenderindex_tests.cpp:126 (head).

Details and suggested fix

txospenderindex_key_encoding supplies the prefix itself, while the lookup tests derive prefixes through the same CreateKeyPrefix used for writing. Changing how this wrapper feeds outpoint.n into the hash could therefore keep fresh-database tests passing while making previously stored rows unreachable. Primitive SipHash vectors and txindex_hash_prefix cover the underlying hash and shared truncation, not this outpoint-specific composition. Add fixed-salt, fixed-outpoint vectors with literal expected prefixes, including two output indices of the same txid. Calculate the expected values independently of the helper under test.


Link

[suggestion] · Hashed spender persistence is not checked after restart

The only positive post-reopen lookup uses legacy data; the hashed spender is checked only before restart, so losing hashed lookup state on reopening would escape this test.

Location: test/functional/feature_txospenderindex_compatibility.py:84 (head).

Details and suggested fix

The first reopen serves tx1 from v31's legacy rows. tx2 is written and found in the hashed format, but its ancestor is invalidated before the next restart, after which every lookup expects absence. A regression that regenerated the outpoint salt on reopening could therefore leave these assertions passing. Restart node 0 after the mixed-format positive checks and before invalidateblock, wait for synchronization, and repeat the positive checks for both transactions with their original spending txids and block hashes.


Link

[suggestion] · Legacy detection adds an avoidable LevelDB open

For an existing on-disk database without wipe, legacy detection opens LevelDB twice even though reading the legacy salt after the normal open preserves valid-database behavior.

Location: src/index/txospenderindex.cpp:52 (head).

Details and suggested fix

Unlike txindex, this index always uses f_bloom=false, so it needs no pre-open format decision. The raw 's' probe also matches "siphash_key\0", which the legacy constructor wrote synchronously before indexing. Read DB_LEGACY_SIPHASH_KEY after opening once and use m_legacy_hasher.has_value() for the log and fallback, removing m_has_legacy and the probe. This preserves behavior for valid databases. Rows with a missing or malformed salt are already unusable by the current fallback.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.