Skip to content
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

feat(anvil): add eth_simulateV1 rpc call #10030

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

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

Sorry, something went wrong.

Verified

This commit was signed with the committer’s verified signature.
dbeal-eth dbeal

Verified

This commit was signed with the committer’s verified signature.
dbeal-eth dbeal
now the response returns. joy!

Verified

This commit was signed with the committer’s verified signature.
dbeal-eth dbeal

Verified

This commit was signed with the committer’s verified signature.
dbeal-eth dbeal
and also some structural fixes

Verified

This commit was signed with the committer’s verified signature.
dbeal-eth dbeal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

None yet

1 participant