Skip to content

Comments

feat(anvil): add eth_simulateV1 rpc call#10030

Closed
dbeal-eth wants to merge 5 commits intofoundry-rs:masterfrom
dbeal-eth:master
Closed

feat(anvil): add eth_simulateV1 rpc call#10030
dbeal-eth wants to merge 5 commits intofoundry-rs:masterfrom
dbeal-eth:master

Conversation

@dbeal-eth
Copy link
Contributor

Motivation

#9593

Solution

A simulate function was added to the memory backend which calls upon the existing snapshot, revert, and block mining functionalities to replicate the behavior of eth_simulateV1. Alloy conveniently provides most of the needed types for eth_simulateV1, so its mostly just a matter of type conversion.

This is probably not the most efficient or beautiful solution, but for my surface level knowledge of the repo it seemed like a reasonable enough approach. Please let me know if there is some way better.

I am not a professional rust developer, so I probably did some unusual things. Please point out what I should do to improve!

Currently missing features of eth_simulateV1 on this PR:

  • ability to respond to block tag (I spent hours on this and couldn't figure out how to get the database memory management correct)

Additional issues:

  • When constructing the simulation, there are some issues that can occur:
    • If a transaction is "invalid" (ex. the account calling doesnt have enough eth for gas, or the base fee is too low, what is reccomended way to solve?)
    • If a gas_limit is not specified, what should be used as the gas limit? should it be auto set to the block max limit, or should the block gas limit be set higher somehow?
  • Please see the TODOs throughout the repo on other things I ran into misc problems/questions about

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@mattsse
Copy link
Member

mattsse commented Apr 2, 2025

closing, superseded by #10227

ty @dbeal-eth

@mattsse mattsse closed this Apr 2, 2025
@github-project-automation github-project-automation bot moved this to Done in Foundry Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants