From cb264d95c168dae9aa0c014aaefeabbcf8cedd6e Mon Sep 17 00:00:00 2001 From: Aviv Greenburg Date: Tue, 3 Dec 2024 17:24:44 +0200 Subject: [PATCH] chore(blockifier): remove only_qury from IvokeTxArgs --- .../src/transaction/account_transactions_test.rs | 2 -- .../src/transaction/execution_flavors_test.rs | 15 +++------------ crates/blockifier/src/transaction/test_utils.rs | 10 +++------- .../src/transaction/transactions_test.rs | 1 - 4 files changed, 6 insertions(+), 22 deletions(-) diff --git a/crates/blockifier/src/transaction/account_transactions_test.rs b/crates/blockifier/src/transaction/account_transactions_test.rs index d5955f4d0c..32365b81db 100644 --- a/crates/blockifier/src/transaction/account_transactions_test.rs +++ b/crates/blockifier/src/transaction/account_transactions_test.rs @@ -307,7 +307,6 @@ fn test_account_flow_test( max_fee: Fee, #[case] tx_version: TransactionVersion, #[case] resource_bounds: ValidResourceBounds, - #[values(true, false)] only_query: bool, ) { let TestInitData { mut state, account_address, contract_address, mut nonce_manager } = create_test_init_data(&block_context.chain_info, CairoVersion::Cairo0); @@ -323,7 +322,6 @@ fn test_account_flow_test( version: tx_version, resource_bounds, nonce: nonce_manager.next(account_address), - only_query, }, ) .unwrap(); diff --git a/crates/blockifier/src/transaction/execution_flavors_test.rs b/crates/blockifier/src/transaction/execution_flavors_test.rs index d369fc0d09..084c4566b8 100644 --- a/crates/blockifier/src/transaction/execution_flavors_test.rs +++ b/crates/blockifier/src/transaction/execution_flavors_test.rs @@ -185,7 +185,6 @@ fn recurse_calldata(contract_address: ContractAddress, fail: bool, depth: u32) - fn get_pre_validate_test_args( cairo_version: CairoVersion, version: TransactionVersion, - only_query: bool, ) -> (BlockContext, CachedState, InvokeTxArgs, NonceManager) { let block_context = BlockContext::create_for_account_testing(); let max_fee = MAX_FEE; @@ -203,7 +202,6 @@ fn get_pre_validate_test_args( sender_address: account_address, calldata: create_trivial_calldata(test_contract_address), version, - only_query, }; (block_context, state, pre_validation_base_args, nonce_manager) } @@ -219,7 +217,7 @@ fn test_invalid_nonce_pre_validate( #[values(TransactionVersion::ONE, TransactionVersion::THREE)] version: TransactionVersion, ) { let (block_context, mut state, pre_validation_base_args, _) = - get_pre_validate_test_args(cairo_version, version, only_query); + get_pre_validate_test_args(cairo_version, version); let account_address = pre_validation_base_args.sender_address; // First scenario: invalid nonce. Regardless of flags, should fail. @@ -261,7 +259,7 @@ fn test_simulate_validate_pre_validate_with_charge_fee( ) { let charge_fee = true; let (block_context, mut state, pre_validation_base_args, mut nonce_manager) = - get_pre_validate_test_args(cairo_version, version, only_query); + get_pre_validate_test_args(cairo_version, version); let account_address = pre_validation_base_args.sender_address; // First scenario: minimal fee not covered. Actual fee is precomputed. @@ -379,7 +377,7 @@ fn test_simulate_validate_pre_validate_not_charge_fee( ) { let charge_fee = false; let (block_context, mut state, pre_validation_base_args, mut nonce_manager) = - get_pre_validate_test_args(cairo_version, version, only_query); + get_pre_validate_test_args(cairo_version, version); let account_address = pre_validation_base_args.sender_address; let tx = invoke_tx(invoke_tx_args! { @@ -596,14 +594,12 @@ fn test_simulate_validate_charge_fee_mid_execution( resource_bounds: default_l1_resource_bounds, sender_address: account_address, version, - only_query, }; // First scenario: logic error. Should result in revert; actual fee should be shown. let tx = invoke_tx(invoke_tx_args! { calldata: recurse_calldata(test_contract_address, true, 3), nonce: nonce_manager.next(account_address), - only_query, ..execution_base_args.clone() }); let account_tx = AccountTransaction { @@ -655,8 +651,6 @@ fn test_simulate_validate_charge_fee_mid_execution( resource_bounds: l1_resource_bounds(gas_bound, gas_price.into()), calldata: recurse_calldata(test_contract_address, false, 1000), nonce: nonce_manager.next(account_address), - only_query, - ..execution_base_args.clone() }); let account_tx = AccountTransaction { @@ -804,7 +798,6 @@ fn test_simulate_validate_charge_fee_post_execution( nonce: nonce_manager.next(account_address), sender_address: account_address, version, - only_query, }); let account_tx = AccountTransaction { tx, @@ -867,8 +860,6 @@ fn test_simulate_validate_charge_fee_post_execution( nonce: nonce_manager.next(account_address), sender_address: account_address, version, - only_query, - }); let account_tx = AccountTransaction { tx, diff --git a/crates/blockifier/src/transaction/test_utils.rs b/crates/blockifier/src/transaction/test_utils.rs index 982b65bc91..4f8f0de287 100644 --- a/crates/blockifier/src/transaction/test_utils.rs +++ b/crates/blockifier/src/transaction/test_utils.rs @@ -45,7 +45,7 @@ use crate::test_utils::{ use crate::transaction::account_transaction::{AccountTransaction, ExecutionFlags}; use crate::transaction::objects::{TransactionExecutionInfo, TransactionExecutionResult}; use crate::transaction::transaction_types::TransactionType; -use crate::transaction::transactions::{enforce_fee, ExecutableTransaction}; +use crate::transaction::transactions::ExecutableTransaction; // Corresponding constants to the ones in faulty_account. pub const VALID: u64 = 0; @@ -303,8 +303,7 @@ pub fn create_account_tx_for_validate_test( // TODO(AvivG): Consider removing this function. pub fn account_invoke_tx(invoke_args: InvokeTxArgs) -> AccountTransaction { - let only_query = invoke_args.only_query; - let execution_flags = ExecutionFlags { only_query, ..ExecutionFlags::default() }; + let execution_flags = ExecutionFlags::default(); AccountTransaction { tx: invoke_tx(invoke_args), execution_flags } } @@ -313,11 +312,8 @@ pub fn run_invoke_tx( block_context: &BlockContext, invoke_args: InvokeTxArgs, ) -> TransactionExecutionResult { - let only_query = invoke_args.only_query; let tx = invoke_tx(invoke_args); - let execution_flags = - ExecutionFlags { only_query, charge_fee: enforce_fee(&tx, only_query), validate: true }; - let account_tx = AccountTransaction { tx, execution_flags }; + let account_tx = AccountTransaction::new_for_sequencing(tx); account_tx.execute(state, block_context) } diff --git a/crates/blockifier/src/transaction/transactions_test.rs b/crates/blockifier/src/transaction/transactions_test.rs index ea51654b65..fa467cf602 100644 --- a/crates/blockifier/src/transaction/transactions_test.rs +++ b/crates/blockifier/src/transaction/transactions_test.rs @@ -2241,7 +2241,6 @@ fn test_only_query_flag( calldata: execute_calldata, resource_bounds: default_all_resource_bounds, sender_address, - only_query, }); let execution_flags = ExecutionFlags { only_query, ..Default::default() }; let invoke_tx = AccountTransaction { tx, execution_flags };