Skip to content

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

Open
Sahil-4555 wants to merge 1 commit into
erigontech:mainfrom
Sahil-4555:fix/rpc-erigon-blocknumber-numeric-selector
Open

rpc/jsonrpc: return requested numeric selector in erigon_blockNumber#23127
Sahil-4555 wants to merge 1 commit 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

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

1 participant