diff --git a/crates/blockifier/src/concurrency/fee_utils_test.rs b/crates/blockifier/src/concurrency/fee_utils_test.rs index dba90531562..3e36d6998f7 100644 --- a/crates/blockifier/src/concurrency/fee_utils_test.rs +++ b/crates/blockifier/src/concurrency/fee_utils_test.rs @@ -1,7 +1,7 @@ use num_bigint::BigUint; use rstest::rstest; use starknet_api::felt; -use starknet_api::transaction::{DeprecatedResourceBoundsMapping, Fee}; +use starknet_api::transaction::{Fee, ValidResourceBounds}; use starknet_types_core::felt::Felt; use crate::concurrency::fee_utils::{add_fee_to_sequencer_balance, fill_sequencer_balance_reads}; @@ -19,7 +19,7 @@ use crate::transaction::test_utils::{account_invoke_tx, block_context, max_resou #[rstest] pub fn test_fill_sequencer_balance_reads( block_context: BlockContext, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] erc20_version: CairoVersion, ) { let account = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); diff --git a/crates/blockifier/src/concurrency/versioned_state_test.rs b/crates/blockifier/src/concurrency/versioned_state_test.rs index d05e3125ec8..d378ab8da1a 100644 --- a/crates/blockifier/src/concurrency/versioned_state_test.rs +++ b/crates/blockifier/src/concurrency/versioned_state_test.rs @@ -11,7 +11,7 @@ use starknet_api::core::{ Nonce, PatriciaKey, }; -use starknet_api::transaction::{Calldata, ContractAddressSalt, DeprecatedResourceBoundsMapping}; +use starknet_api::transaction::{Calldata, ContractAddressSalt, ValidResourceBounds}; use starknet_api::{calldata, class_hash, contract_address, felt, patricia_key}; use crate::abi::abi_utils::{get_fee_token_var_address, get_storage_var_address}; @@ -201,7 +201,7 @@ fn test_versioned_state_proxy() { #[rstest] // Test parallel execution of two transactions that use the same versioned state. -fn test_run_parallel_txs(max_resource_bounds: DeprecatedResourceBoundsMapping) { +fn test_run_parallel_txs(max_resource_bounds: ValidResourceBounds) { let block_context = BlockContext::create_for_account_testing(); let chain_info = &block_context.chain_info; let zero_bounds = true; diff --git a/crates/blockifier/src/concurrency/worker_logic_test.rs b/crates/blockifier/src/concurrency/worker_logic_test.rs index 3f9a9ebcace..e6aca5c932a 100644 --- a/crates/blockifier/src/concurrency/worker_logic_test.rs +++ b/crates/blockifier/src/concurrency/worker_logic_test.rs @@ -5,9 +5,9 @@ use rstest::rstest; use starknet_api::core::{ContractAddress, Nonce, PatriciaKey}; use starknet_api::transaction::{ ContractAddressSalt, - DeprecatedResourceBoundsMapping, Fee, TransactionVersion, + ValidResourceBounds, }; use starknet_api::{contract_address, felt, patricia_key}; use starknet_types_core::felt::Felt; @@ -256,7 +256,7 @@ fn test_commit_tx_when_sender_is_sequencer() { } #[rstest] -fn test_worker_execute(max_resource_bounds: DeprecatedResourceBoundsMapping) { +fn test_worker_execute(max_resource_bounds: ValidResourceBounds) { // Settings. let block_context = BlockContext::create_for_account_testing(); let account_contract = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); @@ -430,7 +430,7 @@ fn test_worker_execute(max_resource_bounds: DeprecatedResourceBoundsMapping) { } #[rstest] -fn test_worker_validate(max_resource_bounds: DeprecatedResourceBoundsMapping) { +fn test_worker_validate(max_resource_bounds: ValidResourceBounds) { // Settings. let block_context = BlockContext::create_for_account_testing(); let account_contract = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); @@ -537,7 +537,7 @@ fn test_worker_validate(max_resource_bounds: DeprecatedResourceBoundsMapping) { #[case::declare_cairo1(CairoVersion::Cairo1, TransactionVersion::THREE)] fn test_deploy_before_declare( max_fee: Fee, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, #[case] cairo_version: CairoVersion, #[case] version: TransactionVersion, ) { @@ -629,7 +629,7 @@ fn test_deploy_before_declare( } #[rstest] -fn test_worker_commit_phase(max_resource_bounds: DeprecatedResourceBoundsMapping) { +fn test_worker_commit_phase(max_resource_bounds: ValidResourceBounds) { // Settings. let block_context = BlockContext::create_for_account_testing(); let account_contract = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); diff --git a/crates/blockifier/src/execution/stack_trace_test.rs b/crates/blockifier/src/execution/stack_trace_test.rs index fb649ff74a5..f51e86fb878 100644 --- a/crates/blockifier/src/execution/stack_trace_test.rs +++ b/crates/blockifier/src/execution/stack_trace_test.rs @@ -5,10 +5,10 @@ use starknet_api::core::{calculate_contract_address, Nonce}; use starknet_api::transaction::{ Calldata, ContractAddressSalt, - DeprecatedResourceBoundsMapping, Fee, TransactionSignature, TransactionVersion, + ValidResourceBounds, }; use starknet_api::{calldata, felt}; @@ -599,7 +599,7 @@ An ASSERT_EQ instruction failed: 1 != 0. /// point selector). fn test_contract_ctor_frame_stack_trace( block_context: BlockContext, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, ) { let chain_info = &block_context.chain_info; diff --git a/crates/blockifier/src/fee/actual_cost_test.rs b/crates/blockifier/src/fee/actual_cost_test.rs index 06cccec6a6e..46d812d3597 100644 --- a/crates/blockifier/src/fee/actual_cost_test.rs +++ b/crates/blockifier/src/fee/actual_cost_test.rs @@ -1,5 +1,5 @@ use rstest::{fixture, rstest}; -use starknet_api::transaction::{DeprecatedResourceBoundsMapping, L2ToL1Payload}; +use starknet_api::transaction::{L2ToL1Payload, ValidResourceBounds}; use starknet_types_core::felt::Felt; use crate::context::BlockContext; @@ -286,7 +286,7 @@ fn test_calculate_tx_gas_usage_basic<'a>(#[values(false, true)] use_kzg_da: bool // resources are taken into account). #[rstest] fn test_calculate_tx_gas_usage( - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, #[values(false, true)] use_kzg_da: bool, ) { let account_cairo_version = CairoVersion::Cairo0; diff --git a/crates/blockifier/src/test_utils.rs b/crates/blockifier/src/test_utils.rs index b2afd89626a..694860e77be 100644 --- a/crates/blockifier/src/test_utils.rs +++ b/crates/blockifier/src/test_utils.rs @@ -18,10 +18,9 @@ use starknet_api::state::StorageKey; use starknet_api::transaction::{ Calldata, ContractAddressSalt, - DeprecatedResourceBoundsMapping, - Resource, ResourceBounds, TransactionVersion, + ValidResourceBounds, }; use starknet_api::{contract_address, felt, patricia_key}; use starknet_types_core::felt::Felt; @@ -211,14 +210,10 @@ pub fn trivial_external_entry_point_with_address( } } -fn default_testing_resource_bounds() -> DeprecatedResourceBoundsMapping { - DeprecatedResourceBoundsMapping::try_from(vec![ - (Resource::L1Gas, ResourceBounds { max_amount: 0, max_price_per_unit: 1 }), - // TODO(Dori, 1/2/2024): When fee market is developed, change the default price of - // L2 gas. - (Resource::L2Gas, ResourceBounds { max_amount: 0, max_price_per_unit: 0 }), - ]) - .unwrap() +fn default_testing_resource_bounds() -> ValidResourceBounds { + // TODO(Dori, 1/2/2024): When fee market is developed, change the default price of + // L2 gas. + ValidResourceBounds::L1Gas(ResourceBounds { max_amount: 0, max_price_per_unit: 1 }) } #[macro_export] diff --git a/crates/blockifier/src/test_utils/declare.rs b/crates/blockifier/src/test_utils/declare.rs index eb794a97f6d..308f2c54ea3 100644 --- a/crates/blockifier/src/test_utils/declare.rs +++ b/crates/blockifier/src/test_utils/declare.rs @@ -5,13 +5,13 @@ use starknet_api::transaction::{ DeclareTransactionV0V1, DeclareTransactionV2, DeclareTransactionV3, - DeprecatedResourceBoundsMapping, Fee, PaymasterData, Tip, TransactionHash, TransactionSignature, TransactionVersion, + ValidResourceBounds, }; use crate::execution::contract_class::ClassInfo; @@ -25,7 +25,7 @@ pub struct DeclareTxArgs { pub signature: TransactionSignature, pub sender_address: ContractAddress, pub version: TransactionVersion, - pub resource_bounds: DeprecatedResourceBoundsMapping, + pub resource_bounds: ValidResourceBounds, pub tip: Tip, pub nonce_data_availability_mode: DataAvailabilityMode, pub fee_data_availability_mode: DataAvailabilityMode, @@ -108,7 +108,7 @@ pub fn declare_tx(declare_tx_args: DeclareTxArgs, class_info: ClassInfo) -> Acco starknet_api::transaction::DeclareTransaction::V3(DeclareTransactionV3 { signature: declare_tx_args.signature, sender_address: declare_tx_args.sender_address, - resource_bounds: declare_tx_args.resource_bounds.try_into().expect("todo"), + resource_bounds: declare_tx_args.resource_bounds, tip: declare_tx_args.tip, nonce_data_availability_mode: declare_tx_args.nonce_data_availability_mode, fee_data_availability_mode: declare_tx_args.fee_data_availability_mode, diff --git a/crates/blockifier/src/test_utils/deploy_account.rs b/crates/blockifier/src/test_utils/deploy_account.rs index 128a4309457..6f2c9a58038 100644 --- a/crates/blockifier/src/test_utils/deploy_account.rs +++ b/crates/blockifier/src/test_utils/deploy_account.rs @@ -5,13 +5,13 @@ use starknet_api::transaction::{ ContractAddressSalt, DeployAccountTransactionV1, DeployAccountTransactionV3, - DeprecatedResourceBoundsMapping, Fee, PaymasterData, Tip, TransactionHash, TransactionSignature, TransactionVersion, + ValidResourceBounds, }; use crate::test_utils::{default_testing_resource_bounds, NonceManager}; @@ -23,7 +23,7 @@ pub struct DeployAccountTxArgs { pub signature: TransactionSignature, pub deployer_address: ContractAddress, pub version: TransactionVersion, - pub resource_bounds: DeprecatedResourceBoundsMapping, + pub resource_bounds: ValidResourceBounds, pub tip: Tip, pub nonce_data_availability_mode: DataAvailabilityMode, pub fee_data_availability_mode: DataAvailabilityMode, @@ -96,7 +96,7 @@ pub fn deploy_account_tx( } else if deploy_tx_args.version == TransactionVersion::THREE { starknet_api::transaction::DeployAccountTransaction::V3(DeployAccountTransactionV3 { signature: deploy_tx_args.signature, - resource_bounds: deploy_tx_args.resource_bounds.try_into().expect("todo"), + resource_bounds: deploy_tx_args.resource_bounds, tip: deploy_tx_args.tip, nonce_data_availability_mode: deploy_tx_args.nonce_data_availability_mode, fee_data_availability_mode: deploy_tx_args.fee_data_availability_mode, diff --git a/crates/blockifier/src/test_utils/invoke.rs b/crates/blockifier/src/test_utils/invoke.rs index 64b68479603..0c8cbc9196b 100644 --- a/crates/blockifier/src/test_utils/invoke.rs +++ b/crates/blockifier/src/test_utils/invoke.rs @@ -4,7 +4,6 @@ use starknet_api::data_availability::DataAvailabilityMode; use starknet_api::transaction::{ AccountDeploymentData, Calldata, - DeprecatedResourceBoundsMapping, Fee, InvokeTransactionV0, InvokeTransactionV1, @@ -14,6 +13,7 @@ use starknet_api::transaction::{ TransactionHash, TransactionSignature, TransactionVersion, + ValidResourceBounds, }; use crate::abi::abi_utils::selector_from_name; @@ -28,7 +28,7 @@ pub struct InvokeTxArgs { pub sender_address: ContractAddress, pub calldata: Calldata, pub version: TransactionVersion, - pub resource_bounds: DeprecatedResourceBoundsMapping, + pub resource_bounds: ValidResourceBounds, pub tip: Tip, pub nonce_data_availability_mode: DataAvailabilityMode, pub fee_data_availability_mode: DataAvailabilityMode, @@ -96,7 +96,7 @@ pub fn invoke_tx(invoke_args: InvokeTxArgs) -> InvokeTransaction { }) } else if invoke_args.version == TransactionVersion::THREE { starknet_api::transaction::InvokeTransaction::V3(InvokeTransactionV3 { - resource_bounds: invoke_args.resource_bounds.try_into().expect("todo"), + resource_bounds: invoke_args.resource_bounds, calldata: invoke_args.calldata, sender_address: invoke_args.sender_address, nonce: invoke_args.nonce, diff --git a/crates/blockifier/src/transaction/account_transactions_test.rs b/crates/blockifier/src/transaction/account_transactions_test.rs index 72dd2b4ab5d..342954cab10 100644 --- a/crates/blockifier/src/transaction/account_transactions_test.rs +++ b/crates/blockifier/src/transaction/account_transactions_test.rs @@ -11,10 +11,10 @@ use starknet_api::transaction::{ Calldata, ContractAddressSalt, DeclareTransactionV2, - DeprecatedResourceBoundsMapping, Fee, TransactionHash, TransactionVersion, + ValidResourceBounds, }; use starknet_api::{calldata, class_hash, contract_address, felt, patricia_key}; use starknet_types_core::felt::Felt; @@ -79,7 +79,7 @@ use crate::{ }; #[rstest] -fn test_circuit(block_context: BlockContext, max_resource_bounds: DeprecatedResourceBoundsMapping) { +fn test_circuit(block_context: BlockContext, max_resource_bounds: ValidResourceBounds) { let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1); let account = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); let chain_info = &block_context.chain_info; @@ -113,10 +113,7 @@ fn test_circuit(block_context: BlockContext, max_resource_bounds: DeprecatedReso } #[rstest] -fn test_rc96_holes( - block_context: BlockContext, - max_resource_bounds: DeprecatedResourceBoundsMapping, -) { +fn test_rc96_holes(block_context: BlockContext, max_resource_bounds: ValidResourceBounds) { let test_contract = FeatureContract::TestContract(CairoVersion::Cairo1); let account = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1); let chain_info = &block_context.chain_info; @@ -207,7 +204,7 @@ fn test_enforce_fee_false_works(block_context: BlockContext, #[case] version: Tr fn test_account_flow_test( block_context: BlockContext, max_fee: Fee, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, #[values(TransactionVersion::ZERO, TransactionVersion::ONE, TransactionVersion::THREE)] tx_version: TransactionVersion, #[values(true, false)] only_query: bool, @@ -239,7 +236,7 @@ fn test_account_flow_test( fn test_invoke_tx_from_non_deployed_account( block_context: BlockContext, max_fee: Fee, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, #[case] tx_version: TransactionVersion, ) { let TestInitData { mut state, account_address, contract_address: _, mut nonce_manager } = @@ -288,7 +285,7 @@ fn test_infinite_recursion( #[values(true, false)] success: bool, #[values(true, false)] normal_recurse: bool, mut block_context: BlockContext, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, ) { // Limit the number of execution steps (so we quickly hit the limit). block_context.versioned_constants.invoke_tx_max_n_steps = 4100; @@ -343,7 +340,7 @@ fn test_infinite_recursion( fn test_max_fee_limit_validate( block_context: BlockContext, #[case] version: TransactionVersion, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, ) { let chain_info = &block_context.chain_info; let TestInitData { mut state, account_address, contract_address, mut nonce_manager } = @@ -448,7 +445,7 @@ fn test_recursion_depth_exceeded( #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, block_context: BlockContext, max_fee: Fee, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, ) { let TestInitData { mut state, account_address, contract_address, mut nonce_manager } = create_test_init_data(&block_context.chain_info, cairo_version); @@ -692,7 +689,7 @@ fn recursive_function_calldata( #[case(TransactionVersion::THREE)] fn test_reverted_reach_steps_limit( max_fee: Fee, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, mut block_context: BlockContext, #[case] version: TransactionVersion, #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, @@ -800,7 +797,7 @@ fn test_reverted_reach_steps_limit( /// asserts false. We test deltas between consecutive depths, and further depths. fn test_n_reverted_steps( block_context: BlockContext, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, ) { let TestInitData { mut state, account_address, contract_address, mut nonce_manager } = @@ -983,7 +980,7 @@ fn test_max_fee_to_max_steps_conversion( /// recorded and max_fee is charged. fn test_insufficient_max_fee_reverts( block_context: BlockContext, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, ) { let TestInitData { mut state, account_address, contract_address, mut nonce_manager } = @@ -1050,7 +1047,7 @@ fn test_insufficient_max_fee_reverts( #[rstest] fn test_deploy_account_constructor_storage_write( - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, block_context: BlockContext, #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, ) { @@ -1094,7 +1091,7 @@ fn test_deploy_account_constructor_storage_write( fn test_count_actual_storage_changes( max_fee: Fee, block_context: BlockContext, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, #[case] version: TransactionVersion, #[case] fee_type: FeeType, #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, @@ -1275,7 +1272,7 @@ fn test_count_actual_storage_changes( #[case::tx_version_3(TransactionVersion::THREE)] fn test_concurrency_execute_fee_transfer( max_fee: Fee, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, #[case] version: TransactionVersion, ) { // TODO(Meshi, 01/06/2024): make the test so it will include changes in @@ -1375,7 +1372,7 @@ fn test_concurrency_execute_fee_transfer( #[case::tx_version_3(TransactionVersion::THREE)] fn test_concurrent_fee_transfer_when_sender_is_sequencer( max_fee: Fee, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, #[case] version: TransactionVersion, ) { let mut block_context = BlockContext::create_for_account_testing(); diff --git a/crates/blockifier/src/transaction/execution_flavors_test.rs b/crates/blockifier/src/transaction/execution_flavors_test.rs index 608feac8920..ca9442bb9bf 100644 --- a/crates/blockifier/src/transaction/execution_flavors_test.rs +++ b/crates/blockifier/src/transaction/execution_flavors_test.rs @@ -5,10 +5,10 @@ use starknet_api::core::ContractAddress; use starknet_api::felt; use starknet_api::transaction::{ Calldata, - DeprecatedResourceBoundsMapping, Fee, TransactionSignature, TransactionVersion, + ValidResourceBounds, }; use starknet_types_core::felt::Felt; @@ -349,7 +349,7 @@ fn test_simulate_validate_charge_fee_fail_validate( #[values(CairoVersion::Cairo0)] cairo_version: CairoVersion, #[case] version: TransactionVersion, #[case] fee_type: FeeType, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, ) { let block_context = BlockContext::create_for_account_testing(); let max_fee = Fee(MAX_FEE); @@ -411,7 +411,7 @@ fn test_simulate_validate_charge_fee_mid_execution( #[values(CairoVersion::Cairo0)] cairo_version: CairoVersion, #[case] version: TransactionVersion, #[case] fee_type: FeeType, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, ) { let block_context = BlockContext::create_for_account_testing(); let chain_info = &block_context.chain_info; diff --git a/crates/blockifier/src/transaction/post_execution_test.rs b/crates/blockifier/src/transaction/post_execution_test.rs index 271718e7e07..0c5d9c10cc2 100644 --- a/crates/blockifier/src/transaction/post_execution_test.rs +++ b/crates/blockifier/src/transaction/post_execution_test.rs @@ -2,12 +2,7 @@ use assert_matches::assert_matches; use rstest::rstest; use starknet_api::core::{ContractAddress, PatriciaKey}; use starknet_api::state::StorageKey; -use starknet_api::transaction::{ - Calldata, - DeprecatedResourceBoundsMapping, - Fee, - TransactionVersion, -}; +use starknet_api::transaction::{Calldata, Fee, TransactionVersion, ValidResourceBounds}; use starknet_api::{felt, patricia_key}; use starknet_types_core::felt::Felt; @@ -72,7 +67,7 @@ fn calldata_for_write_and_transfer( #[case(TransactionVersion::THREE, FeeType::Strk)] fn test_revert_on_overdraft( max_fee: Fee, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, block_context: BlockContext, #[case] version: TransactionVersion, #[case] fee_type: FeeType, @@ -217,7 +212,7 @@ fn test_revert_on_overdraft( #[case(TransactionVersion::THREE, "Insufficient max L1 gas", true)] fn test_revert_on_resource_overuse( max_fee: Fee, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, block_context: BlockContext, #[case] version: TransactionVersion, #[case] expected_error_prefix: &str, diff --git a/crates/blockifier/src/transaction/test_utils.rs b/crates/blockifier/src/transaction/test_utils.rs index 2b401ebc6dc..fd3c39781fa 100644 --- a/crates/blockifier/src/transaction/test_utils.rs +++ b/crates/blockifier/src/transaction/test_utils.rs @@ -3,16 +3,15 @@ use starknet_api::core::{ClassHash, ContractAddress, Nonce}; use starknet_api::transaction::{ Calldata, ContractAddressSalt, - DeprecatedResourceBoundsMapping, Fee, InvokeTransactionV0, InvokeTransactionV1, InvokeTransactionV3, - Resource, ResourceBounds, TransactionHash, TransactionSignature, TransactionVersion, + ValidResourceBounds, }; use starknet_api::{calldata, felt}; use starknet_types_core::felt::Felt; @@ -82,7 +81,7 @@ pub fn max_fee() -> Fee { } #[fixture] -pub fn max_resource_bounds() -> DeprecatedResourceBoundsMapping { +pub fn max_resource_bounds() -> ValidResourceBounds { l1_resource_bounds(MAX_L1_GAS_AMOUNT, MAX_L1_GAS_PRICE) } @@ -291,12 +290,8 @@ pub fn run_invoke_tx( /// Creates a `ResourceBoundsMapping` with the given `max_amount` and `max_price` for L1 gas limits. /// No guarantees on the values of the other resources bounds. -pub fn l1_resource_bounds(max_amount: u64, max_price: u128) -> DeprecatedResourceBoundsMapping { - DeprecatedResourceBoundsMapping::try_from(vec![ - (Resource::L1Gas, ResourceBounds { max_amount, max_price_per_unit: max_price }), - (Resource::L2Gas, ResourceBounds { max_amount: 0, max_price_per_unit: 0 }), - ]) - .unwrap() +pub fn l1_resource_bounds(max_amount: u64, max_price: u128) -> ValidResourceBounds { + ValidResourceBounds::L1Gas(ResourceBounds { max_amount, max_price_per_unit: max_price }) } pub fn calculate_class_info_for_testing(contract_class: ContractClass) -> ClassInfo { diff --git a/crates/blockifier/src/transaction/transactions_test.rs b/crates/blockifier/src/transaction/transactions_test.rs index d06a33e41d5..21506d385d8 100644 --- a/crates/blockifier/src/transaction/transactions_test.rs +++ b/crates/blockifier/src/transaction/transactions_test.rs @@ -14,7 +14,6 @@ use starknet_api::deprecated_contract_class::EntryPointType; use starknet_api::state::StorageKey; use starknet_api::transaction::{ Calldata, - DeprecatedResourceBoundsMapping, EventContent, EventData, EventKey, @@ -22,6 +21,7 @@ use starknet_api::transaction::{ L2ToL1Payload, TransactionSignature, TransactionVersion, + ValidResourceBounds, }; use starknet_api::{calldata, class_hash, contract_address, felt, patricia_key}; use starknet_types_core::felt::Felt; @@ -383,7 +383,7 @@ fn add_kzg_da_resources_to_resources_mapping( }, CairoVersion::Cairo1)] fn test_invoke_tx( - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, #[case] expected_arguments: ExpectedResultTestInvokeTx, #[case] account_cairo_version: CairoVersion, #[values(false, true)] use_kzg_da: bool, @@ -576,7 +576,7 @@ fn verify_storage_after_invoke_advanced_operations( #[rstest] fn test_invoke_tx_advanced_operations( block_context: BlockContext, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, ) { let block_context = &block_context; @@ -818,7 +818,7 @@ fn assert_failure_if_resource_bounds_exceed_balance( #[rstest] fn test_max_fee_exceeds_balance( block_context: BlockContext, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] account_cairo_version: CairoVersion, ) { let block_context = &block_context; @@ -974,7 +974,7 @@ fn test_insufficient_resource_bounds( #[rstest] fn test_actual_fee_gt_resource_bounds( block_context: BlockContext, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] account_cairo_version: CairoVersion, ) { let block_context = &block_context; @@ -1014,7 +1014,7 @@ fn test_actual_fee_gt_resource_bounds( #[rstest] fn test_invalid_nonce( block_context: BlockContext, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] account_cairo_version: CairoVersion, ) { let account_contract = FeatureContract::AccountWithoutValidations(account_cairo_version); @@ -1134,7 +1134,7 @@ fn declare_expected_state_changes_count(version: TransactionVersion) -> StateCha #[case(TransactionVersion::TWO, CairoVersion::Cairo1)] #[case(TransactionVersion::THREE, CairoVersion::Cairo1)] fn test_declare_tx( - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] account_cairo_version: CairoVersion, #[case] tx_version: TransactionVersion, #[case] empty_contract_version: CairoVersion, @@ -1287,7 +1287,7 @@ fn test_declare_tx( fn test_deploy_account_tx( #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] cairo_version: CairoVersion, #[values(false, true)] use_kzg_da: bool, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, ) { let block_context = &BlockContext::create_for_account_testing_with_kzg(use_kzg_da); let versioned_constants = &block_context.versioned_constants; @@ -1454,7 +1454,7 @@ fn test_deploy_account_tx( #[rstest] fn test_fail_deploy_account_undeclared_class_hash( block_context: BlockContext, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, ) { let block_context = &block_context; let chain_info = &block_context.chain_info; @@ -1685,7 +1685,7 @@ fn test_validate_accounts_tx( #[rstest] fn test_valid_flag( block_context: BlockContext, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] account_cairo_version: CairoVersion, #[values(CairoVersion::Cairo0, CairoVersion::Cairo1)] test_contract_cairo_version: CairoVersion, ) { @@ -1713,7 +1713,7 @@ fn test_valid_flag( #[rstest] fn test_only_query_flag( block_context: BlockContext, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, #[values(true, false)] only_query: bool, ) { let account_balance = BALANCE; @@ -1955,7 +1955,7 @@ fn test_l1_handler(#[values(false, true)] use_kzg_da: bool) { #[rstest] fn test_execute_tx_with_invalid_transaction_version( block_context: BlockContext, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, ) { let cairo_version = CairoVersion::Cairo0; let account = FeatureContract::AccountWithoutValidations(cairo_version); @@ -2028,7 +2028,7 @@ fn max_event_data() -> usize { }))] fn test_emit_event_exceeds_limit( block_context: BlockContext, - max_resource_bounds: DeprecatedResourceBoundsMapping, + max_resource_bounds: ValidResourceBounds, #[case] event_keys: Vec, #[case] event_data: Vec, #[case] n_emitted_events: usize,