From 7042bd16e538aa3e6ca438dd87e40fa80781ec59 Mon Sep 17 00:00:00 2001 From: Eagle941 <8973725+Eagle941@users.noreply.github.com> Date: Wed, 4 Sep 2024 02:47:20 +0100 Subject: [PATCH] chore: added test only methods --- crates/blockifier/src/bouncer_test.rs | 7 +- .../blockifier/src/concurrency/flow_test.rs | 13 ++- .../src/concurrency/versioned_state.rs | 8 ++ .../src/concurrency/versioned_state_test.rs | 86 +++++++++---------- .../src/concurrency/worker_logic.rs | 13 ++- .../src/concurrency/worker_logic_test.rs | 41 ++++++--- crates/blockifier/src/state/cached_state.rs | 13 ++- .../src/transaction/transactions_test.rs | 7 +- 8 files changed, 112 insertions(+), 76 deletions(-) diff --git a/crates/blockifier/src/bouncer_test.rs b/crates/blockifier/src/bouncer_test.rs index d0a744704a..edb4806e5c 100644 --- a/crates/blockifier/src/bouncer_test.rs +++ b/crates/blockifier/src/bouncer_test.rs @@ -12,8 +12,7 @@ use crate::blockifier::transaction_executor::{ use crate::bouncer::{verify_tx_weights_in_bounds, Bouncer, BouncerWeights, BuiltinCount}; use crate::context::BlockContext; use crate::execution::call_info::ExecutionSummary; -use crate::state::cached_state::{StateChangesKeys, TransactionalState}; -use crate::state::visited_pcs::VisitedPcsSet; +use crate::state::cached_state::StateChangesKeys; use crate::storage_key; use crate::test_utils::initial_test_state::test_state; use crate::transaction::errors::TransactionExecutionError; @@ -185,11 +184,11 @@ fn test_bouncer_try_update( ) { use cairo_vm::vm::runners::cairo_runner::ExecutionResources; + use crate::state::cached_state::TransactionalState; use crate::transaction::objects::TransactionResources; let state = &mut test_state(&BlockContext::create_for_account_testing().chain_info, 0, &[]); - let mut transactional_state: TransactionalState<'_, _, VisitedPcsSet> = - TransactionalState::create_transactional(state); + let mut transactional_state = TransactionalState::create_transactional_for_testing(state); // Setup the bouncer. let block_max_capacity = BouncerWeights { diff --git a/crates/blockifier/src/concurrency/flow_test.rs b/crates/blockifier/src/concurrency/flow_test.rs index 4e6a7e1cac..2eaf1b06c0 100644 --- a/crates/blockifier/src/concurrency/flow_test.rs +++ b/crates/blockifier/src/concurrency/flow_test.rs @@ -9,7 +9,7 @@ use starknet_api::{contract_address, felt, patricia_key}; use crate::abi::sierra_types::{SierraType, SierraU128}; use crate::concurrency::scheduler::{Scheduler, Task, TransactionStatus}; use crate::concurrency::test_utils::{safe_versioned_state_for_testing, DEFAULT_CHUNK_SIZE}; -use crate::concurrency::versioned_state::{ThreadSafeVersionedState, VersionedStateProxy}; +use crate::concurrency::versioned_state::ThreadSafeVersionedState; use crate::state::cached_state::{CachedState, ContractClassMapping, StateMaps}; use crate::state::state_api::UpdatableState; use crate::state::visited_pcs::VisitedPcsSet; @@ -29,7 +29,6 @@ fn scheduler_flow_test( // transaction sequentially advances a counter by reading the previous value and bumping it by // 1. - use crate::concurrency::versioned_state::VersionedStateProxy; use crate::state::visited_pcs::VisitedPcsSet; let scheduler = Arc::new(Scheduler::new(DEFAULT_CHUNK_SIZE)); let versioned_state = @@ -76,8 +75,7 @@ fn scheduler_flow_test( Task::AskForTask } Task::ValidationTask(tx_index) => { - let state_proxy: VersionedStateProxy<_, VisitedPcsSet> = - versioned_state.pin_version(tx_index); + let state_proxy = versioned_state.pin_version_for_testing(tx_index); let (reads, writes) = get_reads_writes_for(Task::ValidationTask(tx_index), &versioned_state); let read_set_valid = state_proxy.validate_reads(&reads); @@ -129,14 +127,14 @@ fn get_reads_writes_for( ) -> (StateMaps, StateMaps) { match task { Task::ExecutionTask(tx_index) => { - let state_proxy: VersionedStateProxy<_, VisitedPcsSet> = match tx_index { + let state_proxy = match tx_index { 0 => { return ( state_maps_with_single_storage_entry(0), state_maps_with_single_storage_entry(1), ); } - _ => versioned_state.pin_version(tx_index - 1), + _ => versioned_state.pin_version_for_testing(tx_index - 1), }; let tx_written_value = SierraU128::from_storage( &state_proxy, @@ -151,8 +149,7 @@ fn get_reads_writes_for( ) } Task::ValidationTask(tx_index) => { - let state_proxy: VersionedStateProxy<_, VisitedPcsSet> = - versioned_state.pin_version(tx_index); + let state_proxy = versioned_state.pin_version_for_testing(tx_index); let tx_written_value = SierraU128::from_storage( &state_proxy, &contract_address!(CONTRACT_ADDRESS), diff --git a/crates/blockifier/src/concurrency/versioned_state.rs b/crates/blockifier/src/concurrency/versioned_state.rs index d2e8692484..ee4631fa89 100644 --- a/crates/blockifier/src/concurrency/versioned_state.rs +++ b/crates/blockifier/src/concurrency/versioned_state.rs @@ -234,6 +234,14 @@ impl ThreadSafeVersionedState { VersionedStateProxy { tx_index, state: self.0.clone(), _marker: PhantomData } } + #[cfg(test)] + pub fn pin_version_for_testing( + &self, + tx_index: TxIndex, + ) -> VersionedStateProxy { + VersionedStateProxy { tx_index, state: self.0.clone(), _marker: PhantomData } + } + pub fn into_inner_state(self) -> VersionedState { Arc::try_unwrap(self.0) .unwrap_or_else(|_| { diff --git a/crates/blockifier/src/concurrency/versioned_state_test.rs b/crates/blockifier/src/concurrency/versioned_state_test.rs index bec9541a10..cec3f6a26f 100644 --- a/crates/blockifier/src/concurrency/versioned_state_test.rs +++ b/crates/blockifier/src/concurrency/versioned_state_test.rs @@ -14,9 +14,7 @@ use crate::abi::abi_utils::{get_fee_token_var_address, get_storage_var_address}; use crate::concurrency::test_utils::{ class_hash, contract_address, safe_versioned_state_for_testing, }; -use crate::concurrency::versioned_state::{ - ThreadSafeVersionedState, VersionedState, VersionedStateProxy, -}; +use crate::concurrency::versioned_state::{ThreadSafeVersionedState, VersionedState}; use crate::concurrency::TxIndex; use crate::context::BlockContext; use crate::state::cached_state::{ @@ -73,9 +71,8 @@ fn test_versioned_state_proxy() { let versioned_state = Arc::new(Mutex::new(VersionedState::new(cached_state))); let safe_versioned_state = ThreadSafeVersionedState(Arc::clone(&versioned_state)); - let versioned_state_proxys: Vec< - VersionedStateProxy, VisitedPcsSet>, - > = (0..20).map(|i| safe_versioned_state.pin_version(i)).collect(); + let versioned_state_proxys: Vec<_> = + (0..20).map(|i| safe_versioned_state.pin_version_for_testing(i)).collect(); // Read initial data assert_eq!(versioned_state_proxys[5].get_nonce_at(contract_address).unwrap(), nonce); @@ -210,14 +207,12 @@ fn test_run_parallel_txs(max_resource_bounds: ResourceBoundsMapping) { )))); let safe_versioned_state = ThreadSafeVersionedState(Arc::clone(&versioned_state)); - let mut versioned_state_proxy_1: VersionedStateProxy<_, VisitedPcsSet> = - safe_versioned_state.pin_version(1); - let mut state_1: TransactionalState<'_, _, VisitedPcsSet> = - TransactionalState::create_transactional(&mut versioned_state_proxy_1); - let mut versioned_state_proxy_2: VersionedStateProxy<_, VisitedPcsSet> = - safe_versioned_state.pin_version(2); - let mut state_2: TransactionalState<'_, _, VisitedPcsSet> = - TransactionalState::create_transactional(&mut versioned_state_proxy_2); + let mut versioned_state_proxy_1 = safe_versioned_state.pin_version_for_testing(1); + let mut state_1 = + TransactionalState::create_transactional_for_testing(&mut versioned_state_proxy_1); + let mut versioned_state_proxy_2 = safe_versioned_state.pin_version_for_testing(2); + let mut state_2 = + TransactionalState::create_transactional_for_testing(&mut versioned_state_proxy_2); // Prepare transactions let deploy_account_tx_1 = deploy_account_tx( @@ -288,10 +283,9 @@ fn test_validate_reads( ) { let storage_key = storage_key!(0x10_u8); - let mut version_state_proxy: VersionedStateProxy<_, VisitedPcsSet> = - safe_versioned_state.pin_version(1); - let transactional_state: TransactionalState<'_, _, VisitedPcsSet> = - TransactionalState::create_transactional(&mut version_state_proxy); + let mut version_state_proxy = safe_versioned_state.pin_version_for_testing(1); + let transactional_state = + TransactionalState::create_transactional_for_testing(&mut version_state_proxy); // Validating tx index 0 always succeeds. assert!( @@ -380,8 +374,7 @@ fn test_false_validate_reads( #[case] tx_0_writes: StateMaps, safe_versioned_state: ThreadSafeVersionedState>, ) { - let version_state_proxy: VersionedStateProxy<_, VisitedPcsSet> = - safe_versioned_state.pin_version(0); + let version_state_proxy = safe_versioned_state.pin_version_for_testing(0); version_state_proxy.state().apply_writes(0, &tx_0_writes, &HashMap::default()); assert!(!safe_versioned_state.pin_version::(1).validate_reads(&tx_1_reads)); } @@ -398,8 +391,7 @@ fn test_false_validate_reads_declared_contracts( declared_contracts: HashMap::from([(class_hash!(1_u8), true)]), ..Default::default() }; - let version_state_proxy: VersionedStateProxy<_, VisitedPcsSet> = - safe_versioned_state.pin_version(0); + let version_state_proxy = safe_versioned_state.pin_version_for_testing(0); let compiled_contract_calss = FeatureContract::TestContract(CairoVersion::Cairo1).get_class(); let class_hash_to_class = HashMap::from([(class_hash!(1_u8), compiled_contract_calss)]); version_state_proxy.state().apply_writes(0, &tx_0_writes, &class_hash_to_class); @@ -412,10 +404,12 @@ fn test_apply_writes( class_hash: ClassHash, safe_versioned_state: ThreadSafeVersionedState>, ) { - let mut versioned_proxy_states: Vec> = - (0..2).map(|i| safe_versioned_state.pin_version(i)).collect(); - let mut transactional_states: Vec> = - versioned_proxy_states.iter_mut().map(TransactionalState::create_transactional).collect(); + let mut versioned_proxy_states: Vec<_> = + (0..2).map(|i| safe_versioned_state.pin_version_for_testing(i)).collect(); + let mut transactional_states: Vec<_> = versioned_proxy_states + .iter_mut() + .map(TransactionalState::create_transactional_for_testing) + .collect(); // Transaction 0 class hash. let class_hash_0 = class_hash!(76_u8); @@ -429,7 +423,7 @@ fn test_apply_writes( transactional_states[0].set_contract_class(class_hash, contract_class_0.clone()).unwrap(); assert_eq!(transactional_states[0].class_hash_to_class.borrow().len(), 1); - safe_versioned_state.pin_version(0).apply_writes( + safe_versioned_state.pin_version_for_testing(0).apply_writes( &transactional_states[0].cache.borrow().writes, &transactional_states[0].class_hash_to_class.borrow().clone(), &VisitedPcsSet::default(), @@ -447,10 +441,12 @@ fn test_apply_writes_reexecute_scenario( class_hash: ClassHash, safe_versioned_state: ThreadSafeVersionedState>, ) { - let mut versioned_proxy_states: Vec> = - (0..2).map(|i| safe_versioned_state.pin_version(i)).collect(); - let mut transactional_states: Vec> = - versioned_proxy_states.iter_mut().map(TransactionalState::create_transactional).collect(); + let mut versioned_proxy_states: Vec<_> = + (0..2).map(|i| safe_versioned_state.pin_version_for_testing(i)).collect(); + let mut transactional_states: Vec<_> = versioned_proxy_states + .iter_mut() + .map(TransactionalState::create_transactional_for_testing) + .collect(); // Transaction 0 class hash. let class_hash_0 = class_hash!(76_u8); @@ -460,7 +456,7 @@ fn test_apply_writes_reexecute_scenario( // updated. assert!(transactional_states[1].get_class_hash_at(contract_address).unwrap() == class_hash); - safe_versioned_state.pin_version(0).apply_writes( + safe_versioned_state.pin_version_for_testing(0).apply_writes( &transactional_states[0].cache.borrow().writes, &transactional_states[0].class_hash_to_class.borrow().clone(), &VisitedPcsSet::default(), @@ -471,7 +467,7 @@ fn test_apply_writes_reexecute_scenario( // TODO: Use re-execution native util once it's ready. // "Re-execute" the transaction. - let mut versioned_state_proxy = safe_versioned_state.pin_version(1); + let mut versioned_state_proxy = safe_versioned_state.pin_version_for_testing(1); transactional_states[1] = TransactionalState::create_transactional(&mut versioned_state_proxy); // The class hash should be updated. assert!(transactional_states[1].get_class_hash_at(contract_address).unwrap() == class_hash_0); @@ -483,10 +479,12 @@ fn test_delete_writes( safe_versioned_state: ThreadSafeVersionedState>, ) { let num_of_txs = 3; - let mut versioned_proxy_states: Vec> = - (0..num_of_txs).map(|i| safe_versioned_state.pin_version(i)).collect(); - let mut transactional_states: Vec> = - versioned_proxy_states.iter_mut().map(TransactionalState::create_transactional).collect(); + let mut versioned_proxy_states: Vec<_> = + (0..num_of_txs).map(|i| safe_versioned_state.pin_version_for_testing(i)).collect(); + let mut transactional_states: Vec<_> = versioned_proxy_states + .iter_mut() + .map(TransactionalState::create_transactional_for_testing) + .collect(); // Setting 2 instances of the contract to ensure `delete_writes` removes information from // multiple keys. Class hash values are not checked in this test. @@ -504,7 +502,7 @@ fn test_delete_writes( tx_state .set_contract_class(feature_contract.get_class_hash(), feature_contract.get_class()) .unwrap(); - safe_versioned_state.pin_version(i).apply_writes( + safe_versioned_state.pin_version_for_testing(i).apply_writes( &tx_state.cache.borrow().writes, &tx_state.class_hash_to_class.borrow(), &VisitedPcsSet::default(), @@ -564,7 +562,7 @@ fn test_delete_writes_completeness( HashMap::from([(feature_contract.get_class_hash(), feature_contract.get_class())]); let tx_index = 0; - let mut versioned_state_proxy = safe_versioned_state.pin_version(tx_index); + let mut versioned_state_proxy = safe_versioned_state.pin_version_for_testing(tx_index); versioned_state_proxy.apply_writes( &state_maps_writes, @@ -608,13 +606,13 @@ fn test_versioned_proxy_state_flow( let contract_address = contract_address!("0x1"); let class_hash = ClassHash(felt!(27_u8)); - let mut versioned_proxy_states: Vec> = - (0..4).map(|i| safe_versioned_state.pin_version(i)).collect(); + let mut versioned_proxy_states: Vec<_> = + (0..4).map(|i| safe_versioned_state.pin_version_for_testing(i)).collect(); - let mut transactional_states: Vec> = - Vec::with_capacity(4); + let mut transactional_states = Vec::with_capacity(4); for proxy_state in &mut versioned_proxy_states { - transactional_states.push(TransactionalState::create_transactional(proxy_state)); + transactional_states + .push(TransactionalState::create_transactional_for_testing(proxy_state)); } // Clients class hash values. diff --git a/crates/blockifier/src/concurrency/worker_logic.rs b/crates/blockifier/src/concurrency/worker_logic.rs index 8576f69217..485ce2dd68 100644 --- a/crates/blockifier/src/concurrency/worker_logic.rs +++ b/crates/blockifier/src/concurrency/worker_logic.rs @@ -17,7 +17,7 @@ use crate::state::cached_state::{ ContractClassMapping, StateChanges, StateMaps, TransactionalState, }; use crate::state::state_api::{StateReader, UpdatableState}; -use crate::state::visited_pcs::VisitedPcs; +use crate::state::visited_pcs::{VisitedPcs, VisitedPcsSet}; use crate::transaction::objects::{TransactionExecutionInfo, TransactionExecutionResult}; use crate::transaction::transaction_execution::Transaction; use crate::transaction::transactions::{ExecutableTransaction, ExecutionFlags}; @@ -45,6 +45,17 @@ pub struct WorkerExecutor<'a, S: StateReader, V: VisitedPcs> { pub block_context: &'a BlockContext, pub bouncer: Mutex<&'a mut Bouncer>, } +impl<'a, S: StateReader> WorkerExecutor<'a, S, VisitedPcsSet> { + #[cfg(test)] + pub fn new_for_testing( + state: ThreadSafeVersionedState, + chunk: &'a [Transaction], + block_context: &'a BlockContext, + bouncer: Mutex<&'a mut Bouncer>, + ) -> WorkerExecutor<'a, S, VisitedPcsSet> { + WorkerExecutor::new(state, chunk, block_context, bouncer) + } +} impl<'a, S: StateReader, V: VisitedPcs> WorkerExecutor<'a, S, V> { pub fn new( state: ThreadSafeVersionedState, diff --git a/crates/blockifier/src/concurrency/worker_logic_test.rs b/crates/blockifier/src/concurrency/worker_logic_test.rs index da61c09aab..925a7fae57 100644 --- a/crates/blockifier/src/concurrency/worker_logic_test.rs +++ b/crates/blockifier/src/concurrency/worker_logic_test.rs @@ -9,7 +9,6 @@ use starknet_api::transaction::{ use starknet_api::{contract_address, felt, patricia_key}; use starknet_types_core::felt::Felt; -use super::WorkerExecutor; use crate::abi::abi_utils::get_fee_token_var_address; use crate::abi::sierra_types::next_storage_key; use crate::bouncer::Bouncer; @@ -17,7 +16,7 @@ use crate::concurrency::fee_utils::STORAGE_READ_SEQUENCER_BALANCE_INDICES; use crate::concurrency::scheduler::{Task, TransactionStatus}; use crate::concurrency::test_utils::safe_versioned_state_for_testing; use crate::concurrency::versioned_state::ThreadSafeVersionedState; -use crate::concurrency::worker_logic::lock_mutex_in_array; +use crate::concurrency::worker_logic::{lock_mutex_in_array, WorkerExecutor}; use crate::context::{BlockContext, TransactionContext}; use crate::fee::fee_utils::get_sequencer_balance_keys; use crate::state::cached_state::StateMaps; @@ -106,8 +105,12 @@ pub fn test_commit_tx() { let cached_state = test_state(&block_context.chain_info, BALANCE, &[(account, 1), (test_contract, 1)]); let versioned_state = safe_versioned_state_for_testing(cached_state); - let executor: WorkerExecutor<'_, _, VisitedPcsSet> = - WorkerExecutor::new(versioned_state, &txs, &block_context, Mutex::new(&mut bouncer)); + let executor = WorkerExecutor::new_for_testing( + versioned_state, + &txs, + &block_context, + Mutex::new(&mut bouncer), + ); // Execute transactions. // Simulate a concurrent run by executing tx1 before tx0. @@ -206,7 +209,7 @@ fn test_commit_tx_when_sender_is_sequencer() { let state = test_state(&block_context.chain_info, BALANCE, &[(account, 1), (test_contract, 1)]); let versioned_state = safe_versioned_state_for_testing(state); - let executor: WorkerExecutor<'_, _, VisitedPcsSet> = WorkerExecutor::new( + let executor = WorkerExecutor::new_for_testing( versioned_state, &sequencer_tx, &block_context, @@ -313,7 +316,7 @@ fn test_worker_execute(max_resource_bounds: ResourceBoundsMapping) { .collect::>(); let mut bouncer = Bouncer::new(block_context.bouncer_config.clone()); - let worker_executor: WorkerExecutor<'_, _, VisitedPcsSet> = WorkerExecutor::new( + let worker_executor = WorkerExecutor::new_for_testing( safe_versioned_state.clone(), &txs, &block_context, @@ -481,7 +484,7 @@ fn test_worker_validate(max_resource_bounds: ResourceBoundsMapping) { .collect::>(); let mut bouncer = Bouncer::new(block_context.bouncer_config.clone()); - let worker_executor: WorkerExecutor<'_, _, VisitedPcsSet> = WorkerExecutor::new( + let worker_executor = WorkerExecutor::new_for_testing( safe_versioned_state.clone(), &txs, &block_context, @@ -594,8 +597,12 @@ fn test_deploy_before_declare( .collect::>(); let mut bouncer = Bouncer::new(block_context.bouncer_config.clone()); - let worker_executor: WorkerExecutor<'_, _, VisitedPcsSet> = - WorkerExecutor::new(safe_versioned_state, &txs, &block_context, Mutex::new(&mut bouncer)); + let worker_executor = WorkerExecutor::new_for_testing( + safe_versioned_state, + &txs, + &block_context, + Mutex::new(&mut bouncer), + ); // Creates 2 active tasks. worker_executor.scheduler.next_task(); @@ -666,8 +673,12 @@ fn test_worker_commit_phase(max_resource_bounds: ResourceBoundsMapping) { .collect::>(); let mut bouncer = Bouncer::new(block_context.bouncer_config.clone()); - let worker_executor: WorkerExecutor<'_, _, VisitedPcsSet> = - WorkerExecutor::new(safe_versioned_state, &txs, &block_context, Mutex::new(&mut bouncer)); + let worker_executor = WorkerExecutor::new_for_testing( + safe_versioned_state, + &txs, + &block_context, + Mutex::new(&mut bouncer), + ); // Try to commit before any transaction is ready. worker_executor.commit_while_possible(); @@ -756,8 +767,12 @@ fn test_worker_commit_phase_with_halt() { .collect::>(); let mut bouncer = Bouncer::new(block_context.bouncer_config.clone()); - let worker_executor: WorkerExecutor<'_, _, VisitedPcsSet> = - WorkerExecutor::new(safe_versioned_state, &txs, &block_context, Mutex::new(&mut bouncer)); + let worker_executor = WorkerExecutor::new_for_testing( + safe_versioned_state, + &txs, + &block_context, + Mutex::new(&mut bouncer), + ); // Creates 2 active tasks. // Creating these tasks changes the status of both transactions to `Executing`. If we skip this diff --git a/crates/blockifier/src/state/cached_state.rs b/crates/blockifier/src/state/cached_state.rs index bcbc5ee203..85b921b5d9 100644 --- a/crates/blockifier/src/state/cached_state.rs +++ b/crates/blockifier/src/state/cached_state.rs @@ -7,7 +7,7 @@ use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce}; use starknet_api::state::StorageKey; use starknet_types_core::felt::Felt; -use super::visited_pcs::VisitedPcs; +use super::visited_pcs::{VisitedPcs, VisitedPcsSet}; use crate::abi::abi_utils::get_fee_token_var_address; use crate::context::TransactionContext; use crate::execution::contract_class::ContractClass; @@ -124,7 +124,7 @@ impl UpdatableState for CachedState { } #[cfg(any(feature = "testing", test))] -impl From for CachedState { +impl From for CachedState { fn from(state_reader: S) -> Self { CachedState::new(state_reader) } @@ -513,7 +513,14 @@ impl<'a, S: StateReader + ?Sized> StateReader for MutRefState<'a, S> { } pub type TransactionalState<'a, U, V> = CachedState, V>; - +impl<'a, S: StateReader> TransactionalState<'a, S, VisitedPcsSet> { + #[cfg(test)] + pub fn create_transactional_for_testing( + state: &mut S, + ) -> TransactionalState<'_, S, VisitedPcsSet> { + TransactionalState::create_transactional(state) + } +} impl<'a, S: StateReader, V: VisitedPcs> TransactionalState<'a, S, V> { /// Creates a transactional instance from the given updatable state. /// It allows performing buffered modifying actions on the given state, which diff --git a/crates/blockifier/src/transaction/transactions_test.rs b/crates/blockifier/src/transaction/transactions_test.rs index 65454a00d4..5d9f830b6e 100644 --- a/crates/blockifier/src/transaction/transactions_test.rs +++ b/crates/blockifier/src/transaction/transactions_test.rs @@ -38,7 +38,7 @@ use crate::fee::fee_utils::balance_to_big_uint; use crate::fee::gas_usage::{ estimate_minimal_gas_vector, get_da_gas_cost, get_onchain_data_segment_length, }; -use crate::state::cached_state::{CachedState, StateChangesCount, TransactionalState}; +use crate::state::cached_state::{CachedState, StateChangesCount}; use crate::state::errors::StateError; use crate::state::state_api::{State, StateReader}; use crate::state::visited_pcs::VisitedPcsSet; @@ -970,6 +970,8 @@ fn test_invalid_nonce( max_resource_bounds: ResourceBoundsMapping, #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] account_cairo_version: CairoVersion, ) { + use crate::state::cached_state::TransactionalState; + let account_contract = FeatureContract::AccountWithoutValidations(account_cairo_version); let test_contract = FeatureContract::TestContract(CairoVersion::Cairo0); let state = &mut test_state( @@ -982,8 +984,7 @@ fn test_invalid_nonce( calldata: create_trivial_calldata(test_contract.get_instance_address(0)), resource_bounds: max_resource_bounds, }; - let mut transactional_state: TransactionalState<'_, _, VisitedPcsSet> = - TransactionalState::create_transactional(state); + let mut transactional_state = TransactionalState::create_transactional_for_testing(state); // Strict, negative flow: account nonce = 0, incoming tx nonce = 1. let invalid_nonce = nonce!(1_u8);