Skip to content

Default Block param to 'latest' on eth_* state methods - #812

Closed
manusw7 wants to merge 1 commit into
ethereum:mainfrom
manusw7:feat/state-block-default-latest
Closed

manusw7 wants to merge 1 commit into
ethereum:mainfrom
manusw7:feat/state-block-default-latest

Conversation

@manusw7

@manusw7 manusw7 commented Jun 1, 2026 •

Copy link
Copy Markdown

Marks the Block parameter required: false (default latest) on the six state-reading methods in state.yaml: eth_getBalance, eth_getStorageAt, eth_getStorageValues, eth_getTransactionCount, eth_getCode, eth_getProof.

Proposal for discussion — opening for visibility ahead of an RPC Standards discussion (ref: NethermindEth/nethermind#11764). Not expected to merge until client consensus + go-ethereum implementation.

Why

The spec is internally inconsistent on this. eth_call, eth_estimateGas and eth_createAccessList already mark Block required: false, and eth_simulateV1 documents default: 'latest' — yet the state-reading methods require it.
This PR aligns them under one rule.

Client behaviour is also already split: reth and Nethermind default an omitted block param to latest, while geth, erigon and besu reject it.
Standardising on default-to-latest matches existing behaviour in 2 of 5 clients and removes a client-diversity footgun, rather than leaving it implementation-defined.

Changes

  • src/eth/state.yaml — Block → required: false + description: "default: 'latest'" on all six methods (mirrors the eth_simulateV1 idiom).

TBD

  • Reach consensus between all EL clients (only Nethermind/Reth rn implement this default-to-latest behaviour)
  • Enforce compliance via hive tests with a test case that explicitly omits the block tag (asserting default-to-latest behaviour)

Mark the Block param required: false (default 'latest') on the six
state-reading methods in state.yaml: eth_getBalance, eth_getStorageAt,
eth_getStorageValues, eth_getTransactionCount, eth_getCode, eth_getProof.

Mirrors the eth_simulateV1 idiom (description "default: 'latest'") since a
bare default: keyword sibling to $ref is ignored by JSON-Schema tooling.

Spec-only. Conformance fixtures (tests/*.io) are generated by rpctestgen
against go-ethereum and cannot be filled until geth implements
default-to-latest; per CONTRIBUTING the behavior must land in go-ethereum
first. Proposal for discussion at RPC Standards (ref NethermindEth/nethermind#11764).
@manusw7
manusw7 marked this pull request as ready for review June 1, 2026 12:23
@manusw7 manusw7 mentioned this pull request Jun 1, 2026
1 of 4 tasks
@taratorio

Copy link
Copy Markdown

good with Erigon 👍

@MysticRyuujin

Copy link
Copy Markdown
Contributor

@manusw7 - I could be wrong but I'm testing making this change in go-ethereum and it APPEARS that Nethermind isn't defaulting to "latest" for eth_getStorageValues

@manusw7

manusw7 commented Jun 2, 2026

Copy link
Copy Markdown
Author

@manusw7 - I could be wrong but I'm testing making this change in go-ethereum and it APPEARS that Nethermind isn't defaulting to "latest" for eth_getStorageValues

hey @MysticRyuujin, you're right. That was the only exception I noticed missing this behaviour.
I've seen the PR, thanks! 🙌

s1na added a commit to ethereum/go-ethereum that referenced this pull request Jun 3, 2026
…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>
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>
MysticRyuujin added a commit to MysticRyuujin/execution-apis that referenced this pull request Jun 9, 2026
Mark the Block parameter required:false (default 'latest') on the six
state-reading methods: eth_getBalance, eth_getStorageAt,
eth_getStorageValues, eth_getTransactionCount, eth_getCode and
eth_getProof. Add rpctestgen cases and fixtures that omit the block
parameter and assert default-to-latest behavior.
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>
MysticRyuujin added a commit to MysticRyuujin/execution-apis that referenced this pull request Jun 29, 2026
Mark the Block parameter required:false (default 'latest') on the six
state-reading methods: eth_getBalance, eth_getStorageAt,
eth_getStorageValues, eth_getTransactionCount, eth_getCode and
eth_getProof. Add rpctestgen cases and fixtures that omit the block
parameter and assert default-to-latest behavior.
@manusw7

manusw7 commented Jun 30, 2026

Copy link
Copy Markdown
Author

Closed by #814

@manusw7 manusw7 closed this Jun 30, 2026
qianhh pushed a commit to bane-labs/go-ethereum that referenced this pull request Aug 12, 2026
…#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>
qianhh pushed a commit to bane-labs/go-ethereum that referenced this pull request Aug 19, 2026
…#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>
qianhh pushed a commit to bane-labs/go-ethereum that referenced this pull request Aug 31, 2026
…#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>
qianhh pushed a commit to bane-labs/go-ethereum that referenced this pull request Sep 16, 2026
…#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>
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>
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.

4 participants