Repository navigation
internal/ethapi: default block parameter to latest on state methods - #35100
Merged
s1na merged 3 commits intoJun 3, 2026
Merged
Conversation
Make the block parameter optional on eth_getBalance, eth_getCode, eth_getStorageAt, eth_getTransactionCount, eth_getProof and eth_getStorageValues. When omitted, it now defaults to the latest block, matching execution-apis (Block marked required:false, default 'latest') and the existing behavior of eth_call.
This was referenced Jun 2, 2026
Merged
Contributor
|
Overall looks good, just one small improvement for consistency with other methods, change Even without that change the console works fine, sort of by accident, because the JSON serializer produces null for an unprovided argument, and the server accepting null and setting the default latest. But would be nice to also have it more correct at the client side. |
…Values Use inputDefaultBlockNumberFormatter so the console supplies latest when the block arg is omitted, consistent with the other state methods.
Contributor
Author
|
Done in 18e0fd8 — switched |
s1na
reviewed
Jun 3, 2026
0xjvn
pushed a commit
to 0xjvn/go-ethereum
that referenced
this pull request
Jun 5, 2026
…thereum#35100) Make the `Block` parameter optional on the six state-reading methods, defaulting to `latest` when omitted: - `eth_getBalance` - `eth_getCode` - `eth_getStorageAt` - `eth_getTransactionCount` - `eth_getProof` - `eth_getStorageValues` This implements the behavior proposed in ethereum/execution-apis#812. --------- Co-authored-by: Sina M <1591639+s1na@users.noreply.github.com>
gballet
pushed a commit
to gballet/go-ethereum
that referenced
this pull request
Jun 12, 2026
…thereum#35100) Make the `Block` parameter optional on the six state-reading methods, defaulting to `latest` when omitted: - `eth_getBalance` - `eth_getCode` - `eth_getStorageAt` - `eth_getTransactionCount` - `eth_getProof` - `eth_getStorageValues` This implements the behavior proposed in ethereum/execution-apis#812. --------- Co-authored-by: Sina M <1591639+s1na@users.noreply.github.com>
AdityaSripal
pushed a commit
to AdityaSripal/go-ethereum
that referenced
this pull request
Jun 21, 2026
…thereum#35100) Make the `Block` parameter optional on the six state-reading methods, defaulting to `latest` when omitted: - `eth_getBalance` - `eth_getCode` - `eth_getStorageAt` - `eth_getTransactionCount` - `eth_getProof` - `eth_getStorageValues` This implements the behavior proposed in ethereum/execution-apis#812. --------- Co-authored-by: Sina M <1591639+s1na@users.noreply.github.com>
rjl493456442
pushed a commit
that referenced
this pull request
Aug 28, 2026
`debug_traceCall` requires the block number or hash parameter today. `TraceCall` takes `rpc.BlockNumberOrHash` by value, so an omitted parameter returns "missing value for required argument 1". The pending callTracer spec (ethereum/execution-apis#855) marks the parameter optional with a default of `latest`, consistent with the state-method defaults from #35100 (execution-apis #812/#814 lineage). This changes the argument to `*rpc.BlockNumberOrHash` and defaults to latest when nil. A regression test calls `debug_traceCall` through the RPC server with the parameter omitted and compares against an explicit `latest`. No behavior change when the parameter is supplied.
jimmyc256
pushed a commit
to Lambda256/go-ethereum-ralim
that referenced
this pull request
Sep 23, 2026
…35583) `debug_traceCall` requires the block number or hash parameter today. `TraceCall` takes `rpc.BlockNumberOrHash` by value, so an omitted parameter returns "missing value for required argument 1". The pending callTracer spec (ethereum/execution-apis#855) marks the parameter optional with a default of `latest`, consistent with the state-method defaults from ethereum#35100 (execution-apis ethereum#812/ethereum#814 lineage). This changes the argument to `*rpc.BlockNumberOrHash` and defaults to latest when nil. A regression test calls `debug_traceCall` through the RPC server with the parameter omitted and compares against an explicit `latest`. No behavior change when the parameter is supplied.
MegaRedHand
added a commit
to suna4/ethrex
that referenced
this pull request
Oct 27, 2026
…aclass#6780) ## Summary Two related JSON-RPC changes aligning ethrex with **ethereum/execution-apis#812** by **@manusw7** (Block parameter optional, default `latest`): 1. **Default an omitted block parameter to `latest`** on the state methods that previously required it. `eth_getBalance`, `eth_getCode`, `eth_getStorageAt`, `eth_getTransactionCount`, and `eth_getProof` did a strict `params.len() != N` check and returned `-32000 "Expected N params"` when the block was omitted. They now accept the block as optional and default it to `latest` via a new `impl Default for BlockIdentifierOrHash` (latest). 2. **Implement `eth_getStorageValues`** (previously `-32601 method not found`): batches storage-slot reads for multiple accounts at a block, mirroring `eth_getStorageAt`, with the same optional-block default and a 1024-slot cap. Registered in the `eth` dispatch. Slots follow the spec's `bytesMax32` (`0x` and at most 64 hex digits, `0x` alone is slot 0). An invalid slot or an empty request returns `-32602`, and more than 1,024 slots in total returns `-32005`. Every slot is read from the state root of one resolved block, so a block hash reads that block and a block the node does not have is an error. ## Motivation Aligns ethrex with execution-apis#812 (@manusw7) and matches the other clients implementing the same change. Full credit to @manusw7 for the proposal. ## Testing - New parse-layer tests assert each state method resolves an **omitted** block to `latest` (`test_state_methods_default_block_to_latest_when_omitted`). The `eth_getStorageValues` tests cover the slot format, the empty request, the slot cap, and the handler: values, lowercase keys, zeros for an absent account, a lookup by hash, and the error for an unknown block. - Confirmed via the hive `rpc-compat` simulator that the omitted-block request now produces the **same** response as an explicit `"latest"` request for every method (previously the omitted form errored). ### Note on hive rpc-compat value fixtures (out of scope) ethrex does not currently pass the rpc-compat *value* fixtures for these state methods in the hive default chain — but this is **pre-existing and unrelated to this change**: a stock ethrex build returns the same results for an explicit `"latest"` request (e.g. `eth_getBalance(addr, "latest")` returns `0x0` where other clients return the funded balance), and `*-blockhash` requests error with "Could not resolve block number". That points to an ethrex/hive default-chain state-serving issue, which is out of scope here. This PR makes the omitted-block path behave identically to the explicit-`latest` path (the spec change), proven by the unit tests above. ## Related - Source proposal: ethereum/execution-apis#812 (by @manusw7) - execution-apis spec + conformance tests: ethereum/execution-apis#814 - go-ethereum: ethereum/go-ethereum#35100 - Nethermind: NethermindEth/nethermind#11883 - Erigon: erigontech/erigon#21586 - Besu: besu-eth/besu#10587 --------- Co-authored-by: ilitteri <ivanlitteri@hotmail.com> Co-authored-by: Tomás Grüner <47506558+MegaRedHand@users.noreply.github.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
Make the
Blockparameter optional on the six state-reading methods, defaulting tolatestwhen omitted:eth_getBalanceeth_getCodeeth_getStorageAteth_getTransactionCounteth_getProofeth_getStorageValuesEach now takes
*rpc.BlockNumberOrHashand resolves anil(omitted/null) value tolatestvia a smallblockNrOrHashOrLatesthelper — mirroring the behavioreth_callalready implements. This requires the pointer type because go-ethereum'srpcpackage only permits omitting a trailing positional argument when its Go type is a pointer; a value type is mandatory and an omitted block currently fails with-32602 missing value for required argument N.Motivation
This implements the behavior proposed in ethereum/execution-apis#812 by @manusw7, which marks the
Blockparameterrequired: false(defaultlatest) on these methods to align them witheth_call,eth_estimateGas,eth_createAccessList, andeth_simulateV1. Full credit for the proposal and rationale goes to @manusw7. That PR notes it was "not expected to merge until client consensus + go-ethereum implementation" — this PR provides that go-ethereum implementation.Testing
TestStateMethodsDefaultToLatestdrives the full JSON-RPC server stack (rpc.DialInProc) and asserts that omitting the block parameter yields the same result as passing"latest"for all six methods.hiverpc-compatsimulator with new.iofixtures that omit the block parameter: all six pass on this branch.Related
eth_getStorageValues: JsonRpc: default omitted block to latest for eth_getStorageValues NethermindEth/nethermind#11883