diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 84e236f92f8b..e42300d6a59c 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -1,9 +1,6 @@ //! Transaction related types -use crate::eth::{ - transaction::optimism::{DepositTransaction, DepositTransactionRequest}, - utils::eip_to_revm_access_list, -}; +use crate::eth::transaction::optimism::{DepositTransaction, DepositTransactionRequest}; use alloy_consensus::{ AnyReceiptEnvelope, BlobTransactionSidecar, Receipt, ReceiptEnvelope, ReceiptWithBloom, Signed, TxEip1559, TxEip2930, TxEip4844, TxEip4844Variant, TxEip4844WithSidecar, TxEnvelope, TxLegacy, @@ -25,8 +22,6 @@ use revm::{ use serde::{Deserialize, Serialize}; use std::ops::Deref; -use super::utils::from_eip_to_alloy_access_list; - pub mod optimism; /// The signature used to bypass signing via the `eth_sendUnsignedTransaction` cheat RPC @@ -393,7 +388,7 @@ pub fn to_alloy_transaction_with_hash_and_sender( v: U256::from(t.signature().v().y_parity_byte()), y_parity: Some(alloy_rpc_types::Parity::from(t.signature().v().y_parity())), }), - access_list: Some(from_eip_to_alloy_access_list(t.tx().tx().access_list.clone())), + access_list: Some(t.tx().tx().access_list.clone()), transaction_type: Some(3), max_fee_per_blob_gas: Some(t.tx().tx().max_fee_per_blob_gas), blob_versioned_hashes: Some(t.tx().tx().blob_versioned_hashes.clone()), @@ -482,7 +477,7 @@ impl PendingTransaction { TxEnv { caller, transact_to: transact_to(to), - data: alloy_primitives::Bytes(input.0.clone()), + data: input.clone(), chain_id, nonce: Some(*nonce), value: (*value), @@ -508,14 +503,14 @@ impl PendingTransaction { TxEnv { caller, transact_to: transact_to(to), - data: alloy_primitives::Bytes(input.0.clone()), + data: input.clone(), chain_id: Some(*chain_id), nonce: Some(*nonce), value: *value, gas_price: U256::from(*gas_price), gas_priority_fee: None, gas_limit: *gas_limit as u64, - access_list: eip_to_revm_access_list(access_list.0.clone()), + access_list: access_list.flattened(), ..Default::default() } } @@ -535,14 +530,14 @@ impl PendingTransaction { TxEnv { caller, transact_to: transact_to(to), - data: alloy_primitives::Bytes(input.0.clone()), + data: input.clone(), chain_id: Some(*chain_id), nonce: Some(*nonce), value: *value, gas_price: U256::from(*max_fee_per_gas), gas_priority_fee: Some(U256::from(*max_priority_fee_per_gas)), gas_limit: *gas_limit as u64, - access_list: eip_to_revm_access_list(access_list.0.clone()), + access_list: access_list.flattened(), ..Default::default() } } @@ -564,7 +559,7 @@ impl PendingTransaction { TxEnv { caller, transact_to: TransactTo::call(*to), - data: alloy_primitives::Bytes(input.0.clone()), + data: input.clone(), chain_id: Some(*chain_id), nonce: Some(*nonce), value: *value, @@ -573,7 +568,7 @@ impl PendingTransaction { max_fee_per_blob_gas: Some(U256::from(*max_fee_per_blob_gas)), blob_hashes: blob_versioned_hashes.clone(), gas_limit: *gas_limit as u64, - access_list: eip_to_revm_access_list(access_list.0.clone()), + access_list: access_list.flattened(), ..Default::default() } } @@ -593,7 +588,7 @@ impl PendingTransaction { TxEnv { caller, transact_to: transact_to(kind), - data: alloy_primitives::Bytes(input.0.clone()), + data: input.clone(), chain_id, nonce: Some(*nonce), value: *value, diff --git a/crates/anvil/core/src/eth/utils.rs b/crates/anvil/core/src/eth/utils.rs index 27bb46523da4..a60439280123 100644 --- a/crates/anvil/core/src/eth/utils.rs +++ b/crates/anvil/core/src/eth/utils.rs @@ -1,35 +1,4 @@ -use alloy_eips::eip2930::{ - AccessList as AlloyEipAccessList, AccessListItem as AlloyEipAccessListItem, -}; -use alloy_primitives::{Address, Parity, U256}; -use alloy_rpc_types::{AccessList as AlloyAccessList, AccessListItem as AlloyAccessListItem}; - -pub fn alloy_to_revm_access_list(list: Vec) -> Vec<(Address, Vec)> { - list.into_iter() - .map(|item| (item.address, item.storage_keys.into_iter().map(|k| k.into()).collect())) - .collect() -} - -/// Translates a vec of [AlloyEipAccessListItem] to a [AlloyAccessList], translating from internal -/// type to rpc type. -pub fn from_eip_to_alloy_access_list(list: AlloyEipAccessList) -> AlloyAccessList { - AlloyAccessList( - list.0 - .into_iter() - .map(|item| AlloyAccessListItem { - address: item.address, - storage_keys: item.storage_keys.into_iter().collect(), - }) - .collect(), - ) -} - -/// Translates a vec of [AlloyEipAccessListItem] to a revm style Access List. -pub fn eip_to_revm_access_list(list: Vec) -> Vec<(Address, Vec)> { - list.into_iter() - .map(|item| (item.address, item.storage_keys.into_iter().map(|k| k.into()).collect())) - .collect() -} +use alloy_primitives::Parity; /// See /// > If you do, then the v of the signature MUST be set to {0,1} + CHAIN_ID * 2 + 35 where diff --git a/crates/anvil/src/eth/backend/mem/mod.rs b/crates/anvil/src/eth/backend/mem/mod.rs index 939913b842a8..792ca250e1e9 100644 --- a/crates/anvil/src/eth/backend/mem/mod.rs +++ b/crates/anvil/src/eth/backend/mem/mod.rs @@ -53,7 +53,7 @@ use anvil_core::{ DepositReceipt, MaybeImpersonatedTransaction, PendingTransaction, ReceiptResponse, TransactionInfo, TypedReceipt, TypedTransaction, }, - utils::{alloy_to_revm_access_list, meets_eip155}, + utils::meets_eip155, }, types::{Forking, Index}, }; @@ -1097,7 +1097,7 @@ impl Backend { data: input.into_input().unwrap_or_default(), chain_id: None, nonce, - access_list: alloy_to_revm_access_list(access_list.unwrap_or_default().0), + access_list: access_list.unwrap_or_default().flattened(), ..Default::default() };