Skip to content

rpc/jsonrpc: return requested numeric selector in erigon_blockNumber - #23127

Merged
awskii merged 3 commits into
erigontech:mainfrom
Sahil-4555:fix/rpc-erigon-blocknumber-numeric-selector
Aug 11, 2026
Merged

rpc/jsonrpc: return requested numeric selector in erigon_blockNumber#23127
awskii merged 3 commits into
erigontech:mainfrom
Sahil-4555:fix/rpc-erigon-blocknumber-numeric-selector

Conversation

@Sahil-4555

Copy link
Copy Markdown
Collaborator

Fixes an issue where erigon_blockNumber accepted a numeric block number parameter (e.g. ["0x1"]) but ignored it, returning the latest executed block height instead.

BlockNumber() parses numeric parameters into rpcBlockNum. However, because rpc.LatestExecutedBlockNumber was not an explicit case in the switch rpcBlockNum, both rpc.LatestExecutedBlockNumber (-5) and valid positive numeric block selectors (such as 1 or 7) fell through to default:, which unconditionally called rpchelper.GetLatestExecutedBlockNumber(tx).

  • Added an explicit case rpc.LatestExecutedBlockNumber, rpc.PendingBlockNumber: branch that calls rpchelper.GetLatestExecutedBlockNumber(tx).
  • Updated default: to set blockNum = uint64(rpcBlockNum), returning the requested numeric block number.
  • Added TestErigonBlockNumber unit tests covering omitted parameters, named tags ("latest", "earliest"), and numeric selectors ("0x0", "0x1", "0x7").

Closes #23118

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes erigon_blockNumber so numeric selectors return the requested block number.

Changes:

  • Handles latest-executed and pending selectors explicitly.
  • Returns numeric selectors directly.
  • Adds regression tests for omitted, named, and numeric selectors.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
rpc/jsonrpc/erigon_system.go Corrects block selector handling.
rpc/jsonrpc/erigon_system_test.go Adds selector regression coverage.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread rpc/jsonrpc/erigon_system.go
@awskii

awskii commented Aug 11, 2026

Copy link
Copy Markdown
Member

please cherry pick to release/3.6 branch (and another rpc related PR #23129)

Handle negative rpcBlockNum values in the default branch of erigon_blockNumber
and add unit test coverage for invalid negative block numbers.

Closes erigontech#23118
@awskii
awskii enabled auto-merge August 11, 2026 08:52
@awskii
awskii added this pull request to the merge queue Aug 11, 2026
Merged via the queue into erigontech:main with commit 633d563 Aug 11, 2026
134 checks passed
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.

erigon_blockNumber ignores a numeric blockNumber selector and returns the latest executed height

3 participants