Skip to content

bug: EthTxIndex -1 sentinel wraps to MaxUint64 in ReceiptsFromCometBlock, breaking JS clients #1032

@Aboudjem

Description

@Aboudjem

Bug Description

In rpc/backend/comet_to_eth.go, ReceiptsFromCometBlock casts TxResult.EthTxIndex directly to uint without resolving the -1 sentinel value:

TransactionIndex: uint(txResult.EthTxIndex), // #nosec G115

When EthTxIndex == -1 (meaning "not yet determined by indexer"), int32(-1) wraps to uint64(18446744073709551615).

Reproduction

  1. Run a cosmos/evm chain and submit EVM transactions during fast block production
  2. If the indexer hasn't assigned EthTxIndex yet, it is stored as -1
  3. Call eth_getTransactionReceipt for that transaction
  4. The transactionIndex field in the receipt is 0xffffffffffffffff instead of the correct index

Impact

Expected Behavior

The -1 sentinel should be resolved to the correct transaction index (the loop counter), matching the existing fallback pattern in tx_info.go:68-76:

if txResult.EthTxIndex == -1 {
    txResult.EthTxIndex = int32(i)
}

Proposed Fix

Add sentinel resolution before the uint cast in ReceiptsFromCometBlock, matching the pattern already used in GetTransactionByHash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions