From 92dacf4f5282338ae64e189331c002fd29921205 Mon Sep 17 00:00:00 2001 From: Thomas Coratger <60488569+tcoratger@users.noreply.github.com> Date: Tue, 17 Sep 2024 14:18:03 +0200 Subject: [PATCH] execution: add transaction and header AT to `ConfigureEvmEnv` (#10754) Co-authored-by: Matthias Seitz --- crates/ethereum/evm/src/lib.rs | 2 ++ crates/evm/src/lib.rs | 3 +++ crates/optimism/evm/src/lib.rs | 2 ++ examples/custom-evm/src/main.rs | 2 ++ examples/stateful-precompile/src/main.rs | 2 ++ 5 files changed, 11 insertions(+) diff --git a/crates/ethereum/evm/src/lib.rs b/crates/ethereum/evm/src/lib.rs index b854b78ac..8f9b22257 100644 --- a/crates/ethereum/evm/src/lib.rs +++ b/crates/ethereum/evm/src/lib.rs @@ -48,6 +48,8 @@ impl EthEvmConfig { } impl ConfigureEvmEnv for EthEvmConfig { + type Header = Header; + fn fill_cfg_env( &self, cfg_env: &mut CfgEnvWithHandlerCfg, diff --git a/crates/evm/src/lib.rs b/crates/evm/src/lib.rs index 04f476143..067f1e35b 100644 --- a/crates/evm/src/lib.rs +++ b/crates/evm/src/lib.rs @@ -108,6 +108,9 @@ pub trait ConfigureEvm: ConfigureEvmEnv { /// Default trait method implementation is done w.r.t. L1. #[auto_impl::auto_impl(&, Arc)] pub trait ConfigureEvmEnv: Send + Sync + Unpin + Clone + 'static { + /// The header type used by the EVM. + type Header; + /// Returns a [`TxEnv`] from a [`TransactionSignedEcRecovered`]. fn tx_env(&self, transaction: &TransactionSignedEcRecovered) -> TxEnv { let mut tx_env = TxEnv::default(); diff --git a/crates/optimism/evm/src/lib.rs b/crates/optimism/evm/src/lib.rs index 3867fe8da..d650bd27d 100644 --- a/crates/optimism/evm/src/lib.rs +++ b/crates/optimism/evm/src/lib.rs @@ -50,6 +50,8 @@ impl OptimismEvmConfig { } impl ConfigureEvmEnv for OptimismEvmConfig { + type Header = Header; + fn fill_tx_env(&self, tx_env: &mut TxEnv, transaction: &TransactionSigned, sender: Address) { transaction.fill_tx_env(tx_env, sender); } diff --git a/examples/custom-evm/src/main.rs b/examples/custom-evm/src/main.rs index 1ddc53d1e..8f5840a14 100644 --- a/examples/custom-evm/src/main.rs +++ b/examples/custom-evm/src/main.rs @@ -87,6 +87,8 @@ impl MyEvmConfig { } impl ConfigureEvmEnv for MyEvmConfig { + type Header = Header; + fn fill_cfg_env( &self, cfg_env: &mut CfgEnvWithHandlerCfg, diff --git a/examples/stateful-precompile/src/main.rs b/examples/stateful-precompile/src/main.rs index ae5b9feab..0ecb7f57d 100644 --- a/examples/stateful-precompile/src/main.rs +++ b/examples/stateful-precompile/src/main.rs @@ -144,6 +144,8 @@ impl StatefulPrecompileMut for WrappedPrecompile { } impl ConfigureEvmEnv for MyEvmConfig { + type Header = Header; + fn fill_tx_env(&self, tx_env: &mut TxEnv, transaction: &TransactionSigned, sender: Address) { self.inner.fill_tx_env(tx_env, transaction, sender) }