Skip to content

Pass block hash through parse_block_identifier instead of resolving it#3841

Open
genisis0x wants to merge 1 commit into
ApeWorX:mainfrom
genisis0x:fix/3646-blockhash-passthrough-parse-block-identifier
Open

Pass block hash through parse_block_identifier instead of resolving it#3841
genisis0x wants to merge 1 commit into
ApeWorX:mainfrom
genisis0x:fix/3646-blockhash-passthrough-parse-block-identifier

Conversation

@genisis0x
Copy link
Copy Markdown

Summary

`Contract.call` and the async variant routed user-supplied block hashes through `parse_block_identifier` / `async_parse_block_identifier`, which called `eth.get_block(...)` purely to read `block["number"]` and then forwarded the number to `eth_call`. The execution-apis spec lists block hashes as a valid default-block parameter, and the major clients (geth, reth, erigon, nethermind) accept them on `eth_call` / `eth_estimateGas`, so the lookup was a redundant round-trip.

Forward the hash (normalized via `to_hex_if_bytes`) directly. If a node does not support block hashes for these methods, its native RPC error propagates to the caller unchanged.

Closes #3646

Test plan

  • Updated `tests/core/contracts/test_contract_util_functions.py::test_parse_block_identifier_bytes_and_hex` (and its async twin) to assert passthrough instead of number-resolution.
  • No other call site of `parse_block_identifier` expects a numeric return when the input is a hash; downstream is `eth.call(block_identifier=...)` which serializes the hex string through the standard `call_munger` path.

`Contract.call` and the async variant routed user-supplied block hashes
through `parse_block_identifier` / `async_parse_block_identifier`, which
called `eth.get_block(...)` purely to read back `block["number"]` and
then forwarded that number to `eth_call`. The execution-apis spec lists
block hashes as a valid default-block parameter, and the major clients
(geth, reth, erigon, nethermind) accept them on `eth_call` and
`eth_estimateGas`, so the lookup was a redundant round-trip.

Forward the hash (normalized via `to_hex_if_bytes`) directly. Existing
parse-block-identifier tests are updated to assert passthrough. If a node
does not support block hashes for these methods, its native RPC error
propagates to the caller unchanged.

Closes ApeWorX#3646
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.

Call contract method with blockhash requires fetching block number

1 participant