Skip to content

Commit

Permalink
chore(blockifier): remove declare.rs deploy_account.rs invoke.rs from…
Browse files Browse the repository at this point in the history
… blockifier
  • Loading branch information
avivg-starkware committed Dec 5, 2024
1 parent d6e849f commit a196512
Show file tree
Hide file tree
Showing 21 changed files with 103 additions and 144 deletions.
12 changes: 6 additions & 6 deletions crates/blockifier/src/blockifier/transaction_executor_test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use assert_matches::assert_matches;
use pretty_assertions::assert_eq;
use rstest::rstest;
use starknet_api::test_utils::declare::executable_declare_tx;
use starknet_api::test_utils::deploy_account::executable_deploy_account_tx;
use starknet_api::test_utils::invoke::executable_invoke_tx;
use starknet_api::test_utils::NonceManager;
use starknet_api::transaction::fields::Fee;
use starknet_api::transaction::TransactionVersion;
Expand All @@ -18,10 +21,7 @@ use crate::context::BlockContext;
use crate::state::cached_state::CachedState;
use crate::state::state_api::StateReader;
use crate::test_utils::contracts::FeatureContract;
use crate::test_utils::declare::declare_tx;
use crate::test_utils::deploy_account::deploy_account_tx;
use crate::test_utils::initial_test_state::test_state;
use crate::test_utils::invoke::invoke_tx;
use crate::test_utils::l1_handler::l1handler_tx;
use crate::test_utils::{
create_calldata,
Expand Down Expand Up @@ -121,7 +121,7 @@ fn test_declare(
let declared_contract = FeatureContract::Empty(cairo_version);
let state = test_state(&block_context.chain_info, BALANCE, &[(account_contract, 1)]);

let declare_tx = declare_tx(
let declare_tx = executable_declare_tx(
declare_tx_args! {
sender_address: account_contract.get_instance_address(0),
class_hash: declared_contract.get_class_hash(),
Expand All @@ -144,7 +144,7 @@ fn test_deploy_account(
let account_contract = FeatureContract::AccountWithoutValidations(cairo_version);
let state = test_state(&block_context.chain_info, BALANCE, &[(account_contract, 0)]);

let deploy_account_tx = deploy_account_tx(
let deploy_account_tx = executable_deploy_account_tx(
deploy_account_tx_args! {
class_hash: account_contract.get_class_hash(),
resource_bounds: l1_resource_bounds(0_u8.into(), DEFAULT_STRK_L1_GAS_PRICE.into()),
Expand Down Expand Up @@ -219,7 +219,7 @@ fn test_invoke(

let calldata =
create_calldata(test_contract.get_instance_address(0), entry_point_name, &entry_point_args);
let invoke_tx = invoke_tx(invoke_tx_args! {
let invoke_tx = executable_invoke_tx(invoke_tx_args! {
sender_address: account_contract.get_instance_address(0),
calldata,
version,
Expand Down
6 changes: 3 additions & 3 deletions crates/blockifier/src/concurrency/versioned_state_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use assert_matches::assert_matches;
use rstest::{fixture, rstest};
use starknet_api::abi::abi_utils::{get_fee_token_var_address, get_storage_var_address};
use starknet_api::core::{calculate_contract_address, ClassHash, ContractAddress};
use starknet_api::test_utils::deploy_account::executable_deploy_account_tx;
use starknet_api::test_utils::NonceManager;
use starknet_api::transaction::fields::{ContractAddressSalt, ValidResourceBounds};
use starknet_api::{
Expand Down Expand Up @@ -40,7 +41,6 @@ use crate::state::cached_state::{
use crate::state::errors::StateError;
use crate::state::state_api::{State, StateReader, UpdatableState};
use crate::test_utils::contracts::FeatureContract;
use crate::test_utils::deploy_account::deploy_account_tx;
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};
Expand Down Expand Up @@ -226,7 +226,7 @@ fn test_run_parallel_txs(default_all_resource_bounds: ValidResourceBounds) {
let mut state_2 = TransactionalState::create_transactional(&mut versioned_state_proxy_2);

// Prepare transactions
let tx = deploy_account_tx(
let tx = executable_deploy_account_tx(
deploy_account_tx_args! {
class_hash: account_without_validation.get_class_hash(),
resource_bounds: l1_resource_bounds(
Expand All @@ -249,7 +249,7 @@ fn test_run_parallel_txs(default_all_resource_bounds: ValidResourceBounds) {
constructor_calldata: constructor_calldata.clone(),
};
let nonce_manager = &mut NonceManager::default();
let tx = deploy_account_tx(deploy_tx_args, nonce_manager);
let tx = executable_deploy_account_tx(deploy_tx_args, nonce_manager);
let delpoy_account_tx_2 = AccountTransaction::new_for_sequencing(tx);

let account_address = delpoy_account_tx_2.sender_address();
Expand Down
4 changes: 2 additions & 2 deletions crates/blockifier/src/concurrency/worker_logic_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use std::sync::Mutex;
use rstest::rstest;
use starknet_api::abi::abi_utils::get_fee_token_var_address;
use starknet_api::core::{ContractAddress, Nonce};
use starknet_api::test_utils::declare::executable_declare_tx;
use starknet_api::test_utils::NonceManager;
use starknet_api::transaction::constants::DEPLOY_CONTRACT_FUNCTION_ENTRY_POINT_NAME;
use starknet_api::transaction::fields::{ContractAddressSalt, Fee, ValidResourceBounds};
Expand All @@ -23,7 +24,6 @@ use crate::fee::fee_utils::get_sequencer_balance_keys;
use crate::state::cached_state::StateMaps;
use crate::state::state_api::StateReader;
use crate::test_utils::contracts::FeatureContract;
use crate::test_utils::declare::declare_tx;
use crate::test_utils::initial_test_state::test_state;
use crate::test_utils::{
create_calldata,
Expand Down Expand Up @@ -549,7 +549,7 @@ fn test_deploy_before_declare(
let test_class_hash = test_contract.get_class_hash();
let test_class_info = calculate_class_info_for_testing(test_contract.get_class());
let test_compiled_class_hash = test_contract.get_compiled_class_hash();
let declare_tx = AccountTransaction::new_with_default_flags(declare_tx(
let declare_tx = AccountTransaction::new_with_default_flags(executable_declare_tx(
declare_tx_args! {
sender_address: account_address_0,
resource_bounds: default_all_resource_bounds,
Expand Down
3 changes: 0 additions & 3 deletions crates/blockifier/src/test_utils.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
pub mod cairo_compile;
pub mod contracts;
pub mod declare;
pub mod deploy_account;
pub mod dict_state_reader;
pub mod initial_test_state;
pub mod invoke;
pub mod l1_handler;
pub mod prices;
pub mod struct_impls;
Expand Down
11 changes: 0 additions & 11 deletions crates/blockifier/src/test_utils/declare.rs

This file was deleted.

14 changes: 0 additions & 14 deletions crates/blockifier/src/test_utils/deploy_account.rs

This file was deleted.

8 changes: 0 additions & 8 deletions crates/blockifier/src/test_utils/invoke.rs

This file was deleted.

4 changes: 2 additions & 2 deletions crates/blockifier/src/test_utils/transfers_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use rand::{Rng, SeedableRng};
use starknet_api::abi::abi_utils::selector_from_name;
use starknet_api::core::ContractAddress;
use starknet_api::executable_transaction::AccountTransaction as ApiExecutableTransaction;
use starknet_api::test_utils::invoke::executable_invoke_tx;
use starknet_api::test_utils::NonceManager;
use starknet_api::transaction::constants::TRANSFER_ENTRY_POINT_NAME;
use starknet_api::transaction::fields::Fee;
Expand All @@ -16,7 +17,6 @@ use crate::context::{BlockContext, ChainInfo};
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::invoke::invoke_tx;
use crate::test_utils::{CairoVersion, BALANCE, MAX_FEE};
use crate::transaction::account_transaction::AccountTransaction;
use crate::transaction::transaction_execution::Transaction;
Expand Down Expand Up @@ -181,7 +181,7 @@ impl TransfersGenerator {
felt!(0_u8) // Calldata: msb amount.
];

invoke_tx(invoke_tx_args! {
executable_invoke_tx(invoke_tx_args! {
max_fee: self.config.max_fee,
sender_address,
calldata: execute_calldata,
Expand Down
13 changes: 6 additions & 7 deletions crates/blockifier/src/transaction/account_transactions_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ use starknet_api::executable_transaction::{
use starknet_api::execution_resources::GasAmount;
use starknet_api::hash::StarkHash;
use starknet_api::state::StorageKey;
use starknet_api::test_utils::invoke::InvokeTxArgs;
use starknet_api::test_utils::declare::executable_declare_tx;
use starknet_api::test_utils::deploy_account::executable_deploy_account_tx;
use starknet_api::test_utils::invoke::{executable_invoke_tx, InvokeTxArgs};
use starknet_api::test_utils::NonceManager;
use starknet_api::transaction::constants::TRANSFER_ENTRY_POINT_NAME;
use starknet_api::transaction::fields::{
Expand Down Expand Up @@ -63,10 +65,7 @@ use crate::fee::gas_usage::estimate_minimal_gas_vector;
use crate::state::cached_state::{StateChangesCount, StateChangesCountForFee, TransactionalState};
use crate::state::state_api::{State, StateReader};
use crate::test_utils::contracts::FeatureContract;
use crate::test_utils::declare::declare_tx;
use crate::test_utils::deploy_account::deploy_account_tx;
use crate::test_utils::initial_test_state::{fund_account, test_state};
use crate::test_utils::invoke::invoke_tx;
use crate::test_utils::syscall::build_recurse_calldata;
use crate::test_utils::{
create_calldata,
Expand Down Expand Up @@ -194,7 +193,7 @@ fn test_fee_enforcement(
) {
let account = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo0);
let state = &mut test_state(&block_context.chain_info, BALANCE, &[(account, 1)]);
let tx = deploy_account_tx(
let tx = executable_deploy_account_tx(
deploy_account_tx_args! {
class_hash: account.get_class_hash(),
max_fee: Fee(if zero_bounds { 0 } else { MAX_FEE.0 }),
Expand Down Expand Up @@ -454,7 +453,7 @@ fn test_max_fee_limit_validate(
let class_info = calculate_class_info_for_testing(grindy_validate_account.get_class());

// Declare the grindy-validation account.
let tx = declare_tx(
let tx = executable_declare_tx(
declare_tx_args! {
class_hash: grindy_class_hash,
sender_address: account_address,
Expand Down Expand Up @@ -1756,7 +1755,7 @@ fn test_revert_in_execute(

// Skip validate phase, as we want to test the revert in the execute phase.
let validate = false;
let tx = invoke_tx(invoke_tx_args! {
let tx = executable_invoke_tx(invoke_tx_args! {
resource_bounds: default_all_resource_bounds,
..tx_args
});
Expand Down
26 changes: 13 additions & 13 deletions crates/blockifier/src/transaction/execution_flavors_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rstest::rstest;
use starknet_api::block::FeeType;
use starknet_api::core::ContractAddress;
use starknet_api::execution_resources::{GasAmount, GasVector};
use starknet_api::test_utils::invoke::InvokeTxArgs;
use starknet_api::test_utils::invoke::{executable_invoke_tx, InvokeTxArgs};
use starknet_api::test_utils::NonceManager;
use starknet_api::transaction::fields::{
Calldata,
Expand All @@ -26,7 +26,6 @@ use crate::state::state_api::StateReader;
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::invoke::invoke_tx;
use crate::test_utils::{
create_calldata,
create_trivial_calldata,
Expand Down Expand Up @@ -223,7 +222,8 @@ fn test_invalid_nonce_pre_validate(
// First scenario: invalid nonce. Regardless of flags, should fail.
let invalid_nonce = nonce!(7_u8);
let account_nonce = state.get_nonce_at(account_address).unwrap();
let tx = invoke_tx(invoke_tx_args! {nonce: invalid_nonce, ..pre_validation_base_args});
let tx =
executable_invoke_tx(invoke_tx_args! {nonce: invalid_nonce, ..pre_validation_base_args});
let execution_flags = ExecutionFlags { only_query, charge_fee, validate };
let account_tx = AccountTransaction { tx, execution_flags };
let result = account_tx.execute(&mut state, &block_context);
Expand Down Expand Up @@ -297,7 +297,7 @@ fn test_simulate_validate_pre_validate_with_charge_fee(
// Second scenario: resource bounds greater than balance.
let gas_price = block_context.block_info.gas_prices.l1_gas_price(&fee_type);
let balance_over_gas_price = BALANCE.checked_div(gas_price).unwrap();
let tx = invoke_tx(invoke_tx_args! {
let tx = executable_invoke_tx(invoke_tx_args! {
max_fee: Fee(BALANCE.0 + 1),
resource_bounds: l1_resource_bounds(
(balance_over_gas_price.0 + 10).into(),
Expand Down Expand Up @@ -337,7 +337,7 @@ fn test_simulate_validate_pre_validate_with_charge_fee(

// Third scenario: L1 gas price bound lower than the price on the block.
if !is_deprecated {
let tx = invoke_tx(invoke_tx_args! {
let tx = executable_invoke_tx(invoke_tx_args! {
resource_bounds: l1_resource_bounds(DEFAULT_L1_GAS_AMOUNT, (gas_price.get().0 - 1).into()),
nonce: nonce_manager.next(account_address),

Expand Down Expand Up @@ -380,7 +380,7 @@ fn test_simulate_validate_pre_validate_not_charge_fee(
get_pre_validate_test_args(cairo_version, version);
let account_address = pre_validation_base_args.sender_address;

let tx = invoke_tx(invoke_tx_args! {
let tx = executable_invoke_tx(invoke_tx_args! {
nonce: nonce_manager.next(account_address),
..pre_validation_base_args.clone()
});
Expand All @@ -402,7 +402,7 @@ fn test_simulate_validate_pre_validate_not_charge_fee(
let (actual_gas_used, actual_fee) = gas_and_fee(base_gas, validate, &fee_type);
macro_rules! execute_and_check_gas_and_fee {
($max_fee:expr, $resource_bounds:expr) => {{
let tx = invoke_tx(invoke_tx_args! {
let tx = executable_invoke_tx(invoke_tx_args! {
max_fee: $max_fee,
resource_bounds: $resource_bounds,
nonce: nonce_manager.next(account_address),
Expand Down Expand Up @@ -466,7 +466,7 @@ fn execute_fail_validation(
} = create_flavors_test_state(&block_context.chain_info, cairo_version);

// Validation scenario: fallible validation.
let tx = invoke_tx(invoke_tx_args! {
let tx = executable_invoke_tx(invoke_tx_args! {
max_fee,
resource_bounds: max_resource_bounds,
signature: TransactionSignature(vec![
Expand Down Expand Up @@ -597,7 +597,7 @@ fn test_simulate_validate_charge_fee_mid_execution(
};

// First scenario: logic error. Should result in revert; actual fee should be shown.
let tx = invoke_tx(invoke_tx_args! {
let tx = executable_invoke_tx(invoke_tx_args! {
calldata: recurse_calldata(test_contract_address, true, 3),
nonce: nonce_manager.next(account_address),
..execution_base_args.clone()
Expand Down Expand Up @@ -646,7 +646,7 @@ fn test_simulate_validate_charge_fee_mid_execution(
validate,
&fee_type,
);
let tx = invoke_tx(invoke_tx_args! {
let tx = executable_invoke_tx(invoke_tx_args! {
max_fee: fee_bound,
resource_bounds: l1_resource_bounds(gas_bound, gas_price.into()),
calldata: recurse_calldata(test_contract_address, false, 1000),
Expand Down Expand Up @@ -703,7 +703,7 @@ fn test_simulate_validate_charge_fee_mid_execution(
&fee_type,
);

let tx = invoke_tx(invoke_tx_args! {
let tx = executable_invoke_tx(invoke_tx_args! {
max_fee: huge_fee,
resource_bounds: l1_resource_bounds(huge_gas_limit, gas_price.into()),
calldata: recurse_calldata(test_contract_address, false, 10000),
Expand Down Expand Up @@ -791,7 +791,7 @@ fn test_simulate_validate_charge_fee_post_execution(
validate,
&fee_type,
);
let tx = invoke_tx(invoke_tx_args! {
let tx = executable_invoke_tx(invoke_tx_args! {
max_fee: just_not_enough_fee_bound,
resource_bounds: l1_resource_bounds(just_not_enough_gas_bound, gas_price.into()),
calldata: recurse_calldata(test_contract_address, false, 1000),
Expand Down Expand Up @@ -853,7 +853,7 @@ fn test_simulate_validate_charge_fee_post_execution(
felt!(0_u8),
],
);
let tx = invoke_tx(invoke_tx_args! {
let tx = executable_invoke_tx(invoke_tx_args! {
max_fee: actual_fee,
resource_bounds: l1_resource_bounds(success_actual_gas, gas_price.into()),
calldata: transfer_calldata,
Expand Down
Loading

0 comments on commit a196512

Please sign in to comment.