diff --git a/crates/blockifier/src/blockifier/transaction_executor_test.rs b/crates/blockifier/src/blockifier/transaction_executor_test.rs index 3089818a87..9a954fb999 100644 --- a/crates/blockifier/src/blockifier/transaction_executor_test.rs +++ b/crates/blockifier/src/blockifier/transaction_executor_test.rs @@ -227,13 +227,17 @@ fn test_invoke( } #[rstest] -fn test_l1_handler(block_context: BlockContext) { +fn test_l1_handler( + block_context: BlockContext, + #[values(TransactionVersion::ZERO, TransactionVersion::THREE)] version: TransactionVersion, +) { let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1); let state = test_state(&block_context.chain_info, BALANCE, &[(test_contract, 1)]); let tx = Transaction::L1Handler(l1handler_tx( Fee(1908000000000000), test_contract.get_instance_address(0), + version, )); let expected_bouncer_weights = BouncerWeights { state_diff_size: 4, diff --git a/crates/blockifier/src/test_utils/l1_handler.rs b/crates/blockifier/src/test_utils/l1_handler.rs index a57d08b8b6..8471a32657 100644 --- a/crates/blockifier/src/test_utils/l1_handler.rs +++ b/crates/blockifier/src/test_utils/l1_handler.rs @@ -7,7 +7,11 @@ use starknet_api::transaction::fields::Fee; use starknet_api::transaction::TransactionVersion; use starknet_types_core::felt::Felt; -pub fn l1handler_tx(l1_fee: Fee, contract_address: ContractAddress) -> L1HandlerTransaction { +pub fn l1handler_tx( + l1_fee: Fee, + contract_address: ContractAddress, + version: TransactionVersion, +) -> L1HandlerTransaction { let calldata = calldata![ Felt::from(0x123), // from_address. Felt::from(0x876), // key. @@ -15,7 +19,7 @@ pub fn l1handler_tx(l1_fee: Fee, contract_address: ContractAddress) -> L1Handler ]; executable_l1_handler_tx(L1HandlerTxArgs { - version: TransactionVersion::ZERO, + version, contract_address, entry_point_selector: selector_from_name("l1_handler_set_value"), calldata, diff --git a/crates/blockifier/src/transaction/transactions_test.rs b/crates/blockifier/src/transaction/transactions_test.rs index 7ee175ec79..cf1c8db5b0 100644 --- a/crates/blockifier/src/transaction/transactions_test.rs +++ b/crates/blockifier/src/transaction/transactions_test.rs @@ -2242,7 +2242,10 @@ fn test_only_query_flag( } #[rstest] -fn test_l1_handler(#[values(false, true)] use_kzg_da: bool) { +fn test_l1_handler( + #[values(false, true)] use_kzg_da: bool, + #[values(TransactionVersion::ZERO, TransactionVersion::THREE)] version: TransactionVersion, +) { let gas_mode = GasVectorComputationMode::NoL2Gas; let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1); let chain_info = &ChainInfo::create_for_testing(); @@ -2250,7 +2253,7 @@ fn test_l1_handler(#[values(false, true)] use_kzg_da: bool) { let block_context = &BlockContext::create_for_account_testing_with_kzg(use_kzg_da); let contract_address = test_contract.get_instance_address(0); let versioned_constants = &block_context.versioned_constants; - let tx = l1handler_tx(Fee(1), contract_address); + let tx = l1handler_tx(Fee(1), contract_address, version); let calldata = tx.tx.calldata.clone(); let key = calldata.0[1]; let value = calldata.0[2]; @@ -2384,9 +2387,9 @@ fn test_l1_handler(#[values(false, true)] use_kzg_da: bool) { // set the storage back to 0, so the fee will also include the storage write. // TODO(Meshi, 15/6/2024): change the l1_handler_set_value cairo function to - // always uptade the storage instad. + // always update the storage instead. state.set_storage_at(contract_address, StorageKey::try_from(key).unwrap(), Felt::ZERO).unwrap(); - let tx_no_fee = l1handler_tx(Fee(0), contract_address); + let tx_no_fee = l1handler_tx(Fee(0), contract_address, version); let error = tx_no_fee.execute(state, block_context, false, true).unwrap_err(); // Do not charge fee as L1Handler's resource bounds (/max fee) is 0. // Today, we check that the paid_fee is positive, no matter what was the actual fee. let expected_actual_fee = diff --git a/crates/starknet_api/src/test_utils/l1_handler.rs b/crates/starknet_api/src/test_utils/l1_handler.rs index e977469b11..0610ac8711 100644 --- a/crates/starknet_api/src/test_utils/l1_handler.rs +++ b/crates/starknet_api/src/test_utils/l1_handler.rs @@ -48,15 +48,9 @@ macro_rules! l1_handler_tx_args { pub fn executable_l1_handler_tx( l1_handler_tx_args: L1HandlerTxArgs, ) -> ExecutableL1HandlerTransaction { - let tx_version = l1_handler_tx_args.version; - // TODO(Arni): Re-enable this validation. - // if tx_version != TransactionVersion::THREE { - // panic!("Unsupported transaction version: {:?}.", l1_handler_tx_args.version); - // } - ExecutableL1HandlerTransaction { tx: L1HandlerTransaction { - version: tx_version, + version: l1_handler_tx_args.version, nonce: l1_handler_tx_args.nonce, contract_address: l1_handler_tx_args.contract_address, entry_point_selector: l1_handler_tx_args.entry_point_selector,