From 3c9252919c5ee19a0427f20ca78cb1071041c942 Mon Sep 17 00:00:00 2001 From: Arni Hod Date: Tue, 3 Dec 2024 10:31:07 +0200 Subject: [PATCH] chore(starknet_api): move gas price related test consts to starknet api --- .../blockifier/transaction_executor_test.rs | 3 +- .../src/concurrency/versioned_state_test.rs | 4 +-- crates/blockifier/src/fee/fee_test.rs | 21 +++++------- crates/blockifier/src/fee/gas_usage_test.rs | 7 ++-- crates/blockifier/src/test_utils.rs | 34 ++++++------------- .../blockifier/src/test_utils/struct_impls.rs | 3 +- .../transaction/account_transactions_test.rs | 16 +++++---- .../src/transaction/execution_flavors_test.rs | 10 +++--- .../src/transaction/post_execution_test.rs | 3 +- .../blockifier/src/transaction/test_utils.rs | 24 ++++++------- .../src/transaction/transactions_test.rs | 18 +++++----- .../state_reader/reexecution_state_reader.rs | 2 +- crates/native_blockifier/src/py_state_diff.rs | 1 + crates/starknet_api/src/test_utils.rs | 26 +++++++++++++- .../src/state_reader.rs | 3 +- 15 files changed, 91 insertions(+), 84 deletions(-) diff --git a/crates/blockifier/src/blockifier/transaction_executor_test.rs b/crates/blockifier/src/blockifier/transaction_executor_test.rs index da5d3bab1a..fbdd6c89f4 100644 --- a/crates/blockifier/src/blockifier/transaction_executor_test.rs +++ b/crates/blockifier/src/blockifier/transaction_executor_test.rs @@ -4,7 +4,7 @@ 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::test_utils::{NonceManager, DEFAULT_STRK_L1_GAS_PRICE}; use starknet_api::transaction::fields::Fee; use starknet_api::transaction::TransactionVersion; use starknet_api::{declare_tx_args, deploy_account_tx_args, felt, invoke_tx_args, nonce}; @@ -29,7 +29,6 @@ use crate::test_utils::{ CairoVersion, RunnableCairo1, BALANCE, - DEFAULT_STRK_L1_GAS_PRICE, }; use crate::transaction::account_transaction::AccountTransaction; use crate::transaction::errors::TransactionExecutionError; diff --git a/crates/blockifier/src/concurrency/versioned_state_test.rs b/crates/blockifier/src/concurrency/versioned_state_test.rs index 6db3b95a1d..4c09b2cacd 100644 --- a/crates/blockifier/src/concurrency/versioned_state_test.rs +++ b/crates/blockifier/src/concurrency/versioned_state_test.rs @@ -7,7 +7,7 @@ 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::test_utils::{NonceManager, DEFAULT_STRK_L1_GAS_PRICE}; use starknet_api::transaction::fields::{ContractAddressSalt, ValidResourceBounds}; use starknet_api::{ calldata, @@ -43,7 +43,7 @@ use crate::state::state_api::{State, StateReader, UpdatableState}; 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::{CairoVersion, RunnableCairo1, BALANCE, DEFAULT_STRK_L1_GAS_PRICE}; +use crate::test_utils::{CairoVersion, RunnableCairo1, BALANCE}; use crate::transaction::account_transaction::AccountTransaction; use crate::transaction::objects::HasRelatedFeeType; use crate::transaction::test_utils::{default_all_resource_bounds, l1_resource_bounds}; diff --git a/crates/blockifier/src/fee/fee_test.rs b/crates/blockifier/src/fee/fee_test.rs index aa59e48f62..74ab5b3596 100644 --- a/crates/blockifier/src/fee/fee_test.rs +++ b/crates/blockifier/src/fee/fee_test.rs @@ -4,6 +4,14 @@ use rstest::rstest; use starknet_api::block::{FeeType, GasPrice, NonzeroGasPrice}; use starknet_api::execution_resources::{GasAmount, GasVector}; use starknet_api::invoke_tx_args; +use starknet_api::test_utils::{ + DEFAULT_ETH_L1_DATA_GAS_PRICE, + DEFAULT_ETH_L1_GAS_PRICE, + DEFAULT_L1_DATA_GAS_MAX_AMOUNT, + DEFAULT_L1_GAS_AMOUNT, + DEFAULT_L2_GAS_MAX_AMOUNT, + DEFAULT_STRK_L1_GAS_PRICE, +}; use starknet_api::transaction::fields::{ AllResourceBounds, Fee, @@ -20,18 +28,7 @@ use crate::fee::fee_utils::{get_fee_by_gas_vector, get_vm_resources_cost}; use crate::fee::receipt::TransactionReceipt; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; -use crate::test_utils::{ - gas_vector_from_vm_usage, - get_vm_resource_usage, - CairoVersion, - BALANCE, - DEFAULT_ETH_L1_DATA_GAS_PRICE, - DEFAULT_ETH_L1_GAS_PRICE, - DEFAULT_L1_DATA_GAS_MAX_AMOUNT, - DEFAULT_L1_GAS_AMOUNT, - DEFAULT_L2_GAS_MAX_AMOUNT, - DEFAULT_STRK_L1_GAS_PRICE, -}; +use crate::test_utils::{gas_vector_from_vm_usage, get_vm_resource_usage, CairoVersion, BALANCE}; use crate::transaction::test_utils::{ all_resource_bounds, block_context, diff --git a/crates/blockifier/src/fee/gas_usage_test.rs b/crates/blockifier/src/fee/gas_usage_test.rs index f6fe3e315a..a3fd66b4eb 100644 --- a/crates/blockifier/src/fee/gas_usage_test.rs +++ b/crates/blockifier/src/fee/gas_usage_test.rs @@ -6,6 +6,7 @@ use rstest::{fixture, rstest}; use starknet_api::block::{FeeType, StarknetVersion}; use starknet_api::execution_resources::{GasAmount, GasVector}; use starknet_api::invoke_tx_args; +use starknet_api::test_utils::{DEFAULT_ETH_L1_DATA_GAS_PRICE, DEFAULT_ETH_L1_GAS_PRICE}; use starknet_api::transaction::fields::GasVectorComputationMode; use starknet_api::transaction::{EventContent, EventData, EventKey}; use starknet_types_core::felt::Felt; @@ -23,11 +24,7 @@ use crate::fee::resources::{ TransactionResources, }; use crate::state::cached_state::StateChangesCount; -use crate::test_utils::{ - get_vm_resource_usage, - DEFAULT_ETH_L1_DATA_GAS_PRICE, - DEFAULT_ETH_L1_GAS_PRICE, -}; +use crate::test_utils::get_vm_resource_usage; use crate::transaction::test_utils::invoke_tx_with_default_flags; use crate::utils::u64_from_usize; use crate::versioned_constants::{ResourceCost, VersionedConstants, VmResourceCosts}; diff --git a/crates/blockifier/src/test_utils.rs b/crates/blockifier/src/test_utils.rs index 95e461807f..b5b621b49f 100644 --- a/crates/blockifier/src/test_utils.rs +++ b/crates/blockifier/src/test_utils.rs @@ -16,11 +16,20 @@ use cairo_vm::types::builtin_name::BuiltinName; use cairo_vm::vm::runners::cairo_runner::ExecutionResources; use infra_utils::compile_time_cargo_manifest_dir; use starknet_api::abi::abi_utils::{get_fee_token_var_address, selector_from_name}; -use starknet_api::block::{BlockHash, BlockHashAndNumber, BlockNumber, GasPrice, NonzeroGasPrice}; +use starknet_api::block::{BlockHash, BlockHashAndNumber, BlockNumber}; use starknet_api::core::{ClassHash, ContractAddress}; use starknet_api::execution_resources::{GasAmount, GasVector}; use starknet_api::hash::StarkHash; use starknet_api::state::StorageKey; +use starknet_api::test_utils::{ + DEFAULT_L1_DATA_GAS_MAX_AMOUNT, + DEFAULT_L1_GAS_AMOUNT, + DEFAULT_L2_GAS_MAX_AMOUNT, + DEFAULT_STRK_L1_DATA_GAS_PRICE, + DEFAULT_STRK_L1_GAS_PRICE, + DEFAULT_STRK_L2_GAS_PRICE, + MAX_FEE, +}; use starknet_api::transaction::fields::{ Calldata, ContractAddressSalt, @@ -151,29 +160,6 @@ pub fn test_erc20_sequencer_balance_key() -> StorageKey { get_fee_token_var_address(contract_address!(TEST_SEQUENCER_ADDRESS)) } -// The max_fee / resource bounds used for txs in this test. -// V3 transactions: -pub const DEFAULT_L1_GAS_AMOUNT: GasAmount = GasAmount(u64::pow(10, 6)); -pub const DEFAULT_L1_DATA_GAS_MAX_AMOUNT: GasAmount = GasAmount(u64::pow(10, 6)); -pub const DEFAULT_L2_GAS_MAX_AMOUNT: GasAmount = GasAmount(u64::pow(10, 9)); -pub const MAX_L1_GAS_PRICE: NonzeroGasPrice = DEFAULT_STRK_L1_GAS_PRICE; -pub const MAX_L2_GAS_PRICE: NonzeroGasPrice = DEFAULT_STRK_L2_GAS_PRICE; -pub const MAX_L1_DATA_GAS_PRICE: NonzeroGasPrice = DEFAULT_STRK_L1_DATA_GAS_PRICE; - -pub const DEFAULT_ETH_L1_GAS_PRICE: NonzeroGasPrice = - NonzeroGasPrice::new_unchecked(GasPrice(100 * u128::pow(10, 9))); // Given in units of Wei. -pub const DEFAULT_STRK_L1_GAS_PRICE: NonzeroGasPrice = - NonzeroGasPrice::new_unchecked(GasPrice(100 * u128::pow(10, 9))); // Given in units of Fri. -pub const DEFAULT_ETH_L1_DATA_GAS_PRICE: NonzeroGasPrice = - NonzeroGasPrice::new_unchecked(GasPrice(u128::pow(10, 6))); // Given in units of Wei. -pub const DEFAULT_STRK_L1_DATA_GAS_PRICE: NonzeroGasPrice = - NonzeroGasPrice::new_unchecked(GasPrice(u128::pow(10, 9))); // Given in units of Fri. -pub const DEFAULT_STRK_L2_GAS_PRICE: NonzeroGasPrice = - NonzeroGasPrice::new_unchecked(GasPrice(u128::pow(10, 9))); - -// Deprecated transactions: -pub const MAX_FEE: Fee = DEFAULT_L1_GAS_AMOUNT.nonzero_saturating_mul(DEFAULT_ETH_L1_GAS_PRICE); - // Commitment fee bounds. const DEFAULT_L1_BOUNDS_COMMITTED_FEE: Fee = DEFAULT_L1_GAS_AMOUNT.nonzero_saturating_mul(DEFAULT_STRK_L1_GAS_PRICE); diff --git a/crates/blockifier/src/test_utils/struct_impls.rs b/crates/blockifier/src/test_utils/struct_impls.rs index fe9fdebff5..e16b4b9de9 100644 --- a/crates/blockifier/src/test_utils/struct_impls.rs +++ b/crates/blockifier/src/test_utils/struct_impls.rs @@ -14,6 +14,7 @@ use starknet_api::block::{BlockInfo, BlockNumber, BlockTimestamp, NonzeroGasPric use starknet_api::contract_address; use starknet_api::core::{ChainId, ClassHash}; use starknet_api::deprecated_contract_class::ContractClass as DeprecatedContractClass; +use starknet_api::test_utils::{DEFAULT_ETH_L1_DATA_GAS_PRICE, DEFAULT_ETH_L1_GAS_PRICE}; use super::{ update_json_value, @@ -40,8 +41,6 @@ use crate::test_utils::{ get_raw_contract_class, CURRENT_BLOCK_NUMBER, CURRENT_BLOCK_TIMESTAMP, - DEFAULT_ETH_L1_DATA_GAS_PRICE, - DEFAULT_ETH_L1_GAS_PRICE, DEFAULT_STRK_L1_DATA_GAS_PRICE, DEFAULT_STRK_L1_GAS_PRICE, }; diff --git a/crates/blockifier/src/transaction/account_transactions_test.rs b/crates/blockifier/src/transaction/account_transactions_test.rs index 2deb9e53ab..53468d4d64 100644 --- a/crates/blockifier/src/transaction/account_transactions_test.rs +++ b/crates/blockifier/src/transaction/account_transactions_test.rs @@ -23,7 +23,15 @@ use starknet_api::state::StorageKey; 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::test_utils::{ + NonceManager, + DEFAULT_L1_DATA_GAS_MAX_AMOUNT, + DEFAULT_L1_GAS_AMOUNT, + DEFAULT_L2_GAS_MAX_AMOUNT, + DEFAULT_STRK_L1_GAS_PRICE, + DEFAULT_STRK_L2_GAS_PRICE, + MAX_FEE, +}; use starknet_api::transaction::constants::TRANSFER_ENTRY_POINT_NAME; use starknet_api::transaction::fields::{ AllResourceBounds, @@ -76,12 +84,6 @@ use crate::test_utils::{ CompilerBasedVersion, RunnableCairo1, BALANCE, - DEFAULT_L1_DATA_GAS_MAX_AMOUNT, - DEFAULT_L1_GAS_AMOUNT, - DEFAULT_L2_GAS_MAX_AMOUNT, - DEFAULT_STRK_L1_GAS_PRICE, - DEFAULT_STRK_L2_GAS_PRICE, - MAX_FEE, }; use crate::transaction::account_transaction::{ AccountTransaction, diff --git a/crates/blockifier/src/transaction/execution_flavors_test.rs b/crates/blockifier/src/transaction/execution_flavors_test.rs index e13abc1a1d..fecc882b32 100644 --- a/crates/blockifier/src/transaction/execution_flavors_test.rs +++ b/crates/blockifier/src/transaction/execution_flavors_test.rs @@ -5,7 +5,12 @@ use starknet_api::block::FeeType; use starknet_api::core::ContractAddress; use starknet_api::execution_resources::{GasAmount, GasVector}; use starknet_api::test_utils::invoke::{executable_invoke_tx, InvokeTxArgs}; -use starknet_api::test_utils::NonceManager; +use starknet_api::test_utils::{ + NonceManager, + DEFAULT_L1_GAS_AMOUNT, + DEFAULT_STRK_L1_GAS_PRICE, + MAX_FEE, +}; use starknet_api::transaction::fields::{ Calldata, Fee, @@ -33,9 +38,6 @@ use crate::test_utils::{ get_tx_resources, CairoVersion, BALANCE, - DEFAULT_L1_GAS_AMOUNT, - DEFAULT_STRK_L1_GAS_PRICE, - MAX_FEE, }; use crate::transaction::account_transaction::{AccountTransaction, ExecutionFlags}; use crate::transaction::errors::{ diff --git a/crates/blockifier/src/transaction/post_execution_test.rs b/crates/blockifier/src/transaction/post_execution_test.rs index fe1a880e5e..7cd84fc960 100644 --- a/crates/blockifier/src/transaction/post_execution_test.rs +++ b/crates/blockifier/src/transaction/post_execution_test.rs @@ -4,6 +4,7 @@ use starknet_api::block::FeeType; use starknet_api::core::ContractAddress; use starknet_api::execution_resources::{GasAmount, GasVector}; use starknet_api::state::StorageKey; +use starknet_api::test_utils::DEFAULT_STRK_L1_GAS_PRICE; use starknet_api::transaction::fields::{ AllResourceBounds, Calldata, @@ -22,7 +23,7 @@ use crate::fee::fee_checks::FeeCheckError; use crate::state::state_api::StateReader; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; -use crate::test_utils::{create_calldata, CairoVersion, BALANCE, DEFAULT_STRK_L1_GAS_PRICE}; +use crate::test_utils::{create_calldata, CairoVersion, BALANCE}; use crate::transaction::account_transaction::AccountTransaction; use crate::transaction::errors::TransactionExecutionError; use crate::transaction::objects::{HasRelatedFeeType, TransactionInfoCreator}; diff --git a/crates/blockifier/src/transaction/test_utils.rs b/crates/blockifier/src/transaction/test_utils.rs index bf3ed8ec25..c4049ff8c9 100644 --- a/crates/blockifier/src/transaction/test_utils.rs +++ b/crates/blockifier/src/transaction/test_utils.rs @@ -7,7 +7,16 @@ use starknet_api::execution_resources::{GasAmount, GasVector}; use starknet_api::test_utils::declare::executable_declare_tx; use starknet_api::test_utils::deploy_account::{executable_deploy_account_tx, DeployAccountTxArgs}; use starknet_api::test_utils::invoke::{executable_invoke_tx, InvokeTxArgs}; -use starknet_api::test_utils::NonceManager; +use starknet_api::test_utils::{ + NonceManager, + DEFAULT_L1_DATA_GAS_MAX_AMOUNT, + DEFAULT_L1_GAS_AMOUNT, + DEFAULT_L2_GAS_MAX_AMOUNT, + DEFAULT_STRK_L1_DATA_GAS_PRICE, + DEFAULT_STRK_L1_GAS_PRICE, + DEFAULT_STRK_L2_GAS_PRICE, + MAX_FEE, +}; use starknet_api::transaction::fields::{ AllResourceBounds, ContractAddressSalt, @@ -28,18 +37,7 @@ use crate::state::state_api::State; 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::{ - create_calldata, - CairoVersion, - BALANCE, - DEFAULT_L1_DATA_GAS_MAX_AMOUNT, - DEFAULT_L1_GAS_AMOUNT, - DEFAULT_L2_GAS_MAX_AMOUNT, - DEFAULT_STRK_L1_DATA_GAS_PRICE, - DEFAULT_STRK_L1_GAS_PRICE, - DEFAULT_STRK_L2_GAS_PRICE, - MAX_FEE, -}; +use crate::test_utils::{create_calldata, CairoVersion, BALANCE}; use crate::transaction::account_transaction::{AccountTransaction, ExecutionFlags}; use crate::transaction::objects::{TransactionExecutionInfo, TransactionExecutionResult}; use crate::transaction::transaction_types::TransactionType; diff --git a/crates/blockifier/src/transaction/transactions_test.rs b/crates/blockifier/src/transaction/transactions_test.rs index e6d3465172..e2b3cfc1af 100644 --- a/crates/blockifier/src/transaction/transactions_test.rs +++ b/crates/blockifier/src/transaction/transactions_test.rs @@ -22,7 +22,16 @@ use starknet_api::state::StorageKey; use starknet_api::test_utils::declare::executable_declare_tx; use starknet_api::test_utils::deploy_account::{executable_deploy_account_tx, DeployAccountTxArgs}; use starknet_api::test_utils::invoke::{executable_invoke_tx, InvokeTxArgs}; -use starknet_api::test_utils::NonceManager; +use starknet_api::test_utils::{ + NonceManager, + DEFAULT_L1_DATA_GAS_MAX_AMOUNT, + DEFAULT_L1_GAS_AMOUNT, + DEFAULT_L2_GAS_MAX_AMOUNT, + DEFAULT_STRK_L1_DATA_GAS_PRICE, + DEFAULT_STRK_L1_GAS_PRICE, + DEFAULT_STRK_L2_GAS_PRICE, + MAX_FEE, +}; use starknet_api::transaction::fields::Resource::{L1DataGas, L1Gas, L2Gas}; use starknet_api::transaction::fields::{ AllResourceBounds, @@ -106,13 +115,6 @@ use crate::test_utils::{ CURRENT_BLOCK_NUMBER_FOR_VALIDATE, CURRENT_BLOCK_TIMESTAMP, CURRENT_BLOCK_TIMESTAMP_FOR_VALIDATE, - DEFAULT_L1_DATA_GAS_MAX_AMOUNT, - DEFAULT_L1_GAS_AMOUNT, - DEFAULT_L2_GAS_MAX_AMOUNT, - DEFAULT_STRK_L1_DATA_GAS_PRICE, - DEFAULT_STRK_L1_GAS_PRICE, - DEFAULT_STRK_L2_GAS_PRICE, - MAX_FEE, TEST_SEQUENCER_ADDRESS, }; use crate::transaction::account_transaction::{AccountTransaction, ExecutionFlags}; diff --git a/crates/blockifier_reexecution/src/state_reader/reexecution_state_reader.rs b/crates/blockifier_reexecution/src/state_reader/reexecution_state_reader.rs index 05203c9010..19b52b66a4 100644 --- a/crates/blockifier_reexecution/src/state_reader/reexecution_state_reader.rs +++ b/crates/blockifier_reexecution/src/state_reader/reexecution_state_reader.rs @@ -2,13 +2,13 @@ use blockifier::blockifier::config::TransactionExecutorConfig; use blockifier::blockifier::transaction_executor::TransactionExecutor; use blockifier::state::cached_state::CommitmentStateDiff; use blockifier::state::state_api::{StateReader, StateResult}; -use blockifier::test_utils::MAX_FEE; use blockifier::transaction::account_transaction::ExecutionFlags; use blockifier::transaction::transaction_execution::Transaction as BlockifierTransaction; use papyrus_execution::DEPRECATED_CONTRACT_SIERRA_SIZE; use starknet_api::block::{BlockHash, BlockNumber}; use starknet_api::contract_class::{ClassInfo, SierraVersion}; use starknet_api::core::ClassHash; +use starknet_api::test_utils::MAX_FEE; use starknet_api::transaction::{Transaction, TransactionHash}; use starknet_core::types::ContractClass as StarknetContractClass; diff --git a/crates/native_blockifier/src/py_state_diff.rs b/crates/native_blockifier/src/py_state_diff.rs index b6e6647ff1..af6353fa6f 100644 --- a/crates/native_blockifier/src/py_state_diff.rs +++ b/crates/native_blockifier/src/py_state_diff.rs @@ -19,6 +19,7 @@ use crate::errors::{ }; use crate::py_utils::PyFelt; +// TODO(Arni): consider moving to starknet api. const DEFAULT_ETH_L1_GAS_PRICE: GasPrice = GasPrice(100 * u128::pow(10, 9)); const DEFAULT_STRK_L1_GAS_PRICE: GasPrice = GasPrice(100 * u128::pow(10, 9)); const DEFAULT_ETH_L1_DATA_GAS_PRICE: GasPrice = GasPrice(u128::pow(10, 6)); diff --git a/crates/starknet_api/src/test_utils.rs b/crates/starknet_api/src/test_utils.rs index 1d114beecd..1841cb0e12 100644 --- a/crates/starknet_api/src/test_utils.rs +++ b/crates/starknet_api/src/test_utils.rs @@ -7,9 +7,11 @@ use serde::{Deserialize, Serialize}; use serde_json::to_string_pretty; use starknet_types_core::felt::Felt; -use crate::block::BlockNumber; +use crate::block::{BlockNumber, GasPrice, NonzeroGasPrice}; use crate::core::{ChainId, ContractAddress, Nonce}; +use crate::execution_resources::GasAmount; use crate::rpc_transaction::RpcTransaction; +use crate::transaction::fields::Fee; use crate::transaction::{Transaction, TransactionHash}; pub mod declare; @@ -113,3 +115,25 @@ pub fn rpc_tx_to_json(tx: &RpcTransaction) -> String { // Serialize back to pretty JSON string to_string_pretty(&tx_json).expect("Failed to serialize transaction") } + +// V3 transactions: +pub const DEFAULT_L1_GAS_AMOUNT: GasAmount = GasAmount(u64::pow(10, 6)); +pub const DEFAULT_L1_DATA_GAS_MAX_AMOUNT: GasAmount = GasAmount(u64::pow(10, 6)); +pub const DEFAULT_L2_GAS_MAX_AMOUNT: GasAmount = GasAmount(u64::pow(10, 9)); +pub const MAX_L1_GAS_PRICE: NonzeroGasPrice = DEFAULT_STRK_L1_GAS_PRICE; +pub const MAX_L2_GAS_PRICE: NonzeroGasPrice = DEFAULT_STRK_L2_GAS_PRICE; +pub const MAX_L1_DATA_GAS_PRICE: NonzeroGasPrice = DEFAULT_STRK_L1_DATA_GAS_PRICE; + +pub const DEFAULT_ETH_L1_GAS_PRICE: NonzeroGasPrice = + NonzeroGasPrice::new_unchecked(GasPrice(100 * u128::pow(10, 9))); // Given in units of Wei. +pub const DEFAULT_STRK_L1_GAS_PRICE: NonzeroGasPrice = + NonzeroGasPrice::new_unchecked(GasPrice(100 * u128::pow(10, 9))); // Given in units of Fri. +pub const DEFAULT_ETH_L1_DATA_GAS_PRICE: NonzeroGasPrice = + NonzeroGasPrice::new_unchecked(GasPrice(u128::pow(10, 6))); // Given in units of Wei. +pub const DEFAULT_STRK_L1_DATA_GAS_PRICE: NonzeroGasPrice = + NonzeroGasPrice::new_unchecked(GasPrice(u128::pow(10, 9))); // Given in units of Fri. +pub const DEFAULT_STRK_L2_GAS_PRICE: NonzeroGasPrice = + NonzeroGasPrice::new_unchecked(GasPrice(u128::pow(10, 9))); + +// Deprecated transactions: +pub const MAX_FEE: Fee = DEFAULT_L1_GAS_AMOUNT.nonzero_saturating_mul(DEFAULT_ETH_L1_GAS_PRICE); diff --git a/crates/starknet_integration_tests/src/state_reader.rs b/crates/starknet_integration_tests/src/state_reader.rs index 7462991e16..f037b5c59c 100644 --- a/crates/starknet_integration_tests/src/state_reader.rs +++ b/crates/starknet_integration_tests/src/state_reader.rs @@ -9,8 +9,6 @@ use blockifier::test_utils::{ RunnableCairo1, BALANCE, CURRENT_BLOCK_TIMESTAMP, - DEFAULT_ETH_L1_GAS_PRICE, - DEFAULT_STRK_L1_GAS_PRICE, TEST_SEQUENCER_ADDRESS, }; use blockifier::versioned_constants::VersionedConstants; @@ -39,6 +37,7 @@ use starknet_api::block::{ use starknet_api::core::{ChainId, ClassHash, ContractAddress, Nonce, SequencerContractAddress}; use starknet_api::deprecated_contract_class::ContractClass as DeprecatedContractClass; use starknet_api::state::{SierraContractClass, StorageKey, ThinStateDiff}; +use starknet_api::test_utils::{DEFAULT_ETH_L1_GAS_PRICE, DEFAULT_STRK_L1_GAS_PRICE}; use starknet_api::transaction::fields::Fee; use starknet_api::{contract_address, felt}; use starknet_client::reader::PendingData;