From 74a1151c076f40e686731017a50dba9c01854037 Mon Sep 17 00:00:00 2001 From: Arsenii Kulikov Date: Fri, 21 Feb 2025 18:50:28 +0400 Subject: [PATCH] feat: integrate `TxEnv` conversions (#14630) --- Cargo.lock | 7 ++-- Cargo.toml | 4 +-- book/sources/Cargo.toml | 4 +-- crates/ethereum/evm/src/execute.rs | 21 +++++------- crates/ethereum/evm/src/lib.rs | 16 ++------- crates/ethereum/payload/src/lib.rs | 1 - crates/ethereum/primitives/Cargo.toml | 2 ++ crates/ethereum/primitives/src/transaction.rs | 19 ++++++----- crates/evm/src/lib.rs | 12 +++---- crates/optimism/evm/src/execute.rs | 34 ++++++------------- crates/optimism/evm/src/lib.rs | 16 ++------- crates/optimism/payload/src/builder.rs | 1 - crates/optimism/primitives/Cargo.toml | 2 ++ .../primitives/src/transaction/signed.rs | 17 +++++----- examples/custom-evm/src/main.rs | 10 +----- examples/stateful-precompile/src/main.rs | 11 ++---- 16 files changed, 63 insertions(+), 114 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b2354616a..03d1fddea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -261,8 +261,9 @@ dependencies = [ [[package]] name = "alloy-evm" version = "0.1.0" -source = "git+https://github.com/alloy-rs/evm?rev=3a57c0d#3a57c0db813d45ddf9b5dcbe4756ae2ce3fc2569" +source = "git+https://github.com/alloy-rs/evm?rev=beb6832#beb68324d7e05ae2eafad9f726a94cb0b63d15a5" dependencies = [ + "alloy-consensus", "alloy-primitives", "revm", "revm-optimism", @@ -368,7 +369,7 @@ dependencies = [ [[package]] name = "alloy-op-evm" version = "0.1.0" -source = "git+https://github.com/alloy-rs/evm?rev=3a57c0d#3a57c0db813d45ddf9b5dcbe4756ae2ce3fc2569" +source = "git+https://github.com/alloy-rs/evm?rev=beb6832#beb68324d7e05ae2eafad9f726a94cb0b63d15a5" dependencies = [ "alloy-evm", "alloy-primitives", @@ -7702,6 +7703,7 @@ version = "1.2.0" dependencies = [ "alloy-consensus", "alloy-eips", + "alloy-evm", "alloy-network", "alloy-primitives", "alloy-rlp", @@ -8717,6 +8719,7 @@ version = "1.2.0" dependencies = [ "alloy-consensus", "alloy-eips", + "alloy-evm", "alloy-network", "alloy-primitives", "alloy-rlp", diff --git a/Cargo.toml b/Cargo.toml index db81100df..b0ab50f66 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -623,8 +623,8 @@ snmalloc-rs = { version = "0.3.7", features = ["build_cc"] } crunchy = "=0.2.2" [patch.crates-io] -alloy-evm = { git = "https://github.com/alloy-rs/evm", rev = "3a57c0d" } -alloy-op-evm = { git = "https://github.com/alloy-rs/evm", rev = "3a57c0d" } +alloy-evm = { git = "https://github.com/alloy-rs/evm", rev = "beb6832" } +alloy-op-evm = { git = "https://github.com/alloy-rs/evm", rev = "beb6832" } revm = { git = "https://github.com/bluealloy/revm", rev = "a8a9893b" } revm-bytecode = { git = "https://github.com/bluealloy/revm", rev = "a8a9893b" } diff --git a/book/sources/Cargo.toml b/book/sources/Cargo.toml index 9b09846aa..ba9bd2400 100644 --- a/book/sources/Cargo.toml +++ b/book/sources/Cargo.toml @@ -13,8 +13,8 @@ reth-tracing = { path = "../../crates/tracing" } reth-node-api = { path = "../../crates/node/api" } [patch.crates-io] -alloy-evm = { git = "https://github.com/alloy-rs/evm", rev = "3a57c0d" } -alloy-op-evm = { git = "https://github.com/alloy-rs/evm", rev = "3a57c0d" } +alloy-evm = { git = "https://github.com/alloy-rs/evm", rev = "beb6832" } +alloy-op-evm = { git = "https://github.com/alloy-rs/evm", rev = "beb6832" } revm = { git = "https://github.com/bluealloy/revm", rev = "a8b9b1e" } revm-bytecode = { git = "https://github.com/bluealloy/revm", rev = "a8b9b1e" } diff --git a/crates/ethereum/evm/src/execute.rs b/crates/ethereum/evm/src/execute.rs index ccac63899..7482c31a8 100644 --- a/crates/ethereum/evm/src/execute.rs +++ b/crates/ethereum/evm/src/execute.rs @@ -7,6 +7,7 @@ use crate::{ use alloc::{boxed::Box, sync::Arc, vec::Vec}; use alloy_consensus::{Header, Transaction}; use alloy_eips::{eip4895::Withdrawals, eip6110, eip7685::Requests}; +use alloy_evm::FromRecoveredTx; use alloy_primitives::{Address, B256}; use reth_chainspec::{ChainSpec, EthereumHardfork, EthereumHardforks, MAINNET}; use reth_evm::{ @@ -16,7 +17,7 @@ use reth_evm::{ }, state_change::post_block_balance_increments, system_calls::{OnStateHook, StateChangePostBlockSource, StateChangeSource, SystemCaller}, - ConfigureEvm, ConfigureEvmEnv, Database, Evm, + ConfigureEvm, Database, Evm, }; use reth_execution_types::BlockExecutionResult; use reth_primitives::{ @@ -76,7 +77,7 @@ where DB: Database, { let evm = self.evm_config.evm_for_block(db, block.header()); - EthExecutionStrategy::new(evm, block.sealed_block(), &self.chain_spec, &self.evm_config) + EthExecutionStrategy::new(evm, block.sealed_block(), &self.chain_spec) } } @@ -118,11 +119,9 @@ impl<'a> From<&'a SealedBlock> for EthBlockExecutionInput<'a> { /// Block execution strategy for Ethereum. #[derive(Debug)] -pub struct EthExecutionStrategy<'a, Evm, EvmConfig> { +pub struct EthExecutionStrategy<'a, Evm> { /// Reference to the [`ChainSpec`]. chain_spec: &'a ChainSpec, - /// How to configure the EVM. - evm_config: EvmConfig, /// Input for block execution. input: EthBlockExecutionInput<'a>, @@ -137,18 +136,16 @@ pub struct EthExecutionStrategy<'a, Evm, EvmConfig> { gas_used: u64, } -impl<'a, Evm, EvmConfig> EthExecutionStrategy<'a, Evm, EvmConfig> { +impl<'a, Evm> EthExecutionStrategy<'a, Evm> { /// Creates a new [`EthExecutionStrategy`] pub fn new( evm: Evm, input: impl Into>, chain_spec: &'a ChainSpec, - evm_config: EvmConfig, ) -> Self { Self { evm, chain_spec, - evm_config, input: input.into(), receipts: Vec::new(), gas_used: 0, @@ -157,11 +154,10 @@ impl<'a, Evm, EvmConfig> EthExecutionStrategy<'a, Evm, EvmConfig> { } } -impl<'db, DB, E, EvmConfig> BlockExecutionStrategy for EthExecutionStrategy<'_, E, EvmConfig> +impl<'db, DB, E> BlockExecutionStrategy for EthExecutionStrategy<'_, E> where DB: Database + 'db, - E: Evm, Tx = EvmConfig::TxEnv>, - EvmConfig: ConfigureEvmEnv, + E: Evm, Tx: FromRecoveredTx>, { type Error = BlockExecutionError; type Primitives = EthPrimitives; @@ -194,12 +190,11 @@ where .into()) } - let tx_env = self.evm_config.tx_env(tx.clone()); let hash = tx.hash(); // Execute transaction. let result_and_state = - self.evm.transact(tx_env).map_err(move |err| BlockExecutionError::evm(err, *hash))?; + self.evm.transact(&tx).map_err(move |err| BlockExecutionError::evm(err, *hash))?; self.system_caller .on_state(StateChangeSource::Transaction(self.receipts.len()), &result_and_state.state); let ResultAndState { result, state } = result_and_state; diff --git a/crates/ethereum/evm/src/lib.rs b/crates/ethereum/evm/src/lib.rs index 3b7c3244d..2a5b2055a 100644 --- a/crates/ethereum/evm/src/lib.rs +++ b/crates/ethereum/evm/src/lib.rs @@ -17,8 +17,8 @@ extern crate alloc; -use alloc::{borrow::Borrow, sync::Arc}; -use alloy_consensus::{transaction::Recovered, BlockHeader, Header}; +use alloc::sync::Arc; +use alloy_consensus::{BlockHeader, Header}; pub use alloy_evm::EthEvm; use alloy_evm::EthEvmFactory; use alloy_primitives::U256; @@ -26,7 +26,6 @@ use core::{convert::Infallible, fmt::Debug}; use reth_chainspec::{ChainSpec, EthChainSpec, MAINNET}; use reth_evm::{ConfigureEvm, ConfigureEvmEnv, EvmEnv, NextBlockEnvAttributes}; use reth_primitives::TransactionSigned; -use reth_primitives_traits::transaction::execute::FillTxEnv; use reth_revm::{ context::{BlockEnv, CfgEnv, TxEnv}, context_interface::block::BlobExcessGasAndPrice, @@ -77,17 +76,6 @@ impl ConfigureEvmEnv for EthEvmConfig { type TxEnv = TxEnv; type Spec = SpecId; - fn tx_env>( - &self, - transaction: impl Borrow>, - ) -> Self::TxEnv { - let transaction = transaction.borrow(); - - let mut tx_env = TxEnv::default(); - transaction.tx().borrow().fill_tx_env(&mut tx_env, transaction.signer()); - tx_env - } - fn evm_env(&self, header: &Self::Header) -> EvmEnv { let spec = config::revm_spec(self.chain_spec(), header); diff --git a/crates/ethereum/payload/src/lib.rs b/crates/ethereum/payload/src/lib.rs index b93fd8d47..cf66d203b 100644 --- a/crates/ethereum/payload/src/lib.rs +++ b/crates/ethereum/payload/src/lib.rs @@ -190,7 +190,6 @@ where withdrawals: Some(&attributes.withdrawals), }, &chain_spec, - &evm_config, ); strategy.apply_pre_execution_changes().map_err(|err| { diff --git a/crates/ethereum/primitives/Cargo.toml b/crates/ethereum/primitives/Cargo.toml index 66d94679e..333944a02 100644 --- a/crates/ethereum/primitives/Cargo.toml +++ b/crates/ethereum/primitives/Cargo.toml @@ -18,6 +18,7 @@ reth-primitives-traits.workspace = true reth-zstd-compressors = { workspace = true, optional = true } # ethereum +alloy-evm.workspace = true alloy-eips = { workspace = true, features = ["k256"] } alloy-primitives.workspace = true alloy-network = { workspace = true, optional = true } @@ -68,6 +69,7 @@ std = [ "alloy-serde?/std", "alloy-rpc-types-eth?/std", "revm-context/std", + "alloy-evm/std", ] reth-codec = [ "std", diff --git a/crates/ethereum/primitives/src/transaction.rs b/crates/ethereum/primitives/src/transaction.rs index f21af0d14..e2c5f7a21 100644 --- a/crates/ethereum/primitives/src/transaction.rs +++ b/crates/ethereum/primitives/src/transaction.rs @@ -10,6 +10,7 @@ use alloy_eips::{ eip2930::AccessList, eip7702::SignedAuthorization, }; +use alloy_evm::FromRecoveredTx; use alloy_primitives::{ keccak256, Address, Bytes, ChainId, PrimitiveSignature as Signature, TxHash, TxKind, B256, U256, }; @@ -19,7 +20,7 @@ use reth_primitives_traits::{ crypto::secp256k1::{recover_signer, recover_signer_unchecked}, sync::OnceLock, transaction::{error::TransactionConversionError, signed::RecoveryError}, - FillTxEnv, InMemorySize, SignedTransaction, + InMemorySize, SignedTransaction, }; use revm_context::TxEnv; use serde::{Deserialize, Serialize}; @@ -750,10 +751,10 @@ impl reth_codecs::Compact for TransactionSigned { } } -impl FillTxEnv for TransactionSigned { - fn fill_tx_env(&self, tx_env: &mut TxEnv, sender: Address) { - *tx_env = match self.as_ref() { - Transaction::Legacy(tx) => TxEnv { +impl FromRecoveredTx for TxEnv { + fn from_recovered_tx(tx: &TransactionSigned, sender: Address) -> Self { + match tx.as_ref() { + Transaction::Legacy(tx) => Self { gas_limit: tx.gas_limit, gas_price: tx.gas_price, gas_priority_fee: None, @@ -769,7 +770,7 @@ impl FillTxEnv for TransactionSigned { tx_type: 0, caller: sender, }, - Transaction::Eip2930(tx) => TxEnv { + Transaction::Eip2930(tx) => Self { gas_limit: tx.gas_limit, gas_price: tx.gas_price, gas_priority_fee: None, @@ -785,7 +786,7 @@ impl FillTxEnv for TransactionSigned { tx_type: 1, caller: sender, }, - Transaction::Eip1559(tx) => TxEnv { + Transaction::Eip1559(tx) => Self { gas_limit: tx.gas_limit, gas_price: tx.max_fee_per_gas, gas_priority_fee: Some(tx.max_priority_fee_per_gas), @@ -801,7 +802,7 @@ impl FillTxEnv for TransactionSigned { tx_type: 2, caller: sender, }, - Transaction::Eip4844(tx) => TxEnv { + Transaction::Eip4844(tx) => Self { gas_limit: tx.gas_limit, gas_price: tx.max_fee_per_gas, gas_priority_fee: Some(tx.max_priority_fee_per_gas), @@ -817,7 +818,7 @@ impl FillTxEnv for TransactionSigned { tx_type: 3, caller: sender, }, - Transaction::Eip7702(tx) => TxEnv { + Transaction::Eip7702(tx) => Self { gas_limit: tx.gas_limit, gas_price: tx.max_fee_per_gas, gas_priority_fee: Some(tx.max_priority_fee_per_gas), diff --git a/crates/evm/src/lib.rs b/crates/evm/src/lib.rs index 1f3331c6d..fed1a09fc 100644 --- a/crates/evm/src/lib.rs +++ b/crates/evm/src/lib.rs @@ -17,10 +17,9 @@ extern crate alloc; -use alloc::borrow::Borrow; -use alloy_consensus::transaction::Recovered; use alloy_eips::eip2930::AccessList; pub use alloy_evm::evm::EvmFactory; +use alloy_evm::{FromRecoveredTx, IntoTxEnv}; use alloy_primitives::{Address, B256}; use core::fmt::Debug; use reth_primitives_traits::{BlockHeader, SignedTransaction}; @@ -155,7 +154,7 @@ pub trait ConfigureEvmEnv: Send + Sync + Unpin + Clone { type Transaction: SignedTransaction; /// Transaction environment used by EVM. - type TxEnv: TransactionEnv; + type TxEnv: TransactionEnv + FromRecoveredTx + IntoTxEnv; /// The error type that is returned by [`Self::next_evm_env`]. type Error: core::error::Error + Send + Sync + 'static; @@ -164,10 +163,9 @@ pub trait ConfigureEvmEnv: Send + Sync + Unpin + Clone { type Spec: Debug + Copy + Send + Sync + 'static; /// Returns a [`TxEnv`] from a transaction and [`Address`]. - fn tx_env>( - &self, - transaction: impl Borrow>, - ) -> Self::TxEnv; + fn tx_env(&self, transaction: impl IntoTxEnv) -> Self::TxEnv { + transaction.into_tx_env() + } /// Creates a new [`EvmEnv`] for the given header. fn evm_env(&self, header: &Self::Header) -> EvmEnv; diff --git a/crates/optimism/evm/src/execute.rs b/crates/optimism/evm/src/execute.rs index fb6aa7945..11c0a475c 100644 --- a/crates/optimism/evm/src/execute.rs +++ b/crates/optimism/evm/src/execute.rs @@ -8,6 +8,7 @@ use alloc::{boxed::Box, sync::Arc, vec::Vec}; use alloy_consensus::{ transaction::Recovered, BlockHeader, Eip658Value, Header, Receipt, Transaction as _, TxReceipt, }; +use alloy_evm::FromRecoveredTx; use op_alloy_consensus::OpDepositReceipt; use reth_evm::{ execute::{ @@ -96,7 +97,6 @@ where evm, block.sealed_block(), &self.chain_spec, - &self.evm_config, self.receipt_builder.as_ref(), ) } @@ -134,19 +134,16 @@ impl<'a, B: Block> From<&'a SealedBlock> for OpBlockExecutionInput { /// Block execution strategy for Optimism. #[derive(Debug)] -pub struct OpExecutionStrategy<'a, Evm, N: NodePrimitives, ChainSpec, EvmConfig: ConfigureEvm> { +pub struct OpExecutionStrategy<'a, E: Evm, N: NodePrimitives, ChainSpec> { /// Chainspec. chain_spec: ChainSpec, - /// How to configure the EVM. - evm_config: EvmConfig, /// Receipt builder. - receipt_builder: - &'a dyn OpReceiptBuilder, Receipt = N::Receipt>, + receipt_builder: &'a dyn OpReceiptBuilder, /// Input for block execution. input: OpBlockExecutionInput, /// The EVM used by strategy. - evm: Evm, + evm: E, /// Receipts of executed transactions. receipts: Vec, /// Total gas used by executed transactions. @@ -157,23 +154,18 @@ pub struct OpExecutionStrategy<'a, Evm, N: NodePrimitives, ChainSpec, EvmConfig: system_caller: SystemCaller, } -impl<'a, Evm, N, ChainSpec, EvmConfig> OpExecutionStrategy<'a, Evm, N, ChainSpec, EvmConfig> +impl<'a, E, N, ChainSpec> OpExecutionStrategy<'a, E, N, ChainSpec> where + E: Evm, N: NodePrimitives, ChainSpec: OpHardforks, - EvmConfig: ConfigureEvm, { /// Creates a new [`OpExecutionStrategy`] pub fn new( - evm: Evm, + evm: E, input: impl Into, chain_spec: ChainSpec, - evm_config: EvmConfig, - receipt_builder: &'a dyn OpReceiptBuilder< - N::SignedTx, - HaltReasonFor, - Receipt = N::Receipt, - >, + receipt_builder: &'a dyn OpReceiptBuilder, ) -> Self { let input = input.into(); Self { @@ -181,7 +173,6 @@ where evm, system_caller: SystemCaller::new(chain_spec.clone()), chain_spec, - evm_config, receipt_builder, receipts: Vec::new(), gas_used: 0, @@ -190,14 +181,12 @@ where } } -impl<'db, DB, E, N, ChainSpec, EvmConfig> BlockExecutionStrategy - for OpExecutionStrategy<'_, E, N, ChainSpec, EvmConfig> +impl<'db, DB, E, N, ChainSpec> BlockExecutionStrategy for OpExecutionStrategy<'_, E, N, ChainSpec> where DB: Database + 'db, - E: Evm, Tx = EvmConfig::TxEnv, HaltReason = HaltReasonFor>, + E: Evm, Tx: FromRecoveredTx>, N: NodePrimitives, ChainSpec: OpHardforks, - EvmConfig: ConfigureEvmFor, { type Primitives = N; type Error = BlockExecutionError; @@ -248,12 +237,11 @@ where .transpose() .map_err(|_| OpBlockExecutionError::AccountLoadFailed(tx.signer()))?; - let tx_env = self.evm_config.tx_env(&tx); let hash = tx.tx_hash(); // Execute transaction. let result_and_state = - self.evm.transact(tx_env).map_err(move |err| BlockExecutionError::evm(err, *hash))?; + self.evm.transact(&tx).map_err(move |err| BlockExecutionError::evm(err, *hash))?; trace!( target: "evm", diff --git a/crates/optimism/evm/src/lib.rs b/crates/optimism/evm/src/lib.rs index 1b5730bf6..eeb7668a1 100644 --- a/crates/optimism/evm/src/lib.rs +++ b/crates/optimism/evm/src/lib.rs @@ -11,10 +11,10 @@ extern crate alloc; use alloc::sync::Arc; -use alloy_consensus::{transaction::Recovered, BlockHeader, Header}; +use alloy_consensus::{BlockHeader, Header}; use alloy_op_evm::OpEvmFactory; use alloy_primitives::U256; -use core::{borrow::Borrow, fmt::Debug}; +use core::fmt::Debug; use op_alloy_consensus::EIP1559ParamError; use reth_chainspec::EthChainSpec; use reth_evm::{ConfigureEvm, ConfigureEvmEnv, EvmEnv, NextBlockEnvAttributes}; @@ -22,7 +22,6 @@ use reth_optimism_chainspec::OpChainSpec; use reth_optimism_consensus::next_block_base_fee; use reth_optimism_forks::OpHardforks; use reth_optimism_primitives::OpTransactionSigned; -use reth_primitives_traits::FillTxEnv; use revm::{ context::{BlockEnv, CfgEnv, TxEnv}, context_interface::block::BlobExcessGasAndPrice, @@ -74,17 +73,6 @@ impl ConfigureEvmEnv for OpEvmC type TxEnv = OpTransaction; type Spec = OpSpecId; - fn tx_env>( - &self, - transaction: impl Borrow>, - ) -> Self::TxEnv { - let transaction = transaction.borrow(); - - let mut tx_env = Default::default(); - transaction.tx().borrow().fill_tx_env(&mut tx_env, transaction.signer()); - tx_env - } - fn evm_env(&self, header: &Self::Header) -> EvmEnv { let spec = config::revm_spec(self.chain_spec(), header); diff --git a/crates/optimism/payload/src/builder.rs b/crates/optimism/payload/src/builder.rs index f66e9a4b7..333fc45ec 100644 --- a/crates/optimism/payload/src/builder.rs +++ b/crates/optimism/payload/src/builder.rs @@ -369,7 +369,6 @@ impl OpBuilder<'_, Txs> { beneficiary: ctx.evm_env.block_env.beneficiary, }, &ctx.chain_spec, - &ctx.evm_config, ctx.receipt_builder.as_ref(), ); diff --git a/crates/optimism/primitives/Cargo.toml b/crates/optimism/primitives/Cargo.toml index 04b2b60d4..03ddae948 100644 --- a/crates/optimism/primitives/Cargo.toml +++ b/crates/optimism/primitives/Cargo.toml @@ -18,6 +18,7 @@ reth-codecs = { workspace = true, optional = true, features = ["op"] } reth-zstd-compressors = { workspace = true, optional = true } # ethereum +alloy-evm.workspace = true alloy-primitives.workspace = true alloy-consensus.workspace = true alloy-rlp.workspace = true @@ -75,6 +76,7 @@ std = [ "alloy-serde?/std", "revm-context/std", "serde_json/std", + "alloy-evm/std", ] alloy-compat = ["dep:alloy-network", "dep:alloy-serde", "dep:alloy-rpc-types-eth", "op-alloy-consensus/alloy-compat"] reth-codec = [ diff --git a/crates/optimism/primitives/src/transaction/signed.rs b/crates/optimism/primitives/src/transaction/signed.rs index 859c962e5..4191a0086 100644 --- a/crates/optimism/primitives/src/transaction/signed.rs +++ b/crates/optimism/primitives/src/transaction/signed.rs @@ -10,6 +10,7 @@ use alloy_eips::{ eip2930::AccessList, eip7702::SignedAuthorization, }; +use alloy_evm::FromRecoveredTx; use alloy_primitives::{ keccak256, Address, Bytes, PrimitiveSignature as Signature, TxHash, TxKind, Uint, B256, }; @@ -29,7 +30,7 @@ use reth_primitives_traits::{ crypto::secp256k1::{recover_signer, recover_signer_unchecked}, sync::OnceLock, transaction::{error::TransactionConversionError, signed::RecoveryError}, - FillTxEnv, InMemorySize, SignedTransaction, + InMemorySize, SignedTransaction, }; use revm_context::TxEnv; use revm_optimism::transaction::deposit::DepositTransactionParts; @@ -213,11 +214,11 @@ impl OpTransaction for OpTransactionSigned { } } -impl FillTxEnv> for OpTransactionSigned { - fn fill_tx_env(&self, tx_env: &mut revm_optimism::OpTransaction, sender: Address) { - let envelope = self.encoded_2718(); +impl FromRecoveredTx for revm_optimism::OpTransaction { + fn from_recovered_tx(tx: &OpTransactionSigned, sender: Address) -> Self { + let envelope = tx.encoded_2718(); - let base = match &self.transaction { + let base = match &tx.transaction { OpTypedTransaction::Legacy(tx) => TxEnv { gas_limit: tx.gas_limit, gas_price: tx.gas_price, @@ -300,10 +301,10 @@ impl FillTxEnv> for OpTransactionSigned { }, }; - *tx_env = revm_optimism::OpTransaction { + Self { base, enveloped_tx: Some(envelope.into()), - deposit: if let OpTypedTransaction::Deposit(tx) = &self.transaction { + deposit: if let OpTypedTransaction::Deposit(tx) = &tx.transaction { DepositTransactionParts { is_system_transaction: tx.is_system_transaction, source_hash: tx.source_hash, @@ -312,7 +313,7 @@ impl FillTxEnv> for OpTransactionSigned { } else { Default::default() }, - }; + } } } diff --git a/examples/custom-evm/src/main.rs b/examples/custom-evm/src/main.rs index 02f93baa4..e21db6683 100644 --- a/examples/custom-evm/src/main.rs +++ b/examples/custom-evm/src/main.rs @@ -41,10 +41,9 @@ use reth_node_ethereum::{ node::{EthereumAddOns, EthereumPayloadBuilder}, BasicBlockExecutorProvider, EthExecutionStrategyFactory, EthereumNode, }; -use reth_primitives::{EthPrimitives, Recovered, TransactionSigned}; +use reth_primitives::{EthPrimitives, TransactionSigned}; use reth_tracing::{RethTracer, Tracer}; use std::{ - borrow::Borrow, convert::Infallible, sync::{Arc, OnceLock}, }; @@ -106,13 +105,6 @@ impl ConfigureEvmEnv for MyEvmConfig { type TxEnv = TxEnv; type Spec = SpecId; - fn tx_env>( - &self, - transaction: impl Borrow>, - ) -> Self::TxEnv { - self.inner.tx_env(transaction) - } - fn evm_env(&self, header: &Self::Header) -> EvmEnv { self.inner.evm_env(header) } diff --git a/examples/stateful-precompile/src/main.rs b/examples/stateful-precompile/src/main.rs index 77b34c3f0..9edc3e528 100644 --- a/examples/stateful-precompile/src/main.rs +++ b/examples/stateful-precompile/src/main.rs @@ -33,10 +33,10 @@ use reth_node_ethereum::{ evm::EthEvm, node::EthereumAddOns, BasicBlockExecutorProvider, EthEvmConfig, EthExecutionStrategyFactory, EthereumNode, }; -use reth_primitives::{EthPrimitives, Recovered, TransactionSigned}; +use reth_primitives::{EthPrimitives, TransactionSigned}; use reth_tracing::{RethTracer, Tracer}; use schnellru::{ByLength, LruMap}; -use std::{borrow::Borrow, collections::HashMap, convert::Infallible, sync::Arc}; +use std::{collections::HashMap, convert::Infallible, sync::Arc}; /// Type alias for the LRU cache used within the [`PrecompileCache`]. type PrecompileLRUCache = LruMap<(SpecId, Bytes, u64), Result>; @@ -186,13 +186,6 @@ impl ConfigureEvmEnv for MyEvmConfig { type TxEnv = TxEnv; type Spec = SpecId; - fn tx_env>( - &self, - transaction: impl Borrow>, - ) -> Self::TxEnv { - self.inner.tx_env(transaction) - } - fn evm_env(&self, header: &Self::Header) -> EvmEnv { self.inner.evm_env(header) }