Skip to content

Conversation

@Cordtus
Copy link
Contributor

@Cordtus Cordtus commented Oct 20, 2025

Fixes eth_getProof RPC endpoint failing with "cannot query with height < 0" error when using special block parameters like "latest", "pending",
or "earliest".

Problem: Direct type cast int64(blockNum) preserves negative values from special block constants (EthLatestBlockNumber = -2,
EthPendingBlockNumber = -1, EthEarliestBlockNumber = -5), failing query validation

Fix: Use blockNum.Int64() method which converts negative values to 0

rpc/backend/ (see GetCode, GetBalance, GetStorageAt).

Review: Check rpc/backend/account_info.go:51 - for consistency with other methods.

---

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...

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

Problem: eth_getProof fails with 'cannot query with height < 0' when
using 'latest' block parameter.

Fix: Use blockNum.Int64() instead of int64(blockNum). The Int64() method
converts special block numbers (-2, -1, -5) to 0, while direct cast
preserves negative values.

Source: This is the standard pattern used throughout rpc/backend/
(see GetCode, GetBalance, GetStorageAt).
@Cordtus Cordtus force-pushed the fix/rpc-eth-getproof-height-bug branch from 64e623c to 628fb50 Compare October 20, 2025 16:51
}

height := int64(blockNum)
height := blockNum.Int64()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's refactor the Int64() function to be named AdjustedInt64() to clearly denote that it transforms 0's into 1's. Otherwise, PR looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants