alloy-rs / evm

EVM abstraction layer

Repository from Github https://github.comalloy-rs/evmRepository from Github https://github.comalloy-rs/evm

[Feature] Pass the TxEnv to precompiles as well.

nuntax opened this issue · comments

commented

Describe the feature you would like

I am using the PrecompilesMap for adding and managing Precompiles. However, I now ran into the issue that the EvmInternals field in the PrecompileInput only contains the BlockEnv and not the TxEnv, which I need to access in a precompile.

pub struct EvmInternals<'a> {
internals: Box<dyn EvmInternalsTr + 'a>,
block_env: &'a (dyn Block + 'a),
}

Would also open a PR myself and add it, just don't know if there's maybe a specific reason that the TxEnv is not in there.

Additional context

No response

ideally we keep this free of generics, so what we could probably do is tx_env: dyn revm::Transaction

@mablr perhaps you want to take this :) ?

commented

The issue is that the Transaction trait isn't dyn compatible. I have a fork which I use for now in which I solved this by adding a wrapper dyn compatible TransactionTr trait, similar to the EvmInternalsTr trait. It's quite a bit messy though and I didn't really know if there's a better solution.

commented

@mattsse I'll have a look by the end of the day 👍

The issue is that the Transaction trait isn't dyn compatible

ah sigh...
there's possibly a workaround for this

commented

My workaround looks like this but as I said this adds some boilerplate code:
https://github.com/nuntax/evm/blob/d8ecbd963c4edce8155e9362f5e1e5165ea29bb5/crates/evm/src/traits.rs#L44-L171
Could clean this up and open a PR.