Skip to content

Commit

Permalink
chore(blockifier): remove only_qury from IvokeTxArgs
Browse files Browse the repository at this point in the history
  • Loading branch information
avivg-starkware committed Dec 5, 2024
1 parent df889dd commit 1849cee
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -323,7 +322,6 @@ fn test_account_flow_test(
version: tx_version,
resource_bounds,
nonce: nonce_manager.next(account_address),
only_query,
},
)
.unwrap();
Expand Down
15 changes: 3 additions & 12 deletions crates/blockifier/src/transaction/execution_flavors_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<DictStateReader>, InvokeTxArgs, NonceManager) {
let block_context = BlockContext::create_for_account_testing();
let max_fee = MAX_FEE;
Expand All @@ -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)
}
Expand All @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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! {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 3 additions & 7 deletions crates/blockifier/src/transaction/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 }
}

Expand All @@ -313,11 +312,8 @@ pub fn run_invoke_tx(
block_context: &BlockContext,
invoke_args: InvokeTxArgs,
) -> TransactionExecutionResult<TransactionExecutionInfo> {
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)
}
Expand Down
1 change: 0 additions & 1 deletion crates/blockifier/src/transaction/transactions_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down

0 comments on commit 1849cee

Please sign in to comment.