Skip to content

feat(anvil): add eth_call block overrides (like geth) #10458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cruzdanilo opened this issue May 7, 2025 · 4 comments · Fixed by #10487
Closed

feat(anvil): add eth_call block overrides (like geth) #10458

cruzdanilo opened this issue May 7, 2025 · 4 comments · Fixed by #10487
Assignees
Labels
A-reth-anvil Area: reth-anvil C-anvil Command: anvil first issue A good way to start contributing T-feature Type: feature

Comments

@cruzdanilo
Copy link
Contributor

cruzdanilo commented May 7, 2025

Component

Anvil

Describe the feature you would like

add support for block context overrides in eth_call.

this would allow specifying parameters like block.timestamp, block.number, etc., for an eth_call's execution context, not just state overrides.

Additional context

geth implemented this in its v1.12.0 release (may 25, 2023), via an optional fourth argument to eth_call. (see "add block overrides to eth_call (#26414)" in the geth v1.12.0 release notes).

geth eth_call documentation: https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-eth#eth-call

@cruzdanilo cruzdanilo added T-feature Type: feature T-needs-triage Type: this issue needs to be labelled labels May 7, 2025
@github-project-automation github-project-automation bot moved this to Backlog in Foundry May 7, 2025
@zerosnacks zerosnacks added C-anvil Command: anvil A-reth-anvil Area: reth-anvil first issue A good way to start contributing and removed T-needs-triage Type: this issue needs to be labelled labels May 8, 2025
@mablr
Copy link
Contributor

mablr commented May 9, 2025

Could I try working on this feature?

@mattsse
Copy link
Member

mattsse commented May 9, 2025

yes please
the way this should be impl is adding another optional field for BlockOverrides here:

#[serde(default)] Option<StateOverride>,

and then change this field

overrides: Option<StateOverride>,

to EvmOverrides:

https://github.com/alloy-rs/alloy/blob/833f9a22ca7c30079d64554d435561877c15267a/crates/rpc-types-eth/src/state.rs#L262-L262

which has both state and block overrides.

for actually applying block overrides, we can copy and modify:

https://github.com/paradigmxyz/reth/blob/a3c067c2b23353b0f5e78ceff1fb2ea35d32c1db/crates/rpc/rpc-eth-types/src/revm_utils.rs#L218-L261

@mablr updated instructions, ty!

@mablr
Copy link
Contributor

mablr commented May 9, 2025

Thank you very much @mattsse for these precise instructions!

Since this issue concerns the eth_call handler, I was wondering if it would be relevant to add BlockOverrides field for the eth_estimateGas handler as well?

@mattsse
Copy link
Member

mattsse commented May 9, 2025

yeah, let's also do that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-reth-anvil Area: reth-anvil C-anvil Command: anvil first issue A good way to start contributing T-feature Type: feature
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants