diff --git a/crates/blockifier/src/blockifier/block_test.rs b/crates/blockifier/src/blockifier/block_test.rs index 1822dc9349..99c8010131 100644 --- a/crates/blockifier/src/blockifier/block_test.rs +++ b/crates/blockifier/src/blockifier/block_test.rs @@ -8,12 +8,12 @@ use crate::context::ChainInfo; use crate::state::state_api::StateReader; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; -use crate::test_utils::{CairoVersion, BALANCE}; +use crate::test_utils::{CairoVersion, RunnableCairo1, BALANCE}; use crate::versioned_constants::VersionedConstants; #[test] fn test_pre_process_block() { - let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1); + let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1(RunnableCairo1::Casm)); let mut state = test_state(&ChainInfo::create_for_testing(), BALANCE, &[(test_contract, 1)]); let os_constants = VersionedConstants::create_for_testing().os_constants; diff --git a/crates/blockifier/src/blockifier/stateful_validator_test.rs b/crates/blockifier/src/blockifier/stateful_validator_test.rs index 7a0019dd3e..6e5b519dea 100644 --- a/crates/blockifier/src/blockifier/stateful_validator_test.rs +++ b/crates/blockifier/src/blockifier/stateful_validator_test.rs @@ -8,7 +8,7 @@ use crate::blockifier::stateful_validator::StatefulValidator; use crate::context::BlockContext; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::{fund_account, test_state}; -use crate::test_utils::{CairoVersion, BALANCE}; +use crate::test_utils::{CairoVersion, RunnableCairo1, BALANCE}; use crate::transaction::test_utils::{ block_context, create_account_tx_for_validate_test_nonce_0, @@ -37,7 +37,8 @@ fn test_tx_validator( block_context: BlockContext, #[values(default_l1_resource_bounds(), default_all_resource_bounds())] resource_bounds: ValidResourceBounds, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + cairo_version: CairoVersion, ) { let chain_info = &block_context.chain_info; @@ -83,7 +84,7 @@ fn test_tx_validator_skip_validate( resource_bounds: ValidResourceBounds, ) { let block_context = BlockContext::create_for_testing(); - let faulty_account = FeatureContract::FaultyAccount(CairoVersion::Cairo1); + let faulty_account = FeatureContract::FaultyAccount(CairoVersion::Cairo1(RunnableCairo1::Casm)); let state = test_state(&block_context.chain_info, BALANCE, &[(faulty_account, 1)]); // Create a transaction that does not pass validations. diff --git a/crates/blockifier/src/blockifier/transaction_executor_test.rs b/crates/blockifier/src/blockifier/transaction_executor_test.rs index a641efe3d4..e1e9e1ce82 100644 --- a/crates/blockifier/src/blockifier/transaction_executor_test.rs +++ b/crates/blockifier/src/blockifier/transaction_executor_test.rs @@ -27,6 +27,7 @@ use crate::test_utils::{ create_calldata, maybe_dummy_block_hash_and_number, CairoVersion, + RunnableCairo1, BALANCE, DEFAULT_STRK_L1_GAS_PRICE, }; @@ -92,7 +93,7 @@ fn tx_executor_test_body( )] #[case::tx_version_2( TransactionVersion::TWO, - CairoVersion::Cairo1, + CairoVersion::Cairo1(RunnableCairo1::Casm), BouncerWeights { state_diff_size: 4, message_segment_length: 0, @@ -102,7 +103,7 @@ fn tx_executor_test_body( )] #[case::tx_version_3( TransactionVersion::THREE, - CairoVersion::Cairo1, + CairoVersion::Cairo1(RunnableCairo1::Casm), BouncerWeights { state_diff_size: 4, message_segment_length: 0, @@ -112,7 +113,8 @@ fn tx_executor_test_body( )] fn test_declare( block_context: BlockContext, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] account_cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + account_cairo_version: CairoVersion, #[case] tx_version: TransactionVersion, #[case] cairo_version: CairoVersion, #[case] expected_bouncer_weights: BouncerWeights, @@ -139,7 +141,8 @@ fn test_declare( fn test_deploy_account( block_context: BlockContext, #[values(TransactionVersion::ONE, TransactionVersion::THREE)] version: TransactionVersion, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + cairo_version: CairoVersion, ) { let account_contract = FeatureContract::AccountWithoutValidations(cairo_version); let state = test_state(&block_context.chain_info, BALANCE, &[(account_contract, 0)]); @@ -204,7 +207,8 @@ fn test_deploy_account( fn test_invoke( block_context: BlockContext, #[values(TransactionVersion::ONE, TransactionVersion::THREE)] version: TransactionVersion, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + cairo_version: CairoVersion, #[case] entry_point_name: &str, #[case] entry_point_args: Vec, #[case] expected_bouncer_weights: BouncerWeights, @@ -230,7 +234,7 @@ fn test_invoke( #[rstest] fn test_l1_handler(block_context: BlockContext) { - let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1); + let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1(RunnableCairo1::Casm)); let state = test_state(&block_context.chain_info, BALANCE, &[(test_contract, 1)]); let tx = Transaction::L1Handler(l1handler_tx( @@ -265,7 +269,10 @@ fn test_bouncing(#[case] initial_bouncer_weights: BouncerWeights, #[case] n_even let block_context = BlockContext::create_for_bouncer_testing(max_n_events_in_block); let TestInitData { state, account_address, contract_address, mut nonce_manager } = - create_test_init_data(&block_context.chain_info, CairoVersion::Cairo1); + create_test_init_data( + &block_context.chain_info, + CairoVersion::Cairo1(RunnableCairo1::Casm), + ); // TODO(Yoni, 15/6/2024): turn on concurrency mode. let mut tx_executor = @@ -293,8 +300,10 @@ fn test_execute_txs_bouncing(#[values(true, false)] concurrency_enabled: bool) { let max_n_events_in_block = 10; let block_context = BlockContext::create_for_bouncer_testing(max_n_events_in_block); - let TestInitData { state, account_address, contract_address, .. } = - create_test_init_data(&block_context.chain_info, CairoVersion::Cairo1); + let TestInitData { state, account_address, contract_address, .. } = create_test_init_data( + &block_context.chain_info, + CairoVersion::Cairo1(RunnableCairo1::Casm), + ); let mut tx_executor = TransactionExecutor::new(state, block_context, config); diff --git a/crates/blockifier/src/concurrency/fee_utils_test.rs b/crates/blockifier/src/concurrency/fee_utils_test.rs index 231c4620d4..cb458c46f3 100644 --- a/crates/blockifier/src/concurrency/fee_utils_test.rs +++ b/crates/blockifier/src/concurrency/fee_utils_test.rs @@ -12,7 +12,7 @@ use crate::fee::fee_utils::get_sequencer_balance_keys; use crate::state::state_api::StateReader; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::{fund_account, test_state, test_state_inner}; -use crate::test_utils::{create_trivial_calldata, CairoVersion, BALANCE}; +use crate::test_utils::{create_trivial_calldata, CairoVersion, RunnableCairo1, BALANCE}; use crate::transaction::test_utils::{ block_context, default_all_resource_bounds, @@ -23,9 +23,11 @@ use crate::transaction::test_utils::{ pub fn test_fill_sequencer_balance_reads( block_context: BlockContext, default_all_resource_bounds: ValidResourceBounds, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] erc20_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + erc20_version: CairoVersion, ) { - let account = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); + let account = + FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1(RunnableCairo1::Casm)); let account_tx = invoke_tx_with_default_flags(invoke_tx_args! { sender_address: account.get_instance_address(0), calldata: create_trivial_calldata(account.get_instance_address(0)), @@ -61,7 +63,7 @@ pub fn test_add_fee_to_sequencer_balance( #[case] sequencer_balance_high: Felt, ) { let block_context = BlockContext::create_for_account_testing(); - let account = FeatureContract::Empty(CairoVersion::Cairo1); + let account = FeatureContract::Empty(CairoVersion::Cairo1(RunnableCairo1::Casm)); let mut state = test_state(&block_context.chain_info, Fee(0), &[(account, 1)]); let (sequencer_balance_key_low, sequencer_balance_key_high) = get_sequencer_balance_keys(&block_context); diff --git a/crates/blockifier/src/concurrency/versioned_state_test.rs b/crates/blockifier/src/concurrency/versioned_state_test.rs index 6611904b59..6db3b95a1d 100644 --- a/crates/blockifier/src/concurrency/versioned_state_test.rs +++ b/crates/blockifier/src/concurrency/versioned_state_test.rs @@ -43,7 +43,7 @@ use crate::state::state_api::{State, StateReader, UpdatableState}; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::dict_state_reader::DictStateReader; use crate::test_utils::initial_test_state::test_state; -use crate::test_utils::{CairoVersion, BALANCE, DEFAULT_STRK_L1_GAS_PRICE}; +use crate::test_utils::{CairoVersion, RunnableCairo1, BALANCE, DEFAULT_STRK_L1_GAS_PRICE}; use crate::transaction::account_transaction::AccountTransaction; use crate::transaction::objects::HasRelatedFeeType; use crate::transaction::test_utils::{default_all_resource_bounds, l1_resource_bounds}; @@ -116,7 +116,8 @@ fn test_versioned_state_proxy() { let class_hash_v10 = class_hash!(29_u8); let compiled_class_hash_v18 = compiled_class_hash!(30_u8); let contract_class_v11 = - FeatureContract::TestContract(CairoVersion::Cairo1).get_runnable_class(); + FeatureContract::TestContract(CairoVersion::Cairo1(RunnableCairo1::Casm)) + .get_runnable_class(); versioned_state_proxys[3].state().apply_writes( 3, @@ -404,7 +405,8 @@ fn test_false_validate_reads_declared_contracts( }; let version_state_proxy = safe_versioned_state.pin_version(0); let compiled_contract_calss = - FeatureContract::TestContract(CairoVersion::Cairo1).get_runnable_class(); + FeatureContract::TestContract(CairoVersion::Cairo1(RunnableCairo1::Casm)) + .get_runnable_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); assert!(!safe_versioned_state.pin_version(1).validate_reads(&tx_1_reads)); @@ -429,7 +431,9 @@ fn test_apply_writes( assert_eq!(transactional_states[0].cache.borrow().writes.class_hashes.len(), 1); // Transaction 0 contract class. - let contract_class_0 = FeatureContract::TestContract(CairoVersion::Cairo1).get_runnable_class(); + let contract_class_0 = + FeatureContract::TestContract(CairoVersion::Cairo1(RunnableCairo1::Casm)) + .get_runnable_class(); assert!(transactional_states[0].class_hash_to_class.borrow().is_empty()); 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); @@ -498,7 +502,8 @@ fn test_delete_writes( (contract_address!("0x100"), class_hash!(20_u8)), (contract_address!("0x200"), class_hash!(21_u8)), ]; - let feature_contract = FeatureContract::TestContract(CairoVersion::Cairo1); + let feature_contract = + FeatureContract::TestContract(CairoVersion::Cairo1(RunnableCairo1::Casm)); for (i, tx_state) in transactional_states.iter_mut().enumerate() { // Modify the `cache` member of the CachedState. for (contract_address, class_hash) in contract_addresses.iter() { @@ -553,7 +558,8 @@ fn test_delete_writes( fn test_delete_writes_completeness( safe_versioned_state: ThreadSafeVersionedState>, ) { - let feature_contract = FeatureContract::TestContract(CairoVersion::Cairo1); + let feature_contract = + FeatureContract::TestContract(CairoVersion::Cairo1(RunnableCairo1::Casm)); let state_maps_writes = StateMaps { nonces: HashMap::from([(contract_address!("0x1"), nonce!(1_u8))]), class_hashes: HashMap::from([( @@ -633,7 +639,8 @@ fn test_versioned_proxy_state_flow( // Clients contract class values. let contract_class_0 = FeatureContract::TestContract(CairoVersion::Cairo0).get_runnable_class(); let contract_class_2 = - FeatureContract::AccountWithLongValidate(CairoVersion::Cairo1).get_runnable_class(); + FeatureContract::AccountWithLongValidate(CairoVersion::Cairo1(RunnableCairo1::Casm)) + .get_runnable_class(); transactional_states[0].set_contract_class(class_hash, contract_class_0).unwrap(); transactional_states[2].set_contract_class(class_hash, contract_class_2.clone()).unwrap(); diff --git a/crates/blockifier/src/concurrency/worker_logic_test.rs b/crates/blockifier/src/concurrency/worker_logic_test.rs index 34af57f2ad..bf1b29647a 100644 --- a/crates/blockifier/src/concurrency/worker_logic_test.rs +++ b/crates/blockifier/src/concurrency/worker_logic_test.rs @@ -29,6 +29,7 @@ use crate::test_utils::{ create_calldata, create_trivial_calldata, CairoVersion, + RunnableCairo1, BALANCE, TEST_ERC20_CONTRACT_ADDRESS2, }; @@ -80,7 +81,8 @@ fn verify_sequencer_balance_update( #[rstest] pub fn test_commit_tx() { let block_context = BlockContext::create_for_account_testing(); - let account = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); + let account = + FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1(RunnableCairo1::Casm)); let test_contract = FeatureContract::TestContract(CairoVersion::Cairo0); let mut expected_sequencer_balance_low = 0_u128; let mut nonce_manager = NonceManager::default(); @@ -186,7 +188,8 @@ pub fn test_commit_tx() { // commit tx should be the same (except for re-execution changes). fn test_commit_tx_when_sender_is_sequencer() { let mut block_context = BlockContext::create_for_account_testing(); - let account = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); + let account = + FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1(RunnableCairo1::Casm)); let test_contract = FeatureContract::TestContract(CairoVersion::Cairo0); let account_address = account.get_instance_address(0_u16); let test_contract_address = test_contract.get_instance_address(0_u16); @@ -253,7 +256,8 @@ fn test_commit_tx_when_sender_is_sequencer() { fn test_worker_execute(default_all_resource_bounds: ValidResourceBounds) { // Settings. let block_context = BlockContext::create_for_account_testing(); - let account_contract = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); + let account_contract = + FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1(RunnableCairo1::Casm)); let test_contract = FeatureContract::TestContract(CairoVersion::Cairo0); let chain_info = &block_context.chain_info; @@ -427,7 +431,8 @@ fn test_worker_execute(default_all_resource_bounds: ValidResourceBounds) { fn test_worker_validate(default_all_resource_bounds: ValidResourceBounds) { // Settings. let block_context = BlockContext::create_for_account_testing(); - let account_contract = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); + let account_contract = + FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1(RunnableCairo1::Casm)); let test_contract = FeatureContract::TestContract(CairoVersion::Cairo0); let chain_info = &block_context.chain_info; @@ -528,7 +533,7 @@ fn test_worker_validate(default_all_resource_bounds: ValidResourceBounds) { #[rstest] #[case::declare_cairo0(CairoVersion::Cairo0, TransactionVersion::ONE)] -#[case::declare_cairo1(CairoVersion::Cairo1, TransactionVersion::THREE)] +#[case::declare_cairo1(CairoVersion::Cairo1(RunnableCairo1::Casm), TransactionVersion::THREE)] fn test_deploy_before_declare( max_fee: Fee, default_all_resource_bounds: ValidResourceBounds, @@ -538,7 +543,8 @@ fn test_deploy_before_declare( // Create the state. let block_context = BlockContext::create_for_account_testing(); let chain_info = &block_context.chain_info; - let account_contract = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); + let account_contract = + FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1(RunnableCairo1::Casm)); let state = test_state(chain_info, BALANCE, &[(account_contract, 2)]); let safe_versioned_state = safe_versioned_state_for_testing(state); @@ -624,7 +630,8 @@ fn test_deploy_before_declare( fn test_worker_commit_phase(default_all_resource_bounds: ValidResourceBounds) { // Settings. let block_context = BlockContext::create_for_account_testing(); - let account_contract = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); + let account_contract = + FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1(RunnableCairo1::Casm)); let test_contract = FeatureContract::TestContract(CairoVersion::Cairo0); let chain_info = &block_context.chain_info; @@ -717,7 +724,8 @@ fn test_worker_commit_phase_with_halt() { let max_n_events_in_block = 3; let block_context = BlockContext::create_for_bouncer_testing(max_n_events_in_block); - let account_contract = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); + let account_contract = + FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1(RunnableCairo1::Casm)); let test_contract = FeatureContract::TestContract(CairoVersion::Cairo0); let chain_info = &block_context.chain_info; diff --git a/crates/blockifier/src/execution/entry_point_test.rs b/crates/blockifier/src/execution/entry_point_test.rs index a3079aeca0..3983d7dbab 100644 --- a/crates/blockifier/src/execution/entry_point_test.rs +++ b/crates/blockifier/src/execution/entry_point_test.rs @@ -17,7 +17,7 @@ use crate::state::cached_state::CachedState; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::dict_state_reader::DictStateReader; use crate::test_utils::initial_test_state::test_state; -use crate::test_utils::{trivial_external_entry_point_new, CairoVersion, BALANCE}; +use crate::test_utils::{trivial_external_entry_point_new, CairoVersion, RunnableCairo1, BALANCE}; use crate::versioned_constants::VersionedConstants; #[test] @@ -514,7 +514,7 @@ fn test_storage_related_members() { #[test] fn test_cairo1_entry_point_segment_arena() { - let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1); + let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1(RunnableCairo1::Casm)); let chain_info = &ChainInfo::create_for_testing(); let mut state = test_state(chain_info, BALANCE, &[(test_contract, 1)]); let calldata = calldata![]; diff --git a/crates/blockifier/src/execution/stack_trace_test.rs b/crates/blockifier/src/execution/stack_trace_test.rs index 3657dcf9c4..1a4868880c 100644 --- a/crates/blockifier/src/execution/stack_trace_test.rs +++ b/crates/blockifier/src/execution/stack_trace_test.rs @@ -44,7 +44,7 @@ use crate::execution::stack_trace::{ use crate::execution::syscalls::hint_processor::ENTRYPOINT_FAILED_ERROR; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::{fund_account, test_state}; -use crate::test_utils::{create_calldata, CairoVersion, BALANCE}; +use crate::test_utils::{create_calldata, CairoVersion, RunnableCairo1, BALANCE}; use crate::transaction::account_transaction::{AccountTransaction, ExecutionFlags}; use crate::transaction::test_utils::{ block_context, @@ -147,7 +147,8 @@ An ASSERT_EQ instruction failed: 1 != 0. #[rstest] fn test_stack_trace( block_context: BlockContext, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + cairo_version: CairoVersion, ) { let chain_info = ChainInfo::create_for_testing(); let account = FeatureContract::AccountWithoutValidations(cairo_version); @@ -246,9 +247,11 @@ Error in contract (contract address: {test_contract_address_2_felt:#064x}, class let expected_trace = match cairo_version { CairoVersion::Cairo0 => expected_trace_cairo0, - CairoVersion::Cairo1 => expected_trace_cairo1, + CairoVersion::Cairo1(RunnableCairo1::Casm) => expected_trace_cairo1, #[cfg(feature = "cairo_native")] - CairoVersion::Native => panic!("Cairo Native is not yet supported"), + CairoVersion::Cairo1(RunnableCairo1::Native) => { + panic!("Cairo Native is not yet supported") + } }; assert_eq!(tx_execution_error.to_string(), expected_trace); @@ -257,8 +260,8 @@ Error in contract (contract address: {test_contract_address_2_felt:#064x}, class #[rstest] #[case(CairoVersion::Cairo0, "invoke_call_chain", "Couldn't compute operand op0. Unknown value for memory cell 1:37", (1191_u16, 1237_u16))] #[case(CairoVersion::Cairo0, "fail", "An ASSERT_EQ instruction failed: 1 != 0.", (1294_u16, 1245_u16))] -#[case(CairoVersion::Cairo1, "invoke_call_chain", "0x4469766973696f6e2062792030 ('Division by 0')", (0_u16, 0_u16))] -#[case(CairoVersion::Cairo1, "fail", "0x6661696c ('fail')", (0_u16, 0_u16))] +#[case(CairoVersion::Cairo1(RunnableCairo1::Casm), "invoke_call_chain", "0x4469766973696f6e2062792030 ('Division by 0')", (0_u16, 0_u16))] +#[case(CairoVersion::Cairo1(RunnableCairo1::Casm), "fail", "0x6661696c ('fail')", (0_u16, 0_u16))] fn test_trace_callchain_ends_with_regular_call( block_context: BlockContext, #[case] cairo_version: CairoVersion, @@ -353,7 +356,7 @@ Unknown location (pc=0:{expected_pc1}) " ) } - CairoVersion::Cairo1 => { + CairoVersion::Cairo1(RunnableCairo1::Casm) => { format!( "Transaction execution has failed: 0: Error in the called contract (contract address: {account_address_felt:#064x}, class hash: \ @@ -370,7 +373,7 @@ Error in contract (contract address: {contract_address_felt:#064x}, class hash: ) } #[cfg(feature = "cairo_native")] - CairoVersion::Native => { + CairoVersion::Cairo1(RunnableCairo1::Native) => { todo!("Cairo Native is not yet supported here") } }; @@ -383,10 +386,10 @@ Error in contract (contract address: {contract_address_felt:#064x}, class hash: #[case(CairoVersion::Cairo0, "invoke_call_chain", "Couldn't compute operand op0. Unknown value for memory cell 1:23", 1_u8, 1_u8, (49_u16, 1221_u16, 1191_u16, 1276_u16))] #[case(CairoVersion::Cairo0, "fail", "An ASSERT_EQ instruction failed: 1 != 0.", 0_u8, 0_u8, (37_u16, 1203_u16, 1294_u16, 1298_u16))] #[case(CairoVersion::Cairo0, "fail", "An ASSERT_EQ instruction failed: 1 != 0.", 0_u8, 1_u8, (49_u16, 1221_u16, 1294_u16, 1298_u16))] -#[case(CairoVersion::Cairo1, "invoke_call_chain", "0x4469766973696f6e2062792030 ('Division by 0')", 1_u8, 0_u8, (9631_u16, 9631_u16, 0_u16, 0_u16))] -#[case(CairoVersion::Cairo1, "invoke_call_chain", "0x4469766973696f6e2062792030 ('Division by 0')", 1_u8, 1_u8, (9631_u16, 9700_u16, 0_u16, 0_u16))] -#[case(CairoVersion::Cairo1, "fail", "0x6661696c ('fail')", 0_u8, 0_u8, (9631_u16, 9631_u16, 0_u16, 0_u16))] -#[case(CairoVersion::Cairo1, "fail", "0x6661696c ('fail')", 0_u8, 1_u8, (9631_u16, 9700_u16, 0_u16, 0_u16))] +#[case(CairoVersion::Cairo1(RunnableCairo1::Casm), "invoke_call_chain", "0x4469766973696f6e2062792030 ('Division by 0')", 1_u8, 0_u8, (9631_u16, 9631_u16, 0_u16, 0_u16))] +#[case(CairoVersion::Cairo1(RunnableCairo1::Casm), "invoke_call_chain", "0x4469766973696f6e2062792030 ('Division by 0')", 1_u8, 1_u8, (9631_u16, 9700_u16, 0_u16, 0_u16))] +#[case(CairoVersion::Cairo1(RunnableCairo1::Casm), "fail", "0x6661696c ('fail')", 0_u8, 0_u8, (9631_u16, 9631_u16, 0_u16, 0_u16))] +#[case(CairoVersion::Cairo1(RunnableCairo1::Casm), "fail", "0x6661696c ('fail')", 0_u8, 1_u8, (9631_u16, 9700_u16, 0_u16, 0_u16))] fn test_trace_call_chain_with_syscalls( block_context: BlockContext, #[case] cairo_version: CairoVersion, @@ -510,7 +513,7 @@ Unknown location (pc=0:{expected_pc3}) " ) } - CairoVersion::Cairo1 => { + CairoVersion::Cairo1(RunnableCairo1::Casm) => { format!( "Transaction execution has failed: 0: Error in the called contract (contract address: {account_address_felt:#064x}, class hash: \ @@ -529,7 +532,7 @@ Error in contract (contract address: {address_felt:#064x}, class hash: {test_con ) } #[cfg(feature = "cairo_native")] - CairoVersion::Native => { + CairoVersion::Cairo1(RunnableCairo1::Native) => { todo!("Cairo Native not yet supported here.") } }; @@ -579,7 +582,8 @@ fn test_validate_trace( #[case] tx_type: TransactionType, #[case] entry_point_name: &str, #[case] tx_version: TransactionVersion, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + cairo_version: CairoVersion, ) { let create_for_account_testing = &BlockContext::create_for_account_testing(); let block_context = create_for_account_testing; @@ -630,7 +634,7 @@ An ASSERT_EQ instruction failed: 1 != 0. ", class_hash.0 ), - CairoVersion::Cairo1 => format!( + CairoVersion::Cairo1(RunnableCairo1::Casm) => format!( "The `validate` entry point panicked with: Error in contract (contract address: {contract_address:#064x}, class hash: {:#064x}, selector: \ {selector:#064x}): @@ -639,7 +643,9 @@ Error in contract (contract address: {contract_address:#064x}, class hash: {:#06 class_hash.0 ), #[cfg(feature = "cairo_native")] - CairoVersion::Native => todo!("Cairo Native is not yet supported here."), + CairoVersion::Cairo1(RunnableCairo1::Native) => { + todo!("Cairo Native is not yet supported here.") + } }; // Clean pc locations from the trace. @@ -657,7 +663,8 @@ Error in contract (contract address: {contract_address:#064x}, class hash: {:#06 /// traceback (including correct class hash, contract address and constructor entry point selector). fn test_account_ctor_frame_stack_trace( block_context: BlockContext, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + cairo_version: CairoVersion, ) { let chain_info = &block_context.chain_info; let faulty_account = FeatureContract::FaultyAccount(cairo_version); @@ -702,7 +709,7 @@ Unknown location (pc=0:206) An ASSERT_EQ instruction failed: 1 != 0. " .to_string(), - CairoVersion::Cairo1 => format!( + CairoVersion::Cairo1(RunnableCairo1::Casm) => format!( "Execution failed. Failure reason: Error in contract (contract address: {expected_address:#064x}, class hash: {:#064x}, selector: \ {expected_selector:#064x}): @@ -712,7 +719,7 @@ Error in contract (contract address: {expected_address:#064x}, class hash: {:#06 ) .to_string(), #[cfg(feature = "cairo_native")] - CairoVersion::Native => { + CairoVersion::Cairo1(RunnableCairo1::Native) => { todo!("Cairo Native not yet supported here.") } }; @@ -729,7 +736,8 @@ Error in contract (contract address: {expected_address:#064x}, class hash: {:#06 fn test_contract_ctor_frame_stack_trace( block_context: BlockContext, default_all_resource_bounds: ValidResourceBounds, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + cairo_version: CairoVersion, ) { let chain_info = &block_context.chain_info; let account = FeatureContract::AccountWithoutValidations(cairo_version); @@ -832,7 +840,7 @@ An ASSERT_EQ instruction failed: 1 != 0. ctor_offset - 9 ) } - CairoVersion::Cairo1 => { + CairoVersion::Cairo1(RunnableCairo1::Casm) => { // TODO(Dori, 1/1/2025): Get lowest level PC locations from Cairo1 errors (ctor offset // does not appear in the trace). format!( @@ -853,7 +861,7 @@ Error in contract (contract address: {expected_address:#064x}, class hash: {:#06 ) } #[cfg(feature = "cairo_native")] - CairoVersion::Native => { + CairoVersion::Cairo1(RunnableCairo1::Native) => { todo!("Cairo Native not yet supported here.") } }; diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/call_contract.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/call_contract.rs index 0122adebea..ab6bd202d0 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/call_contract.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/call_contract.rs @@ -24,21 +24,23 @@ use crate::test_utils::{ trivial_external_entry_point_new, CairoVersion, CompilerBasedVersion, + RunnableCairo1, BALANCE, }; -#[cfg_attr(feature = "cairo_native", test_case(CairoVersion::Native; "Native"))] -#[test_case(CairoVersion::Cairo1;"VM")] +#[cfg_attr(feature = "cairo_native", test_case(CairoVersion::Cairo1(RunnableCairo1::Native); "Native"))] +#[test_case(CairoVersion::Cairo1(RunnableCairo1::Casm);"VM")] fn test_call_contract_that_panics(cairo_version: CairoVersion) { let test_contract = FeatureContract::TestContract(cairo_version); - let empty_contract = FeatureContract::Empty(CairoVersion::Cairo1); + let empty_contract = FeatureContract::Empty(CairoVersion::Cairo1(RunnableCairo1::Casm)); let chain_info = &ChainInfo::create_for_testing(); let mut state = test_state(chain_info, BALANCE, &[(test_contract, 1), (empty_contract, 0)]); let new_class_hash = empty_contract.get_class_hash(); let outer_entry_point_selector = selector_from_name("test_call_contract_revert"); let calldata = create_calldata( - FeatureContract::TestContract(CairoVersion::Cairo1).get_instance_address(0), + FeatureContract::TestContract(CairoVersion::Cairo1(RunnableCairo1::Casm)) + .get_instance_address(0), "test_revert_helper", &[new_class_hash.0], ); @@ -71,14 +73,14 @@ fn test_call_contract_that_panics(cairo_version: CairoVersion) { #[cfg_attr( feature = "cairo_native", test_case( - FeatureContract::TestContract(CairoVersion::Native), - FeatureContract::TestContract(CairoVersion::Native); + FeatureContract::TestContract(CairoVersion::Cairo1(RunnableCairo1::Native)), + FeatureContract::TestContract(CairoVersion::Cairo1(RunnableCairo1::Native)); "Call Contract between two contracts using Native" ) )] #[test_case( - FeatureContract::TestContract(CairoVersion::Cairo1), - FeatureContract::TestContract(CairoVersion::Cairo1); + FeatureContract::TestContract(CairoVersion::Cairo1(RunnableCairo1::Casm)), + FeatureContract::TestContract(CairoVersion::Cairo1(RunnableCairo1::Casm)); "Call Contract between two contracts using VM" )] fn test_call_contract(outer_contract: FeatureContract, inner_contract: FeatureContract) { @@ -117,15 +119,15 @@ fn test_tracked_resources( #[values( CompilerBasedVersion::CairoVersion(CairoVersion::Cairo0), CompilerBasedVersion::OldCairo1, - CompilerBasedVersion::CairoVersion(CairoVersion::Cairo1), - CompilerBasedVersion::CairoVersion(CairoVersion::Native) + CompilerBasedVersion::CairoVersion(CairoVersion::Cairo1(RunnableCairo1::Casm)), + CompilerBasedVersion::CairoVersion(CairoVersion::Cairo1(RunnableCairo1::Native)) )] outer_version: CompilerBasedVersion, #[values( CompilerBasedVersion::CairoVersion(CairoVersion::Cairo0), CompilerBasedVersion::OldCairo1, - CompilerBasedVersion::CairoVersion(CairoVersion::Cairo1), - CompilerBasedVersion::CairoVersion(CairoVersion::Native) + CompilerBasedVersion::CairoVersion(CairoVersion::Cairo1(RunnableCairo1::Casm)), + CompilerBasedVersion::CairoVersion(CairoVersion::Cairo1(RunnableCairo1::Native)) )] inner_version: CompilerBasedVersion, ) { @@ -139,13 +141,13 @@ fn test_tracked_resources( #[values( CompilerBasedVersion::CairoVersion(CairoVersion::Cairo0), CompilerBasedVersion::OldCairo1, - CompilerBasedVersion::CairoVersion(CairoVersion::Cairo1) + CompilerBasedVersion::CairoVersion(CairoVersion::Cairo1(RunnableCairo1::Casm)) )] outer_version: CompilerBasedVersion, #[values( CompilerBasedVersion::CairoVersion(CairoVersion::Cairo0), CompilerBasedVersion::OldCairo1, - CompilerBasedVersion::CairoVersion(CairoVersion::Cairo1) + CompilerBasedVersion::CairoVersion(CairoVersion::Cairo1(RunnableCairo1::Casm)) )] inner_version: CompilerBasedVersion, ) { @@ -185,15 +187,15 @@ fn test_tracked_resources_fn( assert_eq!(execution.inner_calls.first().unwrap().tracked_resource, expected_inner_resource); } -#[test_case(CompilerBasedVersion::CairoVersion(CairoVersion::Cairo0), CompilerBasedVersion::CairoVersion(CairoVersion::Cairo1); "Cairo0_and_Cairo1")] -#[test_case(CompilerBasedVersion::OldCairo1, CompilerBasedVersion::CairoVersion(CairoVersion::Cairo1); "OldCairo1_and_Cairo1")] +#[test_case(CompilerBasedVersion::CairoVersion(CairoVersion::Cairo0), CompilerBasedVersion::CairoVersion(CairoVersion::Cairo1(RunnableCairo1::Casm)); "Cairo0_and_Cairo1")] +#[test_case(CompilerBasedVersion::OldCairo1, CompilerBasedVersion::CairoVersion(CairoVersion::Cairo1(RunnableCairo1::Casm)); "OldCairo1_and_Cairo1")] #[cfg_attr( feature = "cairo_native", - test_case(CompilerBasedVersion::CairoVersion(CairoVersion::Cairo0), CompilerBasedVersion::CairoVersion(CairoVersion::Native); "Cairo0_and_Native") + test_case(CompilerBasedVersion::CairoVersion(CairoVersion::Cairo0), CompilerBasedVersion::CairoVersion(CairoVersion::Cairo1(RunnableCairo1::Native)); "Cairo0_and_Native") )] #[cfg_attr( feature = "cairo_native", - test_case(CompilerBasedVersion::OldCairo1, CompilerBasedVersion::CairoVersion(CairoVersion::Native); "OldCairo1_and_Native") + test_case(CompilerBasedVersion::OldCairo1, CompilerBasedVersion::CairoVersion(CairoVersion::Cairo1(RunnableCairo1::Native)); "OldCairo1_and_Native") )] fn test_tracked_resources_nested( cairo_steps_contract_version: CompilerBasedVersion, diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs index c358f92910..5fc6876ced 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs @@ -12,14 +12,19 @@ use crate::retdata; use crate::state::state_api::StateReader; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; -use crate::test_utils::{calldata_for_deploy_test, trivial_external_entry_point_new, CairoVersion}; - -#[test_case(CairoVersion::Cairo1;"VM")] -#[cfg_attr(feature = "cairo_native", test_case(CairoVersion::Native;"Native"))] +use crate::test_utils::{ + calldata_for_deploy_test, + trivial_external_entry_point_new, + CairoVersion, + RunnableCairo1, +}; + +#[test_case(CairoVersion::Cairo1(RunnableCairo1::Casm);"VM")] +#[cfg_attr(feature = "cairo_native", test_case(CairoVersion::Cairo1(RunnableCairo1::Native);"Native"))] fn no_constructor(cairo_version: CairoVersion) { // TODO(Yoni): share the init code of the tests in this file. let deployer_contract = FeatureContract::TestContract(cairo_version); - let empty_contract = FeatureContract::Empty(CairoVersion::Cairo1); + let empty_contract = FeatureContract::Empty(CairoVersion::Cairo1(RunnableCairo1::Casm)); let class_hash = empty_contract.get_class_hash(); let mut state = test_state( @@ -59,11 +64,11 @@ fn no_constructor(cairo_version: CairoVersion) { assert_eq!(state.get_class_hash_at(deployed_contract_address).unwrap(), class_hash); } -#[test_case(CairoVersion::Cairo1;"VM")] -#[cfg_attr(feature = "cairo_native", test_case(CairoVersion::Native;"Native"))] +#[test_case(CairoVersion::Cairo1(RunnableCairo1::Casm);"VM")] +#[cfg_attr(feature = "cairo_native", test_case(CairoVersion::Cairo1(RunnableCairo1::Native);"Native"))] fn no_constructor_nonempty_calldata(cairo_version: CairoVersion) { let deployer_contract = FeatureContract::TestContract(cairo_version); - let empty_contract = FeatureContract::Empty(CairoVersion::Cairo1); + let empty_contract = FeatureContract::Empty(CairoVersion::Cairo1(RunnableCairo1::Casm)); let class_hash = empty_contract.get_class_hash(); let mut state = test_state( @@ -87,8 +92,8 @@ fn no_constructor_nonempty_calldata(cairo_version: CairoVersion) { )); } -#[test_case(CairoVersion::Cairo1;"VM")] -#[cfg_attr(feature = "cairo_native", test_case(CairoVersion::Native;"Native"))] +#[test_case(CairoVersion::Cairo1(RunnableCairo1::Casm);"VM")] +#[cfg_attr(feature = "cairo_native", test_case(CairoVersion::Cairo1(RunnableCairo1::Native);"Native"))] fn with_constructor(cairo_version: CairoVersion) { let deployer_contract = FeatureContract::TestContract(cairo_version); let mut state = test_state(&ChainInfo::create_for_testing(), Fee(0), &[(deployer_contract, 1)]); @@ -138,8 +143,8 @@ fn with_constructor(cairo_version: CairoVersion) { assert_eq!(state.get_class_hash_at(contract_address).unwrap(), class_hash); } -#[test_case(CairoVersion::Cairo1;"VM")] -#[cfg_attr(feature = "cairo_native", test_case(CairoVersion::Native;"Native"))] +#[test_case(CairoVersion::Cairo1(RunnableCairo1::Casm);"VM")] +#[cfg_attr(feature = "cairo_native", test_case(CairoVersion::Cairo1(RunnableCairo1::Native);"Native"))] fn to_unavailable_address(cairo_version: CairoVersion) { let deployer_contract = FeatureContract::TestContract(cairo_version); let mut state = test_state(&ChainInfo::create_for_testing(), Fee(0), &[(deployer_contract, 1)]); diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/emit_event.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/emit_event.rs index 46e7564bd2..78e2bad691 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/emit_event.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/emit_event.rs @@ -15,7 +15,7 @@ use crate::execution::errors::EntryPointExecutionError; use crate::execution::syscalls::hint_processor::EmitEventError; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; -use crate::test_utils::{trivial_external_entry_point_new, CairoVersion, BALANCE}; +use crate::test_utils::{trivial_external_entry_point_new, CairoVersion, RunnableCairo1, BALANCE}; use crate::versioned_constants::VersionedConstants; const KEYS: [Felt; 2] = [Felt::from_hex_unchecked("0x2019"), Felt::from_hex_unchecked("0x2020")]; @@ -26,8 +26,8 @@ const DATA: [Felt; 3] = [ ]; const N_EMITTED_EVENTS: [Felt; 1] = [Felt::from_hex_unchecked("0x1")]; -#[cfg_attr(feature = "cairo_native", test_case(CairoVersion::Native;"Native"))] -#[test_case(CairoVersion::Cairo1;"VM")] +#[cfg_attr(feature = "cairo_native", test_case(CairoVersion::Cairo1(RunnableCairo1::Native);"Native"))] +#[test_case(CairoVersion::Cairo1(RunnableCairo1::Casm);"VM")] fn positive_flow(cairo_version: CairoVersion) { let test_contract = FeatureContract::TestContract(cairo_version); let call_info = emit_events(test_contract, &N_EMITTED_EVENTS, &KEYS, &DATA) @@ -47,8 +47,8 @@ fn positive_flow(cairo_version: CairoVersion) { ); } -#[cfg_attr(feature = "cairo_native", test_case(CairoVersion::Native;"Native"))] -#[test_case(CairoVersion::Cairo1;"VM")] +#[cfg_attr(feature = "cairo_native", test_case(CairoVersion::Cairo1(RunnableCairo1::Native);"Native"))] +#[test_case(CairoVersion::Cairo1(RunnableCairo1::Casm);"VM")] fn data_length_exceeds_limit(cairo_version: CairoVersion) { let test_contract = FeatureContract::TestContract(cairo_version); let versioned_constants = VersionedConstants::create_for_testing(); @@ -67,8 +67,8 @@ fn data_length_exceeds_limit(cairo_version: CairoVersion) { assert!(error_message.contains(&expected_error.to_string())); } -#[cfg_attr(feature = "cairo_native", test_case(CairoVersion::Native;"Native"))] -#[test_case(CairoVersion::Cairo1;"VM")] +#[cfg_attr(feature = "cairo_native", test_case(CairoVersion::Cairo1(RunnableCairo1::Native);"Native"))] +#[test_case(CairoVersion::Cairo1(RunnableCairo1::Casm);"VM")] fn keys_length_exceeds_limit(cairo_version: CairoVersion) { let test_contract = FeatureContract::TestContract(cairo_version); let versioned_constants = VersionedConstants::create_for_testing(); @@ -88,8 +88,8 @@ fn keys_length_exceeds_limit(cairo_version: CairoVersion) { assert!(error_message.contains(&expected_error.to_string())); } -#[cfg_attr(feature = "cairo_native", test_case(CairoVersion::Native;"Native"))] -#[test_case(CairoVersion::Cairo1;"VM")] +#[cfg_attr(feature = "cairo_native", test_case(CairoVersion::Cairo1(RunnableCairo1::Native);"Native"))] +#[test_case(CairoVersion::Cairo1(RunnableCairo1::Casm);"VM")] fn event_number_exceeds_limit(cairo_version: CairoVersion) { let test_contract = FeatureContract::TestContract(cairo_version); let versioned_constants = VersionedConstants::create_for_testing(); diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/get_block_hash.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/get_block_hash.rs index 37ef06006f..54a8eee18f 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/get_block_hash.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/get_block_hash.rs @@ -18,6 +18,7 @@ use crate::test_utils::initial_test_state::test_state; use crate::test_utils::{ trivial_external_entry_point_new, CairoVersion, + RunnableCairo1, BALANCE, CURRENT_BLOCK_NUMBER, }; @@ -42,8 +43,8 @@ fn initialize_state(test_contract: FeatureContract) -> (CachedState( assert_eq!(empty_tx_gas_usage_vector, GasVector::default()); // Declare. - for cairo_version in [CairoVersion::Cairo0, CairoVersion::Cairo1] { + for cairo_version in [CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm)] { let empty_contract = FeatureContract::Empty(cairo_version).get_class(); let class_info = calculate_class_info_for_testing(empty_contract); let declare_tx_starknet_resources = StarknetResources::new( diff --git a/crates/blockifier/src/test_utils.rs b/crates/blockifier/src/test_utils.rs index b238ee13e3..958da9297b 100644 --- a/crates/blockifier/src/test_utils.rs +++ b/crates/blockifier/src/test_utils.rs @@ -57,14 +57,19 @@ pub const TEST_ERC20_CONTRACT_CLASS_HASH: &str = "0x1010"; pub const ERC20_CONTRACT_PATH: &str = "./ERC20/ERC20_Cairo0/ERC20_without_some_syscalls/ERC20/\ erc20_contract_without_some_syscalls_compiled.json"; +#[derive(Clone, Hash, PartialEq, Eq, Copy, Debug)] +pub enum RunnableCairo1 { + Casm, + #[cfg(feature = "cairo_native")] + Native, +} + // TODO(Aviv, 14/7/2024): Move from test utils module, and use it in ContractClassVersionMismatch // error. #[derive(Clone, Hash, PartialEq, Eq, Copy, Debug)] pub enum CairoVersion { Cairo0, - Cairo1, - #[cfg(feature = "cairo_native")] - Native, + Cairo1(RunnableCairo1), } impl Default for CairoVersion { @@ -81,7 +86,7 @@ impl CairoVersion { if tx_version == TransactionVersion::ZERO || tx_version == TransactionVersion::ONE { CairoVersion::Cairo0 } else if tx_version == TransactionVersion::TWO || tx_version == TransactionVersion::THREE { - CairoVersion::Cairo1 + CairoVersion::Cairo1(RunnableCairo1::Casm) } else { panic!("Transaction version {:?} is not supported.", tx_version) } @@ -89,19 +94,19 @@ impl CairoVersion { pub fn other(&self) -> Self { match self { - Self::Cairo0 => Self::Cairo1, - Self::Cairo1 => Self::Cairo0, + Self::Cairo0 => CairoVersion::Cairo1(RunnableCairo1::Casm), + CairoVersion::Cairo1(RunnableCairo1::Casm) => Self::Cairo0, #[cfg(feature = "cairo_native")] - Self::Native => panic!("There is no other version for native"), + CairoVersion::Cairo1(RunnableCairo1::Native) => { + panic!("There is no other version for native") + } } } pub fn is_cairo0(&self) -> bool { match self { Self::Cairo0 => true, - Self::Cairo1 => false, - #[cfg(feature = "cairo_native")] - Self::Native => false, + Self::Cairo1(_) => false, } } } @@ -127,9 +132,7 @@ impl CompilerBasedVersion { Self::CairoVersion(CairoVersion::Cairo0) | Self::OldCairo1 => { TrackedResource::CairoSteps } - Self::CairoVersion(CairoVersion::Cairo1) => TrackedResource::SierraGas, - #[cfg(feature = "cairo_native")] - Self::CairoVersion(CairoVersion::Native) => TrackedResource::SierraGas, + Self::CairoVersion(CairoVersion::Cairo1(_)) => TrackedResource::SierraGas, } } } @@ -341,19 +344,8 @@ macro_rules! check_tx_execution_error_for_invalid_scenario { $validate_constructor, ); } - CairoVersion::Cairo1 => { - if let $crate::transaction::errors::TransactionExecutionError::ValidateTransactionError { - error, .. - } = $error { - assert_eq!( - error.to_string(), - "Execution failed. Failure reason: 0x496e76616c6964207363656e6172696f \ - ('Invalid scenario')." - ) - } - } - #[cfg(feature = "cairo_native")] - CairoVersion::Native => { + + CairoVersion::Cairo1(_) => { if let $crate::transaction::errors::TransactionExecutionError::ValidateTransactionError { error, .. } = $error { diff --git a/crates/blockifier/src/test_utils/contracts.rs b/crates/blockifier/src/test_utils/contracts.rs index 1f6d7bb603..06331b9649 100644 --- a/crates/blockifier/src/test_utils/contracts.rs +++ b/crates/blockifier/src/test_utils/contracts.rs @@ -25,7 +25,7 @@ use crate::execution::native::contract_class::NativeCompiledClassV1; use crate::test_utils::cairo_compile::starknet_compile; use crate::test_utils::cairo_compile::{cairo0_compile, cairo1_compile, CompilationArtifacts}; use crate::test_utils::struct_impls::LoadContractFromFile; -use crate::test_utils::{get_raw_contract_class, CairoVersion}; +use crate::test_utils::{get_raw_contract_class, CairoVersion, RunnableCairo1}; pub const CAIRO1_FEATURE_CONTRACTS_DIR: &str = "feature_contracts/cairo1"; pub const SIERRA_CONTRACTS_SUBDIR: &str = "sierra"; @@ -124,9 +124,11 @@ impl FeatureContract { | Self::TestContract(version) | Self::ERC20(version) => *version, Self::SecurityTests => CairoVersion::Cairo0, - Self::LegacyTestContract | Self::CairoStepsTestContract => CairoVersion::Cairo1, + Self::LegacyTestContract | Self::CairoStepsTestContract => { + CairoVersion::Cairo1(RunnableCairo1::Casm) + } #[cfg(feature = "cairo_native")] - Self::SierraExecutionInfoV1Contract => CairoVersion::Native, + Self::SierraExecutionInfoV1Contract => CairoVersion::Cairo1(RunnableCairo1::Native), } } @@ -169,9 +171,13 @@ impl FeatureContract { pub fn get_compiled_class_hash(&self) -> CompiledClassHash { match self.cairo_version() { CairoVersion::Cairo0 => CompiledClassHash(Felt::ZERO), - CairoVersion::Cairo1 => CompiledClassHash(felt!(self.get_integer_base())), + CairoVersion::Cairo1(RunnableCairo1::Casm) => { + CompiledClassHash(felt!(self.get_integer_base())) + } #[cfg(feature = "cairo_native")] - CairoVersion::Native => CompiledClassHash(felt!(self.get_integer_base())), + CairoVersion::Cairo1(RunnableCairo1::Native) => { + CompiledClassHash(felt!(self.get_integer_base())) + } } } @@ -186,11 +192,11 @@ impl FeatureContract { CairoVersion::Cairo0 => { ContractClass::V0(DeprecatedContractClass::from_file(&self.get_compiled_path())) } - CairoVersion::Cairo1 => { + CairoVersion::Cairo1(RunnableCairo1::Casm) => { ContractClass::V1(CasmContractClass::from_file(&self.get_compiled_path())) } #[cfg(feature = "cairo_native")] - CairoVersion::Native => { + CairoVersion::Cairo1(RunnableCairo1::Native) => { panic!("Native contracts are not supported by this function.") } } @@ -198,7 +204,7 @@ impl FeatureContract { pub fn get_runnable_class(&self) -> RunnableCompiledClass { #[cfg(feature = "cairo_native")] - if CairoVersion::Native == self.cairo_version() { + if CairoVersion::Cairo1(RunnableCairo1::Native) == self.cairo_version() { let native_contract_class = NativeCompiledClassV1::compile_or_get_cached(&self.get_compiled_path()); return RunnableCompiledClass::V1Native(native_contract_class); @@ -229,9 +235,9 @@ impl FeatureContract { fn get_cairo_version_bit(&self) -> u32 { match self.cairo_version() { CairoVersion::Cairo0 => 0, - CairoVersion::Cairo1 => CAIRO1_BIT, + CairoVersion::Cairo1(RunnableCairo1::Casm) => CAIRO1_BIT, #[cfg(feature = "cairo_native")] - CairoVersion::Native => CAIRO1_BIT, + CairoVersion::Cairo1(RunnableCairo1::Native) => CAIRO1_BIT, } } @@ -291,9 +297,11 @@ impl FeatureContract { if let Self::ERC20(cairo_version) = self { match cairo_version { CairoVersion::Cairo0 => ERC20_CAIRO0_CONTRACT_SOURCE_PATH, - CairoVersion::Cairo1 => ERC20_CAIRO1_CONTRACT_SOURCE_PATH, + CairoVersion::Cairo1(RunnableCairo1::Casm) => ERC20_CAIRO1_CONTRACT_SOURCE_PATH, #[cfg(feature = "cairo_native")] - CairoVersion::Native => todo!("ERC20 contract is not supported by Native yet"), + CairoVersion::Cairo1(RunnableCairo1::Native) => { + todo!("ERC20 contract is not supported by Native yet") + } } .into() } else { @@ -301,9 +309,9 @@ impl FeatureContract { "feature_contracts/cairo{}/{}.cairo", match self.cairo_version() { CairoVersion::Cairo0 => "0", - CairoVersion::Cairo1 => "1", + CairoVersion::Cairo1(RunnableCairo1::Casm) => "1", #[cfg(feature = "cairo_native")] - CairoVersion::Native => "_native", + CairoVersion::Cairo1(RunnableCairo1::Native) => "_native", }, self.get_non_erc20_base_name() ) @@ -312,7 +320,8 @@ impl FeatureContract { pub fn get_sierra_path(&self) -> String { assert_ne!(self.cairo_version(), CairoVersion::Cairo0); - assert_ne!(self, &Self::ERC20(CairoVersion::Cairo1)); + // TODO (Meshi 01/01/2025): add a spacial case for ERC20 when ERC20 sierra is supported. + assert!(!matches!(self, &Self::ERC20(CairoVersion::Cairo1(_)))); format!( "{CAIRO1_FEATURE_CONTRACTS_DIR}/{SIERRA_CONTRACTS_SUBDIR}/{}.sierra.json", self.get_non_erc20_base_name() @@ -324,9 +333,11 @@ impl FeatureContract { if let Self::ERC20(cairo_version) = self { match cairo_version { CairoVersion::Cairo0 => ERC20_CAIRO0_CONTRACT_PATH, - CairoVersion::Cairo1 => ERC20_CAIRO1_CONTRACT_PATH, + CairoVersion::Cairo1(RunnableCairo1::Casm) => ERC20_CAIRO1_CONTRACT_PATH, #[cfg(feature = "cairo_native")] - CairoVersion::Native => todo!("ERC20 cannot be tested with Native"), + CairoVersion::Cairo1(RunnableCairo1::Native) => { + todo!("ERC20 cannot be tested with Native") + } } .into() } else { @@ -335,16 +346,16 @@ impl FeatureContract { "feature_contracts/cairo{}/compiled/{}{}.json", match cairo_version { CairoVersion::Cairo0 => "0", - CairoVersion::Cairo1 => "1", + CairoVersion::Cairo1(RunnableCairo1::Casm) => "1", #[cfg(feature = "cairo_native")] - CairoVersion::Native => "_native", + CairoVersion::Cairo1(RunnableCairo1::Native) => "_native", }, self.get_non_erc20_base_name(), match cairo_version { CairoVersion::Cairo0 => "_compiled", - CairoVersion::Cairo1 => ".casm", + CairoVersion::Cairo1(RunnableCairo1::Casm) => ".casm", #[cfg(feature = "cairo_native")] - CairoVersion::Native => ".sierra", + CairoVersion::Cairo1(RunnableCairo1::Native) => ".sierra", } ) } @@ -374,12 +385,12 @@ impl FeatureContract { }; cairo0_compile(self.get_source_path(), extra_arg, false) } - CairoVersion::Cairo1 => { + CairoVersion::Cairo1(RunnableCairo1::Casm) => { let (tag_override, cargo_nightly_arg) = self.fixed_tag_and_rust_toolchain(); cairo1_compile(self.get_source_path(), tag_override, cargo_nightly_arg) } #[cfg(feature = "cairo_native")] - CairoVersion::Native => { + CairoVersion::Cairo1(RunnableCairo1::Native) => { let (tag_override, cargo_nightly_arg) = self.fixed_tag_and_rust_toolchain(); let sierra_output = starknet_compile( self.get_source_path(), diff --git a/crates/blockifier/src/transaction/account_transactions_test.rs b/crates/blockifier/src/transaction/account_transactions_test.rs index 97cd130b14..c902dd7c70 100644 --- a/crates/blockifier/src/transaction/account_transactions_test.rs +++ b/crates/blockifier/src/transaction/account_transactions_test.rs @@ -74,6 +74,7 @@ use crate::test_utils::{ get_tx_resources, CairoVersion, CompilerBasedVersion, + RunnableCairo1, BALANCE, DEFAULT_L1_DATA_GAS_MAX_AMOUNT, DEFAULT_L1_GAS_AMOUNT, @@ -112,8 +113,9 @@ use crate::utils::u64_from_usize; #[rstest] fn test_circuit(block_context: BlockContext, default_all_resource_bounds: ValidResourceBounds) { - let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1); - let account = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); + let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1(RunnableCairo1::Casm)); + let account = + FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1(RunnableCairo1::Casm)); let chain_info = &block_context.chain_info; let state = &mut test_state(chain_info, BALANCE, &[(test_contract, 1), (account, 1)]); let test_contract_address = test_contract.get_instance_address(0); @@ -145,8 +147,9 @@ fn test_circuit(block_context: BlockContext, default_all_resource_bounds: ValidR #[rstest] fn test_rc96_holes(block_context: BlockContext, default_all_resource_bounds: ValidResourceBounds) { - let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1); - let account = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); + let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1(RunnableCairo1::Casm)); + let account = + FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1(RunnableCairo1::Casm)); let chain_info = &block_context.chain_info; let state = &mut test_state(chain_info, BALANCE, &[(test_contract, 1), (account, 1)]); let test_contract_address = test_contract.get_instance_address(0); @@ -448,8 +451,9 @@ fn test_max_fee_limit_validate( let chain_info = &block_context.chain_info; let gas_computation_mode = resource_bounds.get_gas_vector_computation_mode(); let TestInitData { mut state, account_address, contract_address, mut nonce_manager } = - create_test_init_data(chain_info, CairoVersion::Cairo1); - let grindy_validate_account = FeatureContract::AccountWithLongValidate(CairoVersion::Cairo1); + create_test_init_data(chain_info, CairoVersion::Cairo1(RunnableCairo1::Casm)); + let grindy_validate_account = + FeatureContract::AccountWithLongValidate(CairoVersion::Cairo1(RunnableCairo1::Casm)); let grindy_class_hash = grindy_validate_account.get_class_hash(); let block_info = &block_context.block_info; let class_info = calculate_class_info_for_testing(grindy_validate_account.get_class()); @@ -577,7 +581,8 @@ fn test_max_fee_limit_validate( #[case::all_bounds(TransactionVersion::THREE, default_all_resource_bounds())] fn test_recursion_depth_exceeded( #[case] tx_version: TransactionVersion, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + cairo_version: CairoVersion, block_context: BlockContext, max_fee: Fee, #[case] resource_bounds: ValidResourceBounds, @@ -719,7 +724,8 @@ fn test_revert_invoke( /// Tests that failing account deployment should not change state (no fee charge or nonce bump). fn test_fail_deploy_account( block_context: BlockContext, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + cairo_version: CairoVersion, #[values(TransactionVersion::ONE, TransactionVersion::THREE)] tx_version: TransactionVersion, ) { let chain_info = &block_context.chain_info; @@ -767,7 +773,8 @@ fn test_fail_declare(block_context: BlockContext, max_fee: Fee) { let TestInitData { mut state, account_address, mut nonce_manager, .. } = create_test_init_data(chain_info, CairoVersion::Cairo0); let class_hash = class_hash!(0xdeadeadeaf72_u128); - let contract_class = FeatureContract::Empty(CairoVersion::Cairo1).get_class(); + let contract_class = + FeatureContract::Empty(CairoVersion::Cairo1(RunnableCairo1::Casm)).get_class(); let next_nonce = nonce_manager.next(account_address); // Cannot fail executing a declare tx unless it's V2 or above, and already declared. @@ -832,7 +839,8 @@ fn test_reverted_reach_steps_limit( mut block_context: BlockContext, #[case] version: TransactionVersion, #[case] resource_bounds: ValidResourceBounds, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + cairo_version: CairoVersion, ) { let TestInitData { mut state, account_address, contract_address, mut nonce_manager } = create_test_init_data(&block_context.chain_info, cairo_version); @@ -941,7 +949,8 @@ fn test_n_reverted_steps( block_context: BlockContext, #[values(default_l1_resource_bounds(), default_all_resource_bounds())] resource_bounds: ValidResourceBounds, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + cairo_version: CairoVersion, ) { let TestInitData { mut state, account_address, contract_address, mut nonce_manager } = create_test_init_data(&block_context.chain_info, cairo_version); @@ -1179,7 +1188,8 @@ fn test_insufficient_max_fee_reverts( block_context: BlockContext, #[values(default_l1_resource_bounds(), default_all_resource_bounds())] resource_bounds: ValidResourceBounds, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + cairo_version: CairoVersion, ) { let gas_mode = resource_bounds.get_gas_vector_computation_mode(); let TestInitData { mut state, account_address, contract_address, mut nonce_manager } = @@ -1273,7 +1283,8 @@ fn test_insufficient_max_fee_reverts( fn test_deploy_account_constructor_storage_write( default_all_resource_bounds: ValidResourceBounds, block_context: BlockContext, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + cairo_version: CairoVersion, ) { let grindy_account = FeatureContract::AccountWithLongValidate(cairo_version); let class_hash = grindy_account.get_class_hash(); @@ -1318,7 +1329,8 @@ fn test_count_actual_storage_changes( default_all_resource_bounds: ValidResourceBounds, #[case] version: TransactionVersion, #[case] fee_type: FeeType, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + cairo_version: CairoVersion, ) { // FeeType according to version. @@ -1516,7 +1528,8 @@ fn test_concurrency_execute_fee_transfer( const SEQUENCER_BALANCE_LOW_INITIAL: u128 = 50; let block_context = BlockContext::create_for_account_testing(); - let account = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); + let account = + FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1(RunnableCairo1::Casm)); let test_contract = FeatureContract::TestContract(CairoVersion::Cairo0); let chain_info = &block_context.chain_info; let state = &mut test_state(chain_info, BALANCE, &[(account, 1), (test_contract, 1)]); @@ -1610,7 +1623,8 @@ fn test_concurrent_fee_transfer_when_sender_is_sequencer( #[case] version: TransactionVersion, ) { let mut block_context = BlockContext::create_for_account_testing(); - let account = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); + let account = + FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1(RunnableCairo1::Casm)); let account_address = account.get_instance_address(0_u16); block_context.block_info.sequencer_address = account_address; let test_contract = FeatureContract::TestContract(CairoVersion::Cairo0); @@ -1646,10 +1660,10 @@ fn test_concurrent_fee_transfer_when_sender_is_sequencer( /// history. #[rstest] #[case(&[ - CompilerBasedVersion::CairoVersion(CairoVersion::Cairo1), - CompilerBasedVersion::CairoVersion(CairoVersion::Cairo1), + CompilerBasedVersion::CairoVersion(CairoVersion::Cairo1(RunnableCairo1::Casm)), + CompilerBasedVersion::CairoVersion(CairoVersion::Cairo1(RunnableCairo1::Casm)), CompilerBasedVersion::CairoVersion(CairoVersion::Cairo0), - CompilerBasedVersion::CairoVersion(CairoVersion::Cairo1) + CompilerBasedVersion::CairoVersion(CairoVersion::Cairo1(RunnableCairo1::Casm)) ])] // TODO(Tzahi, 1/12/2024): Add a case with OldCairo1 instead of Cairo0. fn test_initial_gas( @@ -1657,7 +1671,7 @@ fn test_initial_gas( default_all_resource_bounds: ValidResourceBounds, ) { let block_context = BlockContext::create_for_account_testing(); - let account_version = CairoVersion::Cairo1; + let account_version = CairoVersion::Cairo1(RunnableCairo1::Casm); let account = FeatureContract::AccountWithoutValidations(account_version); let account_address = account.get_instance_address(0_u16); let used_test_contracts: HashSet = @@ -1709,7 +1723,10 @@ fn test_initial_gas( false, ) => { // First time we are in VM mode. - assert_eq!(prev_version, &CompilerBasedVersion::CairoVersion(CairoVersion::Cairo1)); + assert_eq!( + prev_version, + &CompilerBasedVersion::CairoVersion(CairoVersion::Cairo1(RunnableCairo1::Casm)) + ); assert_eq!( curr_initial_gas, block_context.versioned_constants.default_initial_gas_cost() @@ -1720,7 +1737,11 @@ fn test_initial_gas( // prev_version is a non Cairo0 contract, thus it consumes gas from the initial // gas. assert!(curr_initial_gas < prev_initial_gas); - if version == &CompilerBasedVersion::CairoVersion(CairoVersion::Cairo1) { + if version + == &CompilerBasedVersion::CairoVersion(CairoVersion::Cairo1( + RunnableCairo1::Casm, + )) + { assert!(execute_call_info.execution.gas_consumed > 0); } else { assert!(execute_call_info.execution.gas_consumed == 0); @@ -1742,7 +1763,8 @@ fn test_revert_in_execute( block_context: BlockContext, default_all_resource_bounds: ValidResourceBounds, ) { - let account = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); + let account = + FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1(RunnableCairo1::Casm)); let chain_info = &block_context.chain_info; let state = &mut test_state(chain_info, BALANCE, &[(account, 1)]); let account_address = account.get_instance_address(0); @@ -1776,8 +1798,8 @@ fn test_revert_in_execute( } #[rstest] -#[cfg_attr(feature = "cairo_native", case::native(CairoVersion::Native))] -#[case::vm(CairoVersion::Cairo1)] +#[cfg_attr(feature = "cairo_native", case::native(CairoVersion::Cairo1(RunnableCairo1::Native)))] +#[case::vm(CairoVersion::Cairo1(RunnableCairo1::Casm))] fn test_call_contract_that_panics( #[case] cairo_version: CairoVersion, mut block_context: BlockContext, @@ -1789,7 +1811,8 @@ fn test_call_contract_that_panics( block_context.versioned_constants.enable_reverts = enable_reverts; let test_contract = FeatureContract::TestContract(cairo_version); // TODO(Yoni): use `class_version` here once the feature contract fully supports Native. - let account = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); + let account = + FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1(RunnableCairo1::Casm)); let chain_info = &block_context.chain_info; let state = &mut test_state(chain_info, BALANCE, &[(test_contract, 1), (account, 1)]); let test_contract_address = test_contract.get_instance_address(0); @@ -1799,7 +1822,10 @@ fn test_call_contract_that_panics( let new_class_hash = test_contract.get_class_hash(); let calldata = [ - *FeatureContract::TestContract(CairoVersion::Cairo1).get_instance_address(0).0.key(), + *FeatureContract::TestContract(CairoVersion::Cairo1(RunnableCairo1::Casm)) + .get_instance_address(0) + .0 + .key(), selector_from_name(inner_selector).0, felt!(1_u8), new_class_hash.0, diff --git a/crates/blockifier/src/transaction/transactions_test.rs b/crates/blockifier/src/transaction/transactions_test.rs index 39ef530f6f..479ba7104a 100644 --- a/crates/blockifier/src/transaction/transactions_test.rs +++ b/crates/blockifier/src/transaction/transactions_test.rs @@ -100,6 +100,7 @@ use crate::test_utils::{ get_tx_resources, test_erc20_sequencer_balance_key, CairoVersion, + RunnableCairo1, SaltManager, BALANCE, CURRENT_BLOCK_NUMBER, @@ -196,30 +197,40 @@ fn expected_validate_call_info( ) -> Option { let retdata = match cairo_version { CairoVersion::Cairo0 => Retdata::default(), - CairoVersion::Cairo1 => retdata!(*constants::VALIDATE_RETDATA), + CairoVersion::Cairo1(RunnableCairo1::Casm) => retdata!(*constants::VALIDATE_RETDATA), #[cfg(feature = "cairo_native")] - CairoVersion::Native => retdata!(*constants::VALIDATE_RETDATA), + CairoVersion::Cairo1(RunnableCairo1::Native) => { + retdata!(*constants::VALIDATE_RETDATA) + } }; // Extra range check in regular (invoke) validate call, due to passing the calldata as an array. let n_range_checks = match cairo_version { CairoVersion::Cairo0 => { usize::from(entry_point_selector_name == constants::VALIDATE_ENTRY_POINT_NAME) } - CairoVersion::Cairo1 => { + CairoVersion::Cairo1(RunnableCairo1::Casm) => { if entry_point_selector_name == constants::VALIDATE_ENTRY_POINT_NAME { 7 } else { 2 } } #[cfg(feature = "cairo_native")] - CairoVersion::Native => { + CairoVersion::Cairo1(RunnableCairo1::Native) => { if entry_point_selector_name == constants::VALIDATE_ENTRY_POINT_NAME { 7 } else { 2 } } }; let n_steps = match (entry_point_selector_name, cairo_version) { (constants::VALIDATE_DEPLOY_ENTRY_POINT_NAME, CairoVersion::Cairo0) => 13_usize, - (constants::VALIDATE_DEPLOY_ENTRY_POINT_NAME, CairoVersion::Cairo1) => 32_usize, + ( + constants::VALIDATE_DEPLOY_ENTRY_POINT_NAME, + CairoVersion::Cairo1(RunnableCairo1::Casm), + ) => 32_usize, (constants::VALIDATE_DECLARE_ENTRY_POINT_NAME, CairoVersion::Cairo0) => 12_usize, - (constants::VALIDATE_DECLARE_ENTRY_POINT_NAME, CairoVersion::Cairo1) => 28_usize, + ( + constants::VALIDATE_DECLARE_ENTRY_POINT_NAME, + CairoVersion::Cairo1(RunnableCairo1::Casm), + ) => 28_usize, (constants::VALIDATE_ENTRY_POINT_NAME, CairoVersion::Cairo0) => 21_usize, - (constants::VALIDATE_ENTRY_POINT_NAME, CairoVersion::Cairo1) => 100_usize, + (constants::VALIDATE_ENTRY_POINT_NAME, CairoVersion::Cairo1(RunnableCairo1::Casm)) => { + 100_usize + } (selector, _) => panic!("Selector {selector} is not a known validate selector."), }; let resources = ExecutionResources { @@ -436,7 +447,7 @@ fn add_kzg_da_resources_to_resources_mapping( execute_gas_consumed: 112080, inner_call_initial_gas: versioned_constants_for_account_testing().default_initial_gas_cost(), }, - CairoVersion::Cairo1)] + CairoVersion::Cairo1(RunnableCairo1::Casm))] // TODO(Tzahi): Add calls to cairo1 test contracts (where gas flows to and from the inner call). fn test_invoke_tx( #[values(default_l1_resource_bounds(), default_all_resource_bounds())] @@ -653,7 +664,8 @@ fn verify_storage_after_invoke_advanced_operations( fn test_invoke_tx_advanced_operations( block_context: BlockContext, default_all_resource_bounds: ValidResourceBounds, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + cairo_version: CairoVersion, ) { let block_context = &block_context; let account = FeatureContract::AccountWithoutValidations(cairo_version); @@ -821,7 +833,8 @@ fn test_state_get_fee_token_balance( block_context: BlockContext, #[case] tx_version: TransactionVersion, #[case] fee_type: FeeType, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] account_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + account_version: CairoVersion, ) { let block_context = &block_context; let chain_info = &block_context.chain_info; @@ -917,7 +930,8 @@ fn test_estimate_minimal_gas_vector( #[values(true, false)] use_kzg_da: bool, #[values(GasVectorComputationMode::NoL2Gas, GasVectorComputationMode::All)] gas_vector_computation_mode: GasVectorComputationMode, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] account_cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + account_cairo_version: CairoVersion, ) { block_context.block_info.use_kzg_da = use_kzg_da; let block_context = &block_context; @@ -953,7 +967,8 @@ fn test_max_fee_exceeds_balance( #[values(default_l1_resource_bounds(), default_all_resource_bounds())] resource_bounds: ValidResourceBounds, #[values(true, false)] use_kzg_da: bool, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] account_cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + account_cairo_version: CairoVersion, ) { block_context.block_info.use_kzg_da = use_kzg_da; let block_context = &block_context; @@ -999,7 +1014,8 @@ fn test_max_fee_exceeds_balance( }); assert_resource_bounds_exceed_balance_failure(state, block_context, invalid_tx); // Declare. - let contract_to_declare = FeatureContract::Empty(CairoVersion::Cairo1); + let contract_to_declare = + FeatureContract::Empty(CairoVersion::Cairo1(RunnableCairo1::Casm)); let class_info = calculate_class_info_for_testing(contract_to_declare.get_class()); let invalid_tx = AccountTransaction::new_with_default_flags(executable_declare_tx( declare_tx_args! { @@ -1063,7 +1079,8 @@ fn test_max_fee_exceeds_balance( fn test_insufficient_new_resource_bounds_pre_validation( mut block_context: BlockContext, #[values(true, false)] use_kzg_da: bool, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] account_cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + account_cairo_version: CairoVersion, ) { block_context.block_info.use_kzg_da = use_kzg_da; let block_context = &block_context; @@ -1195,7 +1212,8 @@ fn test_insufficient_new_resource_bounds_pre_validation( #[rstest] fn test_insufficient_deprecated_resource_bounds_pre_validation( block_context: BlockContext, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] account_cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + account_cairo_version: CairoVersion, ) { let block_context = &block_context; let account_contract = FeatureContract::AccountWithoutValidations(account_cairo_version); @@ -1287,7 +1305,8 @@ fn test_actual_fee_gt_resource_bounds( mut block_context: BlockContext, #[case] resource_bounds: ValidResourceBounds, #[case] overdraft_resource: Resource, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] account_cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + account_cairo_version: CairoVersion, ) { let block_context = &mut block_context; block_context.versioned_constants.allocation_cost = AllocationCost::ZERO; @@ -1363,7 +1382,8 @@ fn test_actual_fee_gt_resource_bounds( fn test_invalid_nonce( block_context: BlockContext, default_all_resource_bounds: ValidResourceBounds, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] account_cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + account_cairo_version: CairoVersion, ) { let account_contract = FeatureContract::AccountWithoutValidations(account_cairo_version); let test_contract = FeatureContract::TestContract(CairoVersion::Cairo0); @@ -1486,11 +1506,12 @@ fn declare_expected_state_changes_count(version: TransactionVersion) -> StateCha #[rstest] #[case(TransactionVersion::ZERO, CairoVersion::Cairo0)] #[case(TransactionVersion::ONE, CairoVersion::Cairo0)] -#[case(TransactionVersion::TWO, CairoVersion::Cairo1)] -#[case(TransactionVersion::THREE, CairoVersion::Cairo1)] +#[case(TransactionVersion::TWO, CairoVersion::Cairo1(RunnableCairo1::Casm))] +#[case(TransactionVersion::THREE, CairoVersion::Cairo1(RunnableCairo1::Casm))] fn test_declare_tx( default_all_resource_bounds: ValidResourceBounds, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] account_cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + account_cairo_version: CairoVersion, #[case] tx_version: TransactionVersion, #[case] empty_contract_version: CairoVersion, #[values(false, true)] use_kzg_da: bool, @@ -1660,7 +1681,8 @@ fn test_declare_tx_v0(default_l1_resource_bounds: ValidResourceBounds) { let tx_version = TransactionVersion::ZERO; let block_context = &BlockContext::create_for_account_testing(); let empty_contract = FeatureContract::Empty(CairoVersion::Cairo0); - let account = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); + let account = + FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1(RunnableCairo1::Casm)); let chain_info = &block_context.chain_info; let state = &mut test_state(chain_info, BALANCE, &[(account, 1)]); let class_hash = empty_contract.get_class_hash(); @@ -1694,7 +1716,8 @@ fn test_declare_tx_v0(default_l1_resource_bounds: ValidResourceBounds) { #[rstest] fn test_deploy_account_tx( - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + cairo_version: CairoVersion, #[values(false, true)] use_kzg_da: bool, default_all_resource_bounds: ValidResourceBounds, ) { @@ -1942,7 +1965,8 @@ fn test_validate_accounts_tx( #[case] tx_type: TransactionType, #[case] validate_constructor: bool, #[case] tx_version: TransactionVersion, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + cairo_version: CairoVersion, ) { let block_context = &block_context; let account_balance = Fee(0); @@ -1993,7 +2017,7 @@ fn test_validate_accounts_tx( validate_constructor, ); - if let CairoVersion::Cairo1 = cairo_version { + if let CairoVersion::Cairo1(RunnableCairo1::Casm) = cairo_version { // Try to use the syscall get_block_hash (forbidden). let account_tx = create_account_tx_for_validate_test_nonce_0(FaultyAccountTxCreatorArgs { scenario: GET_BLOCK_HASH, @@ -2098,7 +2122,7 @@ fn test_validate_accounts_tx( assert!(result.is_ok(), "Execution failed: {:?}", result.unwrap_err()); } - if let CairoVersion::Cairo1 = cairo_version { + if let CairoVersion::Cairo1(RunnableCairo1::Casm) = cairo_version { let account_tx = create_account_tx_for_validate_test( // Call the syscall get_execution_info and assert the returned block_info was // modified for validate. @@ -2125,8 +2149,10 @@ fn test_validate_accounts_tx( fn test_valid_flag( block_context: BlockContext, default_all_resource_bounds: ValidResourceBounds, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] account_cairo_version: CairoVersion, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] test_contract_cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + account_cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + test_contract_cairo_version: CairoVersion, ) { let block_context = &block_context; let account_contract = FeatureContract::AccountWithoutValidations(account_cairo_version); @@ -2161,8 +2187,9 @@ fn test_only_query_flag( ) { let account_balance = BALANCE; let block_context = &block_context; - let account = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); - let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1); + let account = + FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1(RunnableCairo1::Casm)); + let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1(RunnableCairo1::Casm)); let state = &mut test_state( &block_context.chain_info, account_balance, @@ -2255,7 +2282,7 @@ fn test_only_query_flag( #[rstest] fn test_l1_handler(#[values(false, true)] use_kzg_da: bool) { let gas_mode = GasVectorComputationMode::NoL2Gas; - let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1); + let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1(RunnableCairo1::Casm)); let chain_info = &ChainInfo::create_for_testing(); let state = &mut test_state(chain_info, BALANCE, &[(test_contract, 1)]); let block_context = &BlockContext::create_for_account_testing_with_kzg(use_kzg_da); @@ -2493,10 +2520,12 @@ fn test_emit_event_exceeds_limit( #[case] event_data: Vec, #[case] n_emitted_events: usize, #[case] expected_error: Option, - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + cairo_version: CairoVersion, ) { let test_contract = FeatureContract::TestContract(cairo_version); - let account_contract = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); + let account_contract = + FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1(RunnableCairo1::Casm)); let block_context = &block_context; let state = &mut test_state( &block_context.chain_info, diff --git a/crates/blockifier/tests/feature_contracts_compatibility_test.rs b/crates/blockifier/tests/feature_contracts_compatibility_test.rs index 18ca3deece..2cacee6189 100644 --- a/crates/blockifier/tests/feature_contracts_compatibility_test.rs +++ b/crates/blockifier/tests/feature_contracts_compatibility_test.rs @@ -9,7 +9,7 @@ use blockifier::test_utils::contracts::{ CAIRO1_FEATURE_CONTRACTS_DIR, SIERRA_CONTRACTS_SUBDIR, }; -use blockifier::test_utils::CairoVersion; +use blockifier::test_utils::{CairoVersion, RunnableCairo1}; use pretty_assertions::assert_eq; use rstest::rstest; @@ -194,15 +194,15 @@ fn verify_and_get_files(cairo_version: CairoVersion) -> Vec CAIRO0_FEATURE_CONTRACTS_DIR, - CairoVersion::Cairo1 => CAIRO1_FEATURE_CONTRACTS_DIR, + CairoVersion::Cairo1(RunnableCairo1::Casm) => CAIRO1_FEATURE_CONTRACTS_DIR, #[cfg(feature = "cairo_native")] - CairoVersion::Native => NATIVE_FEATURE_CONTRACTS_DIR, + CairoVersion::Cairo1(RunnableCairo1::Native) => NATIVE_FEATURE_CONTRACTS_DIR, }; let compiled_extension = match cairo_version { CairoVersion::Cairo0 => "_compiled.json", - CairoVersion::Cairo1 => ".casm.json", + CairoVersion::Cairo1(RunnableCairo1::Casm) => ".casm.json", #[cfg(feature = "cairo_native")] - CairoVersion::Native => ".sierra.json", + CairoVersion::Cairo1(RunnableCairo1::Native) => ".sierra.json", }; for file in fs::read_dir(directory).unwrap() { let path = file.unwrap().path(); @@ -238,7 +238,7 @@ fn verify_and_get_files(cairo_version: CairoVersion) -> Vec { + CairoVersion::Cairo1(RunnableCairo1::Casm) => { let existing_sierra_path = format!("{directory}/{SIERRA_CONTRACTS_SUBDIR}/{file_name}.sierra.json"); paths.push(FeatureContractMetadata::Cairo1(Cairo1FeatureContractMetadata { @@ -249,7 +249,7 @@ fn verify_and_get_files(cairo_version: CairoVersion) -> Vec { + CairoVersion::Cairo1(RunnableCairo1::Native) => { let existing_sierra_path = format!("{directory}/{SIERRA_CONTRACTS_SUBDIR}/{file_name}.sierra.json"); paths.push(FeatureContractMetadata::Cairo1(Cairo1FeatureContractMetadata { @@ -294,7 +294,8 @@ fn verify_feature_contracts_cairo1_logic( #[rstest] fn verify_feature_contracts_match_enum( - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + cairo_version: CairoVersion, ) { let mut compiled_paths_from_enum: Vec = FeatureContract::all_feature_contracts() .filter(|contract| contract.cairo_version() == cairo_version) @@ -311,11 +312,11 @@ fn verify_feature_contracts_match_enum( compiled_paths_on_filesystem.sort(); assert_eq!(compiled_paths_from_enum, compiled_paths_on_filesystem); } - CairoVersion::Cairo1 => { + CairoVersion::Cairo1(RunnableCairo1::Casm) => { verify_feature_contracts_cairo1_logic(cairo_version, compiled_paths_from_enum); } #[cfg(feature = "cairo_native")] - CairoVersion::Native => { + CairoVersion::Cairo1(RunnableCairo1::Native) => { verify_feature_contracts_cairo1_logic(cairo_version, compiled_paths_from_enum); } } @@ -325,7 +326,8 @@ fn verify_feature_contracts_match_enum( #[rstest] #[ignore] fn verify_feature_contracts( - #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, + #[values(CairoVersion::Cairo0, CairoVersion::Cairo1(RunnableCairo1::Casm))] + cairo_version: CairoVersion, ) { let fix_features = std::env::var("FIX_FEATURE_TEST").is_ok(); verify_feature_contracts_compatibility(fix_features, cairo_version) diff --git a/crates/mempool_test_utils/src/starknet_api_test_utils.rs b/crates/mempool_test_utils/src/starknet_api_test_utils.rs index e6338ec67f..ba46f766cc 100644 --- a/crates/mempool_test_utils/src/starknet_api_test_utils.rs +++ b/crates/mempool_test_utils/src/starknet_api_test_utils.rs @@ -7,7 +7,7 @@ use std::sync::LazyLock; use assert_matches::assert_matches; use blockifier::test_utils::contracts::FeatureContract; -use blockifier::test_utils::{create_trivial_calldata, CairoVersion}; +use blockifier::test_utils::{create_trivial_calldata, CairoVersion, RunnableCairo1}; use infra_utils::path::resolve_project_relative_path; use pretty_assertions::assert_ne; use starknet_api::block::GasPrice; @@ -79,7 +79,8 @@ pub fn declare_tx() -> RpcTransaction { let contract_class = contract_class(); let compiled_class_hash = *COMPILED_CLASS_HASH; - let account_contract = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); + let account_contract = + FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1(RunnableCairo1::Casm)); let account_address = account_contract.get_instance_address(0); let mut nonce_manager = NonceManager::default(); let nonce = nonce_manager.next(account_address); @@ -151,11 +152,12 @@ type SharedNonceManager = Rc>; /// /// ``` /// use blockifier::test_utils::contracts::FeatureContract; -/// use blockifier::test_utils::CairoVersion; +/// use blockifier::test_utils::{CairoVersion, RunnableCairo1}; /// use mempool_test_utils::starknet_api_test_utils::MultiAccountTransactionGenerator; /// /// let mut tx_generator = MultiAccountTransactionGenerator::new(); -/// let some_account_type = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); +/// let some_account_type = +/// FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1(RunnableCairo1::Casm)); /// // Initialize multiple accounts, these can be any account type in `FeatureContract`. /// tx_generator.register_account_for_flow_test(some_account_type.clone()); /// tx_generator.register_account_for_flow_test(some_account_type); diff --git a/crates/starknet_gateway/src/gateway_test.rs b/crates/starknet_gateway/src/gateway_test.rs index c388f886c6..e8502f43ae 100644 --- a/crates/starknet_gateway/src/gateway_test.rs +++ b/crates/starknet_gateway/src/gateway_test.rs @@ -2,7 +2,7 @@ use std::sync::Arc; use assert_matches::assert_matches; use blockifier::context::ChainInfo; -use blockifier::test_utils::CairoVersion; +use blockifier::test_utils::{CairoVersion, RunnableCairo1}; use mempool_test_utils::starknet_api_test_utils::{declare_tx, invoke_tx}; use mockall::predicate::eq; use papyrus_network_types::network_types::BroadcastedMessageMetadata; @@ -41,7 +41,7 @@ fn compiler() -> GatewayCompiler { #[fixture] fn state_reader_factory() -> TestStateReaderFactory { - local_test_state_reader_factory(CairoVersion::Cairo1, false) + local_test_state_reader_factory(CairoVersion::Cairo1(RunnableCairo1::Casm), false) } #[fixture] @@ -79,7 +79,7 @@ impl MockDependencies { type SenderAddress = ContractAddress; fn create_tx() -> (RpcTransaction, SenderAddress) { - let tx = invoke_tx(CairoVersion::Cairo1); + let tx = invoke_tx(CairoVersion::Cairo1(RunnableCairo1::Casm)); let sender_address = match &tx { RpcTransaction::Invoke(starknet_api::rpc_transaction::RpcInvokeTransaction::V3( invoke_tx, diff --git a/crates/starknet_gateway/src/stateful_transaction_validator_test.rs b/crates/starknet_gateway/src/stateful_transaction_validator_test.rs index 2223e5697d..de734b71cd 100644 --- a/crates/starknet_gateway/src/stateful_transaction_validator_test.rs +++ b/crates/starknet_gateway/src/stateful_transaction_validator_test.rs @@ -3,7 +3,7 @@ use blockifier::blockifier::stateful_validator::{ StatefulValidatorResult as BlockifierStatefulValidatorResult, }; use blockifier::context::ChainInfo; -use blockifier::test_utils::CairoVersion; +use blockifier::test_utils::{CairoVersion, RunnableCairo1}; use blockifier::transaction::errors::{TransactionFeeError, TransactionPreValidationError}; use mempool_test_utils::starknet_api_test_utils::{ executable_invoke_tx as create_executable_invoke_tx, @@ -54,11 +54,11 @@ fn stateful_validator() -> StatefulTransactionValidator { // TODO(Arni): consider testing declare and deploy account. #[rstest] #[case::valid_tx( - create_executable_invoke_tx(CairoVersion::Cairo1), + create_executable_invoke_tx(CairoVersion::Cairo1(RunnableCairo1::Casm)), Ok(()) )] #[case::invalid_tx( - create_executable_invoke_tx(CairoVersion::Cairo1), + create_executable_invoke_tx(CairoVersion::Cairo1(RunnableCairo1::Casm)), Err(STATEFUL_VALIDATOR_FEE_ERROR) )] fn test_stateful_tx_validator( @@ -83,7 +83,8 @@ fn test_stateful_tx_validator( #[rstest] fn test_instantiate_validator(stateful_validator: StatefulTransactionValidator) { - let state_reader_factory = local_test_state_reader_factory(CairoVersion::Cairo1, false); + let state_reader_factory = + local_test_state_reader_factory(CairoVersion::Cairo1(RunnableCairo1::Casm), false); let mut mock_state_reader_factory = MockStateReaderFactory::new(); diff --git a/crates/starknet_integration_tests/src/state_reader.rs b/crates/starknet_integration_tests/src/state_reader.rs index 0dedd6055f..a04340f2a4 100644 --- a/crates/starknet_integration_tests/src/state_reader.rs +++ b/crates/starknet_integration_tests/src/state_reader.rs @@ -6,6 +6,7 @@ use blockifier::context::ChainInfo; use blockifier::test_utils::contracts::FeatureContract; use blockifier::test_utils::{ CairoVersion, + RunnableCairo1, BALANCE, CURRENT_BLOCK_TIMESTAMP, DEFAULT_ETH_L1_GAS_PRICE, @@ -89,7 +90,7 @@ fn create_test_state( }; let default_test_contracts = [ FeatureContract::TestContract(CairoVersion::Cairo0), - FeatureContract::TestContract(CairoVersion::Cairo1), + FeatureContract::TestContract(CairoVersion::Cairo1(RunnableCairo1::Casm)), ] .into_iter() .map(into_contract) diff --git a/crates/starknet_integration_tests/src/utils.rs b/crates/starknet_integration_tests/src/utils.rs index 2cbf630e05..2ebdec966a 100644 --- a/crates/starknet_integration_tests/src/utils.rs +++ b/crates/starknet_integration_tests/src/utils.rs @@ -4,7 +4,7 @@ use std::time::Duration; use blockifier::context::ChainInfo; use blockifier::test_utils::contracts::FeatureContract; -use blockifier::test_utils::CairoVersion; +use blockifier::test_utils::{CairoVersion, RunnableCairo1}; use mempool_test_utils::starknet_api_test_utils::{AccountId, MultiAccountTransactionGenerator}; use papyrus_consensus::config::ConsensusConfig; use papyrus_network::network_manager::test_utils::create_network_configs_connected_to_broadcast_channels; @@ -111,7 +111,7 @@ pub fn create_integration_test_tx_generator() -> MultiAccountTransactionGenerato MultiAccountTransactionGenerator::new(); for account in [ - FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1), + FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1(RunnableCairo1::Casm)), FeatureContract::AccountWithoutValidations(CairoVersion::Cairo0), ] { tx_generator.register_account_for_flow_test(account);