cosmos / cosmos/evm

[Bug] eth_getProof fails for every block tag (latest/pending/earliest): "proof queries at height <= 2 are not supported"

Open
#1,279 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
164
Forks
213
Avg merge
3d 58m
Merged PRs (30d)
12

Description

## Type

- [x] Bug
- [ ] Feature
- [ ] Proposal / Discussion

## Summary

`eth_getProof` fails for every block tag (`latest`, `pending`, `finalized`, `safe`, `earliest`); only explicit numeric heights work. `GetProof` uses the raw `BlockNumber` sentinel as the proof height:

https://github.com/cosmos/evm/blob/469142db41aee479102cf878f8ac2bbe2b0c7a22/rpc/backend/account_info.go#L62-L85

```go
height := int64(blockNum) // "latest" = -2, "pending" = -1, "earliest" = -5
_, err = b.CometHeaderByNumber(ctx, blockNum)
...
if height == 0 { /* resolve latest */ } // never true for a tag
...
clientCtx := b.ClientCtx.WithHeight(height) // -2
```

and `QueryClient.GetProof` then rejects it with `proof queries at height <= 2 are not supported`. This is a regression from #373, which changed `blockNum.Int64()` (which maps negative tags to 0 and hit the `height == 0` branch) to `int64(blockNum)`.

## Reproduction (for bugs)

`main` (`469142d`), `./local_node.sh -y`:

```
eth_getProof ["0xcA11bde05977b3631167028862bE2a173976CA11",["0x0"],"latest"]
-> {"code":-32000,"message":"proof queries at height <= 2 are not supported"}

eth_getProof ["0xcA11bde05977b3631167028862bE2a173976CA11",["0x0"],"0x5"]
-> {"address":"0xca11…","accountProof":["0x12e6…"],...} (works)
```

Same for `"pending"`, `"finalized"` and `"earliest"`.

## Impact

Any consumer of `eth_getProof` that uses a tag (most do, `"latest"` is the default in ethers/viem/web3.py) gets an error instead of a proof. Fix is to take the height from the header that `CometHeaderByNumber` already resolves for the requested block (this also makes `earliest` resolve to the node's earliest available height). I have a PR with the fix and `TestGetProof` cases for the three tags ready.

## Related

- #373 (introduced the regression)

## Checklist

- [x] Linked to a GitHub Issue (or this is the Issue)
- [x] Repro steps included (for bugs)
- [x] Impact described
- [x] I understand minor typo/style doc fixes will not be accepted

Contributor guide

Open the contributing guide

Research direction

Start in rpc/backend/account_info.go at GetProof and reproduce the failure with ./local_node.sh -y using tagged block arguments. Inspect how CometHeaderByNumber resolves each tag and review the existing TestGetProof coverage. Done means latest, pending, finalized, safe, and earliest return proofs while explicit numeric heights continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, blockchain
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.