Skip to content

Commit c0fe76c

Browse files
authored
chore(evm): use AnyRpcTransaction in configure_tx_env/commit_transaction (#13572)
1 parent 73f9986 commit c0fe76c

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

crates/cast/src/cmd/run.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ impl RunArgs {
259259
break;
260260
}
261261

262-
configure_tx_env(&mut env.as_env_mut(), &tx.inner);
262+
configure_tx_env(&mut env.as_env_mut(), tx);
263263

264264
env.evm_env.cfg_env.disable_balance_check = true;
265265

@@ -300,7 +300,7 @@ impl RunArgs {
300300
let result = {
301301
executor.set_trace_printer(self.trace_printer);
302302

303-
configure_tx_env(&mut env.as_env_mut(), &tx.inner);
303+
configure_tx_env(&mut env.as_env_mut(), &tx);
304304
if is_impersonated_tx(tx.inner.inner.inner()) {
305305
env.evm_env.cfg_env.disable_balance_check = true;
306306
}

crates/evm/core/src/backend/mod.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ use crate::{
1111
use alloy_consensus::Typed2718;
1212
use alloy_evm::Evm;
1313
use alloy_genesis::GenesisAccount;
14-
use alloy_network::{AnyNetwork, AnyRpcBlock, AnyTxEnvelope, TransactionResponse};
14+
use alloy_network::{
15+
AnyNetwork, AnyRpcBlock, AnyRpcTransaction, AnyTxEnvelope, TransactionResponse,
16+
};
1517
use alloy_primitives::{Address, B256, TxKind, U256, keccak256, uint};
1618
use alloy_rpc_types::{BlockNumberOrTag, Transaction, TransactionRequest};
1719
use eyre::Context;
@@ -902,7 +904,7 @@ impl Backend {
902904
trace!(tx=?tx.tx_hash(), "committing transaction");
903905

904906
commit_transaction(
905-
&tx.inner,
907+
tx,
906908
&mut env.as_env_mut(),
907909
journaled_state,
908910
fork,
@@ -1296,7 +1298,7 @@ impl DatabaseExt for Backend {
12961298

12971299
let fork = self.inner.get_fork_by_id_mut(id)?;
12981300
commit_transaction(
1299-
&tx.inner,
1301+
&tx,
13001302
&mut env.as_env_mut(),
13011303
journaled_state,
13021304
fork,
@@ -1965,7 +1967,7 @@ fn update_env_block(env: &mut EnvMut<'_>, block: &AnyRpcBlock) {
19651967
/// Executes the given transaction and commits state changes to the database _and_ the journaled
19661968
/// state, with an inspector.
19671969
fn commit_transaction(
1968-
tx: &Transaction<AnyTxEnvelope>,
1970+
tx: &AnyRpcTransaction,
19691971
env: &mut EnvMut<'_>,
19701972
journaled_state: &mut JournaledState,
19711973
fork: &mut Fork,

crates/evm/core/src/utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ use alloy_chains::Chain;
33
use alloy_consensus::{BlockHeader, private::alloy_eips::eip7840::BlobParams};
44
use alloy_hardforks::EthereumHardfork;
55
use alloy_json_abi::{Function, JsonAbi};
6-
use alloy_network::{AnyTxEnvelope, TransactionResponse};
6+
use alloy_network::{AnyRpcTransaction, TransactionResponse};
77
use alloy_primitives::{Address, B256, ChainId, Selector, TxKind, U256};
88
use alloy_provider::{Network, network::BlockResponse};
9-
use alloy_rpc_types::{Transaction, TransactionRequest};
9+
use alloy_rpc_types::TransactionRequest;
1010
use foundry_config::NamedChain;
1111
use foundry_evm_networks::NetworkConfigs;
1212
use revm::primitives::{
@@ -138,9 +138,9 @@ pub fn get_function<'a>(
138138

139139
/// Configures the env for the given RPC transaction.
140140
/// Accounts for an impersonated transaction by resetting the `env.tx.caller` field to `tx.from`.
141-
pub fn configure_tx_env(env: &mut EnvMut<'_>, tx: &Transaction<AnyTxEnvelope>) {
141+
pub fn configure_tx_env(env: &mut EnvMut<'_>, tx: &AnyRpcTransaction) {
142142
let from = tx.from();
143-
if let AnyTxEnvelope::Ethereum(tx) = &tx.inner.inner() {
143+
if let Some(tx) = tx.as_envelope() {
144144
configure_tx_req_env(
145145
env,
146146
&TransactionRequest::from_transaction_with_sender(tx.clone(), from),

crates/verify/src/bytecode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ impl VerifyBytecodeArgs {
490490
break;
491491
}
492492

493-
configure_tx_env(&mut env.as_env_mut(), &tx.inner);
493+
configure_tx_env(&mut env.as_env_mut(), tx);
494494

495495
if let TxKind::Call(_) = tx.inner.kind() {
496496
executor.transact_with_env(env.clone()).wrap_err_with(|| {

0 commit comments

Comments
 (0)