Skip to content

feat(anvil): add block context overrides for eth_call and eth_estimateGas #10487

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mablr
Copy link
Contributor

@mablr mablr commented May 9, 2025

Motivation

Resolve #10458 by implementing block context overrides for eth_call and eth_estimateGas RPC methods, allowing users to specify block parameters like timestamp, number, difficulty, etc. for call execution context.

Solution

Key changes:

  • BlockOverrides added to EthRequest enum variants for eth_call and eth_estimateGas
  • Block overrides handling implemented in anvil::eth::backend::mem::state as apply_block_overrides() function (ported from reth)
  • Add new error type EvmOverrideError to group state and block override related errors (due to fork mode)
  • State override handling refactored:
    • Rename apply_cached_db_state_override() to apply_state_overrides()
    • Modify to take mutable CacheDB reference instead of creating new instance
    • Consistent pattern for apply_state_overrides() and apply_block_overrides()

PR Checklist

  • Fix EthRequest unfulfilled lint expectation
  • Add Tests with State and Block overrides for eth_call and eth_estimateGas

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks great already,

I have a few style nits

@mablr
Copy link
Contributor Author

mablr commented May 10, 2025

Thanks @mattsse for your feedback!
I'm going to commit asap the requested modifications.

I will squash it before marking this PR as ready.

@mablr mablr force-pushed the feature/anvil-block-overrides branch from fb16804 to 5590414 Compare May 11, 2025 20:48
…eGas

This commit implements block context overrides for eth_call and eth_estimateGas RPC methods,
allowing users to specify block parameters like timestamp, number, difficulty, etc. for call
execution context.

Key changes:
- BlockOverrides added to EthRequest enum variants for eth_call and eth_estimateGas
- Block overrides handling implemented in `anvil::eth::backend::mem::state` as `apply_block_overrides()` function (ported from reth)
- Add new error type EvmOverrideError to group state and block override related errors (due to fork mode)
- State override handling refactored:
  - Rename `apply_cached_db_state_override()` to `apply_state_overrides()`
  - Modify to take mutable `CacheDB` reference instead of creating new instance
  - Consistent pattern for `apply_state_overrides()` and `apply_block_overrides()`
@mablr mablr force-pushed the feature/anvil-block-overrides branch from 5590414 to 180f897 Compare May 11, 2025 20:54
@mablr mablr marked this pull request as ready for review May 11, 2025 20:55
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, ty!

this will likely conflict with #10454

so I'm resolving the conflicts after and merge this,

tysm

@mattsse mattsse added the T-blocked Type: blocked label May 16, 2025
@mattsse mattsse moved this to Blocked in Foundry May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-blocked Type: blocked
Projects
Status: Blocked
Development

Successfully merging this pull request may close these issues.

feat(anvil): add eth_call block overrides (like geth)
2 participants