Skip to content

feat(api): support finalized/safe block tags & fix eth_feeHistory blockCount parsing#4943

Open
envestcc wants to merge 1 commit into
masterfrom
fix/web3-finalized-safe-tags
Open

feat(api): support finalized/safe block tags & fix eth_feeHistory blockCount parsing#4943
envestcc wants to merge 1 commit into
masterfrom
fix/web3-finalized-safe-tags

Conversation

@envestcc

Copy link
Copy Markdown
Member

Summary

Addresses the two concrete items in #4942 for IoTeX's EVM JSON-RPC (api/web3server.go):

  1. finalized / safe block tags (primary). eth_getBlockByNumber with finalized/safe previously failed with strconv.ParseUint: parsing "finalized": invalid syntax. The string-based parseBlockNumber only recognized pending/latest/earliest. It now also resolves safe and finalized. Roll-DPoS gives deterministic instant finality, so the committed tip is already irreversible and both tags map to TipHeight() — consistent with the existing rpc.BlockNumberOrHash path (blockNumberOrHashToHeight), which already handled these tags.

  2. eth_feeHistory blockCount hex bug. blockCount was parsed with base-10 strconv.ParseUint, so spec-compliant callers sending a hex quantity ("0x5", e.g. MetaMask EIP-1559 fee estimation) got strconv.ParseUint: parsing "0x5": invalid syntax. It is now parsed as a hex quantity via hexStringToNumber. Backward compatible (0x4 == 4, existing test unaffected).

Out of scope

The optional parity items in #4942eth_getProof (EIP-1186), eth_createAccessList (EIP-2930), and the txpool_* namespace — are not included here. They require new state-trie / txpool plumbing that doesn't exist today and warrant separate PRs. This PR keeps to the concrete request + the small bug fix.

Tests

  • TestParseBlockNumber: added safe and finalized cases.
  • eth_feeHistory integrity test: added a hex-string blockCount ("0x4") case.
  • go build ./api/... and the web3 test suites pass.

Refs #4942

🤖 Generated with Claude Code

…unt parsing

Recognize the standard `finalized` and `safe` block tags in
`parseBlockNumber` (eth_getBlockByNumber path). Roll-DPoS gives
deterministic instant finality, so both resolve to the committed tip,
consistent with the existing rpc.BlockNumberOrHash handling. Closes the
`strconv.ParseUint: parsing "finalized"` error.

Also fix eth_feeHistory to parse `blockCount` as a hex quantity ("0x5")
per the JSON-RPC spec instead of base-10, so standard callers such as
MetaMask's EIP-1559 fee estimation work.

Refs: #4942

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@envestcc
envestcc requested a review from a team as a code owner July 16, 2026 07:53
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.

1 participant