mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 02:49:55 +00:00
feat: integrate TxEnv conversions (#14630)
This commit is contained in:
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -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",
|
||||
|
||||
@ -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" }
|
||||
|
||||
@ -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" }
|
||||
|
||||
@ -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<EthBlockExecutionInput<'a>>,
|
||||
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<DB = &'db mut State<DB>, Tx = EvmConfig::TxEnv>,
|
||||
EvmConfig: ConfigureEvmEnv<Transaction = TransactionSigned>,
|
||||
E: Evm<DB = &'db mut State<DB>, Tx: FromRecoveredTx<TransactionSigned>>,
|
||||
{
|
||||
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;
|
||||
|
||||
@ -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<T: Borrow<Self::Transaction>>(
|
||||
&self,
|
||||
transaction: impl Borrow<Recovered<T>>,
|
||||
) -> 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);
|
||||
|
||||
|
||||
@ -190,7 +190,6 @@ where
|
||||
withdrawals: Some(&attributes.withdrawals),
|
||||
},
|
||||
&chain_spec,
|
||||
&evm_config,
|
||||
);
|
||||
|
||||
strategy.apply_pre_execution_changes().map_err(|err| {
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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<TxEnv> 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<TransactionSigned> 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<TxEnv> 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<TxEnv> 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<TxEnv> 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<TxEnv> 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),
|
||||
|
||||
@ -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<Self::Transaction> + IntoTxEnv<Self::TxEnv>;
|
||||
|
||||
/// 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<T: Borrow<Self::Transaction>>(
|
||||
&self,
|
||||
transaction: impl Borrow<Recovered<T>>,
|
||||
) -> Self::TxEnv;
|
||||
fn tx_env(&self, transaction: impl IntoTxEnv<Self::TxEnv>) -> Self::TxEnv {
|
||||
transaction.into_tx_env()
|
||||
}
|
||||
|
||||
/// Creates a new [`EvmEnv`] for the given header.
|
||||
fn evm_env(&self, header: &Self::Header) -> EvmEnv<Self::Spec>;
|
||||
|
||||
@ -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<B>> 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<N::SignedTx, HaltReasonFor<EvmConfig>, Receipt = N::Receipt>,
|
||||
receipt_builder: &'a dyn OpReceiptBuilder<N::SignedTx, E::HaltReason, Receipt = N::Receipt>,
|
||||
|
||||
/// Input for block execution.
|
||||
input: OpBlockExecutionInput,
|
||||
/// The EVM used by strategy.
|
||||
evm: Evm,
|
||||
evm: E,
|
||||
/// Receipts of executed transactions.
|
||||
receipts: Vec<N::Receipt>,
|
||||
/// Total gas used by executed transactions.
|
||||
@ -157,23 +154,18 @@ pub struct OpExecutionStrategy<'a, Evm, N: NodePrimitives, ChainSpec, EvmConfig:
|
||||
system_caller: SystemCaller<ChainSpec>,
|
||||
}
|
||||
|
||||
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<OpBlockExecutionInput>,
|
||||
chain_spec: ChainSpec,
|
||||
evm_config: EvmConfig,
|
||||
receipt_builder: &'a dyn OpReceiptBuilder<
|
||||
N::SignedTx,
|
||||
HaltReasonFor<EvmConfig>,
|
||||
Receipt = N::Receipt,
|
||||
>,
|
||||
receipt_builder: &'a dyn OpReceiptBuilder<N::SignedTx, E::HaltReason, Receipt = N::Receipt>,
|
||||
) -> 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<DB = &'db mut State<DB>, Tx = EvmConfig::TxEnv, HaltReason = HaltReasonFor<EvmConfig>>,
|
||||
E: Evm<DB = &'db mut State<DB>, Tx: FromRecoveredTx<N::SignedTx>>,
|
||||
N: NodePrimitives<SignedTx: OpTransaction, Receipt: DepositReceipt>,
|
||||
ChainSpec: OpHardforks,
|
||||
EvmConfig: ConfigureEvmFor<N>,
|
||||
{
|
||||
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",
|
||||
|
||||
@ -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<ChainSpec: EthChainSpec + OpHardforks + 'static> ConfigureEvmEnv for OpEvmC
|
||||
type TxEnv = OpTransaction<TxEnv>;
|
||||
type Spec = OpSpecId;
|
||||
|
||||
fn tx_env<T: Borrow<Self::Transaction>>(
|
||||
&self,
|
||||
transaction: impl Borrow<Recovered<T>>,
|
||||
) -> 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<Self::Spec> {
|
||||
let spec = config::revm_spec(self.chain_spec(), header);
|
||||
|
||||
|
||||
@ -369,7 +369,6 @@ impl<Txs> OpBuilder<'_, Txs> {
|
||||
beneficiary: ctx.evm_env.block_env.beneficiary,
|
||||
},
|
||||
&ctx.chain_spec,
|
||||
&ctx.evm_config,
|
||||
ctx.receipt_builder.as_ref(),
|
||||
);
|
||||
|
||||
|
||||
@ -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 = [
|
||||
|
||||
@ -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<revm_optimism::OpTransaction<TxEnv>> for OpTransactionSigned {
|
||||
fn fill_tx_env(&self, tx_env: &mut revm_optimism::OpTransaction<TxEnv>, sender: Address) {
|
||||
let envelope = self.encoded_2718();
|
||||
impl FromRecoveredTx<OpTransactionSigned> for revm_optimism::OpTransaction<TxEnv> {
|
||||
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<revm_optimism::OpTransaction<TxEnv>> 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<revm_optimism::OpTransaction<TxEnv>> for OpTransactionSigned {
|
||||
} else {
|
||||
Default::default()
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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<T: Borrow<Self::Transaction>>(
|
||||
&self,
|
||||
transaction: impl Borrow<Recovered<T>>,
|
||||
) -> Self::TxEnv {
|
||||
self.inner.tx_env(transaction)
|
||||
}
|
||||
|
||||
fn evm_env(&self, header: &Self::Header) -> EvmEnv {
|
||||
self.inner.evm_env(header)
|
||||
}
|
||||
|
||||
@ -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<InterpreterResult, PrecompileErrors>>;
|
||||
@ -186,13 +186,6 @@ impl ConfigureEvmEnv for MyEvmConfig {
|
||||
type TxEnv = TxEnv;
|
||||
type Spec = SpecId;
|
||||
|
||||
fn tx_env<T: Borrow<Self::Transaction>>(
|
||||
&self,
|
||||
transaction: impl Borrow<Recovered<T>>,
|
||||
) -> Self::TxEnv {
|
||||
self.inner.tx_env(transaction)
|
||||
}
|
||||
|
||||
fn evm_env(&self, header: &Self::Header) -> EvmEnv {
|
||||
self.inner.evm_env(header)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user