Repository navigation
eth: default Block param to latest on state methods — implementation + conformance tests (builds on #812) - #814
Merged
Conversation
This was referenced Jun 2, 2026
Merged
Merged
MysticRyuujin
force-pushed
the
feat/state-block-default-latest
branch
from
June 9, 2026 21:44
862433b to
c468416
Compare
MysticRyuujin
marked this pull request as ready for review
June 15, 2026 15:34
moonrager13
approved these changes
Jun 28, 2026
moonrager13
approved these changes
Jun 28, 2026
moonrager13
approved these changes
Jun 28, 2026
moonrager13
approved these changes
Jun 28, 2026
moonrager13
approved these changes
Jun 28, 2026
1 of 4 tasks
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.
MysticRyuujin
force-pushed
the
feat/state-block-default-latest
branch
from
June 29, 2026 15:22
92c7257 to
b14c23c
Compare
2 tasks
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
Builds on #812 by @manusw7 and carries it through to a tested, client-verified state:
src/eth/state.yaml): mark theBlockparameterrequired: falsewithdescription: "default: 'latest'"on the six state-reading methods (eth_getBalance,eth_getStorageAt,eth_getStorageValues,eth_getTransactionCount,eth_getCode,eth_getProof) — identical to @manusw7's proposal in Default Block param to 'latest' on eth_* state methods #812.tools/testgen/generators.go): add a*-default-blockcase to each method that omits theBlockparameter and asserts default-to-latest behavior.tests/**/*.io): generated viamake fillagainst a go-ethereum build that implements the behavior.This addresses the two open items in #812's checklist: a go-ethereum implementation, and hive-enforceable conformance tests for the default-to-latest behavior.
Credit
The proposal, rationale, and spec change originate with @manusw7 in #812. This PR exists to implement and test it across clients — full credit to @manusw7 for the standards work.
Validation
make buildregeneratesopenrpc.jsonwithBlockrequired: falseon all six methods../tools/speccheck -vpasses. Negative-tested: flipping a method back torequired: truemakes speccheck reject the omitted-block fixture (missing required parameter), confirming the spec change is load-bearing.hiverpc-compatagainst a go-ethereum build with the implementation.Cross-client status
eth_getStorageValuesrequired a one-method fix (its block param was non-nullable). (PR linked below.)Related
eth_getStorageValuesfix: JsonRpc: default omitted block to latest for eth_getStorageValues NethermindEth/nethermind#11883CI note (expected red until go-ethereum merges)
The
Testjob'smake fillstep is expected to fail for this PR, and that isstructural — not a defect:
make fillregenerates fixtures by building the geth pinned intools/go.mod.*-default-blockfixtures require a geth that defaults an omitted blockto
latest— i.e. the accompanying go-ethereum PR (internal/ethapi: default block parameter to latest on state methods go-ethereum#35100),which isn't merged yet. Upstream-pinned geth still errors on the omitted block,
so
make fillcan't reproduce the committed fixtures and the "no untracked /changed files" gate fails.
make test(speccheck) andmake lintpass; the fixtures were generated with alocal geth carrying the change and validate against the updated spec.
This resolves once go-ethereum#35100 merges and this PR's
tools/go.modis bumpedto that commit. (A
replaceto a personal fork would make CI green but isn'tmergeable, so it's intentionally not committed.) This is the two-PR ordering
#812 anticipated.