foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Use `ContextPrecompile` instead of `Precompile` in Anvil's precompile injection API

Open alexfertel opened this issue 10 months ago • 0 comments

Component

Anvil

Describe the feature you would like

We've been using the new precompile injection API created in https://github.com/foundry-rs/foundry/pull/7589, and it's working well.

After some use, the need for ContextPrecompile arose: we needed a way to get the code of an account, and with the params of Precompile, this can't be done. If I understand correctly the implementation in revm, ContextPrecompile does give access to account state through InnerEvmContext::code_hash.

Since ContextPrecompile is a superset of Precompile, this should be fine. I tried making an initial PoC, but the generics of ContextPrecompile<DB: Database> get a bit in the way.

Current workaround is creating a provider inside the precompile and making a get_code_at async call. This works fine, it's just that it's a bit awkward having to make an RPC call, when we are executing in the context of an EVM.

Additional context

No response

alexfertel avatar Apr 18 '24 11:04 alexfertel