Skip to content

eth: default Block param to latest on state methods — implementation + conformance tests (builds on #812)#814

Merged
fjl merged 1 commit into
ethereum:mainfrom
MysticRyuujin:feat/state-block-default-latest
Jun 29, 2026
Merged

eth: default Block param to latest on state methods — implementation + conformance tests (builds on #812)#814
fjl merged 1 commit into
ethereum:mainfrom
MysticRyuujin:feat/state-block-default-latest

Conversation

@MysticRyuujin

@MysticRyuujin MysticRyuujin commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Builds on #812 by @manusw7 and carries it through to a tested, client-verified state:

  1. Spec (src/eth/state.yaml): mark the Block parameter required: false with description: "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.
  2. Conformance tests (tools/testgen/generators.go): add a *-default-block case to each method that omits the Block parameter and asserts default-to-latest behavior.
  3. Fixtures (tests/**/*.io): generated via make fill against 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 build regenerates openrpc.json with Block required: false on all six methods.
  • ./tools/speccheck -v passes. Negative-tested: flipping a method back to required: true makes speccheck reject the omitted-block fixture (missing required parameter), confirming the spec change is load-bearing.
  • The six fixtures replay green in hive rpc-compat against a go-ethereum build with the implementation.

Cross-client status

  • go-ethereum: implemented; passes all six. (PR linked below.)
  • Nethermind: defaults to latest for five of six already; eth_getStorageValues required a one-method fix (its block param was non-nullable). (PR linked below.)

Related

CI note (expected red until go-ethereum merges)

The Test job's make fill step is expected to fail for this PR, and that is
structural — not a defect:

  • make fill regenerates fixtures by building the geth pinned in tools/go.mod.
  • The new *-default-block fixtures require a geth that defaults an omitted block
    to 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 fill can't reproduce the committed fixtures and the "no untracked /
    changed files" gate fails.
  • make test (speccheck) and make lint pass; the fixtures were generated with a
    local geth carrying the change and validate against the updated spec.

This resolves once go-ethereum#35100 merges and this PR's tools/go.mod is bumped
to that commit. (A replace to a personal fork would make CI green but isn't
mergeable, so it's intentionally not committed.) This is the two-PR ordering
#812 anticipated.

@MysticRyuujin MysticRyuujin force-pushed the feat/state-block-default-latest branch from 862433b to c468416 Compare June 9, 2026 21:44
@MysticRyuujin MysticRyuujin marked this pull request as ready for review June 15, 2026 15:34
pull Bot pushed a commit to Dustin4444/erigon that referenced this pull request Jun 16, 2026
…tech#21586)

## Summary

Make the `Block` parameter optional (defaulting to `latest` when
omitted) on the six state-reading methods:

- `eth_getBalance`
- `eth_getCode`
- `eth_getStorageAt`
- `eth_getTransactionCount`
- `eth_getProof`
- `eth_getStorageValues`

Each took a value-type `rpc.BlockNumberOrHash`, so omitting the block
parameter failed with `-32602 missing value for required argument N` —
Erigon's `rpc` package (like go-ethereum's) only permits omitting a
*trailing* argument when it is a pointer. This changes the six handlers
(and the `EthAPI` interface) to `*rpc.BlockNumberOrHash` and defaults
`nil` to `latest` via a small `orLatest` helper, reusing the existing
`latestNumOrHash` var. `eth_call` already behaves this way.

Internal callers of the interface are updated accordingly
(`rpc/contracts/direct_backend.go`, `rpc/mcp/*`) along with the affected
tests.

## Motivation

This aligns Erigon with **ethereum/execution-apis#812** by **@manusw7**,
which marks the `Block` parameter `required: false` (default `latest`)
on these methods. Full credit for the proposal and rationale to
@manusw7.

## Testing

- `go vet ./rpc/jsonrpc/` passes (handlers + updated tests compile).
- Verified against the `hive` `rpc-compat` simulator with default-block
conformance fixtures (block parameter omitted): a locally-built Erigon
with this change returns the latest-block values and all six pass
(`tests=7 failed=0`). Before the change, all six failed.

## Related

- Source proposal: ethereum/execution-apis#812 (by @manusw7)
- execution-apis spec + conformance tests: ethereum/execution-apis#814
- go-ethereum implementation: ethereum/go-ethereum#35100
- Nethermind `eth_getStorageValues` fix: NethermindEth/nethermind#11883
- Besu implementation: besu-eth/besu#10587
- ethrex implementation: lambdaclass/ethrex#6780

---------

Co-authored-by: lupin012 <58134934+lupin012@users.noreply.github.com>
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 MysticRyuujin force-pushed the feat/state-block-default-latest branch from 92c7257 to b14c23c Compare June 29, 2026 15:22
@MysticRyuujin MysticRyuujin reopened this Jun 29, 2026
@fjl fjl merged commit ff44b23 into ethereum:main Jun 29, 2026
5 checks passed
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.

3 participants