Skip to content

[F-2026-17740] - KV indexer path misses derived transactions #17

Merged
0xNilesh merged 12 commits into
audit-fixesfrom
audit/kv-index-issue
Jun 12, 2026
Merged

[F-2026-17740] - KV indexer path misses derived transactions #17
0xNilesh merged 12 commits into
audit-fixesfrom
audit/kv-index-issue

Conversation

@AryaLanjewar3005

Copy link
Copy Markdown
Collaborator

[F-2026-17740] - KV indexer path misses derived transactions

Issue

The KV indexer only indexes standard MsgEthereumTx transactions — EVM executions submitted directly via Ethereum RPC. Derived transactions (EVM calls triggered internally by Cosmos modules such as IBC callbacks, governance, and ERC20 hooks) are never written to the index because they do not appear in block.Txs and do not carry the ExtensionOptionsEthereumTx extension option that isEthTx requires.

File: indexer/kv_indexer.go

if !isEthTx(tx) {
    continue  // derived txs always skipped — never indexed
}

At query time, GetTxByEthHash delegates to the KV indexer when one is configured and treats any error as a hard failure with no fallback:

File: rpc/backend/tx_info.go

if b.indexer != nil {
    txRes, err := b.indexer.GetByTxHash(hash)
    if err != nil {
        return nil, nil, err  // derived tx miss → error returned, fallback never reached
    }
    return txRes, nil, nil
}

// fallback to tendermint event search — unreachable when indexer is set

A working fallback path already exists below the indexer block. It searches Tendermint's event index using the ethereum_tx.ethereumTxHash attribute, which derived transactions do emit. On nodes without the KV indexer this path resolves derived txs correctly. On nodes with the KV indexer it is structurally unreachable.

Impact

  • Nodes with KV indexer enabled return errors for eth_getTransactionByHash, eth_getTransactionReceipt, and related APIs when called with a derived transaction hash.
  • Nodes without the KV indexer resolve the same hash correctly.
  • This deployment-dependent inconsistency breaks integrators, block explorers, and indexing infrastructure that assume uniform transaction availability across node configurations.

Solution

Change the error handling in GetTxByEthHash and GetTxByEthHashAndMsgIndex so that a KV indexer miss is treated as a cache miss rather than a hard failure. When GetByTxHash returns an error, fall through to the existing Tendermint event-query reconstruction path instead of propagating the error.

if b.indexer != nil {
    txRes, err := b.indexer.GetByTxHash(hash)
    if err == nil {
        return txRes, nil, nil  // cache hit — fast path preserved
    }
    // indexer miss or no derived-tx metadata — fall through to event-query reconstruction
}

// fallback to tendermint event search — now reachable for any miss

Behavior after fix

Node config Transaction type Result
No KV indexer Standard Eth Tx Found via Tendermint event search
No KV indexer Derived Tx Found via Tendermint event search
KV indexer enabled Standard Eth Tx Found in KV index (fast path, unchanged)
KV indexer enabled Derived Tx KV miss → fallback → found via Tendermint event search

Limitation

The fallback relies on Tendermint's event index. On nodes that prune historical event data, derived transactions older than the pruning window remain unresolvable. A complete fix requires also indexing derived transactions in the KV store during IndexBlock by scanning txResults[i].Events for EventTypeEthereumTx events carrying a DerivedTxType marker — this would give derived txs the same pruning-resistant durability as standard Eth txs.


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • tackled an existing issue or discussed with a team member
  • left instructions on how to review the changes
  • targeted the main branch

@github-actions github-actions Bot added the tests label Jun 11, 2026
0xNilesh added 8 commits June 11, 2026 18:33
Marks them via IsDerivedTx so the RPC backend can rebuild their fields.
Fixes getTransactionByHash/Receipt panic on derived txs (no MsgEthereumTx).
…/kv-index-derived-txs

# Conflicts:
#	rpc/backend/tx_info.go
GetTxByTxIndex reconstructs derived txs (gated by IsDerivedTxByBlockAndIndex) so trace predecessors aren't dropped.
GetTxByEthHash now falls through to tx_search on an indexer miss.
feat: Indexed the derived txs in the kv indexer
@github-actions github-actions Bot added the types label Jun 12, 2026
@0xNilesh 0xNilesh merged commit 4b0cc66 into audit-fixes Jun 12, 2026
15 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants