diff --git a/crates/common/types/account.rs b/crates/common/types/account.rs index 2bc3e1ef29..e680b06e71 100644 --- a/crates/common/types/account.rs +++ b/crates/common/types/account.rs @@ -27,7 +27,7 @@ pub struct Account { pub storage: BTreeMap, } -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize, Eq)] pub struct AccountInfo { pub code_hash: H256, pub balance: U256, diff --git a/crates/common/types/transaction.rs b/crates/common/types/transaction.rs index a8df1275fb..7f77aaef1a 100644 --- a/crates/common/types/transaction.rs +++ b/crates/common/types/transaction.rs @@ -449,7 +449,7 @@ impl RLPDecode for Transaction { } /// The transaction's kind: call or create. -#[derive(Clone, Debug, PartialEq, Eq, Default, RSerialize, RDeserialize, Archive)] +#[derive(Copy, Clone, Debug, PartialEq, Eq, Default, RSerialize, RDeserialize, Archive)] pub enum TxKind { Call(#[rkyv(with=crate::rkyv_utils::H160Wrapper)] Address), #[default] diff --git a/crates/networking/rpc/eth/transaction.rs b/crates/networking/rpc/eth/transaction.rs index cbc9cbc072..83cde943b1 100644 --- a/crates/networking/rpc/eth/transaction.rs +++ b/crates/networking/rpc/eth/transaction.rs @@ -9,6 +9,7 @@ use crate::{ }, utils::RpcErr, }; +use bytes::Bytes; use ethrex_blockchain::{Blockchain, vm::StoreVmDatabase}; use ethrex_common::{ H256, U256, @@ -113,7 +114,7 @@ impl RpcHandler for CallRequest { context.storage, context.blockchain, )?; - serde_json::to_value(format!("0x{:#x}", result.output())) + serde_json::to_value(format!("0x{:#x}", result.output().unwrap_or(&Bytes::new()))) .map_err(|error| RpcErr::Internal(error.to_string())) } } diff --git a/crates/networking/rpc/rpc.rs b/crates/networking/rpc/rpc.rs index 84e25934f8..049387e32f 100644 --- a/crates/networking/rpc/rpc.rs +++ b/crates/networking/rpc/rpc.rs @@ -217,7 +217,7 @@ pub async fn start_api( let service_context = RpcApiContext { storage, blockchain, - active_filters: active_filters.clone(), + active_filters: active_filters.clone(), // ok-clone: increasing arc reference count syncer: Arc::new(syncer), peer_handler, node_data: NodeData { @@ -235,11 +235,11 @@ pub async fn start_api( // Periodically clean up the active filters for the filters endpoints. tokio::task::spawn(async move { let mut interval = tokio::time::interval(FILTER_DURATION); - let filters = active_filters.clone(); + let filters = active_filters.clone(); // ok-clone: increasing arc reference count loop { interval.tick().await; tracing::debug!("Running filter clean task"); - filter::clean_outdated_filters(filters.clone(), FILTER_DURATION); + filter::clean_outdated_filters(filters.clone(), FILTER_DURATION); // ok-clone: increasing arc reference count tracing::debug!("Filter clean task complete"); } }); diff --git a/crates/vm/backends/levm/mod.rs b/crates/vm/backends/levm/mod.rs index 158878d7f0..5709cc4f99 100644 --- a/crates/vm/backends/levm/mod.rs +++ b/crates/vm/backends/levm/mod.rs @@ -28,6 +28,7 @@ use ethrex_levm::{ vm::VM, }; use std::cmp::min; +use std::sync::Arc; /// The struct implements the following functions: /// [LEVM::execute_block] @@ -56,9 +57,9 @@ impl LEVM { cumulative_gas_used += report.gas_used; let receipt = Receipt::new( tx.tx_type(), - matches!(report.result.clone(), TxResult::Success), + matches!(report.result, TxResult::Success), cumulative_gas_used, - report.logs.clone(), + report.logs, ); receipts.push(receipt); @@ -130,7 +131,7 @@ impl LEVM { db: &mut GeneralizedDatabase, vm_type: VMType, ) -> Result { - let env = Self::setup_env(tx, tx_sender, block_header, db)?; + let env = Arc::new(Self::setup_env(tx, tx_sender, block_header, db)?); let mut vm = VM::new(env, db, tx, LevmCallTracer::disabled(), vm_type)?; vm.execute().map_err(VMError::into) @@ -155,6 +156,8 @@ impl LEVM { adjust_disabled_base_fee(&mut env); + let env = Arc::new(env); + let mut vm = vm_from_generic(tx, env, db, vm_type)?; vm.execute() @@ -303,13 +306,15 @@ impl LEVM { adjust_disabled_base_fee(&mut env); - let mut vm = vm_from_generic(&tx, env.clone(), db, vm_type)?; + let env = Arc::new(env); + + let mut vm = vm_from_generic(&tx, env.clone(), db, vm_type)?; // ok-clone: increasing arc reference count vm.stateless_execute()?; // Execute the tx again, now with the created access list. tx.access_list = vm.substate.make_access_list(); - let mut vm = vm_from_generic(&tx, env.clone(), db, vm_type)?; + let mut vm = vm_from_generic(&tx, env, db, vm_type)?; let report = vm.stateless_execute()?; @@ -363,7 +368,7 @@ pub fn generic_system_contract_levm( .current_accounts_state .get(&block_header.coinbase) .cloned(); - let env = Environment { + let env = Arc::new(Environment { origin: system_address, // EIPs 2935, 4788, 7002 and 7251 dictate that the system calls have a gas limit of 30 million and they do not use intrinsic gas. // So we add the base cost that will be taken in the execution. @@ -379,7 +384,7 @@ pub fn generic_system_contract_levm( block_gas_limit: i64::MAX as u64, // System calls, have no constraint on the block's gas limit. config, ..Default::default() - }; + }); let tx = &Transaction::EIP1559Transaction(EIP1559Transaction { to: TxKind::Call(contract_address), @@ -512,7 +517,7 @@ fn env_from_generic( fn vm_from_generic<'a>( tx: &GenericTransaction, - env: Environment, + env: Arc, db: &'a mut GeneralizedDatabase, vm_type: VMType, ) -> Result, VMError> { @@ -538,7 +543,7 @@ fn vm_from_generic<'a>( ..Default::default() }), None => Transaction::EIP1559Transaction(EIP1559Transaction { - to: tx.to.clone(), + to: tx.to, value: tx.value, data: tx.input.clone(), access_list: tx diff --git a/crates/vm/backends/levm/tracing.rs b/crates/vm/backends/levm/tracing.rs index b6b95228c6..db3aeb9021 100644 --- a/crates/vm/backends/levm/tracing.rs +++ b/crates/vm/backends/levm/tracing.rs @@ -1,3 +1,5 @@ +use std::sync::Arc; + use ethrex_common::types::{Block, Transaction}; use ethrex_common::{tracing::CallTrace, types::BlockHeader}; use ethrex_levm::vm::VMType; @@ -50,14 +52,14 @@ impl LEVM { with_log: bool, vm_type: VMType, ) -> Result { - let env = Self::setup_env( + let env = Arc::new(Self::setup_env( tx, tx.sender().map_err(|error| { EvmError::Transaction(format!("Couldn't recover addresses with error: {error}")) })?, block_header, db, - )?; + )?); let mut vm = VM::new( env, db, diff --git a/crates/vm/backends/mod.rs b/crates/vm/backends/mod.rs index edc3b450e5..96b5b01e36 100644 --- a/crates/vm/backends/mod.rs +++ b/crates/vm/backends/mod.rs @@ -89,7 +89,7 @@ impl Evm { tx.tx_type(), execution_report.is_success(), block_header.gas_limit - *remaining_gas, - execution_report.logs.clone(), + execution_report.logs, ); Ok((receipt, execution_report.gas_used)) diff --git a/crates/vm/execution_result.rs b/crates/vm/execution_result.rs index ce1daf08dd..5ac5bbd54d 100644 --- a/crates/vm/execution_result.rs +++ b/crates/vm/execution_result.rs @@ -31,10 +31,10 @@ impl ExecutionResult { ExecutionResult::Halt { gas_used, .. } => *gas_used, } } - pub fn logs(&self) -> Vec { + pub fn logs(&self) -> Option<&Vec> { match self { - ExecutionResult::Success { logs, .. } => logs.clone(), - _ => vec![], + ExecutionResult::Success { logs, .. } => Some(&logs), + _ => None, } } pub fn gas_refunded(&self) -> u64 { @@ -43,12 +43,11 @@ impl ExecutionResult { _ => 0, } } - - pub fn output(&self) -> Bytes { + pub fn output(&self) -> Option<&Bytes> { match self { - ExecutionResult::Success { output, .. } => output.clone(), - ExecutionResult::Revert { output, .. } => output.clone(), - ExecutionResult::Halt { .. } => Bytes::new(), + ExecutionResult::Success { output, .. } => Some(&output), + ExecutionResult::Revert { output, .. } => Some(&output), + ExecutionResult::Halt { .. } => None, } } } diff --git a/crates/vm/levm/bench/revm_comparison/src/levm_bench.rs b/crates/vm/levm/bench/revm_comparison/src/levm_bench.rs index bb5b95ccec..fd07680216 100644 --- a/crates/vm/levm/bench/revm_comparison/src/levm_bench.rs +++ b/crates/vm/levm/bench/revm_comparison/src/levm_bench.rs @@ -31,11 +31,11 @@ pub fn run_with_levm(contract_code: &str, runs: u64, calldata: &str) { // when using stateful execute() we have to use nonce when instantiating the vm. Otherwise use 0. for _nonce in 0..runs - 1 { - let mut vm = init_vm(&mut db, 0, calldata.clone()).unwrap(); + let mut vm = init_vm(&mut db, 0, calldata.clone()).unwrap(); // ok-clone: value needed later, used as part of bench runner let tx_report = black_box(vm.stateless_execute().unwrap()); assert!(tx_report.is_success()); } - let mut vm = init_vm(&mut db, 0, calldata.clone()).unwrap(); + let mut vm = init_vm(&mut db, 0, calldata).unwrap(); let tx_report = black_box(vm.stateless_execute().unwrap()); assert!(tx_report.is_success(), "{:?}", tx_report.result); @@ -58,7 +58,7 @@ fn init_db(bytecode: Bytes) -> GeneralizedDatabase { let cache = BTreeMap::from([ ( Address::from_low_u64_be(CONTRACT_ADDRESS), - Account::new(U256::MAX, bytecode.clone(), 0, BTreeMap::new()), + Account::new(U256::MAX, bytecode, 0, BTreeMap::new()), ), ( Address::from_low_u64_be(SENDER_ADDRESS), diff --git a/crates/vm/levm/bench/revm_comparison/src/revm_bench.rs b/crates/vm/levm/bench/revm_comparison/src/revm_bench.rs index 2e0f0e083f..ee353dd7b9 100644 --- a/crates/vm/levm/bench/revm_comparison/src/revm_bench.rs +++ b/crates/vm/levm/bench/revm_comparison/src/revm_bench.rs @@ -8,7 +8,7 @@ use std::hint::black_box; pub fn run_with_revm(contract_code: &str, runs: u64, calldata: &str) { let rich_acc_address = address!("1000000000000000000000000000000000000000"); let bytes = hex::decode(contract_code).unwrap(); - let raw_bytecode = Bytecode::new_raw(bytes.clone().into()); + let raw_bytecode = Bytecode::new_raw(bytes.into()); let mut evm = Evm::builder() .modify_tx_env(|tx| { diff --git a/crates/vm/levm/runner/src/main.rs b/crates/vm/levm/runner/src/main.rs index 42e4013ca4..b846c31f99 100644 --- a/crates/vm/levm/runner/src/main.rs +++ b/crates/vm/levm/runner/src/main.rs @@ -114,7 +114,7 @@ fn main() { mnemonics_to_bytecode(strings) }; - debug!("Final bytecode: 0x{}", hex::encode(bytecode.clone())); + debug!("Final bytecode: 0x{}", hex::encode(bytecode.clone())); // ok-clone: need to return value, used in test runner bytecode } else { @@ -125,7 +125,7 @@ fn main() { // Now we want to initialize the VM, so we set up the environment and database. // Env - let env = Environment { + let env = Arc::new(Environment { origin: runner_input.transaction.sender, gas_limit: runner_input.transaction.gas_limit, gas_price: runner_input.transaction.gas_price, @@ -136,7 +136,7 @@ fn main() { ), coinbase: COINBASE, ..Default::default() - }; + }); // DB let initial_state = setup_initial_state(&mut runner_input, bytecode); @@ -148,7 +148,7 @@ fn main() { let mut vm = VM::new( env, &mut db, - &Transaction::LegacyTransaction(LegacyTransaction::from(runner_input.transaction.clone())), + &Transaction::LegacyTransaction(LegacyTransaction::from(runner_input.transaction.clone())), // ok-clone: value needed later, used in test runner LevmCallTracer::disabled(), VMType::L1, ) @@ -277,7 +277,7 @@ fn setup_initial_state( let input_pre_state: BTreeMap = runner_input .pre .iter() - .map(|(addr, acc)| (*addr, Account::from(acc.clone()))) + .map(|(addr, acc)| (*addr, Account::from(acc.clone()))) // ok-clone: value needed later, used in test runner .collect(); initial_state.extend(input_pre_state); // Contract bytecode or initcode diff --git a/crates/vm/levm/src/account.rs b/crates/vm/levm/src/account.rs index 919a94f871..787da9166d 100644 --- a/crates/vm/levm/src/account.rs +++ b/crates/vm/levm/src/account.rs @@ -80,7 +80,7 @@ impl LevmAccount { } } -#[derive(Clone, Default, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, Serialize, Deserialize)] pub enum AccountStatus { #[default] Unmodified, diff --git a/crates/vm/levm/src/call_frame.rs b/crates/vm/levm/src/call_frame.rs index 87a41a71dc..eb35df6b6a 100644 --- a/crates/vm/levm/src/call_frame.rs +++ b/crates/vm/levm/src/call_frame.rs @@ -288,9 +288,9 @@ impl CallFrameBackup { self.original_accounts_info .entry(address) .or_insert_with(|| LevmAccount { - info: account.info.clone(), + info: account.info, storage: BTreeMap::new(), - status: account.status.clone(), + status: account.status, }); Ok(()) @@ -425,7 +425,7 @@ impl<'a> VM<'a> { /// Restores the cache state to the state before changes made during a callframe. pub fn restore_cache_state(&mut self) -> Result<(), VMError> { - let callframe_backup = self.current_call_frame.call_frame_backup.clone(); + let callframe_backup = std::mem::take(&mut self.current_call_frame.call_frame_backup); restore_cache_state(self.db, callframe_backup) } diff --git a/crates/vm/levm/src/db/gen_db.rs b/crates/vm/levm/src/db/gen_db.rs index 3afc467189..c1f2e18d0a 100644 --- a/crates/vm/levm/src/db/gen_db.rs +++ b/crates/vm/levm/src/db/gen_db.rs @@ -79,7 +79,7 @@ impl GeneralizedDatabase { Entry::Vacant(entry) => { let info = self.store.get_account_info(address)?; let account = LevmAccount::from(info); - self.initial_accounts_state.insert(address, account.clone()); + self.initial_accounts_state.insert(address, account.clone()); // ok-clone: we're caching the original state of the account Ok(entry.insert(account)) } } @@ -176,7 +176,7 @@ impl GeneralizedDatabase { let new_account_update = AccountUpdate { address: *address, removed: false, - info: Some(new_state_account.info.clone()), + info: Some(new_state_account.info), code: Some( self.codes .get(&new_state_account.info.code_hash) @@ -229,7 +229,7 @@ impl GeneralizedDatabase { } let info = if acc_info_updated { - Some(new_state_account.info.clone()) + Some(new_state_account.info) } else { None }; diff --git a/crates/vm/levm/src/hooks/backup_hook.rs b/crates/vm/levm/src/hooks/backup_hook.rs index 10f49a0535..91f5a13d22 100644 --- a/crates/vm/levm/src/hooks/backup_hook.rs +++ b/crates/vm/levm/src/hooks/backup_hook.rs @@ -14,7 +14,7 @@ pub struct BackupHook { impl Hook for BackupHook { fn prepare_execution(&mut self, vm: &mut crate::vm::VM<'_>) -> Result<(), VMError> { // Here we need to backup the callframe for undoing transaction changes if we want to. - self.pre_execution_backup = vm.current_call_frame.call_frame_backup.clone(); + self.pre_execution_backup = std::mem::take(&mut vm.current_call_frame.call_frame_backup); Ok(()) } @@ -25,7 +25,7 @@ impl Hook for BackupHook { ) -> Result<(), VMError> { // We want to restore to the initial state, this includes saving the changes made by the prepare execution // and the changes made by the execution itself. - let mut execution_backup = vm.current_call_frame.call_frame_backup.clone(); + let mut execution_backup = std::mem::take(&mut vm.current_call_frame.call_frame_backup); let pre_execution_backup = std::mem::take(&mut self.pre_execution_backup); execution_backup.extend(pre_execution_backup); vm.db.tx_backup = Some(execution_backup); diff --git a/crates/vm/levm/src/hooks/default_hook.rs b/crates/vm/levm/src/hooks/default_hook.rs index 4ed68e1c28..92e18e35b5 100644 --- a/crates/vm/levm/src/hooks/default_hook.rs +++ b/crates/vm/levm/src/hooks/default_hook.rs @@ -26,7 +26,7 @@ impl Hook for DefaultHook { /// See 'docs' for more information about validations. fn prepare_execution(&mut self, vm: &mut VM<'_>) -> Result<(), VMError> { let sender_address = vm.env.origin; - let sender_info = vm.db.get_account(sender_address)?.info.clone(); + let sender_info = vm.db.get_account(sender_address)?.info; if vm.env.config.fork >= Fork::Prague { validate_min_gas_limit(vm)?; @@ -243,7 +243,7 @@ pub fn delete_self_destruct_accounts(vm: &mut VM<'_>) -> Result<(), VMError> { pub fn validate_min_gas_limit(vm: &mut VM<'_>) -> Result<(), VMError> { // check for gas limit is grater or equal than the minimum required - let calldata = vm.current_call_frame.calldata.clone(); + let calldata = &vm.current_call_frame.calldata; let intrinsic_gas: u64 = vm.get_intrinsic_gas()?; if vm.current_call_frame.gas_limit < intrinsic_gas { @@ -251,7 +251,7 @@ pub fn validate_min_gas_limit(vm: &mut VM<'_>) -> Result<(), VMError> { } // calldata_cost = tokens_in_calldata * 4 - let calldata_cost: u64 = gas_cost::tx_calldata(&calldata)?; + let calldata_cost: u64 = gas_cost::tx_calldata(calldata)?; // same as calculated in gas_used() let tokens_in_calldata: u64 = calldata_cost / STANDARD_TOKEN_COST; diff --git a/crates/vm/levm/src/opcode_handlers/system.rs b/crates/vm/levm/src/opcode_handlers/system.rs index 67a338a967..14259bbca0 100644 --- a/crates/vm/levm/src/opcode_handlers/system.rs +++ b/crates/vm/levm/src/opcode_handlers/system.rs @@ -960,7 +960,7 @@ impl<'a> VM<'a> { .ok_or(InternalError::Overflow)?; // What to do, depending on TxResult - match ctx_result.result.clone() { + match &ctx_result.result { TxResult::Success => { parent_call_frame.stack.push1(address_to_word(to))?; self.merge_call_frame_backup_with_parent(&call_frame_backup)?; diff --git a/crates/vm/levm/src/utils.rs b/crates/vm/levm/src/utils.rs index eb602b3d39..cb8857c9dc 100644 --- a/crates/vm/levm/src/utils.rs +++ b/crates/vm/levm/src/utils.rs @@ -386,7 +386,7 @@ impl<'a> VM<'a> { }; // 4. Add authority to accessed_addresses (as defined in EIP-2929). - let authority_info = self.db.get_account(authority_address)?.info.clone(); + let authority_info = self.db.get_account(authority_address)?.info; let authority_code = self.db.get_code(authority_info.code_hash)?; self.substate.add_accessed_address(authority_address); diff --git a/crates/vm/levm/src/vm.rs b/crates/vm/levm/src/vm.rs index 751de6e499..1b308da787 100644 --- a/crates/vm/levm/src/vm.rs +++ b/crates/vm/levm/src/vm.rs @@ -27,6 +27,7 @@ use std::{ collections::{BTreeMap, BTreeSet, HashMap, HashSet}, mem, rc::Rc, + sync::Arc, }; pub type Storage = HashMap; @@ -308,7 +309,7 @@ pub struct VM<'a> { pub call_frames: Vec, /// The current call frame. pub current_call_frame: CallFrame, - pub env: Environment, + pub env: Arc, pub substate: Substate, pub db: &'a mut GeneralizedDatabase, pub tx: Transaction, @@ -330,7 +331,7 @@ pub struct VM<'a> { impl<'a> VM<'a> { pub fn new( - env: Environment, + env: Arc, db: &'a mut GeneralizedDatabase, tx: &Transaction, tracer: LevmCallTracer, diff --git a/crates/vm/levm/tests/tests.rs b/crates/vm/levm/tests/tests.rs index 4db14e83b7..426ceb5db4 100644 --- a/crates/vm/levm/tests/tests.rs +++ b/crates/vm/levm/tests/tests.rs @@ -13,7 +13,7 @@ fn pairing_infinity() { // This is from https://eips.ethereum.org/assets/eip-2537/pairing_check_bls.json // test "bls_pairing_non-degeneracy" let mut calldata = hex::decode("0000000000000000000000000000000017f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb0000000000000000000000000000000008b3f481e3aaa0f1a09e30ed741d8ae4fcf5e095d5d00af600db18cb2c04b3edd03cc744a2888ae40caa232946c5e7e100000000000000000000000000000000024aa2b2f08f0a91260805272dc51051c6e47ad4fa403b02b4510b647ae3d1770bac0326a805bbefd48056c8c121bdb80000000000000000000000000000000013e02b6052719f607dacd3a088274f65596bd0d09920b61ab5da61bbdc7f5049334cf11213945d57e5ac7d055d042b7e000000000000000000000000000000000ce5d527727d6e118cc9cdc6da2e351aadfd9baa8cbdd3a76d429a695160d12c923ac9cc3baca289e193548608b82801000000000000000000000000000000000606c4a02ea734cc32acd2b02bc28b99cb3e287e85a763af267492ab572e99ab3f370d275cec1da1aaa9075ff05f79be").unwrap(); - let calldata_bytes = Bytes::from(calldata.clone()); + let calldata_bytes = Bytes::from(calldata.clone()); // ok-clone: clone in test, data needed later let mut remaining_gas = 10000000; let result = bls12_pairing_check(&calldata_bytes, &mut remaining_gas, Fork::Cancun); @@ -29,7 +29,7 @@ fn pairing_infinity() { // We add only the first G2 point of the calldata calldata.extend_from_slice(valid_calldata.get(128..384).unwrap()); - let calldata_bytes = Bytes::from(calldata.clone()); + let calldata_bytes = Bytes::from(calldata); let result = bls12_pairing_check(&calldata_bytes, &mut remaining_gas, Fork::Cancun); diff --git a/tooling/ef_tests/state/runner/levm_runner.rs b/tooling/ef_tests/state/runner/levm_runner.rs index e8e5c781a8..5c3e8c1a90 100644 --- a/tooling/ef_tests/state/runner/levm_runner.rs +++ b/tooling/ef_tests/state/runner/levm_runner.rs @@ -21,6 +21,7 @@ use ethrex_levm::{ }; use ethrex_rlp::encode::RLPEncode; use ethrex_vm::backends; +use std::sync::Arc; pub async fn run_ef_test(test: &EFTest) -> Result { // There are some tests that don't have a hash, unwrap will panic @@ -213,7 +214,7 @@ pub fn prepare_vm_for_tx<'a>( }; VM::new( - Environment { + Arc::new(Environment { origin: test_tx.sender, gas_limit: test_tx.gas_limit, config, @@ -234,7 +235,7 @@ pub fn prepare_vm_for_tx<'a>( tx_nonce: test_tx.nonce, block_gas_limit: test.env.current_gas_limit, is_privileged: false, - }, + }), db, &tx, LevmCallTracer::disabled(), diff --git a/tooling/ef_tests/state_v2/src/modules/runner.rs b/tooling/ef_tests/state_v2/src/modules/runner.rs index 73fc0ec167..2dbcbdc21a 100644 --- a/tooling/ef_tests/state_v2/src/modules/runner.rs +++ b/tooling/ef_tests/state_v2/src/modules/runner.rs @@ -5,6 +5,7 @@ use std::{ fs::{self, OpenOptions}, io::Write, path::PathBuf, + sync::Arc, }; use ethrex_common::{ @@ -124,11 +125,11 @@ pub async fn run_test( pub fn get_vm_env_for_test( test_env: Env, test_case: &TestCase, -) -> Result { +) -> Result, RunnerError> { let blob_schedule = EVMConfig::canonical_values(test_case.fork); let config = EVMConfig::new(test_case.fork, blob_schedule); let gas_price = effective_gas_price(&test_env, test_case)?; - Ok(Environment { + Ok(Arc::new(Environment { origin: test_case.sender, gas_limit: test_case.gas, config, @@ -149,7 +150,7 @@ pub fn get_vm_env_for_test( tx_nonce: test_case.nonce, block_gas_limit: test_env.current_gas_limit, is_privileged: false, - }) + })) } /// Constructs the transaction that will be executed in a specific test case.