Skip to content

Nil Pointer Dereference Error When Querying Transactions with Proof in CometBFT #3352

Closed
@tuky191

Description

Bug Report

Have you tried the latest version: yes

ABCI app: any CosmosSDK chain

What happened?

When querying a transaction from LCD, that has min_retain_blocks set, the result is nil pointer error for transactions from blocks that had been deleted away.

for example:

https://api-injective-ia.cosmosia.notional.ventures/cosmos/tx/v1beta1/txs/71B0034D463EC79CB0011C7F4EA9EE3B39342AF6BE40AA0402C672A43B21DA3B

{"code":2,"message":"runtime error: invalid memory address or nil pointer dereference: panic","details":[]}

The transaction itself is present in the CometBFT, which can be proved by calling the TX RPC endpoint directly with and without a proof.

https://rpc-injective-ia.cosmosia.notional.ventures/tx?hash=0x71B0034D463EC79CB0011C7F4EA9EE3B39342AF6BE40AA0402C672A43B21DA3B&prove=true

{
  "jsonrpc": "2.0",
  "id": -1,
  "error": {
    "code": -32603,
    "message": "Internal error",
    "data": "runtime error: invalid memory address or nil pointer dereference"
  }
}

https://rpc-injective-ia.cosmosia.notional.ventures/tx?hash=0x71B0034D463EC79CB0011C7F4EA9EE3B39342AF6BE40AA0402C672A43B21DA3B&prove=false

{
  "jsonrpc": "2.0",
  "id": -1,
  "result": {
    "hash": "71B0034D463EC79CB0011C7F4EA9EE3B39342AF6BE40AA0402C672A43B21DA3B",
    "height": "75002060",
    "index": 5,
    "tx_result": {
      "code": 0,
      "data": 
omitted

Root cause for the nil pointer error can be found here. When block is no longer available, LoadBlock returns nil Block, which triggers the panic on the next line.

cometbft/rpc/core/tx.go

Lines 116 to 117 in 7f24fd2

block := env.BlockStore.LoadBlock(r.Height)
proof = block.Data.Txs.Proof(int(r.Index))

What did you expect to happen?

I expect an error stating that proof is not available, since block had been pruned away.

Metadata

Assignees

Labels

bugSomething isn't workingrpc

Type

No type

Projects

  • Status

    Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions