# Bug report: tm2 RPC `Tx` Handler Off-by-One **Severity:** Minor **Location:** `tm2/pkg/bft/rpc/core/tx.go` --- ## What's wrong Two bounds checks use the wrong operator, letting the boundary index slip through and panic. ### Line 34 — `>` should be `>=` ```go if int(resultIndex.TxIndex) > numTxs || numTxs == 0 { ... } rawTx := block.Txs[resultIndex.TxIndex] // panics when TxIndex == numTxs ``` ### Line 52 — `<` should be `<=` ```go if len(blockResults.DeliverTxs) < int(resultIndex.TxIndex) { ... } deliverResponse := blockResults.DeliverTxs[resultIndex.TxIndex] // same panic ``` --- ## When it triggers Under normal operation, `TxIndex` is always valid. The off-by-one matters when state becomes inconsistent — DB corruption, block re-org, or a crash between separate DB writes. The bounds check exists to catch exactly these cases, and it misses the boundary.