feat(api): support finalized/safe block tags & fix eth_feeHistory blockCount parsing#4943
Open
envestcc wants to merge 1 commit into
Open
feat(api): support finalized/safe block tags & fix eth_feeHistory blockCount parsing#4943envestcc wants to merge 1 commit into
envestcc wants to merge 1 commit into
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses the two concrete items in #4942 for IoTeX's EVM JSON-RPC (
api/web3server.go):finalized/safeblock tags (primary).eth_getBlockByNumberwithfinalized/safepreviously failed withstrconv.ParseUint: parsing "finalized": invalid syntax. The string-basedparseBlockNumberonly recognizedpending/latest/earliest. It now also resolvessafeandfinalized. Roll-DPoS gives deterministic instant finality, so the committed tip is already irreversible and both tags map toTipHeight()— consistent with the existingrpc.BlockNumberOrHashpath (blockNumberOrHashToHeight), which already handled these tags.eth_feeHistoryblockCounthex bug.blockCountwas parsed with base-10strconv.ParseUint, so spec-compliant callers sending a hex quantity ("0x5", e.g. MetaMask EIP-1559 fee estimation) gotstrconv.ParseUint: parsing "0x5": invalid syntax. It is now parsed as a hex quantity viahexStringToNumber. Backward compatible (0x4 == 4, existing test unaffected).Out of scope
The optional parity items in #4942 —
eth_getProof(EIP-1186),eth_createAccessList(EIP-2930), and thetxpool_*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: addedsafeandfinalizedcases.eth_feeHistoryintegrity test: added a hex-stringblockCount("0x4") case.go build ./api/...and the web3 test suites pass.Refs #4942
🤖 Generated with Claude Code