2 minor findings · 3 suggestions
Earlier concerns neither republished nor resolved: 1 minor finding. See the Run archive for their assessments.
Findings
[minor] · A corrupt txindex candidate can prevent an explicit block lookup
With -txindex, a corrupt index candidate can abort an explicit-blockhash lookup before the requested readable block is checked; this requires local block-file or index corruption, and no production occurrence was identified.
Location: src/index/txindex.cpp:215 (head).
Details and suggested fix
When blockhash is supplied, GetTransaction calls FindTx before reading the requested block. FindTx now throws when it cannot open or deserialize the first candidate; previously, it logged the problem and skipped that candidate. Because candidates are ordered with the active chain first, and each bucket shares only a 40-bit hash prefix, the unreadable candidate can be another block containing the same txid or an unrelated colliding txid. The RPC then rethrows error -1 even when the requested block has data and contains the transaction. This conflicts with the help text, which says the RPC returns the transaction if the specified block is available and contains it, and with the release note's claim that these RPCs previously reported the transaction as missing. If surfacing index corruption on this path is intended, clarify the help text and release note. Otherwise, when block_index is set, catch and log the FindTx error, then fall through to ReadBlock, which throws on a genuine read failure. The behavior is established for this corruption scenario, but no concrete production occurrence was identified.
[minor] · The test can rename blk00000.dat during txindex sync
If background txindex sync reads the block file during the rename, node 0 aborts and the functional test fails intermittently.
Location: test/functional/rpc_rawtransaction.py:112 (head).
Details and suggested fix
Node 0 starts with -txindex on a cached chain without an index, so txindex sync runs in the background after startup. The test framework waits for RPC and mempool loading, not index sync. test_getrawtransaction_block_data_errors runs first and renames blk00000.dat without waiting for sync; the existing sync_txindex call happens later in getrawtransaction_tests. If BaseIndex::Sync reaches ProcessBlock during the rename, ReadBlock fails and FatalErrorf aborts the node. Renaming the file back does not undo the abort. Call sync_txindex(self, node) before the rename, as feature_io_errors.py does with its synced wait. The race depends on thread scheduling, and the small cached chain usually finishes indexing first.
Optional improvements
[suggestion] · Unit tests do not cover FindTx's skip-versus-throw behavior
Reverting the stale-row skip or the legacy TryRead behavior would leave the current tests passing.
Location: src/index/txindex.cpp:196 (head).
Details and suggested fix
FindTx now skips rows whose block is unknown or known, non-active, and without data. It throws when a BlockSeqKey is missing or an active-chain block lacks data. FindLegacyTx uses TryRead, so a legacy value that cannot be deserialized throws rather than appearing absent. The new functional tests only remove blk00000.dat, so they do not exercise these branches. Add unit cases using TxIndexTest::GetDB, BucketPositions, and db.Write: verify that a DBKey mapped by BlockSeqKey to an unknown hash is skipped, and that a DBKey with no BlockSeqKey throws std::runtime_error. In txindex_legacy_fallback, overwrite the legacy value with an unserializable byte, such as uint8_t{0}, and expect a throw; then erase it and expect nullopt.
[suggestion] · The release note misidentifies the RPC error code
Clients interpreting “internal error” as JSON-RPC code -32603 will not match these failures, which use RPC_MISC_ERROR (-1).
Location: doc/release-notes-35728.md:4 (head).
Details and suggested fix
The release note says getrawtransaction, gettxoutproof, utxoupdatepsbt, and descriptorprocesspsbt return an internal error. These failures are plain std::runtime_error exceptions, which ExecuteCommand maps to RPC_MISC_ERROR (-1), as feature_io_errors.py asserts. In JSON-RPC, an internal error is RPC_INTERNAL_ERROR (-32603). The test also asserts -32603 for gettxoutproof's separate “Can't read block from disk” path, so the same RPC reports unreadable block data under different codes depending on the path. State the actual code (-1) in the release note. If -32603 is intended, rethrow these errors as RPC_INTERNAL_ERROR in the RPC callers. The REST wording is accurate because that path returns HTTP 500.
[suggestion] · The declarations do not document the new throwing behavior
The declarations describe only a null result, although these methods now use exceptions to report read failures.
Location: src/node/transaction.cpp:164 (head).
Details and suggested fix
GetTransaction now throws std::runtime_error when it cannot read the requested block and propagates the new FindTx exceptions. Its declaration says only that it returns the transaction if found, otherwise nullptr; TxIndex::FindTx likewise documents only nullopt for a miss. The base FindTx could already throw dbwrapper_error from Read, but this change makes exceptions the designated way to report read and index failures, while nullptr and nullopt mean a genuine miss. Add @throws notes to both declarations distinguishing ordinary misses from read or index failures. Current callers are RPC and REST handlers that catch std::exception, so this documentation is for future callers.
Earlier concerns
Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.
- [minor]: Txindex key decode failures can appear as transaction misses