diff --git a/crates/batcher/src/batcher_test.rs b/crates/batcher/src/batcher_test.rs index 32c2646245..269b5305a9 100644 --- a/crates/batcher/src/batcher_test.rs +++ b/crates/batcher/src/batcher_test.rs @@ -14,7 +14,7 @@ use starknet_api::core::{ContractAddress, Nonce, PatriciaKey, StateDiffCommitmen use starknet_api::executable_transaction::Transaction; use starknet_api::hash::PoseidonHash; use starknet_api::state::ThinStateDiff; -use starknet_api::transaction::TransactionHash; +use starknet_api::transaction::fields::TransactionHash; use starknet_api::{felt, nonce, patricia_key}; use starknet_batcher_types::batcher_types::{ BuildProposalInput, diff --git a/crates/batcher/src/block_builder.rs b/crates/batcher/src/block_builder.rs index 98c25d25cc..4d54e11604 100644 --- a/crates/batcher/src/block_builder.rs +++ b/crates/batcher/src/block_builder.rs @@ -29,7 +29,7 @@ use serde::{Deserialize, Serialize}; use starknet_api::block::{BlockNumber, BlockTimestamp, NonzeroGasPrice}; use starknet_api::core::ContractAddress; use starknet_api::executable_transaction::Transaction; -use starknet_api::transaction::TransactionHash; +use starknet_api::transaction::fields::TransactionHash; use thiserror::Error; use tokio::sync::Mutex; use tokio::{pin, time}; diff --git a/crates/batcher/src/test_utils.rs b/crates/batcher/src/test_utils.rs index 3f4dab3f32..715213b984 100644 --- a/crates/batcher/src/test_utils.rs +++ b/crates/batcher/src/test_utils.rs @@ -7,7 +7,7 @@ use indexmap::IndexMap; use starknet_api::executable_transaction::Transaction; use starknet_api::felt; use starknet_api::test_utils::invoke::{executable_invoke_tx, InvokeTxArgs}; -use starknet_api::transaction::TransactionHash; +use starknet_api::transaction::fields::TransactionHash; use crate::block_builder::BlockExecutionArtifacts; diff --git a/crates/blockifier/src/abi/constants.rs b/crates/blockifier/src/abi/constants.rs index edf924694d..27734bb1a7 100644 --- a/crates/blockifier/src/abi/constants.rs +++ b/crates/blockifier/src/abi/constants.rs @@ -1,4 +1,4 @@ -use starknet_api::transaction::TransactionVersion; +use starknet_api::transaction::fields::TransactionVersion; use starknet_types_core::felt::Felt; pub const CONSTRUCTOR_ENTRY_POINT_NAME: &str = "constructor"; diff --git a/crates/blockifier/src/blockifier/stateful_validator_test.rs b/crates/blockifier/src/blockifier/stateful_validator_test.rs index 42b2b57b04..c5078a1187 100644 --- a/crates/blockifier/src/blockifier/stateful_validator_test.rs +++ b/crates/blockifier/src/blockifier/stateful_validator_test.rs @@ -1,6 +1,6 @@ use assert_matches::assert_matches; use rstest::rstest; -use starknet_api::transaction::{TransactionVersion, ValidResourceBounds}; +use starknet_api::transaction::fields::{TransactionVersion, ValidResourceBounds}; use crate::blockifier::stateful_validator::StatefulValidator; use crate::context::BlockContext; diff --git a/crates/blockifier/src/blockifier/transaction_executor_test.rs b/crates/blockifier/src/blockifier/transaction_executor_test.rs index 014b7a5e7f..332ced3f03 100644 --- a/crates/blockifier/src/blockifier/transaction_executor_test.rs +++ b/crates/blockifier/src/blockifier/transaction_executor_test.rs @@ -2,7 +2,7 @@ use assert_matches::assert_matches; use pretty_assertions::assert_eq; use rstest::rstest; use starknet_api::test_utils::NonceManager; -use starknet_api::transaction::{Fee, TransactionVersion}; +use starknet_api::transaction::fields::{Fee, TransactionVersion}; use starknet_api::{declare_tx_args, deploy_account_tx_args, felt, invoke_tx_args, nonce}; use starknet_types_core::felt::Felt; diff --git a/crates/blockifier/src/bouncer_test.rs b/crates/blockifier/src/bouncer_test.rs index 6973eae1fe..b1bdf52fa3 100644 --- a/crates/blockifier/src/bouncer_test.rs +++ b/crates/blockifier/src/bouncer_test.rs @@ -5,8 +5,8 @@ use cairo_vm::types::builtin_name::BuiltinName; use cairo_vm::vm::runners::cairo_runner::ExecutionResources; use rstest::rstest; use starknet_api::core::{ClassHash, ContractAddress, PatriciaKey}; -use starknet_api::transaction::Fee; -use starknet_api::{class_hash, contract_address, felt, patricia_key, storage_key}; +use starknet_api::transaction::fields::Fee; +use starknet_api::{class_hash, contract_address, patricia_key, storage_key}; use super::BouncerConfig; use crate::blockifier::transaction_executor::TransactionExecutorError; diff --git a/crates/blockifier/src/concurrency/fee_utils.rs b/crates/blockifier/src/concurrency/fee_utils.rs index e40f492319..5b1fb70316 100644 --- a/crates/blockifier/src/concurrency/fee_utils.rs +++ b/crates/blockifier/src/concurrency/fee_utils.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use num_traits::ToPrimitive; use starknet_api::core::ContractAddress; -use starknet_api::transaction::Fee; +use starknet_api::transaction::fields::Fee; use starknet_types_core::felt::Felt; use crate::context::{BlockContext, TransactionContext}; diff --git a/crates/blockifier/src/concurrency/fee_utils_test.rs b/crates/blockifier/src/concurrency/fee_utils_test.rs index ba6cc8df95..1bf84654ed 100644 --- a/crates/blockifier/src/concurrency/fee_utils_test.rs +++ b/crates/blockifier/src/concurrency/fee_utils_test.rs @@ -1,6 +1,6 @@ use num_bigint::BigUint; use rstest::rstest; -use starknet_api::transaction::{Fee, ValidResourceBounds}; +use starknet_api::transaction::fields::{Fee, ValidResourceBounds}; use starknet_api::{felt, invoke_tx_args}; use starknet_types_core::felt::Felt; @@ -56,7 +56,7 @@ pub fn test_fill_sequencer_balance_reads( #[case::overflow(Fee(150_u128), felt!(u128::MAX), felt!(5_u128))] #[case::overflow_edge_case(Fee(500_u128), felt!(u128::MAX), felt!(u128::MAX-1))] pub fn test_add_fee_to_sequencer_balance( - #[case] actual_fee: starknet_api::transaction::Fee, + #[case] actual_fee: Fee, #[case] sequencer_balance_low: Felt, #[case] sequencer_balance_high: Felt, ) { diff --git a/crates/blockifier/src/concurrency/test_utils.rs b/crates/blockifier/src/concurrency/test_utils.rs index 87722b1171..a8c8b92871 100644 --- a/crates/blockifier/src/concurrency/test_utils.rs +++ b/crates/blockifier/src/concurrency/test_utils.rs @@ -1,6 +1,6 @@ use rstest::fixture; use starknet_api::core::{ClassHash, ContractAddress, PatriciaKey}; -use starknet_api::{class_hash, contract_address, felt, patricia_key}; +use starknet_api::{class_hash, contract_address, patricia_key}; use crate::concurrency::versioned_state::{ThreadSafeVersionedState, VersionedState}; use crate::context::BlockContext; diff --git a/crates/blockifier/src/concurrency/versioned_state_test.rs b/crates/blockifier/src/concurrency/versioned_state_test.rs index 52c5621968..07009b6949 100644 --- a/crates/blockifier/src/concurrency/versioned_state_test.rs +++ b/crates/blockifier/src/concurrency/versioned_state_test.rs @@ -12,7 +12,7 @@ use starknet_api::core::{ PatriciaKey, }; use starknet_api::test_utils::NonceManager; -use starknet_api::transaction::{ContractAddressSalt, ValidResourceBounds}; +use starknet_api::transaction::fields::{ContractAddressSalt, ValidResourceBounds}; use starknet_api::{ calldata, class_hash, diff --git a/crates/blockifier/src/concurrency/worker_logic_test.rs b/crates/blockifier/src/concurrency/worker_logic_test.rs index 134324d0bf..30a35fc74c 100644 --- a/crates/blockifier/src/concurrency/worker_logic_test.rs +++ b/crates/blockifier/src/concurrency/worker_logic_test.rs @@ -4,7 +4,7 @@ use std::sync::Mutex; use rstest::rstest; use starknet_api::core::{ContractAddress, Nonce, PatriciaKey}; use starknet_api::test_utils::NonceManager; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ ContractAddressSalt, Fee, TransactionVersion, diff --git a/crates/blockifier/src/context.rs b/crates/blockifier/src/context.rs index 5f577ad1ad..f0ff3bd6cd 100644 --- a/crates/blockifier/src/context.rs +++ b/crates/blockifier/src/context.rs @@ -5,7 +5,11 @@ use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use starknet_api::block::GasPriceVector; use starknet_api::core::{ChainId, ContractAddress}; -use starknet_api::transaction::{AllResourceBounds, GasVectorComputationMode, ValidResourceBounds}; +use starknet_api::transaction::fields::{ + AllResourceBounds, + GasVectorComputationMode, + ValidResourceBounds, +}; use crate::blockifier::block::BlockInfo; use crate::bouncer::BouncerConfig; diff --git a/crates/blockifier/src/execution/call_info.rs b/crates/blockifier/src/execution/call_info.rs index d538c72d7d..e38eb29235 100644 --- a/crates/blockifier/src/execution/call_info.rs +++ b/crates/blockifier/src/execution/call_info.rs @@ -21,7 +21,7 @@ pub struct Retdata(pub Vec); #[macro_export] macro_rules! retdata { ( $( $x:expr ),* ) => { - Retdata(vec![$($x),*]) + $crate::execution::call_info::Retdata(vec![$($x),*]) }; } diff --git a/crates/blockifier/src/execution/contract_address_test.rs b/crates/blockifier/src/execution/contract_address_test.rs index 6344803382..cf20aa5f89 100644 --- a/crates/blockifier/src/execution/contract_address_test.rs +++ b/crates/blockifier/src/execution/contract_address_test.rs @@ -1,11 +1,11 @@ use rstest::rstest; use starknet_api::core::{calculate_contract_address, ClassHash, ContractAddress}; -use starknet_api::transaction::{Calldata, ContractAddressSalt}; +use starknet_api::transaction::fields::{Calldata, ContractAddressSalt}; use starknet_api::{calldata, felt}; use crate::abi::abi_utils::selector_from_name; use crate::context::ChainInfo; -use crate::execution::call_info::{CallExecution, Retdata}; +use crate::execution::call_info::CallExecution; use crate::execution::entry_point::CallEntryPoint; use crate::retdata; use crate::state::cached_state::CachedState; diff --git a/crates/blockifier/src/execution/deprecated_syscalls/deprecated_syscalls_test.rs b/crates/blockifier/src/execution/deprecated_syscalls/deprecated_syscalls_test.rs index e9e309df68..3ee30dd2c8 100644 --- a/crates/blockifier/src/execution/deprecated_syscalls/deprecated_syscalls_test.rs +++ b/crates/blockifier/src/execution/deprecated_syscalls/deprecated_syscalls_test.rs @@ -7,24 +7,22 @@ use pretty_assertions::assert_eq; use rstest::rstest; use starknet_api::core::{calculate_contract_address, ChainId, PatriciaKey}; use starknet_api::state::StorageKey; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ Calldata, ContractAddressSalt, - EventContent, - EventData, - EventKey, Fee, TransactionHash, TransactionVersion, QUERY_VERSION_BASE_BIT, }; +use starknet_api::transaction::{EventContent, EventData, EventKey}; use starknet_api::{calldata, felt, nonce, storage_key}; use starknet_types_core::felt::Felt; use test_case::test_case; use crate::abi::abi_utils::selector_from_name; use crate::context::ChainInfo; -use crate::execution::call_info::{CallExecution, CallInfo, OrderedEvent, Retdata}; +use crate::execution::call_info::{CallExecution, CallInfo, OrderedEvent}; use crate::execution::common_hints::ExecutionMode; use crate::execution::deprecated_syscalls::DeprecatedSyscallSelector; use crate::execution::entry_point::{CallEntryPoint, CallType}; diff --git a/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs b/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs index 4cb8d872d5..c94c4f8806 100644 --- a/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs +++ b/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs @@ -20,7 +20,7 @@ use num_bigint::{BigUint, TryFromBigIntError}; use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector}; use starknet_api::state::StorageKey; -use starknet_api::transaction::Calldata; +use starknet_api::transaction::fields::Calldata; use starknet_api::StarknetApiError; use starknet_types_core::felt::{Felt, FromStrError}; use thiserror::Error; diff --git a/crates/blockifier/src/execution/deprecated_syscalls/mod.rs b/crates/blockifier/src/execution/deprecated_syscalls/mod.rs index 5f61229f02..acdc54b386 100644 --- a/crates/blockifier/src/execution/deprecated_syscalls/mod.rs +++ b/crates/blockifier/src/execution/deprecated_syscalls/mod.rs @@ -11,14 +11,8 @@ use starknet_api::core::{ EthAddress, }; use starknet_api::state::StorageKey; -use starknet_api::transaction::{ - Calldata, - ContractAddressSalt, - EventContent, - EventData, - EventKey, - L2ToL1Payload, -}; +use starknet_api::transaction::fields::{Calldata, ContractAddressSalt}; +use starknet_api::transaction::{EventContent, EventData, EventKey, L2ToL1Payload}; use starknet_types_core::felt::Felt; use strum_macros::EnumIter; diff --git a/crates/blockifier/src/execution/entry_point.rs b/crates/blockifier/src/execution/entry_point.rs index e251e15bff..be52e2059d 100644 --- a/crates/blockifier/src/execution/entry_point.rs +++ b/crates/blockifier/src/execution/entry_point.rs @@ -9,7 +9,7 @@ use serde::Serialize; use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector}; use starknet_api::state::StorageKey; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ AllResourceBounds, Calldata, ResourceBounds, diff --git a/crates/blockifier/src/execution/entry_point_test.rs b/crates/blockifier/src/execution/entry_point_test.rs index 3bc1c9eea5..b3e76b4985 100644 --- a/crates/blockifier/src/execution/entry_point_test.rs +++ b/crates/blockifier/src/execution/entry_point_test.rs @@ -5,12 +5,12 @@ use num_bigint::BigInt; use pretty_assertions::assert_eq; use starknet_api::core::{EntryPointSelector, PatriciaKey}; use starknet_api::execution_utils::format_panic_data; -use starknet_api::transaction::{Calldata, Fee}; +use starknet_api::transaction::fields::{Calldata, Fee}; use starknet_api::{calldata, felt, storage_key}; use crate::abi::abi_utils::{get_storage_var_address, selector_from_name}; use crate::context::ChainInfo; -use crate::execution::call_info::{CallExecution, CallInfo, Retdata}; +use crate::execution::call_info::{CallExecution, CallInfo}; use crate::execution::entry_point::CallEntryPoint; use crate::retdata; use crate::state::cached_state::CachedState; diff --git a/crates/blockifier/src/execution/execution_utils.rs b/crates/blockifier/src/execution/execution_utils.rs index ba9ee42298..f1898af55f 100644 --- a/crates/blockifier/src/execution/execution_utils.rs +++ b/crates/blockifier/src/execution/execution_utils.rs @@ -18,7 +18,7 @@ use cairo_vm::vm::vm_core::VirtualMachine; use num_bigint::BigUint; use starknet_api::core::ClassHash; use starknet_api::deprecated_contract_class::Program as DeprecatedProgram; -use starknet_api::transaction::Calldata; +use starknet_api::transaction::fields::Calldata; use starknet_types_core::felt::Felt; use super::call_info::CallExecution; diff --git a/crates/blockifier/src/execution/stack_trace_test.rs b/crates/blockifier/src/execution/stack_trace_test.rs index dff6a9804c..ff5213fd63 100644 --- a/crates/blockifier/src/execution/stack_trace_test.rs +++ b/crates/blockifier/src/execution/stack_trace_test.rs @@ -2,7 +2,7 @@ use pretty_assertions::assert_eq; use regex::Regex; use rstest::rstest; use starknet_api::core::{calculate_contract_address, Nonce}; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ ContractAddressSalt, Fee, TransactionSignature, diff --git a/crates/blockifier/src/execution/syscalls/hint_processor.rs b/crates/blockifier/src/execution/syscalls/hint_processor.rs index 3fd8060412..e6e3768b7e 100644 --- a/crates/blockifier/src/execution/syscalls/hint_processor.rs +++ b/crates/blockifier/src/execution/syscalls/hint_processor.rs @@ -16,7 +16,12 @@ use cairo_vm::vm::vm_core::VirtualMachine; use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector}; use starknet_api::state::StorageKey; -use starknet_api::transaction::{AllResourceBounds, Calldata, Resource, ValidResourceBounds}; +use starknet_api::transaction::fields::{ + AllResourceBounds, + Calldata, + Resource, + ValidResourceBounds, +}; use starknet_api::StarknetApiError; use starknet_types_core::felt::{Felt, FromStrError}; use thiserror::Error; diff --git a/crates/blockifier/src/execution/syscalls/mod.rs b/crates/blockifier/src/execution/syscalls/mod.rs index 9727840ae3..8aa5902a99 100644 --- a/crates/blockifier/src/execution/syscalls/mod.rs +++ b/crates/blockifier/src/execution/syscalls/mod.rs @@ -11,14 +11,8 @@ use starknet_api::core::{ EthAddress, }; use starknet_api::state::StorageKey; -use starknet_api::transaction::{ - Calldata, - ContractAddressSalt, - EventContent, - EventData, - EventKey, - L2ToL1Payload, -}; +use starknet_api::transaction::fields::{Calldata, ContractAddressSalt}; +use starknet_api::transaction::{EventContent, EventData, EventKey, L2ToL1Payload}; use starknet_types_core::felt::Felt; use self::hint_processor::{ diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/call_contract.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/call_contract.rs index a8824f0fed..53a5ca6f20 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/call_contract.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/call_contract.rs @@ -6,13 +6,13 @@ use pretty_assertions::assert_eq; use rstest::rstest; use starknet_api::execution_utils::format_panic_data; use starknet_api::felt; -use starknet_api::transaction::Calldata; +use starknet_api::transaction::fields::Calldata; use test_case::test_case; use super::constants::REQUIRED_GAS_CALL_CONTRACT_TEST; use crate::abi::abi_utils::selector_from_name; use crate::context::ChainInfo; -use crate::execution::call_info::{CallExecution, Retdata}; +use crate::execution::call_info::CallExecution; use crate::execution::contract_class::TrackedResource; use crate::execution::entry_point::CallEntryPoint; use crate::retdata; diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs index 6897c793e0..113efd93c1 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs @@ -1,12 +1,12 @@ use pretty_assertions::assert_eq; use starknet_api::core::calculate_contract_address; -use starknet_api::transaction::{Calldata, ContractAddressSalt, Fee}; +use starknet_api::transaction::fields::{Calldata, ContractAddressSalt, Fee}; use starknet_api::{calldata, felt}; use test_case::test_case; use crate::abi::abi_utils::selector_from_name; use crate::context::ChainInfo; -use crate::execution::call_info::{CallExecution, Retdata}; +use crate::execution::call_info::CallExecution; use crate::execution::entry_point::CallEntryPoint; use crate::retdata; use crate::state::state_api::StateReader; diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/emit_event.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/emit_event.rs index 3913e47014..8c668740b8 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/emit_event.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/emit_event.rs @@ -1,7 +1,8 @@ use itertools::concat; use pretty_assertions::assert_eq; use starknet_api::felt; -use starknet_api::transaction::{Calldata, EventContent, EventData, EventKey}; +use starknet_api::transaction::fields::Calldata; +use starknet_api::transaction::{EventContent, EventData, EventKey}; use starknet_types_core::felt::Felt; use test_case::test_case; diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/get_block_hash.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/get_block_hash.rs index fbbeeaf610..bec856d07e 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/get_block_hash.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/get_block_hash.rs @@ -9,7 +9,7 @@ use test_case::test_case; use crate::abi::abi_utils::selector_from_name; use crate::abi::constants; use crate::context::ChainInfo; -use crate::execution::call_info::{CallExecution, Retdata}; +use crate::execution::call_info::CallExecution; use crate::execution::entry_point::CallEntryPoint; use crate::state::cached_state::CachedState; use crate::state::state_api::State; diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/get_execution_info.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/get_execution_info.rs index 73a84a9b35..c509a313ca 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/get_execution_info.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/get_execution_info.rs @@ -4,7 +4,7 @@ use starknet_api::block::GasPrice; use starknet_api::core::ChainId; use starknet_api::data_availability::DataAvailabilityMode; use starknet_api::execution_resources::GasAmount; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ AccountDeploymentData, Calldata, Fee, diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/keccak.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/keccak.rs index 585187db9c..326af34d48 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/keccak.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/keccak.rs @@ -1,9 +1,9 @@ -use starknet_api::transaction::Calldata; +use starknet_api::transaction::fields::Calldata; use test_case::test_case; use crate::abi::abi_utils::selector_from_name; use crate::context::ChainInfo; -use crate::execution::call_info::{CallExecution, Retdata}; +use crate::execution::call_info::CallExecution; use crate::execution::entry_point::CallEntryPoint; use crate::retdata; use crate::test_utils::contracts::FeatureContract; diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/library_call.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/library_call.rs index e6eda072d6..6c2c838be5 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/library_call.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/library_call.rs @@ -11,7 +11,7 @@ use test_case::test_case; use crate::abi::abi_utils::selector_from_name; use crate::context::ChainInfo; -use crate::execution::call_info::{CallExecution, CallInfo, Retdata}; +use crate::execution::call_info::{CallExecution, CallInfo}; use crate::execution::entry_point::{CallEntryPoint, CallType}; use crate::execution::syscalls::syscall_tests::constants::{ REQUIRED_GAS_LIBRARY_CALL_TEST, diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/secp.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/secp.rs index a8a363c66b..ff99f8ecd0 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/secp.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/secp.rs @@ -1,4 +1,4 @@ -use starknet_api::transaction::Calldata; +use starknet_api::transaction::fields::Calldata; use test_case::test_case; use crate::abi::abi_utils::selector_from_name; diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/send_message_to_l1.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/send_message_to_l1.rs index 1462e9dd72..106a17fdeb 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/send_message_to_l1.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/send_message_to_l1.rs @@ -1,7 +1,8 @@ use itertools::concat; use starknet_api::core::EthAddress; use starknet_api::felt; -use starknet_api::transaction::{Calldata, L2ToL1Payload}; +use starknet_api::transaction::fields::Calldata; +use starknet_api::transaction::L2ToL1Payload; use test_case::test_case; use crate::abi::abi_utils::selector_from_name; diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/sha256.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/sha256.rs index 9598dd3d51..783adb03ed 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/sha256.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/sha256.rs @@ -1,9 +1,9 @@ -use starknet_api::transaction::Calldata; +use starknet_api::transaction::fields::Calldata; use test_case::test_case; use crate::abi::abi_utils::selector_from_name; use crate::context::ChainInfo; -use crate::execution::call_info::{CallExecution, Retdata}; +use crate::execution::call_info::CallExecution; use crate::execution::entry_point::CallEntryPoint; use crate::retdata; use crate::test_utils::contracts::FeatureContract; diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/storage_read_write.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/storage_read_write.rs index adf201b162..dbc85fff6b 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/storage_read_write.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/storage_read_write.rs @@ -4,7 +4,7 @@ use test_case::test_case; use crate::abi::abi_utils::selector_from_name; use crate::context::ChainInfo; -use crate::execution::call_info::{CallExecution, Retdata}; +use crate::execution::call_info::CallExecution; use crate::execution::entry_point::CallEntryPoint; use crate::execution::syscalls::syscall_tests::constants::REQUIRED_GAS_STORAGE_READ_WRITE_TEST; use crate::retdata; diff --git a/crates/blockifier/src/fee/fee_checks.rs b/crates/blockifier/src/fee/fee_checks.rs index 50a3820b1b..956c0853fc 100644 --- a/crates/blockifier/src/fee/fee_checks.rs +++ b/crates/blockifier/src/fee/fee_checks.rs @@ -1,6 +1,11 @@ use starknet_api::execution_resources::{GasAmount, GasVector}; -use starknet_api::transaction::Resource::{self, L1DataGas, L1Gas, L2Gas}; -use starknet_api::transaction::{AllResourceBounds, Fee, ResourceBounds, ValidResourceBounds}; +use starknet_api::transaction::fields::Resource::{self, L1DataGas, L1Gas, L2Gas}; +use starknet_api::transaction::fields::{ + AllResourceBounds, + Fee, + ResourceBounds, + ValidResourceBounds, +}; use starknet_types_core::felt::Felt; use thiserror::Error; diff --git a/crates/blockifier/src/fee/fee_test.rs b/crates/blockifier/src/fee/fee_test.rs index 33c32a77a8..e96f443431 100644 --- a/crates/blockifier/src/fee/fee_test.rs +++ b/crates/blockifier/src/fee/fee_test.rs @@ -4,7 +4,7 @@ use rstest::rstest; use starknet_api::block::{GasPrice, NonzeroGasPrice}; use starknet_api::execution_resources::{GasAmount, GasVector}; use starknet_api::invoke_tx_args; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ AllResourceBounds, Fee, GasVectorComputationMode, diff --git a/crates/blockifier/src/fee/fee_utils.rs b/crates/blockifier/src/fee/fee_utils.rs index 7e7d5496d7..ecd34df776 100644 --- a/crates/blockifier/src/fee/fee_utils.rs +++ b/crates/blockifier/src/fee/fee_utils.rs @@ -6,8 +6,13 @@ use num_bigint::BigUint; use starknet_api::core::ContractAddress; use starknet_api::execution_resources::GasVector; use starknet_api::state::StorageKey; -use starknet_api::transaction::ValidResourceBounds::{AllResources, L1Gas}; -use starknet_api::transaction::{AllResourceBounds, Fee, GasVectorComputationMode, Resource}; +use starknet_api::transaction::fields::ValidResourceBounds::{AllResources, L1Gas}; +use starknet_api::transaction::fields::{ + AllResourceBounds, + Fee, + GasVectorComputationMode, + Resource, +}; use starknet_types_core::felt::Felt; use crate::abi::abi_utils::get_fee_token_var_address; diff --git a/crates/blockifier/src/fee/gas_usage.rs b/crates/blockifier/src/fee/gas_usage.rs index bf5cfa5e8a..c8d00ca06f 100644 --- a/crates/blockifier/src/fee/gas_usage.rs +++ b/crates/blockifier/src/fee/gas_usage.rs @@ -1,6 +1,6 @@ use cairo_vm::vm::runners::cairo_runner::ExecutionResources; use starknet_api::execution_resources::GasVector; -use starknet_api::transaction::GasVectorComputationMode; +use starknet_api::transaction::fields::GasVectorComputationMode; use super::fee_utils::get_vm_resources_cost; use crate::abi::constants; diff --git a/crates/blockifier/src/fee/gas_usage_test.rs b/crates/blockifier/src/fee/gas_usage_test.rs index 7ef5134b12..153062234f 100644 --- a/crates/blockifier/src/fee/gas_usage_test.rs +++ b/crates/blockifier/src/fee/gas_usage_test.rs @@ -6,7 +6,8 @@ use rstest::{fixture, rstest}; use starknet_api::block::StarknetVersion; use starknet_api::execution_resources::{GasAmount, GasVector}; use starknet_api::invoke_tx_args; -use starknet_api::transaction::{EventContent, EventData, EventKey, GasVectorComputationMode}; +use starknet_api::transaction::fields::GasVectorComputationMode; +use starknet_api::transaction::{EventContent, EventData, EventKey}; use starknet_types_core::felt::Felt; use crate::abi::constants; diff --git a/crates/blockifier/src/fee/receipt.rs b/crates/blockifier/src/fee/receipt.rs index 28e630b73f..3ef2f2b2bf 100644 --- a/crates/blockifier/src/fee/receipt.rs +++ b/crates/blockifier/src/fee/receipt.rs @@ -1,7 +1,7 @@ use cairo_vm::vm::runners::cairo_runner::ExecutionResources; use starknet_api::core::ContractAddress; use starknet_api::execution_resources::GasVector; -use starknet_api::transaction::Fee; +use starknet_api::transaction::fields::Fee; use crate::context::TransactionContext; use crate::execution::call_info::ExecutionSummary; diff --git a/crates/blockifier/src/fee/receipt_test.rs b/crates/blockifier/src/fee/receipt_test.rs index 671b8c3285..95c315918b 100644 --- a/crates/blockifier/src/fee/receipt_test.rs +++ b/crates/blockifier/src/fee/receipt_test.rs @@ -1,6 +1,7 @@ use rstest::{fixture, rstest}; use starknet_api::execution_resources::GasVector; -use starknet_api::transaction::{GasVectorComputationMode, L2ToL1Payload}; +use starknet_api::transaction::fields::GasVectorComputationMode; +use starknet_api::transaction::L2ToL1Payload; use starknet_api::{invoke_tx_args, nonce}; use starknet_types_core::felt::Felt; diff --git a/crates/blockifier/src/fee/resources.rs b/crates/blockifier/src/fee/resources.rs index 9944a736b9..b92e50bf0e 100644 --- a/crates/blockifier/src/fee/resources.rs +++ b/crates/blockifier/src/fee/resources.rs @@ -1,7 +1,7 @@ use cairo_vm::vm::runners::cairo_runner::ExecutionResources; use starknet_api::core::ContractAddress; use starknet_api::execution_resources::{GasAmount, GasVector}; -use starknet_api::transaction::GasVectorComputationMode; +use starknet_api::transaction::fields::GasVectorComputationMode; use crate::execution::call_info::{EventSummary, ExecutionSummary}; use crate::fee::eth_gas_constants; diff --git a/crates/blockifier/src/state/cached_state_test.rs b/crates/blockifier/src/state/cached_state_test.rs index de1ad61866..fc1f77a915 100644 --- a/crates/blockifier/src/state/cached_state_test.rs +++ b/crates/blockifier/src/state/cached_state_test.rs @@ -5,7 +5,7 @@ use indexmap::indexmap; use pretty_assertions::assert_eq; use rstest::rstest; use starknet_api::core::PatriciaKey; -use starknet_api::transaction::Fee; +use starknet_api::transaction::fields::Fee; use starknet_api::{ class_hash, compiled_class_hash, diff --git a/crates/blockifier/src/test_utils.rs b/crates/blockifier/src/test_utils.rs index 111b425dcf..1e99a1ae05 100644 --- a/crates/blockifier/src/test_utils.rs +++ b/crates/blockifier/src/test_utils.rs @@ -18,7 +18,7 @@ use starknet_api::block::{GasPrice, NonzeroGasPrice}; use starknet_api::core::{ClassHash, ContractAddress, PatriciaKey}; use starknet_api::execution_resources::{GasAmount, GasVector}; use starknet_api::state::StorageKey; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ Calldata, ContractAddressSalt, Fee, diff --git a/crates/blockifier/src/test_utils/deploy_account.rs b/crates/blockifier/src/test_utils/deploy_account.rs index ffcd247dad..d85694e93b 100644 --- a/crates/blockifier/src/test_utils/deploy_account.rs +++ b/crates/blockifier/src/test_utils/deploy_account.rs @@ -1,7 +1,7 @@ use starknet_api::core::calculate_contract_address; use starknet_api::test_utils::deploy_account::DeployAccountTxArgs; use starknet_api::test_utils::NonceManager; -use starknet_api::transaction::TransactionHash; +use starknet_api::transaction::fields::TransactionHash; use crate::transaction::transactions::DeployAccountTransaction; diff --git a/crates/blockifier/src/test_utils/initial_test_state.rs b/crates/blockifier/src/test_utils/initial_test_state.rs index 6962244bfc..4e76f69a2f 100644 --- a/crates/blockifier/src/test_utils/initial_test_state.rs +++ b/crates/blockifier/src/test_utils/initial_test_state.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; use starknet_api::core::ContractAddress; use starknet_api::felt; -use starknet_api::transaction::Fee; +use starknet_api::transaction::fields::Fee; use strum::IntoEnumIterator; use crate::abi::abi_utils::get_fee_token_var_address; diff --git a/crates/blockifier/src/test_utils/invoke.rs b/crates/blockifier/src/test_utils/invoke.rs index a5898d31fb..78a67e6a9f 100644 --- a/crates/blockifier/src/test_utils/invoke.rs +++ b/crates/blockifier/src/test_utils/invoke.rs @@ -1,5 +1,6 @@ use starknet_api::test_utils::invoke::InvokeTxArgs; -use starknet_api::transaction::{InvokeTransactionV0, TransactionHash, TransactionVersion}; +use starknet_api::transaction::fields::{TransactionHash, TransactionVersion}; +use starknet_api::transaction::InvokeTransactionV0; use crate::abi::abi_utils::selector_from_name; use crate::transaction::constants::EXECUTE_ENTRY_POINT_NAME; diff --git a/crates/blockifier/src/test_utils/struct_impls.rs b/crates/blockifier/src/test_utils/struct_impls.rs index ca373e5ba4..4e9fa7c6d0 100644 --- a/crates/blockifier/src/test_utils/struct_impls.rs +++ b/crates/blockifier/src/test_utils/struct_impls.rs @@ -5,8 +5,8 @@ use serde_json::Value; use starknet_api::block::{BlockHash, BlockNumber, BlockTimestamp, NonzeroGasPrice}; use starknet_api::core::{ChainId, ClassHash, ContractAddress, Nonce, PatriciaKey}; use starknet_api::hash::StarkHash; -use starknet_api::transaction::{Fee, TransactionHash, TransactionVersion}; -use starknet_api::{calldata, contract_address, felt, patricia_key}; +use starknet_api::transaction::fields::{Fee, TransactionHash, TransactionVersion}; +use starknet_api::{calldata, contract_address, patricia_key}; use starknet_types_core::felt::Felt; use super::update_json_value; diff --git a/crates/blockifier/src/test_utils/transfers_generator.rs b/crates/blockifier/src/test_utils/transfers_generator.rs index 77f26a6c28..25b676aef4 100644 --- a/crates/blockifier/src/test_utils/transfers_generator.rs +++ b/crates/blockifier/src/test_utils/transfers_generator.rs @@ -2,7 +2,7 @@ use rand::rngs::StdRng; use rand::{Rng, SeedableRng}; use starknet_api::core::ContractAddress; use starknet_api::test_utils::NonceManager; -use starknet_api::transaction::{Fee, TransactionVersion}; +use starknet_api::transaction::fields::{Fee, TransactionVersion}; use starknet_api::{calldata, felt, invoke_tx_args}; use starknet_types_core::felt::Felt; diff --git a/crates/blockifier/src/transaction/account_transaction.rs b/crates/blockifier/src/transaction/account_transaction.rs index f07ac385ca..cf6a0b659e 100644 --- a/crates/blockifier/src/transaction/account_transaction.rs +++ b/crates/blockifier/src/transaction/account_transaction.rs @@ -6,8 +6,8 @@ use starknet_api::calldata; use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector, Nonce}; use starknet_api::data_availability::DataAvailabilityMode; -use starknet_api::transaction::Resource::{L1DataGas, L1Gas, L2Gas}; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::Resource::{L1DataGas, L1Gas, L2Gas}; +use starknet_api::transaction::fields::{ AccountDeploymentData, AllResourceBounds, Calldata, @@ -23,7 +23,7 @@ use starknet_types_core::felt::Felt; use crate::abi::abi_utils::selector_from_name; use crate::context::{BlockContext, TransactionContext}; -use crate::execution::call_info::{CallInfo, Retdata}; +use crate::execution::call_info::CallInfo; use crate::execution::contract_class::ContractClass; use crate::execution::entry_point::{CallEntryPoint, CallType, EntryPointExecutionContext}; use crate::execution::stack_trace::extract_trailing_cairo1_revert_trace; diff --git a/crates/blockifier/src/transaction/account_transactions_test.rs b/crates/blockifier/src/transaction/account_transactions_test.rs index 71994d3be9..1917a3d03e 100644 --- a/crates/blockifier/src/transaction/account_transactions_test.rs +++ b/crates/blockifier/src/transaction/account_transactions_test.rs @@ -13,11 +13,10 @@ use starknet_api::hash::StarkHash; use starknet_api::state::StorageKey; use starknet_api::test_utils::invoke::InvokeTxArgs; use starknet_api::test_utils::NonceManager; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ AllResourceBounds, Calldata, ContractAddressSalt, - DeclareTransactionV2, Fee, GasVectorComputationMode, Resource, @@ -26,6 +25,7 @@ use starknet_api::transaction::{ TransactionVersion, ValidResourceBounds, }; +use starknet_api::transaction::DeclareTransactionV2; use starknet_api::{ calldata, class_hash, diff --git a/crates/blockifier/src/transaction/error_format_test.rs b/crates/blockifier/src/transaction/error_format_test.rs index d51ad27d59..2a920556e1 100644 --- a/crates/blockifier/src/transaction/error_format_test.rs +++ b/crates/blockifier/src/transaction/error_format_test.rs @@ -1,6 +1,6 @@ use starknet_api::core::{ClassHash, ContractAddress, Nonce, PatriciaKey}; use starknet_api::hash::StarkHash; -use starknet_api::transaction::TransactionVersion; +use starknet_api::transaction::fields::TransactionVersion; use crate::transaction::errors::{TransactionExecutionError, TransactionPreValidationError}; diff --git a/crates/blockifier/src/transaction/errors.rs b/crates/blockifier/src/transaction/errors.rs index f0f0066039..c075abfe56 100644 --- a/crates/blockifier/src/transaction/errors.rs +++ b/crates/blockifier/src/transaction/errors.rs @@ -3,7 +3,7 @@ use num_bigint::BigUint; use starknet_api::block::GasPrice; use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector, Nonce}; use starknet_api::execution_resources::GasAmount; -use starknet_api::transaction::{Fee, Resource, TransactionVersion}; +use starknet_api::transaction::fields::{Fee, Resource, TransactionVersion}; use starknet_api::StarknetApiError; use starknet_types_core::felt::FromStrError; use thiserror::Error; diff --git a/crates/blockifier/src/transaction/execution_flavors_test.rs b/crates/blockifier/src/transaction/execution_flavors_test.rs index 0e965d44a0..3ed22706df 100644 --- a/crates/blockifier/src/transaction/execution_flavors_test.rs +++ b/crates/blockifier/src/transaction/execution_flavors_test.rs @@ -5,7 +5,7 @@ use starknet_api::core::ContractAddress; use starknet_api::execution_resources::{GasAmount, GasVector}; use starknet_api::test_utils::invoke::InvokeTxArgs; use starknet_api::test_utils::NonceManager; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ Calldata, Fee, GasVectorComputationMode, diff --git a/crates/blockifier/src/transaction/objects.rs b/crates/blockifier/src/transaction/objects.rs index f3a7ed7cf4..3369a53fa4 100644 --- a/crates/blockifier/src/transaction/objects.rs +++ b/crates/blockifier/src/transaction/objects.rs @@ -5,7 +5,7 @@ use cairo_vm::vm::runners::cairo_runner::ExecutionResources; use starknet_api::core::{ContractAddress, Nonce}; use starknet_api::data_availability::DataAvailabilityMode; use starknet_api::execution_resources::GasVector; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ signed_tx_version, AccountDeploymentData, AllResourceBounds, diff --git a/crates/blockifier/src/transaction/objects_test.rs b/crates/blockifier/src/transaction/objects_test.rs index a5bd07b8f9..bcbdd26ef1 100644 --- a/crates/blockifier/src/transaction/objects_test.rs +++ b/crates/blockifier/src/transaction/objects_test.rs @@ -2,7 +2,7 @@ use rstest::rstest; use starknet_api::core::{ClassHash, ContractAddress, EthAddress, PatriciaKey}; use starknet_api::state::StorageKey; use starknet_api::transaction::L2ToL1Payload; -use starknet_api::{class_hash, felt, patricia_key}; +use starknet_api::{class_hash, patricia_key}; use starknet_types_core::felt::Felt; use crate::execution::call_info::{ diff --git a/crates/blockifier/src/transaction/post_execution_test.rs b/crates/blockifier/src/transaction/post_execution_test.rs index 1ac3270c3c..ac1de9156a 100644 --- a/crates/blockifier/src/transaction/post_execution_test.rs +++ b/crates/blockifier/src/transaction/post_execution_test.rs @@ -2,7 +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::{ +use starknet_api::transaction::fields::{ Calldata, Fee, GasVectorComputationMode, diff --git a/crates/blockifier/src/transaction/test_utils.rs b/crates/blockifier/src/transaction/test_utils.rs index 8c20c7f843..d7220fd4a1 100644 --- a/crates/blockifier/src/transaction/test_utils.rs +++ b/crates/blockifier/src/transaction/test_utils.rs @@ -5,20 +5,18 @@ use starknet_api::execution_resources::GasAmount; use starknet_api::test_utils::deploy_account::DeployAccountTxArgs; use starknet_api::test_utils::invoke::InvokeTxArgs; use starknet_api::test_utils::NonceManager; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ AllResourceBounds, ContractAddressSalt, Fee, GasVectorComputationMode, - InvokeTransactionV0, - InvokeTransactionV1, - InvokeTransactionV3, ResourceBounds, TransactionHash, TransactionSignature, TransactionVersion, ValidResourceBounds, }; +use starknet_api::transaction::{InvokeTransactionV0, InvokeTransactionV1, InvokeTransactionV3}; use starknet_api::{calldata, declare_tx_args, deploy_account_tx_args, felt, invoke_tx_args}; use starknet_types_core::felt::Felt; use strum::IntoEnumIterator; diff --git a/crates/blockifier/src/transaction/transaction_execution.rs b/crates/blockifier/src/transaction/transaction_execution.rs index 5b4a1b5acc..3ab21bc459 100644 --- a/crates/blockifier/src/transaction/transaction_execution.rs +++ b/crates/blockifier/src/transaction/transaction_execution.rs @@ -2,7 +2,8 @@ use std::sync::Arc; use cairo_vm::vm::runners::cairo_runner::ExecutionResources; use starknet_api::core::{calculate_contract_address, ContractAddress, Nonce}; -use starknet_api::transaction::{Fee, Transaction as StarknetApiTransaction, TransactionHash}; +use starknet_api::transaction::fields::{Fee, TransactionHash}; +use starknet_api::transaction::Transaction as StarknetApiTransaction; use crate::bouncer::verify_tx_weights_within_max_capacity; use crate::context::BlockContext; diff --git a/crates/blockifier/src/transaction/transactions.rs b/crates/blockifier/src/transaction/transactions.rs index f2317b8261..6e73f21832 100644 --- a/crates/blockifier/src/transaction/transactions.rs +++ b/crates/blockifier/src/transaction/transactions.rs @@ -3,17 +3,16 @@ use std::sync::Arc; use cairo_vm::vm::runners::cairo_runner::ExecutionResources; use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce}; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ AccountDeploymentData, Calldata, ContractAddressSalt, - DeclareTransactionV2, - DeclareTransactionV3, Fee, TransactionHash, TransactionSignature, TransactionVersion, }; +use starknet_api::transaction::{DeclareTransactionV2, DeclareTransactionV3}; use crate::abi::abi_utils::selector_from_name; use crate::context::{BlockContext, TransactionContext}; diff --git a/crates/blockifier/src/transaction/transactions_test.rs b/crates/blockifier/src/transaction/transactions_test.rs index 1e16dffe9a..e616eb8ad2 100644 --- a/crates/blockifier/src/transaction/transactions_test.rs +++ b/crates/blockifier/src/transaction/transactions_test.rs @@ -15,22 +15,19 @@ use starknet_api::execution_resources::GasVector; use starknet_api::state::StorageKey; use starknet_api::test_utils::invoke::InvokeTxArgs; use starknet_api::test_utils::NonceManager; -use starknet_api::transaction::Resource::{L1DataGas, L1Gas, L2Gas}; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::Resource::{L1DataGas, L1Gas, L2Gas}; +use starknet_api::transaction::fields::{ AllResourceBounds, Calldata, - EventContent, - EventData, - EventKey, Fee, GasVectorComputationMode, - L2ToL1Payload, ResourceBounds, TransactionSignature, TransactionVersion, ValidResourceBounds, QUERY_VERSION_BASE_BIT, }; +use starknet_api::transaction::{EventContent, EventData, EventKey, L2ToL1Payload}; use starknet_api::{ calldata, class_hash, diff --git a/crates/blockifier/src/versioned_constants.rs b/crates/blockifier/src/versioned_constants.rs index d6433df961..fea4818f5a 100644 --- a/crates/blockifier/src/versioned_constants.rs +++ b/crates/blockifier/src/versioned_constants.rs @@ -17,7 +17,7 @@ use serde::{Deserialize, Deserializer, Serialize}; use serde_json::{Map, Number, Value}; use starknet_api::block::{GasPrice, StarknetVersion}; use starknet_api::execution_resources::GasAmount; -use starknet_api::transaction::GasVectorComputationMode; +use starknet_api::transaction::fields::GasVectorComputationMode; use strum::IntoEnumIterator; use thiserror::Error; diff --git a/crates/blockifier_reexecution/src/state_reader/test_state_reader.rs b/crates/blockifier_reexecution/src/state_reader/test_state_reader.rs index 64462c996b..bcdb8e9230 100644 --- a/crates/blockifier_reexecution/src/state_reader/test_state_reader.rs +++ b/crates/blockifier_reexecution/src/state_reader/test_state_reader.rs @@ -12,7 +12,8 @@ use serde_json::{json, to_value}; use starknet_api::block::{BlockNumber, StarknetVersion}; use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce}; use starknet_api::state::StorageKey; -use starknet_api::transaction::{Transaction, TransactionHash}; +use starknet_api::transaction::fields::TransactionHash; +use starknet_api::transaction::Transaction; use starknet_core::types::ContractClass as StarknetContractClass; use starknet_core::types::ContractClass::{Legacy, Sierra}; use starknet_gateway::config::RpcStateReaderConfig; diff --git a/crates/blockifier_reexecution/src/state_reader/utils.rs b/crates/blockifier_reexecution/src/state_reader/utils.rs index 4ca8df129e..6d519ec894 100644 --- a/crates/blockifier_reexecution/src/state_reader/utils.rs +++ b/crates/blockifier_reexecution/src/state_reader/utils.rs @@ -4,7 +4,7 @@ use indexmap::IndexMap; use papyrus_execution::{ETH_FEE_CONTRACT_ADDRESS, STRK_FEE_CONTRACT_ADDRESS}; use starknet_api::core::{ChainId, ContractAddress, PatriciaKey}; use starknet_api::transaction::{Transaction, TransactionHash}; -use starknet_api::{contract_address, felt, patricia_key}; +use starknet_api::{contract_address, patricia_key}; use starknet_gateway::config::RpcStateReaderConfig; use crate::state_reader::test_state_reader::ReexecutionResult; diff --git a/crates/committer_cli/src/tests/utils/objects.rs b/crates/committer_cli/src/tests/utils/objects.rs index 0f8a2e239c..98994236da 100644 --- a/crates/committer_cli/src/tests/utils/objects.rs +++ b/crates/committer_cli/src/tests/utils/objects.rs @@ -13,18 +13,16 @@ use starknet_api::core::{ }; use starknet_api::execution_resources::{GasAmount, GasVector}; use starknet_api::state::{StorageKey, ThinStateDiff}; +use starknet_api::transaction::fields::{Fee, TransactionHash, TransactionSignature}; use starknet_api::transaction::{ Event, EventContent, EventData, EventKey, - Fee, L2ToL1Payload, MessageToL1, RevertedTransactionExecutionStatus, TransactionExecutionStatus, - TransactionHash, - TransactionSignature, }; use starknet_types_core::felt::Felt; diff --git a/crates/gateway/src/errors.rs b/crates/gateway/src/errors.rs index 2374b93706..60531d3ff5 100644 --- a/crates/gateway/src/errors.rs +++ b/crates/gateway/src/errors.rs @@ -2,7 +2,7 @@ use axum::http::StatusCode; use blockifier::state::errors::StateError; use serde_json::{Error as SerdeError, Value}; use starknet_api::block::GasPrice; -use starknet_api::transaction::{Resource, ResourceBounds}; +use starknet_api::transaction::fields::{Resource, ResourceBounds}; use starknet_gateway_types::errors::GatewaySpecError; use thiserror::Error; diff --git a/crates/gateway/src/gateway.rs b/crates/gateway/src/gateway.rs index 1f7e9a3c70..9940397a55 100644 --- a/crates/gateway/src/gateway.rs +++ b/crates/gateway/src/gateway.rs @@ -5,7 +5,7 @@ use blockifier::context::ChainInfo; use papyrus_network_types::network_types::BroadcastedMessageMetadata; use starknet_api::executable_transaction::Transaction; use starknet_api::rpc_transaction::RpcTransaction; -use starknet_api::transaction::TransactionHash; +use starknet_api::transaction::fields::TransactionHash; use starknet_gateway_types::errors::GatewaySpecError; use starknet_mempool_infra::component_definitions::ComponentStarter; use starknet_mempool_types::communication::{AddTransactionArgsWrapper, SharedMempoolClient}; diff --git a/crates/gateway/src/state_reader_test_utils.rs b/crates/gateway/src/state_reader_test_utils.rs index c080a3e0d7..c403bdf43c 100644 --- a/crates/gateway/src/state_reader_test_utils.rs +++ b/crates/gateway/src/state_reader_test_utils.rs @@ -10,7 +10,7 @@ use blockifier::test_utils::{CairoVersion, BALANCE}; use starknet_api::block::BlockNumber; use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce}; use starknet_api::state::StorageKey; -use starknet_api::transaction::Fee; +use starknet_api::transaction::fields::Fee; use starknet_types_core::felt::Felt; use crate::state_reader::{MempoolStateReader, StateReaderFactory}; diff --git a/crates/gateway/src/stateful_transaction_validator_test.rs b/crates/gateway/src/stateful_transaction_validator_test.rs index 4a6b09cf02..e407bb6828 100644 --- a/crates/gateway/src/stateful_transaction_validator_test.rs +++ b/crates/gateway/src/stateful_transaction_validator_test.rs @@ -21,7 +21,7 @@ use starknet_api::executable_transaction::Transaction; use starknet_api::execution_resources::GasAmount; use starknet_api::test_utils::deploy_account::executable_deploy_account_tx; use starknet_api::test_utils::invoke::executable_invoke_tx; -use starknet_api::transaction::Resource; +use starknet_api::transaction::fields::Resource; use starknet_api::{deploy_account_tx_args, invoke_tx_args, nonce}; use starknet_gateway_types::errors::GatewaySpecError; diff --git a/crates/gateway/src/stateless_transaction_validator.rs b/crates/gateway/src/stateless_transaction_validator.rs index 2043465da7..b57ce481d4 100644 --- a/crates/gateway/src/stateless_transaction_validator.rs +++ b/crates/gateway/src/stateless_transaction_validator.rs @@ -7,7 +7,7 @@ use starknet_api::rpc_transaction::{ RpcTransaction, }; use starknet_api::state::EntryPoint; -use starknet_api::transaction::{AllResourceBounds, Resource}; +use starknet_api::transaction::fields::{AllResourceBounds, Resource}; use starknet_types_core::felt::Felt; use tracing::{instrument, Level}; diff --git a/crates/gateway/src/stateless_transaction_validator_test.rs b/crates/gateway/src/stateless_transaction_validator_test.rs index 4dd52db0e8..d000830c41 100644 --- a/crates/gateway/src/stateless_transaction_validator_test.rs +++ b/crates/gateway/src/stateless_transaction_validator_test.rs @@ -14,7 +14,7 @@ use rstest::rstest; use starknet_api::core::EntryPointSelector; use starknet_api::rpc_transaction::{ContractClass, EntryPointByType}; use starknet_api::state::EntryPoint; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ AllResourceBounds, Calldata, Resource, diff --git a/crates/gateway_types/src/communication.rs b/crates/gateway_types/src/communication.rs index f208b3de59..43a224f1a8 100644 --- a/crates/gateway_types/src/communication.rs +++ b/crates/gateway_types/src/communication.rs @@ -4,7 +4,7 @@ use async_trait::async_trait; use mockall::predicate::*; use mockall::*; use serde::{Deserialize, Serialize}; -use starknet_api::transaction::TransactionHash; +use starknet_api::transaction::fields::TransactionHash; use starknet_mempool_infra::component_client::{ ClientError, LocalComponentClient, diff --git a/crates/http_server/src/http_server.rs b/crates/http_server/src/http_server.rs index c216f8cf29..c420472c01 100644 --- a/crates/http_server/src/http_server.rs +++ b/crates/http_server/src/http_server.rs @@ -6,7 +6,7 @@ use axum::extract::State; use axum::routing::{get, post}; use axum::{async_trait, Json, Router}; use starknet_api::rpc_transaction::RpcTransaction; -use starknet_api::transaction::TransactionHash; +use starknet_api::transaction::fields::TransactionHash; use starknet_gateway::errors::GatewayRunError; use starknet_gateway_types::communication::SharedGatewayClient; use starknet_gateway_types::errors::GatewaySpecError; diff --git a/crates/http_server/src/http_server_test.rs b/crates/http_server/src/http_server_test.rs index 787bed37f1..921e830166 100644 --- a/crates/http_server/src/http_server_test.rs +++ b/crates/http_server/src/http_server_test.rs @@ -1,7 +1,7 @@ use axum::body::{Bytes, HttpBody}; use axum::http::StatusCode; use axum::response::{IntoResponse, Response}; -use starknet_api::transaction::TransactionHash; +use starknet_api::transaction::fields::TransactionHash; use crate::http_server::add_tx_result_as_json; diff --git a/crates/l1-provider/src/lib.rs b/crates/l1-provider/src/lib.rs index c3d15c1d5e..cbbafce6b3 100644 --- a/crates/l1-provider/src/lib.rs +++ b/crates/l1-provider/src/lib.rs @@ -1,6 +1,7 @@ pub mod errors; -use starknet_api::transaction::{L1HandlerTransaction, TransactionHash}; +use starknet_api::transaction::fields::TransactionHash; +use starknet_api::transaction::L1HandlerTransaction; use crate::errors::L1ProviderError; @@ -41,7 +42,7 @@ impl L1Provider { // about to [optimistically-]propose or validate the next block. pub fn commit_block(&mut self, _commited_txs: &[TransactionHash]) { todo!( - "Purges txs from internal buffers, if was proposer clear staging buffer, + "Purges txs from internal buffers, if was proposer clear staging buffer, reset state to Pending until we get proposing/validating notice from consensus." ) } diff --git a/crates/mempool/src/mempool.rs b/crates/mempool/src/mempool.rs index 30334846e4..999aad0690 100644 --- a/crates/mempool/src/mempool.rs +++ b/crates/mempool/src/mempool.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use starknet_api::block::GasPrice; use starknet_api::core::{ContractAddress, Nonce}; use starknet_api::executable_transaction::Transaction; -use starknet_api::transaction::{Tip, TransactionHash}; +use starknet_api::transaction::fields::{Tip, TransactionHash}; use starknet_mempool_types::errors::MempoolError; use starknet_mempool_types::mempool_types::{ AccountState, diff --git a/crates/mempool/src/mempool_test.rs b/crates/mempool/src/mempool_test.rs index ac1426e22a..6c1c1762ad 100644 --- a/crates/mempool/src/mempool_test.rs +++ b/crates/mempool/src/mempool_test.rs @@ -2,7 +2,7 @@ use pretty_assertions::assert_eq; use rstest::{fixture, rstest}; use starknet_api::core::{ContractAddress, PatriciaKey}; use starknet_api::executable_transaction::Transaction; -use starknet_api::{contract_address, felt, invoke_tx_args, nonce, patricia_key}; +use starknet_api::{contract_address, invoke_tx_args, nonce, patricia_key}; use starknet_mempool_types::errors::MempoolError; use starknet_mempool_types::mempool_types::AddTransactionArgs; diff --git a/crates/mempool/src/test_utils.rs b/crates/mempool/src/test_utils.rs index 2b54bf63b9..dc5c3ebd86 100644 --- a/crates/mempool/src/test_utils.rs +++ b/crates/mempool/src/test_utils.rs @@ -3,7 +3,7 @@ use std::collections::{HashMap, HashSet}; use pretty_assertions::assert_eq; use starknet_api::core::{ContractAddress, PatriciaKey}; use starknet_api::executable_transaction::Transaction; -use starknet_api::transaction::TransactionHash; +use starknet_api::transaction::fields::TransactionHash; use starknet_api::{contract_address, felt, nonce, patricia_key}; use starknet_mempool_types::errors::MempoolError; use starknet_mempool_types::mempool_types::{AddTransactionArgs, CommitBlockArgs}; @@ -21,7 +21,7 @@ macro_rules! tx { use starknet_api::executable_transaction::Transaction; use starknet_api::hash::StarkHash; use starknet_api::test_utils::invoke::executable_invoke_tx; - use starknet_api::transaction::{ + use starknet_api::transaction::fields::{ AllResourceBounds, ResourceBounds, Tip, diff --git a/crates/mempool/src/transaction_pool.rs b/crates/mempool/src/transaction_pool.rs index 75f7800d14..bdfd2693fc 100644 --- a/crates/mempool/src/transaction_pool.rs +++ b/crates/mempool/src/transaction_pool.rs @@ -2,7 +2,7 @@ use std::collections::{hash_map, BTreeMap, HashMap}; use starknet_api::core::{ContractAddress, Nonce}; use starknet_api::executable_transaction::Transaction; -use starknet_api::transaction::TransactionHash; +use starknet_api::transaction::fields::TransactionHash; use starknet_mempool_types::errors::MempoolError; use starknet_mempool_types::mempool_types::{AccountState, MempoolResult}; diff --git a/crates/mempool/src/transaction_queue.rs b/crates/mempool/src/transaction_queue.rs index 04b58303c5..1a885eeea6 100644 --- a/crates/mempool/src/transaction_queue.rs +++ b/crates/mempool/src/transaction_queue.rs @@ -3,7 +3,7 @@ use std::collections::{BTreeSet, HashMap}; use starknet_api::block::GasPrice; use starknet_api::core::{ContractAddress, Nonce}; -use starknet_api::transaction::{Tip, TransactionHash}; +use starknet_api::transaction::fields::{Tip, TransactionHash}; use crate::mempool::TransactionReference; diff --git a/crates/mempool/tests/flow_test.rs b/crates/mempool/tests/flow_test.rs index 4caf19cd9c..b396c4f128 100644 --- a/crates/mempool/tests/flow_test.rs +++ b/crates/mempool/tests/flow_test.rs @@ -1,6 +1,6 @@ use rstest::{fixture, rstest}; use starknet_api::core::{ContractAddress, PatriciaKey}; -use starknet_api::{contract_address, felt, invoke_tx_args, nonce, patricia_key}; +use starknet_api::{contract_address, invoke_tx_args, nonce, patricia_key}; use starknet_mempool::add_tx_input; use starknet_mempool::mempool::Mempool; use starknet_mempool::test_utils::{ diff --git a/crates/mempool_test_utils/src/starknet_api_test_utils.rs b/crates/mempool_test_utils/src/starknet_api_test_utils.rs index 3262cde607..19c5121d3d 100644 --- a/crates/mempool_test_utils/src/starknet_api_test_utils.rs +++ b/crates/mempool_test_utils/src/starknet_api_test_utils.rs @@ -24,7 +24,7 @@ use starknet_api::rpc_transaction::{ }; use starknet_api::test_utils::invoke::InvokeTxArgs; use starknet_api::test_utils::NonceManager; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ AccountDeploymentData, AllResourceBounds, Calldata, diff --git a/crates/mempool_types/src/errors.rs b/crates/mempool_types/src/errors.rs index ac2b622d6e..4405420387 100644 --- a/crates/mempool_types/src/errors.rs +++ b/crates/mempool_types/src/errors.rs @@ -1,6 +1,6 @@ use serde::{Deserialize, Serialize}; use starknet_api::core::{ContractAddress, Nonce}; -use starknet_api::transaction::TransactionHash; +use starknet_api::transaction::fields::TransactionHash; use thiserror::Error; #[derive(Clone, Debug, Error, PartialEq, Eq, Serialize, Deserialize)] diff --git a/crates/mempool_types/src/mempool_types.rs b/crates/mempool_types/src/mempool_types.rs index 01362eeed4..aab44f9e41 100644 --- a/crates/mempool_types/src/mempool_types.rs +++ b/crates/mempool_types/src/mempool_types.rs @@ -3,7 +3,7 @@ use std::collections::{HashMap, HashSet}; use serde::{Deserialize, Serialize}; use starknet_api::core::{ContractAddress, Nonce}; use starknet_api::executable_transaction::Transaction; -use starknet_api::transaction::TransactionHash; +use starknet_api::transaction::fields::TransactionHash; use crate::errors::MempoolError; diff --git a/crates/native_blockifier/src/py_block_executor.rs b/crates/native_blockifier/src/py_block_executor.rs index 7bf28040a1..2bbe9fe102 100644 --- a/crates/native_blockifier/src/py_block_executor.rs +++ b/crates/native_blockifier/src/py_block_executor.rs @@ -19,7 +19,7 @@ use serde::Serialize; use starknet_api::block::BlockNumber; use starknet_api::core::{ChainId, ContractAddress}; use starknet_api::execution_resources::GasVector; -use starknet_api::transaction::Fee; +use starknet_api::transaction::fields::Fee; use starknet_types_core::felt::Felt; use crate::errors::{NativeBlockifierError, NativeBlockifierResult}; diff --git a/crates/native_blockifier/src/py_block_executor_test.rs b/crates/native_blockifier/src/py_block_executor_test.rs index 965a30a204..4a62edd47e 100644 --- a/crates/native_blockifier/src/py_block_executor_test.rs +++ b/crates/native_blockifier/src/py_block_executor_test.rs @@ -6,8 +6,8 @@ use blockifier::state::state_api::StateReader; use cached::Cached; use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; use pretty_assertions::assert_eq; +use starknet_api::class_hash; use starknet_api::core::ClassHash; -use starknet_api::{class_hash, felt}; use starknet_types_core::felt::Felt; use crate::py_block_executor::{PyBlockExecutor, PyOsConfig}; diff --git a/crates/native_blockifier/src/py_declare.rs b/crates/native_blockifier/src/py_declare.rs index b8d74535f0..7c70d1afc7 100644 --- a/crates/native_blockifier/src/py_declare.rs +++ b/crates/native_blockifier/src/py_declare.rs @@ -5,17 +5,19 @@ use blockifier::transaction::transactions::DeclareTransaction; use pyo3::prelude::*; use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce}; use starknet_api::data_availability::DataAvailabilityMode; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ AccountDeploymentData, - DeclareTransactionV0V1, - DeclareTransactionV2, - DeclareTransactionV3, Fee, PaymasterData, Tip, TransactionHash, TransactionSignature, }; +use starknet_api::transaction::{ + DeclareTransactionV0V1, + DeclareTransactionV2, + DeclareTransactionV3, +}; use starknet_types_core::felt::Felt; use crate::errors::{NativeBlockifierInputError, NativeBlockifierResult}; diff --git a/crates/native_blockifier/src/py_deploy_account.rs b/crates/native_blockifier/src/py_deploy_account.rs index b25b464103..b6a7195617 100644 --- a/crates/native_blockifier/src/py_deploy_account.rs +++ b/crates/native_blockifier/src/py_deploy_account.rs @@ -5,17 +5,16 @@ use blockifier::transaction::transactions::DeployAccountTransaction; use pyo3::prelude::*; use starknet_api::core::{ClassHash, ContractAddress, Nonce}; use starknet_api::data_availability::DataAvailabilityMode; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ Calldata, ContractAddressSalt, - DeployAccountTransactionV1, - DeployAccountTransactionV3, Fee, PaymasterData, Tip, TransactionHash, TransactionSignature, }; +use starknet_api::transaction::{DeployAccountTransactionV1, DeployAccountTransactionV3}; use starknet_types_core::felt::Felt; use crate::errors::{NativeBlockifierInputError, NativeBlockifierResult}; diff --git a/crates/native_blockifier/src/py_invoke_function.rs b/crates/native_blockifier/src/py_invoke_function.rs index 974d0b9b1d..63a3cb7fc1 100644 --- a/crates/native_blockifier/src/py_invoke_function.rs +++ b/crates/native_blockifier/src/py_invoke_function.rs @@ -6,18 +6,16 @@ use blockifier::transaction::transactions::InvokeTransaction; use pyo3::prelude::*; use starknet_api::core::{ContractAddress, EntryPointSelector, Nonce}; use starknet_api::data_availability::DataAvailabilityMode; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ AccountDeploymentData, Calldata, Fee, - InvokeTransactionV0, - InvokeTransactionV1, - InvokeTransactionV3, PaymasterData, Tip, TransactionHash, TransactionSignature, }; +use starknet_api::transaction::{InvokeTransactionV0, InvokeTransactionV1, InvokeTransactionV3}; use starknet_types_core::felt::Felt; use crate::errors::{NativeBlockifierInputError, NativeBlockifierResult}; diff --git a/crates/native_blockifier/src/py_l1_handler.rs b/crates/native_blockifier/src/py_l1_handler.rs index 3c72eb7508..d050727653 100644 --- a/crates/native_blockifier/src/py_l1_handler.rs +++ b/crates/native_blockifier/src/py_l1_handler.rs @@ -4,7 +4,7 @@ use blockifier::abi::constants; use blockifier::transaction::transactions::L1HandlerTransaction; use pyo3::prelude::*; use starknet_api::core::{ContractAddress, EntryPointSelector, Nonce}; -use starknet_api::transaction::{Calldata, Fee, TransactionHash}; +use starknet_api::transaction::fields::{Calldata, Fee, TransactionHash}; use crate::errors::{NativeBlockifierInputError, NativeBlockifierResult}; use crate::py_utils::{from_py_felts, py_attr, PyFelt}; diff --git a/crates/native_blockifier/src/py_test_utils.rs b/crates/native_blockifier/src/py_test_utils.rs index 0e66423790..2050bd3b7f 100644 --- a/crates/native_blockifier/src/py_test_utils.rs +++ b/crates/native_blockifier/src/py_test_utils.rs @@ -3,8 +3,8 @@ use std::collections::HashMap; use blockifier::execution::contract_class::ContractClassV0; use blockifier::state::cached_state::CachedState; use blockifier::test_utils::dict_state_reader::DictStateReader; +use starknet_api::class_hash; use starknet_api::core::ClassHash; -use starknet_api::{class_hash, felt}; pub const TOKEN_FOR_TESTING_CLASS_HASH: &str = "0x30"; // This package is run within the StarkWare repository build directory. diff --git a/crates/native_blockifier/src/py_transaction.rs b/crates/native_blockifier/src/py_transaction.rs index f4c54aa395..a0a355b025 100644 --- a/crates/native_blockifier/src/py_transaction.rs +++ b/crates/native_blockifier/src/py_transaction.rs @@ -13,7 +13,7 @@ use pyo3::exceptions::PyValueError; use pyo3::prelude::*; use starknet_api::block::GasPrice; use starknet_api::execution_resources::GasAmount; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ DeprecatedResourceBoundsMapping, Resource, ResourceBounds, @@ -37,11 +37,11 @@ pub enum PyResource { L2Gas, } -impl From for starknet_api::transaction::Resource { +impl From for Resource { fn from(py_resource: PyResource) -> Self { match py_resource { - PyResource::L1Gas => starknet_api::transaction::Resource::L1Gas, - PyResource::L2Gas => starknet_api::transaction::Resource::L2Gas, + PyResource::L1Gas => Resource::L1Gas, + PyResource::L2Gas => Resource::L2Gas, } } } @@ -63,7 +63,7 @@ pub struct PyResourceBounds { pub max_price_per_unit: u128, } -impl From for starknet_api::transaction::ResourceBounds { +impl From for ResourceBounds { fn from(py_resource_bounds: PyResourceBounds) -> Self { Self { max_amount: GasAmount(py_resource_bounds.max_amount), diff --git a/crates/native_blockifier/src/py_validator.rs b/crates/native_blockifier/src/py_validator.rs index e035f0c4ef..6d5b5ff66c 100644 --- a/crates/native_blockifier/src/py_validator.rs +++ b/crates/native_blockifier/src/py_validator.rs @@ -8,7 +8,7 @@ use blockifier::transaction::transaction_types::TransactionType; use blockifier::versioned_constants::VersionedConstants; use pyo3::{pyclass, pymethods, PyAny}; use starknet_api::core::Nonce; -use starknet_api::transaction::TransactionHash; +use starknet_api::transaction::fields::TransactionHash; use starknet_types_core::felt::Felt; use crate::errors::NativeBlockifierResult; diff --git a/crates/native_blockifier/src/state_readers/papyrus_state_test.rs b/crates/native_blockifier/src/state_readers/papyrus_state_test.rs index 499f753b13..5b149df93c 100644 --- a/crates/native_blockifier/src/state_readers/papyrus_state_test.rs +++ b/crates/native_blockifier/src/state_readers/papyrus_state_test.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; use blockifier::abi::abi_utils::selector_from_name; -use blockifier::execution::call_info::{CallExecution, Retdata}; +use blockifier::execution::call_info::CallExecution; use blockifier::execution::entry_point::CallEntryPoint; use blockifier::retdata; use blockifier::state::cached_state::CachedState; diff --git a/crates/papyrus_execution/src/execution_test.rs b/crates/papyrus_execution/src/execution_test.rs index f3d2605bc9..e6da5d329e 100644 --- a/crates/papyrus_execution/src/execution_test.rs +++ b/crates/papyrus_execution/src/execution_test.rs @@ -22,7 +22,7 @@ use starknet_api::core::{ PatriciaKey, }; use starknet_api::state::{StateNumber, ThinStateDiff}; -use starknet_api::transaction::{Calldata, Fee}; +use starknet_api::transaction::fields::{Calldata, Fee}; use starknet_api::{calldata, class_hash, contract_address, felt, patricia_key}; use starknet_types_core::felt::Felt; diff --git a/crates/papyrus_execution/src/lib.rs b/crates/papyrus_execution/src/lib.rs index 97338954c8..27137d9d16 100644 --- a/crates/papyrus_execution/src/lib.rs +++ b/crates/papyrus_execution/src/lib.rs @@ -59,23 +59,25 @@ use starknet_api::core::{ChainId, ClassHash, ContractAddress, EntryPointSelector use starknet_api::data_availability::L1DataAvailabilityMode; use starknet_api::deprecated_contract_class::ContractClass as DeprecatedContractClass; use starknet_api::state::{StateNumber, ThinStateDiff}; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ Calldata, + Fee, + TransactionHash, + TransactionOptions, + TransactionVersion, +}; +use starknet_api::transaction::{ DeclareTransaction, DeclareTransactionV0V1, DeclareTransactionV2, DeclareTransactionV3, DeployAccountTransaction, - Fee, InvokeTransaction, L1HandlerTransaction, Transaction, - TransactionHash, - TransactionOptions, - TransactionVersion, }; use starknet_api::transaction_hash::get_transaction_hash; -use starknet_api::{contract_address, felt, patricia_key, StarknetApiError}; +use starknet_api::{contract_address, patricia_key, StarknetApiError}; use state_reader::ExecutionStateReader; use tracing::trace; diff --git a/crates/papyrus_execution/src/objects.rs b/crates/papyrus_execution/src/objects.rs index 9898c3527d..15eb5f8920 100644 --- a/crates/papyrus_execution/src/objects.rs +++ b/crates/papyrus_execution/src/objects.rs @@ -39,7 +39,8 @@ use starknet_api::execution_resources::{ GasVector as StarknetApiGasVector, }; use starknet_api::state::ThinStateDiff; -use starknet_api::transaction::{Calldata, EventContent, Fee, MessageToL1}; +use starknet_api::transaction::fields::{Calldata, Fee}; +use starknet_api::transaction::{EventContent, MessageToL1}; use starknet_types_core::felt::Felt; use crate::{ExecutionError, ExecutionResult, TransactionExecutionOutput}; diff --git a/crates/papyrus_execution/src/test_utils.rs b/crates/papyrus_execution/src/test_utils.rs index 557384ea36..a09294be96 100644 --- a/crates/papyrus_execution/src/test_utils.rs +++ b/crates/papyrus_execution/src/test_utils.rs @@ -33,15 +33,14 @@ use starknet_api::core::{ use starknet_api::deprecated_contract_class::ContractClass as DeprecatedContractClass; use starknet_api::state::{ContractClass, StateNumber, ThinStateDiff}; use starknet_api::test_utils::read_json_file; +use starknet_api::transaction::fields::{Calldata, Fee, TransactionHash}; use starknet_api::transaction::{ DeclareTransactionV0V1, DeclareTransactionV2, DeployAccountTransaction, DeployAccountTransactionV1, - Fee, InvokeTransaction, InvokeTransactionV1, - TransactionHash, }; use starknet_api::{calldata, class_hash, contract_address, felt, patricia_key}; use starknet_types_core::felt::Felt; diff --git a/crates/papyrus_execution/src/testing_instances.rs b/crates/papyrus_execution/src/testing_instances.rs index 7d464ccf3f..479ab6ad9a 100644 --- a/crates/papyrus_execution/src/testing_instances.rs +++ b/crates/papyrus_execution/src/testing_instances.rs @@ -8,8 +8,9 @@ use starknet_api::block::GasPrice; use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector, PatriciaKey}; use starknet_api::execution_resources::ExecutionResources; -use starknet_api::transaction::{Calldata, EventContent, Fee, MessageToL1}; -use starknet_api::{contract_address, felt, patricia_key}; +use starknet_api::transaction::fields::{Calldata, Fee}; +use starknet_api::transaction::{EventContent, MessageToL1}; +use starknet_api::{contract_address, patricia_key}; use starknet_types_core::felt::Felt; use crate::objects::{ diff --git a/crates/papyrus_node/examples/get_transaction_hash.rs b/crates/papyrus_node/examples/get_transaction_hash.rs index 6cd4b0ed2f..9b9314990c 100644 --- a/crates/papyrus_node/examples/get_transaction_hash.rs +++ b/crates/papyrus_node/examples/get_transaction_hash.rs @@ -8,7 +8,8 @@ use once_cell::sync::OnceCell; use reqwest::Client; use serde_json::{json, to_writer_pretty, Map, Value}; use starknet_api::core::ChainId; -use starknet_api::transaction::{self, Transaction, TransactionOptions}; +use starknet_api::transaction::fields::TransactionOptions; +use starknet_api::transaction::{self, Transaction}; use starknet_api::transaction_hash::{get_transaction_hash, MAINNET_TRANSACTION_HASH_WITH_VERSION}; use starknet_client::reader::objects::transaction::TransactionType; use strum::IntoEnumIterator; diff --git a/crates/papyrus_p2p_sync/src/server/mod.rs b/crates/papyrus_p2p_sync/src/server/mod.rs index 205a10239a..c78a170d06 100644 --- a/crates/papyrus_p2p_sync/src/server/mod.rs +++ b/crates/papyrus_p2p_sync/src/server/mod.rs @@ -27,7 +27,8 @@ use papyrus_storage::{db, StorageReader, StorageTxn}; use starknet_api::block::BlockNumber; use starknet_api::core::ClassHash; use starknet_api::state::ThinStateDiff; -use starknet_api::transaction::{Event, FullTransaction, TransactionHash}; +use starknet_api::transaction::fields::TransactionHash; +use starknet_api::transaction::{Event, FullTransaction}; use tracing::{error, info}; #[cfg(test)] diff --git a/crates/papyrus_p2p_sync/src/server/test.rs b/crates/papyrus_p2p_sync/src/server/test.rs index 8f319bad5c..b977ecc25c 100644 --- a/crates/papyrus_p2p_sync/src/server/test.rs +++ b/crates/papyrus_p2p_sync/src/server/test.rs @@ -42,13 +42,8 @@ use starknet_api::block::{ }; use starknet_api::deprecated_contract_class::ContractClass as DeprecatedContractClass; use starknet_api::state::ContractClass; -use starknet_api::transaction::{ - Event, - FullTransaction, - Transaction, - TransactionHash, - TransactionOutput, -}; +use starknet_api::transaction::fields::TransactionHash; +use starknet_api::transaction::{Event, FullTransaction, Transaction, TransactionOutput}; use super::{split_thin_state_diff, FetchBlockDataFromDb, P2PSyncServer, P2PSyncServerChannels}; use crate::server::register_query; diff --git a/crates/papyrus_protobuf/src/converters/consensus_test.rs b/crates/papyrus_protobuf/src/converters/consensus_test.rs index e30238e2c9..0720e05270 100644 --- a/crates/papyrus_protobuf/src/converters/consensus_test.rs +++ b/crates/papyrus_protobuf/src/converters/consensus_test.rs @@ -8,6 +8,7 @@ use rand::Rng; use starknet_api::block::BlockHash; use starknet_api::core::ContractAddress; use starknet_api::execution_resources::GasAmount; +use starknet_api::transaction::fields::ValidResourceBounds; use starknet_api::transaction::{ DeclareTransaction, DeclareTransactionV3, @@ -16,7 +17,6 @@ use starknet_api::transaction::{ InvokeTransaction, InvokeTransactionV3, Transaction, - ValidResourceBounds, }; use crate::consensus::{ diff --git a/crates/papyrus_protobuf/src/converters/event.rs b/crates/papyrus_protobuf/src/converters/event.rs index 41d9f8c5df..f13b414280 100644 --- a/crates/papyrus_protobuf/src/converters/event.rs +++ b/crates/papyrus_protobuf/src/converters/event.rs @@ -3,7 +3,8 @@ mod event_test; use prost::Message; use starknet_api::core::{ContractAddress, PatriciaKey}; -use starknet_api::transaction::{Event, EventContent, EventData, EventKey, TransactionHash}; +use starknet_api::transaction::fields::TransactionHash; +use starknet_api::transaction::{Event, EventContent, EventData, EventKey}; use starknet_types_core::felt::Felt; use super::ProtobufConversionError; diff --git a/crates/papyrus_protobuf/src/converters/event_test.rs b/crates/papyrus_protobuf/src/converters/event_test.rs index 4a0a3cce58..43abbf26f7 100644 --- a/crates/papyrus_protobuf/src/converters/event_test.rs +++ b/crates/papyrus_protobuf/src/converters/event_test.rs @@ -1,5 +1,6 @@ use papyrus_test_utils::{get_rng, GetTestInstance}; -use starknet_api::transaction::{Event, TransactionHash}; +use starknet_api::transaction::fields::TransactionHash; +use starknet_api::transaction::Event; use crate::sync::DataOrFin; diff --git a/crates/papyrus_protobuf/src/converters/receipt.rs b/crates/papyrus_protobuf/src/converters/receipt.rs index 052c4bf5e5..1caac6cc1c 100644 --- a/crates/papyrus_protobuf/src/converters/receipt.rs +++ b/crates/papyrus_protobuf/src/converters/receipt.rs @@ -2,11 +2,11 @@ use std::collections::HashMap; use starknet_api::core::{ContractAddress, EthAddress, PatriciaKey}; use starknet_api::execution_resources::{Builtin, ExecutionResources, GasVector}; +use starknet_api::transaction::fields::Fee; use starknet_api::transaction::{ DeclareTransactionOutput, DeployAccountTransactionOutput, DeployTransactionOutput, - Fee, InvokeTransactionOutput, L1HandlerTransactionOutput, L2ToL1Payload, diff --git a/crates/papyrus_protobuf/src/converters/rpc_transaction.rs b/crates/papyrus_protobuf/src/converters/rpc_transaction.rs index 292e706736..234a31e3ff 100644 --- a/crates/papyrus_protobuf/src/converters/rpc_transaction.rs +++ b/crates/papyrus_protobuf/src/converters/rpc_transaction.rs @@ -15,12 +15,11 @@ use starknet_api::rpc_transaction::{ RpcTransaction, }; use starknet_api::state::EntryPoint; +use starknet_api::transaction::fields::{AllResourceBounds, ValidResourceBounds}; use starknet_api::transaction::{ - AllResourceBounds, DeclareTransactionV3, DeployAccountTransactionV3, InvokeTransactionV3, - ValidResourceBounds, }; use starknet_types_core::felt::Felt; diff --git a/crates/papyrus_protobuf/src/converters/rpc_transaction_test.rs b/crates/papyrus_protobuf/src/converters/rpc_transaction_test.rs index 7984e4dd5f..081cbf1910 100644 --- a/crates/papyrus_protobuf/src/converters/rpc_transaction_test.rs +++ b/crates/papyrus_protobuf/src/converters/rpc_transaction_test.rs @@ -11,7 +11,7 @@ use starknet_api::rpc_transaction::{ RpcInvokeTransactionV3, RpcTransaction, }; -use starknet_api::transaction::{AllResourceBounds, ResourceBounds}; +use starknet_api::transaction::fields::{AllResourceBounds, ResourceBounds}; use crate::mempool::RpcTransactionWrapper; diff --git a/crates/papyrus_protobuf/src/converters/transaction.rs b/crates/papyrus_protobuf/src/converters/transaction.rs index 81aaf05444..0f3b41891c 100644 --- a/crates/papyrus_protobuf/src/converters/transaction.rs +++ b/crates/papyrus_protobuf/src/converters/transaction.rs @@ -7,11 +7,21 @@ use prost::Message; use starknet_api::block::GasPrice; use starknet_api::core::{ClassHash, CompiledClassHash, EntryPointSelector, Nonce}; use starknet_api::execution_resources::GasAmount; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ AccountDeploymentData, AllResourceBounds, Calldata, ContractAddressSalt, + Fee, + PaymasterData, + ResourceBounds, + Tip, + TransactionHash, + TransactionSignature, + TransactionVersion, + ValidResourceBounds, +}; +use starknet_api::transaction::{ DeclareTransaction, DeclareTransactionV0V1, DeclareTransactionV2, @@ -20,22 +30,14 @@ use starknet_api::transaction::{ DeployAccountTransactionV1, DeployAccountTransactionV3, DeployTransaction, - Fee, FullTransaction, InvokeTransaction, InvokeTransactionV0, InvokeTransactionV1, InvokeTransactionV3, L1HandlerTransaction, - PaymasterData, - ResourceBounds, - Tip, Transaction, - TransactionHash, TransactionOutput, - TransactionSignature, - TransactionVersion, - ValidResourceBounds, }; use starknet_types_core::felt::Felt; diff --git a/crates/papyrus_protobuf/src/converters/transaction_test.rs b/crates/papyrus_protobuf/src/converters/transaction_test.rs index 7134299385..0682bce6fe 100644 --- a/crates/papyrus_protobuf/src/converters/transaction_test.rs +++ b/crates/papyrus_protobuf/src/converters/transaction_test.rs @@ -3,8 +3,13 @@ use papyrus_test_utils::{get_rng, GetTestInstance}; use rand::random; use starknet_api::block::GasPrice; use starknet_api::execution_resources::{Builtin, ExecutionResources, GasAmount, GasVector}; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ AllResourceBounds, + ResourceBounds, + TransactionHash, + ValidResourceBounds, +}; +use starknet_api::transaction::{ DeclareTransaction, DeclareTransactionOutput, DeployAccountTransaction, @@ -14,11 +19,8 @@ use starknet_api::transaction::{ InvokeTransaction, InvokeTransactionOutput, L1HandlerTransactionOutput, - ResourceBounds, Transaction as StarknetApiTransaction, - TransactionHash, TransactionOutput, - ValidResourceBounds, }; use starknet_types_core::felt::Felt; diff --git a/crates/papyrus_rpc/src/api.rs b/crates/papyrus_rpc/src/api.rs index 2d39e47123..e6984cbfca 100644 --- a/crates/papyrus_rpc/src/api.rs +++ b/crates/papyrus_rpc/src/api.rs @@ -8,7 +8,7 @@ use papyrus_storage::StorageReader; use serde::{Deserialize, Serialize}; use starknet_api::block::{BlockHash, BlockNumber}; use starknet_api::core::{ChainId, ContractAddress, EntryPointSelector}; -use starknet_api::transaction::Calldata; +use starknet_api::transaction::fields::Calldata; use starknet_client::reader::PendingData; use starknet_client::writer::StarknetWriter; use tokio::sync::RwLock; diff --git a/crates/papyrus_rpc/src/v0_8/api/api_impl.rs b/crates/papyrus_rpc/src/v0_8/api/api_impl.rs index 59aad18828..2501837aff 100644 --- a/crates/papyrus_rpc/src/v0_8/api/api_impl.rs +++ b/crates/papyrus_rpc/src/v0_8/api/api_impl.rs @@ -26,14 +26,12 @@ use starknet_api::core::{ChainId, ClassHash, ContractAddress, GlobalRoot, Nonce} use starknet_api::execution_utils::format_panic_data; use starknet_api::hash::StarkHash; use starknet_api::state::{StateNumber, StorageKey}; +use starknet_api::transaction::fields::{Fee, TransactionHash, TransactionVersion}; use starknet_api::transaction::{ EventContent, EventIndexInTransactionOutput, - Fee, Transaction as StarknetApiTransaction, - TransactionHash, TransactionOffsetInBlock, - TransactionVersion, }; use starknet_client::reader::objects::pending_data::{ DeprecatedPendingBlock, diff --git a/crates/papyrus_rpc/src/v0_8/api/mod.rs b/crates/papyrus_rpc/src/v0_8/api/mod.rs index 0d9db3941d..435232d2c3 100644 --- a/crates/papyrus_rpc/src/v0_8/api/mod.rs +++ b/crates/papyrus_rpc/src/v0_8/api/mod.rs @@ -25,7 +25,8 @@ use starknet_api::deprecated_contract_class::{ Program, }; use starknet_api::state::{StateNumber, StorageKey}; -use starknet_api::transaction::{EventKey, Fee, TransactionHash, TransactionOffsetInBlock}; +use starknet_api::transaction::fields::{Fee, TransactionHash}; +use starknet_api::transaction::{EventKey, TransactionOffsetInBlock}; use starknet_types_core::felt::Felt; use tracing::debug; diff --git a/crates/papyrus_rpc/src/v0_8/api/test.rs b/crates/papyrus_rpc/src/v0_8/api/test.rs index 5a4b64581a..b1ae1ba4f8 100644 --- a/crates/papyrus_rpc/src/v0_8/api/test.rs +++ b/crates/papyrus_rpc/src/v0_8/api/test.rs @@ -70,6 +70,7 @@ use starknet_api::deprecated_contract_class::{ }; use starknet_api::hash::StarkHash; use starknet_api::state::{ContractClass as StarknetApiContractClass, StateDiff, StorageKey}; +use starknet_api::transaction::fields::TransactionHash; use starknet_api::transaction::{ Event as StarknetApiEvent, EventContent, @@ -77,7 +78,6 @@ use starknet_api::transaction::{ EventIndexInTransactionOutput, EventKey, Transaction as StarknetApiTransaction, - TransactionHash, TransactionOffsetInBlock, TransactionOutput as StarknetApiTransactionOutput, }; diff --git a/crates/papyrus_rpc/src/v0_8/broadcasted_transaction.rs b/crates/papyrus_rpc/src/v0_8/broadcasted_transaction.rs index 496eea2b8b..a7a0dfcbbb 100644 --- a/crates/papyrus_rpc/src/v0_8/broadcasted_transaction.rs +++ b/crates/papyrus_rpc/src/v0_8/broadcasted_transaction.rs @@ -14,7 +14,7 @@ use papyrus_storage::db::serialization::StorageSerdeError; use serde::{Deserialize, Serialize}; use starknet_api::core::{CompiledClassHash, ContractAddress, Nonce}; use starknet_api::data_availability::DataAvailabilityMode; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ AccountDeploymentData, Fee, PaymasterData, diff --git a/crates/papyrus_rpc/src/v0_8/broadcasted_transaction_test.rs b/crates/papyrus_rpc/src/v0_8/broadcasted_transaction_test.rs index 6d89b0a49b..806581ba01 100644 --- a/crates/papyrus_rpc/src/v0_8/broadcasted_transaction_test.rs +++ b/crates/papyrus_rpc/src/v0_8/broadcasted_transaction_test.rs @@ -19,7 +19,7 @@ use starknet_api::deprecated_contract_class::{ StructAbiEntry, }; use starknet_api::state::EntryPoint; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ AccountDeploymentData, Fee, PaymasterData, diff --git a/crates/papyrus_rpc/src/v0_8/execution_test.rs b/crates/papyrus_rpc/src/v0_8/execution_test.rs index 5d7ffe3ceb..940fe77c67 100644 --- a/crates/papyrus_rpc/src/v0_8/execution_test.rs +++ b/crates/papyrus_rpc/src/v0_8/execution_test.rs @@ -66,14 +66,8 @@ use starknet_api::deprecated_contract_class::ContractClass as SN_API_DeprecatedC use starknet_api::hash::StarkHash; use starknet_api::state::{StorageKey, ThinStateDiff as StarknetApiStateDiff}; use starknet_api::test_utils::read_json_file; -use starknet_api::transaction::{ - Calldata, - Fee, - L1HandlerTransaction, - TransactionHash, - TransactionOffsetInBlock, - TransactionVersion, -}; +use starknet_api::transaction::fields::{Calldata, Fee, TransactionHash, TransactionVersion}; +use starknet_api::transaction::{L1HandlerTransaction, TransactionOffsetInBlock}; use starknet_api::{calldata, class_hash, contract_address, felt, patricia_key}; use starknet_client::reader::objects::pending_data::{ PendingBlock, diff --git a/crates/papyrus_rpc/src/v0_8/transaction.rs b/crates/papyrus_rpc/src/v0_8/transaction.rs index 769fc50a0e..514ec164c0 100644 --- a/crates/papyrus_rpc/src/v0_8/transaction.rs +++ b/crates/papyrus_rpc/src/v0_8/transaction.rs @@ -27,24 +27,26 @@ use starknet_api::core::{ use starknet_api::data_availability::DataAvailabilityMode; use starknet_api::execution_resources::GasAmount; use starknet_api::serde_utils::bytes_from_hex_str; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ AccountDeploymentData, AllResourceBounds, Calldata, ContractAddressSalt, - DeployTransaction, Fee, - L1HandlerTransaction, - MessageToL1, PaymasterData, Resource, ResourceBounds, Tip, - TransactionExecutionStatus, TransactionHash, TransactionSignature, TransactionVersion, }; +use starknet_api::transaction::{ + DeployTransaction, + L1HandlerTransaction, + MessageToL1, + TransactionExecutionStatus, +}; use starknet_client::writer::objects::transaction as client_transaction; use starknet_types_core::felt::Felt; @@ -155,14 +157,18 @@ pub struct ResourceBoundsMapping { pub l2_gas: ResourceBounds, } -impl From for starknet_api::transaction::DeprecatedResourceBoundsMapping { +impl From + for starknet_api::transaction::fields::DeprecatedResourceBoundsMapping +{ fn from(value: ResourceBoundsMapping) -> Self { Self([(Resource::L1Gas, value.l1_gas), (Resource::L2Gas, value.l2_gas)].into()) } } -impl From for ResourceBoundsMapping { - fn from(value: starknet_api::transaction::DeprecatedResourceBoundsMapping) -> Self { +impl From + for ResourceBoundsMapping +{ + fn from(value: starknet_api::transaction::fields::DeprecatedResourceBoundsMapping) -> Self { Self { l1_gas: value.0.get(&Resource::L1Gas).cloned().unwrap_or_default(), l2_gas: value.0.get(&Resource::L2Gas).cloned().unwrap_or_default(), @@ -170,7 +176,7 @@ impl From for Resour } } -impl TryFrom for starknet_api::transaction::ValidResourceBounds { +impl TryFrom for starknet_api::transaction::fields::ValidResourceBounds { type Error = ErrorObjectOwned; fn try_from(value: ResourceBoundsMapping) -> Result { if !value.l2_gas.is_zero() { @@ -181,17 +187,15 @@ impl TryFrom for starknet_api::transaction::ValidResource } } -impl From for ResourceBoundsMapping { - fn from(value: starknet_api::transaction::ValidResourceBounds) -> Self { +impl From for ResourceBoundsMapping { + fn from(value: starknet_api::transaction::fields::ValidResourceBounds) -> Self { match value { - starknet_api::transaction::ValidResourceBounds::L1Gas(l1_gas) => { + starknet_api::transaction::fields::ValidResourceBounds::L1Gas(l1_gas) => { Self { l1_gas, l2_gas: ResourceBounds::default() } } - starknet_api::transaction::ValidResourceBounds::AllResources(AllResourceBounds { - l1_gas, - l2_gas, - .. - }) => Self { l1_gas, l2_gas }, + starknet_api::transaction::fields::ValidResourceBounds::AllResources( + AllResourceBounds { l1_gas, l2_gas, .. }, + ) => Self { l1_gas, l2_gas }, } } } diff --git a/crates/papyrus_rpc/src/v0_8/transaction_test.rs b/crates/papyrus_rpc/src/v0_8/transaction_test.rs index 5bd9f0d709..6df6215fa6 100644 --- a/crates/papyrus_rpc/src/v0_8/transaction_test.rs +++ b/crates/papyrus_rpc/src/v0_8/transaction_test.rs @@ -7,18 +7,17 @@ use papyrus_test_utils::{ use pretty_assertions::assert_eq; use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector, Nonce, PatriciaKey}; use starknet_api::data_availability::DataAvailabilityMode; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ AccountDeploymentData, Calldata, ContractAddressSalt, Fee, - L1HandlerTransaction, PaymasterData, Tip, - Transaction, TransactionSignature, TransactionVersion, }; +use starknet_api::transaction::{L1HandlerTransaction, Transaction}; use starknet_api::{calldata, contract_address, felt, patricia_key}; use starknet_client::writer::objects::transaction as client_transaction; diff --git a/crates/papyrus_rpc/src/v0_8/write_api_result.rs b/crates/papyrus_rpc/src/v0_8/write_api_result.rs index ddc54e96f9..fbf710224f 100644 --- a/crates/papyrus_rpc/src/v0_8/write_api_result.rs +++ b/crates/papyrus_rpc/src/v0_8/write_api_result.rs @@ -1,6 +1,6 @@ use serde::{Deserialize, Serialize}; use starknet_api::core::{ClassHash, ContractAddress}; -use starknet_api::transaction::TransactionHash; +use starknet_api::transaction::fields::TransactionHash; use starknet_client::writer::objects::response::{ DeclareResponse, DeployAccountResponse, diff --git a/crates/papyrus_rpc/src/v0_8/write_api_result_test.rs b/crates/papyrus_rpc/src/v0_8/write_api_result_test.rs index f65828553a..7abceab723 100644 --- a/crates/papyrus_rpc/src/v0_8/write_api_result_test.rs +++ b/crates/papyrus_rpc/src/v0_8/write_api_result_test.rs @@ -2,7 +2,7 @@ use papyrus_test_utils::{auto_impl_get_test_instance, get_rng, GetTestInstance}; use serde::Serialize; use starknet_api::core::{ClassHash, ContractAddress, PatriciaKey}; use starknet_api::felt; -use starknet_api::transaction::TransactionHash; +use starknet_api::transaction::fields::TransactionHash; use starknet_client::writer::objects::response::{ DeclareResponse, DeployAccountResponse, diff --git a/crates/papyrus_rpc/tests/gateway_integration_test.rs b/crates/papyrus_rpc/tests/gateway_integration_test.rs index b59a02436e..c5086f4ee0 100644 --- a/crates/papyrus_rpc/tests/gateway_integration_test.rs +++ b/crates/papyrus_rpc/tests/gateway_integration_test.rs @@ -10,7 +10,8 @@ use papyrus_rpc::{ TransactionVersion1RPC0_8, }; use starknet_api::core::{ChainId, ContractAddress, EntryPointSelector, Nonce, PatriciaKey}; -use starknet_api::transaction::{Fee, Transaction, TransactionOptions, TransactionSignature}; +use starknet_api::transaction::fields::{Fee, TransactionOptions, TransactionSignature}; +use starknet_api::transaction::Transaction; use starknet_api::transaction_hash::get_transaction_hash; use starknet_api::{calldata, contract_address, felt, patricia_key}; use starknet_client::writer::objects::transaction::InvokeTransaction as SNClientInvokeTransaction; diff --git a/crates/papyrus_storage/src/body/mod.rs b/crates/papyrus_storage/src/body/mod.rs index 066be012aa..0174945925 100644 --- a/crates/papyrus_storage/src/body/mod.rs +++ b/crates/papyrus_storage/src/body/mod.rs @@ -49,12 +49,8 @@ use papyrus_proc_macros::latency_histogram; use serde::{Deserialize, Serialize}; use starknet_api::block::{BlockBody, BlockNumber}; use starknet_api::core::ContractAddress; -use starknet_api::transaction::{ - Transaction, - TransactionHash, - TransactionOffsetInBlock, - TransactionOutput, -}; +use starknet_api::transaction::fields::TransactionHash; +use starknet_api::transaction::{Transaction, TransactionOffsetInBlock, TransactionOutput}; use tracing::debug; use crate::db::serialization::{NoVersionValueWrapper, VersionZeroWrapper}; diff --git a/crates/papyrus_storage/src/lib.rs b/crates/papyrus_storage/src/lib.rs index a8f4455819..0a6497ead7 100644 --- a/crates/papyrus_storage/src/lib.rs +++ b/crates/papyrus_storage/src/lib.rs @@ -126,7 +126,8 @@ use starknet_api::block::{BlockHash, BlockNumber, BlockSignature, StarknetVersio use starknet_api::core::{ClassHash, ContractAddress, Nonce}; use starknet_api::deprecated_contract_class::ContractClass as DeprecatedContractClass; use starknet_api::state::{ContractClass, StateNumber, StorageKey, ThinStateDiff}; -use starknet_api::transaction::{Transaction, TransactionHash, TransactionOutput}; +use starknet_api::transaction::fields::TransactionHash; +use starknet_api::transaction::{Transaction, TransactionOutput}; use starknet_types_core::felt::Felt; use tracing::{debug, warn}; use validator::Validate; diff --git a/crates/papyrus_storage/src/serialization/serializers.rs b/crates/papyrus_storage/src/serialization/serializers.rs index f092e69aa5..119cd563bc 100644 --- a/crates/papyrus_storage/src/serialization/serializers.rs +++ b/crates/papyrus_storage/src/serialization/serializers.rs @@ -67,11 +67,22 @@ use starknet_api::deprecated_contract_class::{ use starknet_api::execution_resources::{Builtin, ExecutionResources, GasAmount, GasVector}; use starknet_api::hash::{PoseidonHash, StarkHash}; use starknet_api::state::{ContractClass, EntryPoint, FunctionIndex, StorageKey, ThinStateDiff}; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ AccountDeploymentData, AllResourceBounds, Calldata, ContractAddressSalt, + Fee, + PaymasterData, + Resource, + ResourceBounds, + Tip, + TransactionHash, + TransactionSignature, + TransactionVersion, + ValidResourceBounds, +}; +use starknet_api::transaction::{ DeclareTransaction, DeclareTransactionOutput, DeclareTransactionV0V1, @@ -88,7 +99,6 @@ use starknet_api::transaction::{ EventData, EventIndexInTransactionOutput, EventKey, - Fee, InvokeTransaction, InvokeTransactionOutput, InvokeTransactionV0, @@ -100,19 +110,11 @@ use starknet_api::transaction::{ L2ToL1Payload, MessageToL1, MessageToL2, - PaymasterData, - Resource, - ResourceBounds, RevertedTransactionExecutionStatus, - Tip, Transaction, TransactionExecutionStatus, - TransactionHash, TransactionOffsetInBlock, TransactionOutput, - TransactionSignature, - TransactionVersion, - ValidResourceBounds, }; use starknet_types_core::felt::Felt; use tracing::warn; diff --git a/crates/papyrus_storage/src/test_instances.rs b/crates/papyrus_storage/src/test_instances.rs index 583ce74f92..2259d3f428 100644 --- a/crates/papyrus_storage/src/test_instances.rs +++ b/crates/papyrus_storage/src/test_instances.rs @@ -9,11 +9,8 @@ use starknet_api::core::{ TransactionCommitment, }; use starknet_api::data_availability::L1DataAvailabilityMode; -use starknet_api::transaction::{ - EventIndexInTransactionOutput, - TransactionHash, - TransactionOffsetInBlock, -}; +use starknet_api::transaction::fields::TransactionHash; +use starknet_api::transaction::{EventIndexInTransactionOutput, TransactionOffsetInBlock}; use crate::body::TransactionIndex; use crate::compression_utils::IsCompressed; diff --git a/crates/papyrus_test_utils/src/lib.rs b/crates/papyrus_test_utils/src/lib.rs index 1113bc941e..fcb1be3534 100644 --- a/crates/papyrus_test_utils/src/lib.rs +++ b/crates/papyrus_test_utils/src/lib.rs @@ -108,11 +108,22 @@ use starknet_api::state::{ ThinStateDiff, }; use starknet_api::test_utils::read_json_file; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ AccountDeploymentData, AllResourceBounds, Calldata, ContractAddressSalt, + Fee, + PaymasterData, + Resource, + ResourceBounds, + Tip, + TransactionHash, + TransactionSignature, + TransactionVersion, + ValidResourceBounds, +}; +use starknet_api::transaction::{ DeclareTransaction, DeclareTransactionOutput, DeclareTransactionV0V1, @@ -129,7 +140,6 @@ use starknet_api::transaction::{ EventData, EventIndexInTransactionOutput, EventKey, - Fee, InvokeTransaction, InvokeTransactionOutput, InvokeTransactionV0, @@ -141,19 +151,11 @@ use starknet_api::transaction::{ L2ToL1Payload, MessageToL1, MessageToL2, - PaymasterData, - Resource, - ResourceBounds, RevertedTransactionExecutionStatus, - Tip, Transaction, TransactionExecutionStatus, - TransactionHash, TransactionOffsetInBlock, TransactionOutput, - TransactionSignature, - TransactionVersion, - ValidResourceBounds, }; use starknet_types_core::felt::Felt; diff --git a/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context_test.rs b/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context_test.rs index dea03b4000..f14048b0d5 100644 --- a/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context_test.rs +++ b/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context_test.rs @@ -11,7 +11,7 @@ use starknet_api::core::{ContractAddress, StateDiffCommitment}; use starknet_api::executable_transaction::Transaction; use starknet_api::hash::PoseidonHash; use starknet_api::test_utils::invoke::{executable_invoke_tx, InvokeTxArgs}; -use starknet_api::transaction::TransactionHash; +use starknet_api::transaction::fields::TransactionHash; use starknet_batcher_types::batcher_types::{ BuildProposalInput, GetProposalContent, diff --git a/crates/starknet_api/src/block.rs b/crates/starknet_api/src/block.rs index 6588b7a173..032aec6eed 100644 --- a/crates/starknet_api/src/block.rs +++ b/crates/starknet_api/src/block.rs @@ -21,7 +21,8 @@ use crate::data_availability::L1DataAvailabilityMode; use crate::execution_resources::GasAmount; use crate::hash::StarkHash; use crate::serde_utils::{BytesAsHex, PrefixedBytesAsHex}; -use crate::transaction::{Fee, Transaction, TransactionHash, TransactionOutput}; +use crate::transaction::fields::{Fee, TransactionHash}; +use crate::transaction::{Transaction, TransactionOutput}; use crate::StarknetApiError; /// A block. diff --git a/crates/starknet_api/src/block_hash/block_hash_calculator.rs b/crates/starknet_api/src/block_hash/block_hash_calculator.rs index 27864a7091..62e3eb94dc 100644 --- a/crates/starknet_api/src/block_hash/block_hash_calculator.rs +++ b/crates/starknet_api/src/block_hash/block_hash_calculator.rs @@ -20,14 +20,8 @@ use crate::crypto::utils::HashChain; use crate::data_availability::L1DataAvailabilityMode; use crate::execution_resources::GasVector; use crate::state::ThinStateDiff; -use crate::transaction::{ - Event, - Fee, - MessageToL1, - TransactionExecutionStatus, - TransactionHash, - TransactionSignature, -}; +use crate::transaction::fields::{Fee, TransactionHash, TransactionSignature}; +use crate::transaction::{Event, MessageToL1, TransactionExecutionStatus}; use crate::{StarknetApiError, StarknetApiResult}; #[cfg(test)] diff --git a/crates/starknet_api/src/block_hash/block_hash_calculator_test.rs b/crates/starknet_api/src/block_hash/block_hash_calculator_test.rs index fa2754211f..45c5ee39ba 100644 --- a/crates/starknet_api/src/block_hash/block_hash_calculator_test.rs +++ b/crates/starknet_api/src/block_hash/block_hash_calculator_test.rs @@ -30,7 +30,7 @@ use crate::core::{ use crate::data_availability::L1DataAvailabilityMode; use crate::felt; use crate::hash::PoseidonHash; -use crate::transaction::{TransactionHash, TransactionSignature}; +use crate::transaction::fields::{TransactionHash, TransactionSignature}; /// Macro to test if changing any field in the header or commitments /// results a change in the block hash. diff --git a/crates/starknet_api/src/block_hash/event_commitment.rs b/crates/starknet_api/src/block_hash/event_commitment.rs index aa0469b1c5..51d06f7353 100644 --- a/crates/starknet_api/src/block_hash/event_commitment.rs +++ b/crates/starknet_api/src/block_hash/event_commitment.rs @@ -4,7 +4,8 @@ use starknet_types_core::hash::StarkHash; use crate::core::EventCommitment; use crate::crypto::patricia_hash::calculate_root; use crate::crypto::utils::HashChain; -use crate::transaction::{Event, TransactionHash}; +use crate::transaction::fields::TransactionHash; +use crate::transaction::Event; #[cfg(test)] #[path = "event_commitment_test.rs"] diff --git a/crates/starknet_api/src/block_hash/event_commitment_test.rs b/crates/starknet_api/src/block_hash/event_commitment_test.rs index 132bc86d87..9e9334cbf9 100644 --- a/crates/starknet_api/src/block_hash/event_commitment_test.rs +++ b/crates/starknet_api/src/block_hash/event_commitment_test.rs @@ -3,7 +3,8 @@ use starknet_types_core::hash::Poseidon; use super::{calculate_event_commitment, calculate_event_hash, EventLeafElement}; use crate::core::{ContractAddress, EventCommitment, PatriciaKey}; -use crate::transaction::{Event, EventContent, EventData, EventKey, TransactionHash}; +use crate::transaction::fields::TransactionHash; +use crate::transaction::{Event, EventContent, EventData, EventKey}; use crate::{contract_address, felt, patricia_key}; #[test] diff --git a/crates/starknet_api/src/block_hash/receipt_commitment.rs b/crates/starknet_api/src/block_hash/receipt_commitment.rs index 40bec64877..0c6b4d16de 100644 --- a/crates/starknet_api/src/block_hash/receipt_commitment.rs +++ b/crates/starknet_api/src/block_hash/receipt_commitment.rs @@ -7,7 +7,8 @@ use crate::crypto::patricia_hash::calculate_root; use crate::crypto::utils::HashChain; use crate::execution_resources::GasVector; use crate::hash::starknet_keccak_hash; -use crate::transaction::{MessageToL1, TransactionExecutionStatus, TransactionHash}; +use crate::transaction::fields::TransactionHash; +use crate::transaction::{MessageToL1, TransactionExecutionStatus}; #[cfg(test)] #[path = "receipt_commitment_test.rs"] diff --git a/crates/starknet_api/src/block_hash/receipt_commitment_test.rs b/crates/starknet_api/src/block_hash/receipt_commitment_test.rs index 53dc119f78..093d8378ae 100644 --- a/crates/starknet_api/src/block_hash/receipt_commitment_test.rs +++ b/crates/starknet_api/src/block_hash/receipt_commitment_test.rs @@ -11,11 +11,8 @@ use crate::block_hash::receipt_commitment::{ use crate::block_hash::test_utils::{generate_message_to_l1, get_transaction_output}; use crate::core::ReceiptCommitment; use crate::felt; -use crate::transaction::{ - RevertedTransactionExecutionStatus, - TransactionExecutionStatus, - TransactionHash, -}; +use crate::transaction::fields::TransactionHash; +use crate::transaction::{RevertedTransactionExecutionStatus, TransactionExecutionStatus}; #[test] fn test_receipt_hash_regression() { diff --git a/crates/starknet_api/src/block_hash/test_utils.rs b/crates/starknet_api/src/block_hash/test_utils.rs index 08bd00af94..620a8e5210 100644 --- a/crates/starknet_api/src/block_hash/test_utils.rs +++ b/crates/starknet_api/src/block_hash/test_utils.rs @@ -6,8 +6,8 @@ use super::block_hash_calculator::TransactionOutputForHash; use crate::core::{ClassHash, CompiledClassHash, ContractAddress, EthAddress, Nonce}; use crate::execution_resources::{GasAmount, GasVector}; use crate::state::ThinStateDiff; +use crate::transaction::fields::Fee; use crate::transaction::{ - Fee, L2ToL1Payload, MessageToL1, RevertedTransactionExecutionStatus, diff --git a/crates/starknet_api/src/block_hash/transaction_commitment.rs b/crates/starknet_api/src/block_hash/transaction_commitment.rs index 93d23f31a8..4f32eecacb 100644 --- a/crates/starknet_api/src/block_hash/transaction_commitment.rs +++ b/crates/starknet_api/src/block_hash/transaction_commitment.rs @@ -5,7 +5,7 @@ use super::block_hash_calculator::TransactionHashingData; use crate::core::TransactionCommitment; use crate::crypto::patricia_hash::calculate_root; use crate::crypto::utils::HashChain; -use crate::transaction::{TransactionHash, TransactionSignature}; +use crate::transaction::fields::{TransactionHash, TransactionSignature}; #[cfg(test)] #[path = "transaction_commitment_test.rs"] diff --git a/crates/starknet_api/src/block_hash/transaction_commitment_test.rs b/crates/starknet_api/src/block_hash/transaction_commitment_test.rs index bc0d51bb99..6ff58d62b1 100644 --- a/crates/starknet_api/src/block_hash/transaction_commitment_test.rs +++ b/crates/starknet_api/src/block_hash/transaction_commitment_test.rs @@ -8,7 +8,7 @@ use crate::block_hash::transaction_commitment::{ }; use crate::core::TransactionCommitment; use crate::felt; -use crate::transaction::{TransactionHash, TransactionSignature}; +use crate::transaction::fields::{TransactionHash, TransactionSignature}; #[test] fn test_transaction_leaf_regression() { diff --git a/crates/starknet_api/src/core.rs b/crates/starknet_api/src/core.rs index bb8100d238..04050c0e12 100644 --- a/crates/starknet_api/src/core.rs +++ b/crates/starknet_api/src/core.rs @@ -13,7 +13,7 @@ use starknet_types_core::hash::{Pedersen, StarkHash as CoreStarkHash}; use crate::crypto::utils::PublicKey; use crate::hash::{PoseidonHash, StarkHash}; use crate::serde_utils::{BytesAsHex, PrefixedBytesAsHex}; -use crate::transaction::{Calldata, ContractAddressSalt}; +use crate::transaction::fields::{Calldata, ContractAddressSalt}; use crate::{impl_from_through_intermediate, StarknetApiError}; /// Felt. @@ -373,7 +373,7 @@ impl Debug for PatriciaKey { #[macro_export] macro_rules! patricia_key { ($s:expr) => { - PatriciaKey::try_from(felt!($s)).unwrap() + PatriciaKey::try_from($crate::felt!($s)).unwrap() }; } @@ -382,7 +382,7 @@ macro_rules! patricia_key { #[macro_export] macro_rules! class_hash { ($s:expr) => { - ClassHash(felt!($s)) + ClassHash($crate::felt!($s)) }; } diff --git a/crates/starknet_api/src/core_test.rs b/crates/starknet_api/src/core_test.rs index 79dee2ca1c..70ce6d8236 100644 --- a/crates/starknet_api/src/core_test.rs +++ b/crates/starknet_api/src/core_test.rs @@ -16,7 +16,7 @@ use crate::core::{ L2_ADDRESS_UPPER_BOUND, }; use crate::hash::StarkHash; -use crate::transaction::{Calldata, ContractAddressSalt}; +use crate::transaction::fields::{Calldata, ContractAddressSalt}; use crate::{class_hash, felt, patricia_key}; #[test] diff --git a/crates/starknet_api/src/executable_transaction.rs b/crates/starknet_api/src/executable_transaction.rs index 3b4b258a54..1f42dceeb6 100644 --- a/crates/starknet_api/src/executable_transaction.rs +++ b/crates/starknet_api/src/executable_transaction.rs @@ -9,7 +9,7 @@ use crate::rpc_transaction::{ RpcInvokeTransactionV3, RpcTransaction, }; -use crate::transaction::{ +use crate::transaction::fields::{ AccountDeploymentData, AllResourceBounds, Calldata, @@ -17,11 +17,11 @@ use crate::transaction::{ PaymasterData, Tip, TransactionHash, - TransactionHasher, TransactionSignature, TransactionVersion, ValidResourceBounds, }; +use crate::transaction::TransactionHasher; use crate::StarknetApiError; macro_rules! implement_inner_tx_getter_calls { diff --git a/crates/starknet_api/src/execution_resources.rs b/crates/starknet_api/src/execution_resources.rs index 6446a52058..4cce5feed8 100644 --- a/crates/starknet_api/src/execution_resources.rs +++ b/crates/starknet_api/src/execution_resources.rs @@ -5,7 +5,7 @@ use starknet_types_core::felt::Felt; use strum_macros::EnumIter; use crate::block::{GasPrice, GasPriceVector, NonzeroGasPrice}; -use crate::transaction::{Fee, Resource}; +use crate::transaction::fields::{Fee, Resource}; #[cfg_attr( any(test, feature = "testing"), diff --git a/crates/starknet_api/src/rpc_transaction.rs b/crates/starknet_api/src/rpc_transaction.rs index d489835db3..7c47f15c9a 100644 --- a/crates/starknet_api/src/rpc_transaction.rs +++ b/crates/starknet_api/src/rpc_transaction.rs @@ -14,22 +14,24 @@ use crate::core::{ }; use crate::data_availability::DataAvailabilityMode; use crate::state::EntryPoint; -use crate::transaction::{ +use crate::transaction::fields::{ AccountDeploymentData, AllResourceBounds, Calldata, ContractAddressSalt, + PaymasterData, + Tip, + TransactionSignature, + ValidResourceBounds, +}; +use crate::transaction::{ DeclareTransaction, DeclareTransactionV3, DeployAccountTransaction, DeployAccountTransactionV3, InvokeTransaction, InvokeTransactionV3, - PaymasterData, - Tip, Transaction, - TransactionSignature, - ValidResourceBounds, }; use crate::StarknetApiError; diff --git a/crates/starknet_api/src/rpc_transaction_test.rs b/crates/starknet_api/src/rpc_transaction_test.rs index 15faf7f2b8..364dfd0dd0 100644 --- a/crates/starknet_api/src/rpc_transaction_test.rs +++ b/crates/starknet_api/src/rpc_transaction_test.rs @@ -17,7 +17,7 @@ use crate::rpc_transaction::{ RpcInvokeTransactionV3, RpcTransaction, }; -use crate::transaction::{ +use crate::transaction::fields::{ AccountDeploymentData, AllResourceBounds, Calldata, diff --git a/crates/starknet_api/src/test_utils/declare.rs b/crates/starknet_api/src/test_utils/declare.rs index 8a6af8af91..d8c2609e80 100644 --- a/crates/starknet_api/src/test_utils/declare.rs +++ b/crates/starknet_api/src/test_utils/declare.rs @@ -2,12 +2,8 @@ use crate::contract_class::ClassInfo; use crate::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce}; use crate::data_availability::DataAvailabilityMode; use crate::executable_transaction::DeclareTransaction as ExecutableDeclareTransaction; -use crate::transaction::{ +use crate::transaction::fields::{ AccountDeploymentData, - DeclareTransaction, - DeclareTransactionV0V1, - DeclareTransactionV2, - DeclareTransactionV3, Fee, PaymasterData, Tip, @@ -16,6 +12,12 @@ use crate::transaction::{ TransactionVersion, ValidResourceBounds, }; +use crate::transaction::{ + DeclareTransaction, + DeclareTransactionV0V1, + DeclareTransactionV2, + DeclareTransactionV3, +}; #[derive(Clone)] pub struct DeclareTxArgs { diff --git a/crates/starknet_api/src/test_utils/deploy_account.rs b/crates/starknet_api/src/test_utils/deploy_account.rs index b503543b17..be7dbee51a 100644 --- a/crates/starknet_api/src/test_utils/deploy_account.rs +++ b/crates/starknet_api/src/test_utils/deploy_account.rs @@ -1,12 +1,9 @@ use crate::core::{calculate_contract_address, ClassHash, ContractAddress, Nonce}; use crate::data_availability::DataAvailabilityMode; use crate::executable_transaction::DeployAccountTransaction as ExecutableDeployAccountTransaction; -use crate::transaction::{ +use crate::transaction::fields::{ Calldata, ContractAddressSalt, - DeployAccountTransaction, - DeployAccountTransactionV1, - DeployAccountTransactionV3, Fee, PaymasterData, Tip, @@ -15,6 +12,11 @@ use crate::transaction::{ TransactionVersion, ValidResourceBounds, }; +use crate::transaction::{ + DeployAccountTransaction, + DeployAccountTransactionV1, + DeployAccountTransactionV3, +}; #[derive(Clone)] pub struct DeployAccountTxArgs { diff --git a/crates/starknet_api/src/test_utils/invoke.rs b/crates/starknet_api/src/test_utils/invoke.rs index d32612e868..0120f9b4cb 100644 --- a/crates/starknet_api/src/test_utils/invoke.rs +++ b/crates/starknet_api/src/test_utils/invoke.rs @@ -2,13 +2,10 @@ use crate::calldata; use crate::core::{ContractAddress, Nonce}; use crate::data_availability::DataAvailabilityMode; use crate::executable_transaction::InvokeTransaction as ExecutableInvokeTransaction; -use crate::transaction::{ +use crate::transaction::fields::{ AccountDeploymentData, Calldata, Fee, - InvokeTransaction, - InvokeTransactionV1, - InvokeTransactionV3, PaymasterData, Tip, TransactionHash, @@ -16,6 +13,7 @@ use crate::transaction::{ TransactionVersion, ValidResourceBounds, }; +use crate::transaction::{InvokeTransaction, InvokeTransactionV1, InvokeTransactionV3}; #[derive(Clone)] pub struct InvokeTxArgs { diff --git a/crates/starknet_api/src/transaction.rs b/crates/starknet_api/src/transaction.rs index 7a88857833..88707e6e37 100644 --- a/crates/starknet_api/src/transaction.rs +++ b/crates/starknet_api/src/transaction.rs @@ -1,12 +1,7 @@ -use std::collections::BTreeMap; -use std::sync::Arc; - -use num_bigint::BigUint; -use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use serde::{Deserialize, Serialize}; use starknet_types_core::felt::Felt; -use strum_macros::EnumIter; -use crate::block::{BlockHash, BlockNumber, GasPrice, NonzeroGasPrice}; +use crate::block::{BlockHash, BlockNumber}; use crate::core::{ ChainId, ClassHash, @@ -17,9 +12,19 @@ use crate::core::{ Nonce, }; use crate::data_availability::DataAvailabilityMode; -use crate::execution_resources::{ExecutionResources, GasAmount}; -use crate::hash::StarkHash; -use crate::serde_utils::PrefixedBytesAsHex; +use crate::execution_resources::ExecutionResources; +use crate::transaction::fields::{ + AccountDeploymentData, + Calldata, + ContractAddressSalt, + Fee, + PaymasterData, + Tip, + TransactionHash, + TransactionSignature, + TransactionVersion, + ValidResourceBounds, +}; use crate::transaction_hash::{ get_declare_transaction_v0_hash, get_declare_transaction_v1_hash, @@ -39,9 +44,7 @@ use crate::StarknetApiError; #[path = "transaction_test.rs"] mod transaction_test; -// TODO(Noa, 14/11/2023): Replace QUERY_VERSION_BASE_BIT with a lazy calculation. -// pub static QUERY_VERSION_BASE: Lazy = ... -pub const QUERY_VERSION_BASE_BIT: u32 = 128; +pub mod fields; pub trait TransactionHasher { fn calculate_transaction_hash( @@ -105,15 +108,6 @@ impl Transaction { } } -#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)] -pub struct TransactionOptions { - /// Transaction that shouldn't be broadcasted to StarkNet. For example, users that want to - /// test the execution result of a transaction without the risk of it being rebroadcasted (the - /// signature will be different while the execution remain the same). Using this flag will - /// modify the transaction version by setting the 128-th bit to 1. - pub only_query: bool, -} - macro_rules! implement_v3_tx_getters { ($(($field:ident, $field_type:ty)),*) => { $(pub fn $field(&self) -> $field_type { @@ -724,180 +718,6 @@ pub struct RevertedTransactionExecutionStatus { pub revert_reason: String, } -/// A fee. -#[cfg_attr(any(test, feature = "testing"), derive(derive_more::Add, derive_more::Deref))] -#[derive( - Debug, - Copy, - Clone, - Default, - derive_more::Display, - Eq, - PartialEq, - Hash, - Deserialize, - Serialize, - PartialOrd, - Ord, -)] -#[serde(from = "PrefixedBytesAsHex<16_usize>", into = "PrefixedBytesAsHex<16_usize>")] -pub struct Fee(pub u128); - -impl Fee { - pub fn checked_add(self, rhs: Fee) -> Option { - self.0.checked_add(rhs.0).map(Fee) - } - - pub const fn saturating_add(self, rhs: Self) -> Self { - Self(self.0.saturating_add(rhs.0)) - } - - pub fn checked_div_ceil(self, rhs: NonzeroGasPrice) -> Option { - self.checked_div(rhs).map(|value| { - if value - .checked_mul(rhs.into()) - .expect("Multiplying by denominator of floor division cannot overflow.") - < self - { - (value.0 + 1).into() - } else { - value - } - }) - } - - pub fn checked_div(self, rhs: NonzeroGasPrice) -> Option { - match u64::try_from(self.0 / rhs.get().0) { - Ok(value) => Some(value.into()), - Err(_) => None, - } - } - - pub fn saturating_div(self, rhs: NonzeroGasPrice) -> GasAmount { - self.checked_div(rhs).unwrap_or(GasAmount::MAX) - } -} - -impl From> for Fee { - fn from(value: PrefixedBytesAsHex<16_usize>) -> Self { - Self(u128::from_be_bytes(value.0)) - } -} - -impl From for PrefixedBytesAsHex<16_usize> { - fn from(fee: Fee) -> Self { - Self(fee.0.to_be_bytes()) - } -} - -impl From for Felt { - fn from(fee: Fee) -> Self { - Self::from(fee.0) - } -} - -/// The hash of a [Transaction](`crate::transaction::Transaction`). -#[derive( - Debug, - Default, - Copy, - Clone, - Eq, - PartialEq, - Hash, - Deserialize, - Serialize, - PartialOrd, - Ord, - derive_more::Deref, -)] -pub struct TransactionHash(pub StarkHash); - -impl std::fmt::Display for TransactionHash { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.0) - } -} - -/// A contract address salt. -#[derive( - Debug, Copy, Clone, Default, Eq, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord, -)] -pub struct ContractAddressSalt(pub StarkHash); - -/// A transaction signature. -#[derive(Debug, Clone, Default, Eq, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord)] -pub struct TransactionSignature(pub Vec); - -/// A transaction version. -#[derive( - Debug, - Copy, - Clone, - Default, - Eq, - PartialEq, - Hash, - Deserialize, - Serialize, - PartialOrd, - Ord, - derive_more::Deref, -)] -pub struct TransactionVersion(pub Felt); - -impl TransactionVersion { - /// [TransactionVersion] constant that's equal to 0. - pub const ZERO: Self = { Self(Felt::ZERO) }; - - /// [TransactionVersion] constant that's equal to 1. - pub const ONE: Self = { Self(Felt::ONE) }; - - /// [TransactionVersion] constant that's equal to 2. - pub const TWO: Self = { Self(Felt::TWO) }; - - /// [TransactionVersion] constant that's equal to 3. - pub const THREE: Self = { Self(Felt::THREE) }; -} - -// TODO: TransactionVersion and SignedTransactionVersion should probably be separate types. -// Returns the transaction version taking into account the transaction options. -pub fn signed_tx_version_from_tx( - tx: &Transaction, - transaction_options: &TransactionOptions, -) -> TransactionVersion { - signed_tx_version(&tx.version(), transaction_options) -} - -pub fn signed_tx_version( - tx_version: &TransactionVersion, - transaction_options: &TransactionOptions, -) -> TransactionVersion { - // If only_query is true, set the 128-th bit. - let query_only_bit = Felt::TWO.pow(QUERY_VERSION_BASE_BIT); - assert_eq!( - tx_version.0.to_biguint() & query_only_bit.to_biguint(), - BigUint::from(0_u8), - "Requested signed tx version with version that already has query bit set: {tx_version:?}." - ); - if transaction_options.only_query { - TransactionVersion(tx_version.0 + query_only_bit) - } else { - *tx_version - } -} - -/// The calldata of a transaction. -#[derive(Debug, Clone, Default, Eq, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord)] -pub struct Calldata(pub Arc>); - -#[macro_export] -macro_rules! calldata { - ( $( $x:expr ),* ) => { - $crate::transaction::Calldata(vec![$($x),*].into()) - }; -} - /// An L1 to L2 message. #[derive(Debug, Default, Clone, Eq, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord)] pub struct MessageToL2 { @@ -956,302 +776,3 @@ pub struct TransactionOffsetInBlock(pub usize); Debug, Default, Copy, Clone, Eq, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord, )] pub struct EventIndexInTransactionOutput(pub usize); - -/// Transaction fee tip. -#[derive( - Clone, - Copy, - Debug, - Default, - Deserialize, - Eq, - Hash, - Ord, - PartialEq, - PartialOrd, - Serialize, - derive_more::Deref, - derive_more::Display, -)] -#[serde(from = "PrefixedBytesAsHex<8_usize>", into = "PrefixedBytesAsHex<8_usize>")] -pub struct Tip(pub u64); - -impl From> for Tip { - fn from(value: PrefixedBytesAsHex<8_usize>) -> Self { - Self(u64::from_be_bytes(value.0)) - } -} - -impl From for PrefixedBytesAsHex<8_usize> { - fn from(tip: Tip) -> Self { - Self(tip.0.to_be_bytes()) - } -} - -impl From for Felt { - fn from(tip: Tip) -> Self { - Self::from(tip.0) - } -} - -/// Execution resource. -#[derive( - Clone, - Copy, - Debug, - Deserialize, - derive_more::Display, - EnumIter, - Eq, - Hash, - Ord, - PartialEq, - PartialOrd, - Serialize, -)] -pub enum Resource { - #[serde(rename = "L1_GAS")] - L1Gas, - #[serde(rename = "L2_GAS")] - L2Gas, - #[serde(rename = "L1_DATA")] - L1DataGas, -} - -impl Resource { - pub fn to_hex(&self) -> &'static str { - match self { - Resource::L1Gas => "0x00000000000000000000000000000000000000000000000000004c315f474153", - Resource::L2Gas => "0x00000000000000000000000000000000000000000000000000004c325f474153", - Resource::L1DataGas => { - "0x000000000000000000000000000000000000000000000000004c315f44415441" - } - } - } -} - -/// Fee bounds for an execution resource. -/// TODO(Yael): add types ResourceAmount and ResourcePrice and use them instead of u64 and u128. -#[derive( - Clone, Copy, Debug, Default, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize, -)] -// TODO(Nimrod): Consider renaming this struct. -pub struct ResourceBounds { - // Specifies the maximum amount of each resource allowed for usage during the execution. - #[serde(serialize_with = "gas_amount_to_hex", deserialize_with = "hex_to_gas_amount")] - pub max_amount: GasAmount, - - // Specifies the maximum price the user is willing to pay for each resource unit. - #[serde(serialize_with = "gas_price_to_hex", deserialize_with = "hex_to_gas_price")] - pub max_price_per_unit: GasPrice, -} - -impl ResourceBounds { - /// Returns true iff both the max amount and the max amount per unit is zero. - pub fn is_zero(&self) -> bool { - self.max_amount == GasAmount(0) && self.max_price_per_unit == GasPrice(0) - } -} - -fn gas_amount_to_hex(value: &GasAmount, serializer: S) -> Result -where - S: Serializer, -{ - serializer.serialize_str(&format!("0x{:x}", value.0)) -} - -fn hex_to_gas_amount<'de, D>(deserializer: D) -> Result -where - D: Deserializer<'de>, -{ - let s: String = Deserialize::deserialize(deserializer)?; - Ok(GasAmount( - u64::from_str_radix(s.trim_start_matches("0x"), 16).map_err(serde::de::Error::custom)?, - )) -} - -fn gas_price_to_hex(value: &GasPrice, serializer: S) -> Result -where - S: Serializer, -{ - serializer.serialize_str(&format!("0x{:x}", value.0)) -} - -fn hex_to_gas_price<'de, D>(deserializer: D) -> Result -where - D: Deserializer<'de>, -{ - let s: String = Deserialize::deserialize(deserializer)?; - Ok(GasPrice( - u128::from_str_radix(s.trim_start_matches("0x"), 16).map_err(serde::de::Error::custom)?, - )) -} - -#[derive(Debug, PartialEq)] -pub enum GasVectorComputationMode { - All, - NoL2Gas, -} - -/// A mapping from execution resources to their corresponding fee bounds.. -#[derive(Clone, Debug, Default, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] -// TODO(Nimrod): Remove this struct definition. -pub struct DeprecatedResourceBoundsMapping(pub BTreeMap); - -#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] -pub enum ValidResourceBounds { - L1Gas(ResourceBounds), // Pre 0.13.3. Only L1 gas. L2 bounds are signed but never used. - AllResources(AllResourceBounds), -} - -impl ValidResourceBounds { - pub fn get_l1_bounds(&self) -> ResourceBounds { - match self { - Self::L1Gas(l1_bounds) => *l1_bounds, - Self::AllResources(AllResourceBounds { l1_gas, .. }) => *l1_gas, - } - } - - pub fn get_l2_bounds(&self) -> ResourceBounds { - match self { - Self::L1Gas(_) => ResourceBounds::default(), - Self::AllResources(AllResourceBounds { l2_gas, .. }) => *l2_gas, - } - } - - /// Returns the maximum possible fee that can be charged for the transaction. - /// The computation is saturating, meaning that if the result is larger than the maximum - /// possible fee, the maximum possible fee is returned. - pub fn max_possible_fee(&self) -> Fee { - match self { - ValidResourceBounds::L1Gas(l1_bounds) => { - l1_bounds.max_amount.saturating_mul(l1_bounds.max_price_per_unit) - } - ValidResourceBounds::AllResources(AllResourceBounds { - l1_gas, - l2_gas, - l1_data_gas, - }) => l1_gas - .max_amount - .saturating_mul(l1_gas.max_price_per_unit) - .saturating_add(l2_gas.max_amount.saturating_mul(l2_gas.max_price_per_unit)) - .saturating_add( - l1_data_gas.max_amount.saturating_mul(l1_data_gas.max_price_per_unit), - ), - } - } - - pub fn get_gas_vector_computation_mode(&self) -> GasVectorComputationMode { - match self { - Self::AllResources(_) => GasVectorComputationMode::All, - Self::L1Gas(_) => GasVectorComputationMode::NoL2Gas, - } - } - - // TODO(Nimrod): Default testing bounds should probably be AllResourceBounds variant. - #[cfg(any(feature = "testing", test))] - pub fn create_for_testing() -> Self { - Self::L1Gas(ResourceBounds { max_amount: GasAmount(0), max_price_per_unit: GasPrice(1) }) - } -} - -#[derive( - Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Hash, Ord, PartialOrd, Serialize, -)] -pub struct AllResourceBounds { - pub l1_gas: ResourceBounds, - pub l2_gas: ResourceBounds, - pub l1_data_gas: ResourceBounds, -} - -impl AllResourceBounds { - pub fn get_bound(&self, resource: Resource) -> ResourceBounds { - match resource { - Resource::L1Gas => self.l1_gas, - Resource::L2Gas => self.l2_gas, - Resource::L1DataGas => self.l1_data_gas, - } - } -} - -/// Deserializes raw resource bounds, given as map, into valid resource bounds. -// TODO(Nimrod): Figure out how to get same result with adding #[derive(Deserialize)]. -impl<'de> Deserialize<'de> for ValidResourceBounds { - fn deserialize(de: D) -> Result - where - D: Deserializer<'de>, - { - let raw_resource_bounds: BTreeMap = Deserialize::deserialize(de)?; - ValidResourceBounds::try_from(DeprecatedResourceBoundsMapping(raw_resource_bounds)) - .map_err(serde::de::Error::custom) - } -} - -/// Serializes ValidResourceBounds as map for Backwards compatibility. -// TODO(Nimrod): Figure out how to get same result with adding #[derive(Serialize)]. -impl Serialize for ValidResourceBounds { - fn serialize(&self, s: S) -> Result - where - S: Serializer, - { - let map = match self { - ValidResourceBounds::L1Gas(l1_gas) => BTreeMap::from([ - (Resource::L1Gas, *l1_gas), - (Resource::L2Gas, ResourceBounds::default()), - ]), - ValidResourceBounds::AllResources(AllResourceBounds { - l1_gas, - l2_gas, - l1_data_gas, - }) => BTreeMap::from([ - (Resource::L1Gas, *l1_gas), - (Resource::L2Gas, *l2_gas), - (Resource::L1DataGas, *l1_data_gas), - ]), - }; - DeprecatedResourceBoundsMapping(map).serialize(s) - } -} - -impl TryFrom for ValidResourceBounds { - type Error = StarknetApiError; - fn try_from( - resource_bounds_mapping: DeprecatedResourceBoundsMapping, - ) -> Result { - if let (Some(l1_bounds), Some(l2_bounds)) = ( - resource_bounds_mapping.0.get(&Resource::L1Gas), - resource_bounds_mapping.0.get(&Resource::L2Gas), - ) { - match resource_bounds_mapping.0.get(&Resource::L1DataGas) { - Some(data_bounds) => Ok(Self::AllResources(AllResourceBounds { - l1_gas: *l1_bounds, - l1_data_gas: *data_bounds, - l2_gas: *l2_bounds, - })), - None => { - if l2_bounds.is_zero() { - Ok(Self::L1Gas(*l1_bounds)) - } else { - Err(StarknetApiError::InvalidResourceMappingInitializer(format!( - "Missing data gas bounds but L2 gas bound is not zero: \ - {resource_bounds_mapping:?}", - ))) - } - } - } - } else { - Err(StarknetApiError::InvalidResourceMappingInitializer(format!( - "{resource_bounds_mapping:?}", - ))) - } - } -} - -/// Paymaster-related data. -#[derive(Clone, Debug, Default, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] -pub struct PaymasterData(pub Vec); - -/// If nonempty, will contain the required data for deploying and initializing an account contract: -/// its class hash, address salt and constructor calldata. -#[derive(Debug, Clone, Default, Eq, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord)] -pub struct AccountDeploymentData(pub Vec); diff --git a/crates/starknet_api/src/transaction/fields.rs b/crates/starknet_api/src/transaction/fields.rs new file mode 100644 index 0000000000..609f2939d7 --- /dev/null +++ b/crates/starknet_api/src/transaction/fields.rs @@ -0,0 +1,500 @@ +use std::collections::BTreeMap; +use std::sync::Arc; + +use num_bigint::BigUint; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use starknet_types_core::felt::Felt; +use strum_macros::EnumIter; + +use super::Transaction; +use crate::block::{GasPrice, NonzeroGasPrice}; +use crate::execution_resources::GasAmount; +use crate::hash::StarkHash; +use crate::serde_utils::PrefixedBytesAsHex; +use crate::StarknetApiError; + +// TODO(Noa, 14/11/2023): Replace QUERY_VERSION_BASE_BIT with a lazy calculation. +// pub static QUERY_VERSION_BASE: Lazy = ... +pub const QUERY_VERSION_BASE_BIT: u32 = 128; + +#[derive(Copy, Clone, Debug, Eq, PartialEq, Default)] +pub struct TransactionOptions { + /// Transaction that shouldn't be broadcasted to StarkNet. For example, users that want to + /// test the execution result of a transaction without the risk of it being rebroadcasted (the + /// signature will be different while the execution remain the same). Using this flag will + /// modify the transaction version by setting the 128-th bit to 1. + pub only_query: bool, +} + +/// A fee. +#[cfg_attr(any(test, feature = "testing"), derive(derive_more::Add, derive_more::Deref))] +#[derive( + Debug, + Copy, + Clone, + Default, + derive_more::Display, + Eq, + PartialEq, + Hash, + Deserialize, + Serialize, + PartialOrd, + Ord, +)] +#[serde(from = "PrefixedBytesAsHex<16_usize>", into = "PrefixedBytesAsHex<16_usize>")] +pub struct Fee(pub u128); + +impl Fee { + pub fn checked_add(self, rhs: Fee) -> Option { + self.0.checked_add(rhs.0).map(Fee) + } + + pub const fn saturating_add(self, rhs: Self) -> Self { + Self(self.0.saturating_add(rhs.0)) + } + + pub fn checked_div_ceil(self, rhs: NonzeroGasPrice) -> Option { + self.checked_div(rhs).map(|value| { + if value + .checked_mul(rhs.into()) + .expect("Multiplying by denominator of floor division cannot overflow.") + < self + { + (value.0 + 1).into() + } else { + value + } + }) + } + + pub fn checked_div(self, rhs: NonzeroGasPrice) -> Option { + match u64::try_from(self.0 / rhs.get().0) { + Ok(value) => Some(value.into()), + Err(_) => None, + } + } + + pub fn saturating_div(self, rhs: NonzeroGasPrice) -> GasAmount { + self.checked_div(rhs).unwrap_or(GasAmount::MAX) + } +} + +impl From> for Fee { + fn from(value: PrefixedBytesAsHex<16_usize>) -> Self { + Self(u128::from_be_bytes(value.0)) + } +} + +impl From for PrefixedBytesAsHex<16_usize> { + fn from(fee: Fee) -> Self { + Self(fee.0.to_be_bytes()) + } +} + +impl From for Felt { + fn from(fee: Fee) -> Self { + Self::from(fee.0) + } +} + +/// The hash of a [Transaction](`crate::transaction::Transaction`). +#[derive( + Debug, + Default, + Copy, + Clone, + Eq, + PartialEq, + Hash, + Deserialize, + Serialize, + PartialOrd, + Ord, + derive_more::Deref, +)] +pub struct TransactionHash(pub StarkHash); + +impl std::fmt::Display for TransactionHash { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{}", self.0) + } +} + +/// A contract address salt. +#[derive( + Debug, Copy, Clone, Default, Eq, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord, +)] +pub struct ContractAddressSalt(pub StarkHash); + +/// A transaction signature. +#[derive(Debug, Clone, Default, Eq, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord)] +pub struct TransactionSignature(pub Vec); + +/// A transaction version. +#[derive( + Debug, + Copy, + Clone, + Default, + Eq, + PartialEq, + Hash, + Deserialize, + Serialize, + PartialOrd, + Ord, + derive_more::Deref, +)] +pub struct TransactionVersion(pub Felt); + +impl TransactionVersion { + /// [TransactionVersion] constant that's equal to 0. + pub const ZERO: Self = { Self(Felt::ZERO) }; + + /// [TransactionVersion] constant that's equal to 1. + pub const ONE: Self = { Self(Felt::ONE) }; + + /// [TransactionVersion] constant that's equal to 2. + pub const TWO: Self = { Self(Felt::TWO) }; + + /// [TransactionVersion] constant that's equal to 3. + pub const THREE: Self = { Self(Felt::THREE) }; +} + +// TODO: TransactionVersion and SignedTransactionVersion should probably be separate types. +// Returns the transaction version taking into account the transaction options. +pub fn signed_tx_version_from_tx( + tx: &Transaction, + transaction_options: &TransactionOptions, +) -> TransactionVersion { + signed_tx_version(&tx.version(), transaction_options) +} + +pub fn signed_tx_version( + tx_version: &TransactionVersion, + transaction_options: &TransactionOptions, +) -> TransactionVersion { + // If only_query is true, set the 128-th bit. + let query_only_bit = Felt::TWO.pow(QUERY_VERSION_BASE_BIT); + assert_eq!( + tx_version.0.to_biguint() & query_only_bit.to_biguint(), + BigUint::from(0_u8), + "Requested signed tx version with version that already has query bit set: {tx_version:?}." + ); + if transaction_options.only_query { + TransactionVersion(tx_version.0 + query_only_bit) + } else { + *tx_version + } +} + +/// The calldata of a transaction. +#[derive(Debug, Clone, Default, Eq, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord)] +pub struct Calldata(pub Arc>); + +#[macro_export] +macro_rules! calldata { + ( $( $x:expr ),* ) => { + $crate::transaction::fields::Calldata(vec![$($x),*].into()) + }; +} + +/// Transaction fee tip. +#[derive( + Clone, + Copy, + Debug, + Default, + Deserialize, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + Serialize, + derive_more::Deref, + derive_more::Display, +)] +#[serde(from = "PrefixedBytesAsHex<8_usize>", into = "PrefixedBytesAsHex<8_usize>")] +pub struct Tip(pub u64); + +impl From> for Tip { + fn from(value: PrefixedBytesAsHex<8_usize>) -> Self { + Self(u64::from_be_bytes(value.0)) + } +} + +impl From for PrefixedBytesAsHex<8_usize> { + fn from(tip: Tip) -> Self { + Self(tip.0.to_be_bytes()) + } +} + +impl From for Felt { + fn from(tip: Tip) -> Self { + Self::from(tip.0) + } +} + +/// Execution resource. +#[derive( + Clone, + Copy, + Debug, + Deserialize, + derive_more::Display, + EnumIter, + Eq, + Hash, + Ord, + PartialEq, + PartialOrd, + Serialize, +)] +pub enum Resource { + #[serde(rename = "L1_GAS")] + L1Gas, + #[serde(rename = "L2_GAS")] + L2Gas, + #[serde(rename = "L1_DATA")] + L1DataGas, +} + +impl Resource { + pub fn to_hex(&self) -> &'static str { + match self { + Resource::L1Gas => "0x00000000000000000000000000000000000000000000000000004c315f474153", + Resource::L2Gas => "0x00000000000000000000000000000000000000000000000000004c325f474153", + Resource::L1DataGas => { + "0x000000000000000000000000000000000000000000000000004c315f44415441" + } + } + } +} + +/// Fee bounds for an execution resource. +/// TODO(Yael): add types ResourceAmount and ResourcePrice and use them instead of u64 and u128. +#[derive( + Clone, Copy, Debug, Default, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize, +)] +// TODO(Nimrod): Consider renaming this struct. +pub struct ResourceBounds { + // Specifies the maximum amount of each resource allowed for usage during the execution. + #[serde(serialize_with = "gas_amount_to_hex", deserialize_with = "hex_to_gas_amount")] + pub max_amount: GasAmount, + + // Specifies the maximum price the user is willing to pay for each resource unit. + #[serde(serialize_with = "gas_price_to_hex", deserialize_with = "hex_to_gas_price")] + pub max_price_per_unit: GasPrice, +} + +impl ResourceBounds { + /// Returns true iff both the max amount and the max amount per unit is zero. + pub fn is_zero(&self) -> bool { + self.max_amount == GasAmount(0) && self.max_price_per_unit == GasPrice(0) + } +} + +fn gas_amount_to_hex(value: &GasAmount, serializer: S) -> Result +where + S: Serializer, +{ + serializer.serialize_str(&format!("0x{:x}", value.0)) +} + +fn hex_to_gas_amount<'de, D>(deserializer: D) -> Result +where + D: Deserializer<'de>, +{ + let s: String = Deserialize::deserialize(deserializer)?; + Ok(GasAmount( + u64::from_str_radix(s.trim_start_matches("0x"), 16).map_err(serde::de::Error::custom)?, + )) +} + +fn gas_price_to_hex(value: &GasPrice, serializer: S) -> Result +where + S: Serializer, +{ + serializer.serialize_str(&format!("0x{:x}", value.0)) +} + +fn hex_to_gas_price<'de, D>(deserializer: D) -> Result +where + D: Deserializer<'de>, +{ + let s: String = Deserialize::deserialize(deserializer)?; + Ok(GasPrice( + u128::from_str_radix(s.trim_start_matches("0x"), 16).map_err(serde::de::Error::custom)?, + )) +} + +#[derive(Debug, PartialEq)] +pub enum GasVectorComputationMode { + All, + NoL2Gas, +} + +/// A mapping from execution resources to their corresponding fee bounds.. +#[derive(Clone, Debug, Default, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] +// TODO(Nimrod): Remove this struct definition. +pub struct DeprecatedResourceBoundsMapping(pub BTreeMap); + +#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] +pub enum ValidResourceBounds { + L1Gas(ResourceBounds), // Pre 0.13.3. Only L1 gas. L2 bounds are signed but never used. + AllResources(AllResourceBounds), +} + +impl ValidResourceBounds { + pub fn get_l1_bounds(&self) -> ResourceBounds { + match self { + Self::L1Gas(l1_bounds) => *l1_bounds, + Self::AllResources(AllResourceBounds { l1_gas, .. }) => *l1_gas, + } + } + + pub fn get_l2_bounds(&self) -> ResourceBounds { + match self { + Self::L1Gas(_) => ResourceBounds::default(), + Self::AllResources(AllResourceBounds { l2_gas, .. }) => *l2_gas, + } + } + + /// Returns the maximum possible fee that can be charged for the transaction. + /// The computation is saturating, meaning that if the result is larger than the maximum + /// possible fee, the maximum possible fee is returned. + pub fn max_possible_fee(&self) -> Fee { + match self { + ValidResourceBounds::L1Gas(l1_bounds) => { + l1_bounds.max_amount.saturating_mul(l1_bounds.max_price_per_unit) + } + ValidResourceBounds::AllResources(AllResourceBounds { + l1_gas, + l2_gas, + l1_data_gas, + }) => l1_gas + .max_amount + .saturating_mul(l1_gas.max_price_per_unit) + .saturating_add(l2_gas.max_amount.saturating_mul(l2_gas.max_price_per_unit)) + .saturating_add( + l1_data_gas.max_amount.saturating_mul(l1_data_gas.max_price_per_unit), + ), + } + } + + pub fn get_gas_vector_computation_mode(&self) -> GasVectorComputationMode { + match self { + Self::AllResources(_) => GasVectorComputationMode::All, + Self::L1Gas(_) => GasVectorComputationMode::NoL2Gas, + } + } + + // TODO(Nimrod): Default testing bounds should probably be AllResourceBounds variant. + #[cfg(any(feature = "testing", test))] + pub fn create_for_testing() -> Self { + Self::L1Gas(ResourceBounds { max_amount: GasAmount(0), max_price_per_unit: GasPrice(1) }) + } +} + +#[derive( + Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq, Hash, Ord, PartialOrd, Serialize, +)] +pub struct AllResourceBounds { + pub l1_gas: ResourceBounds, + pub l2_gas: ResourceBounds, + pub l1_data_gas: ResourceBounds, +} + +impl AllResourceBounds { + pub fn get_bound(&self, resource: Resource) -> ResourceBounds { + match resource { + Resource::L1Gas => self.l1_gas, + Resource::L2Gas => self.l2_gas, + Resource::L1DataGas => self.l1_data_gas, + } + } +} + +/// Deserializes raw resource bounds, given as map, into valid resource bounds. +// TODO(Nimrod): Figure out how to get same result with adding #[derive(Deserialize)]. +impl<'de> Deserialize<'de> for ValidResourceBounds { + fn deserialize(de: D) -> Result + where + D: Deserializer<'de>, + { + let raw_resource_bounds: BTreeMap = Deserialize::deserialize(de)?; + ValidResourceBounds::try_from(DeprecatedResourceBoundsMapping(raw_resource_bounds)) + .map_err(serde::de::Error::custom) + } +} + +/// Serializes ValidResourceBounds as map for Backwards compatibility. +// TODO(Nimrod): Figure out how to get same result with adding #[derive(Serialize)]. +impl Serialize for ValidResourceBounds { + fn serialize(&self, s: S) -> Result + where + S: Serializer, + { + let map = match self { + ValidResourceBounds::L1Gas(l1_gas) => BTreeMap::from([ + (Resource::L1Gas, *l1_gas), + (Resource::L2Gas, ResourceBounds::default()), + ]), + ValidResourceBounds::AllResources(AllResourceBounds { + l1_gas, + l2_gas, + l1_data_gas, + }) => BTreeMap::from([ + (Resource::L1Gas, *l1_gas), + (Resource::L2Gas, *l2_gas), + (Resource::L1DataGas, *l1_data_gas), + ]), + }; + DeprecatedResourceBoundsMapping(map).serialize(s) + } +} + +impl TryFrom for ValidResourceBounds { + type Error = StarknetApiError; + fn try_from( + resource_bounds_mapping: DeprecatedResourceBoundsMapping, + ) -> Result { + if let (Some(l1_bounds), Some(l2_bounds)) = ( + resource_bounds_mapping.0.get(&Resource::L1Gas), + resource_bounds_mapping.0.get(&Resource::L2Gas), + ) { + match resource_bounds_mapping.0.get(&Resource::L1DataGas) { + Some(data_bounds) => Ok(Self::AllResources(AllResourceBounds { + l1_gas: *l1_bounds, + l1_data_gas: *data_bounds, + l2_gas: *l2_bounds, + })), + None => { + if l2_bounds.is_zero() { + Ok(Self::L1Gas(*l1_bounds)) + } else { + Err(StarknetApiError::InvalidResourceMappingInitializer(format!( + "Missing data gas bounds but L2 gas bound is not zero: \ + {resource_bounds_mapping:?}", + ))) + } + } + } + } else { + Err(StarknetApiError::InvalidResourceMappingInitializer(format!( + "{resource_bounds_mapping:?}", + ))) + } + } +} + +/// Paymaster-related data. +#[derive(Clone, Debug, Default, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] +pub struct PaymasterData(pub Vec); + +/// If nonempty, will contain the required data for deploying and initializing an account contract: +/// its class hash, address salt and constructor calldata. +#[derive(Debug, Clone, Default, Eq, PartialEq, Hash, Deserialize, Serialize, PartialOrd, Ord)] +pub struct AccountDeploymentData(pub Vec); diff --git a/crates/starknet_api/src/transaction_hash.rs b/crates/starknet_api/src/transaction_hash.rs index b6b0d98c6f..ae02ed7b76 100644 --- a/crates/starknet_api/src/transaction_hash.rs +++ b/crates/starknet_api/src/transaction_hash.rs @@ -6,8 +6,16 @@ use crate::block::BlockNumber; use crate::core::{ascii_as_felt, calculate_contract_address, ChainId, ContractAddress}; use crate::crypto::utils::HashChain; use crate::data_availability::DataAvailabilityMode; -use crate::transaction::{ +use crate::transaction::fields::{ signed_tx_version_from_tx, + ResourceBounds, + Tip, + TransactionHash, + TransactionOptions, + TransactionVersion, + ValidResourceBounds, +}; +use crate::transaction::{ DeclareTransaction, DeclareTransactionV0V1, DeclareTransactionV2, @@ -21,13 +29,7 @@ use crate::transaction::{ InvokeTransactionV1, InvokeTransactionV3, L1HandlerTransaction, - ResourceBounds, - Tip, Transaction, - TransactionHash, - TransactionOptions, - TransactionVersion, - ValidResourceBounds, }; use crate::StarknetApiError; diff --git a/crates/starknet_api/src/transaction_hash_test.rs b/crates/starknet_api/src/transaction_hash_test.rs index 1abec8c3b0..438ce87935 100644 --- a/crates/starknet_api/src/transaction_hash_test.rs +++ b/crates/starknet_api/src/transaction_hash_test.rs @@ -7,7 +7,8 @@ use super::{get_transaction_hash, validate_transaction_hash, CONSTRUCTOR_ENTRY_P use crate::block::BlockNumber; use crate::core::ChainId; use crate::test_utils::read_json_file; -use crate::transaction::{Transaction, TransactionHash, TransactionOptions}; +use crate::transaction::fields::{TransactionHash, TransactionOptions}; +use crate::transaction::Transaction; #[test] fn test_constructor_selector() { diff --git a/crates/starknet_client/src/reader/mod.rs b/crates/starknet_client/src/reader/mod.rs index 8120205f69..982e681cad 100644 --- a/crates/starknet_client/src/reader/mod.rs +++ b/crates/starknet_client/src/reader/mod.rs @@ -17,7 +17,7 @@ use serde::{Deserialize, Serialize}; use starknet_api::block::BlockNumber; use starknet_api::core::{ClassHash, SequencerPublicKey}; use starknet_api::deprecated_contract_class::ContractClass as DeprecatedContractClass; -use starknet_api::transaction::TransactionHash; +use starknet_api::transaction::fields::TransactionHash; use starknet_api::StarknetApiError; use starknet_types_core::felt::Felt; use tracing::{debug, error, instrument}; diff --git a/crates/starknet_client/src/reader/objects/block.rs b/crates/starknet_client/src/reader/objects/block.rs index da6700e4e5..982852dabc 100644 --- a/crates/starknet_client/src/reader/objects/block.rs +++ b/crates/starknet_client/src/reader/objects/block.rs @@ -23,9 +23,10 @@ use starknet_api::core::{ TransactionCommitment, }; use starknet_api::data_availability::L1DataAvailabilityMode; +use starknet_api::transaction::fields::TransactionHash; +use starknet_api::transaction::TransactionOffsetInBlock; #[cfg(doc)] use starknet_api::transaction::TransactionOutput as starknet_api_transaction_output; -use starknet_api::transaction::{TransactionHash, TransactionOffsetInBlock}; use starknet_types_core::felt::Felt; use crate::reader::objects::transaction::{ diff --git a/crates/starknet_client/src/reader/objects/block_test.rs b/crates/starknet_client/src/reader/objects/block_test.rs index b3945e5fe7..7438edbaef 100644 --- a/crates/starknet_client/src/reader/objects/block_test.rs +++ b/crates/starknet_client/src/reader/objects/block_test.rs @@ -5,7 +5,8 @@ use starknet_api::block::BlockHash; use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce, PatriciaKey}; use starknet_api::hash::StarkHash; use starknet_api::state::StorageKey; -use starknet_api::transaction::{TransactionHash, TransactionOffsetInBlock}; +use starknet_api::transaction::fields::TransactionHash; +use starknet_api::transaction::TransactionOffsetInBlock; use starknet_api::{felt, patricia_key}; use super::{Block, GlobalRoot, TransactionReceiptsError}; diff --git a/crates/starknet_client/src/reader/objects/test_utils.rs b/crates/starknet_client/src/reader/objects/test_utils.rs index 130aa84d3b..1002eeccb1 100644 --- a/crates/starknet_client/src/reader/objects/test_utils.rs +++ b/crates/starknet_client/src/reader/objects/test_utils.rs @@ -13,22 +13,19 @@ use starknet_api::core::{ use starknet_api::execution_resources::GasVector; use starknet_api::hash::StarkHash; use starknet_api::state::EntryPoint; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ AccountDeploymentData, Calldata, ContractAddressSalt, - Event, Fee, - L1ToL2Payload, - L2ToL1Payload, PaymasterData, Tip, TransactionHash, - TransactionOffsetInBlock, TransactionSignature, TransactionVersion, ValidResourceBounds, }; +use starknet_api::transaction::{Event, L1ToL2Payload, L2ToL1Payload, TransactionOffsetInBlock}; use starknet_types_core::felt::Felt; use crate::reader::objects::state::ContractClass; diff --git a/crates/starknet_client/src/reader/objects/transaction.rs b/crates/starknet_client/src/reader/objects/transaction.rs index aa1cdd5f37..7cbf6b8919 100644 --- a/crates/starknet_client/src/reader/objects/transaction.rs +++ b/crates/starknet_client/src/reader/objects/transaction.rs @@ -16,30 +16,32 @@ use starknet_api::core::{ }; use starknet_api::execution_resources::{GasAmount, GasVector}; use starknet_api::hash::StarkHash; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ AccountDeploymentData, Calldata, ContractAddressSalt, + Fee, + PaymasterData, + Tip, + TransactionHash, + TransactionSignature, + TransactionVersion, + ValidResourceBounds, +}; +use starknet_api::transaction::{ DeclareTransactionOutput, DeployAccountTransactionOutput, DeployTransactionOutput, Event, - Fee, InvokeTransactionOutput, L1HandlerTransactionOutput, L1ToL2Payload, L2ToL1Payload, MessageToL1, - PaymasterData, RevertedTransactionExecutionStatus as SnApiRevertedTransactionExecutionStatus, - Tip, TransactionExecutionStatus as SnApiTransactionExecutionStatus, - TransactionHash, TransactionOffsetInBlock, TransactionOutput, - TransactionSignature, - TransactionVersion, - ValidResourceBounds, }; use strum_macros::EnumIter; use tracing::error; diff --git a/crates/starknet_client/src/reader/starknet_feeder_gateway_client_test.rs b/crates/starknet_client/src/reader/starknet_feeder_gateway_client_test.rs index da9562e704..49937f7491 100644 --- a/crates/starknet_client/src/reader/starknet_feeder_gateway_client_test.rs +++ b/crates/starknet_client/src/reader/starknet_feeder_gateway_client_test.rs @@ -30,7 +30,12 @@ use starknet_api::deprecated_contract_class::{ TypedParameter, }; use starknet_api::state::{EntryPoint, FunctionIndex}; -use starknet_api::transaction::{Fee, TransactionHash, TransactionSignature, TransactionVersion}; +use starknet_api::transaction::fields::{ + Fee, + TransactionHash, + TransactionSignature, + TransactionVersion, +}; use starknet_api::{felt, patricia_key}; use super::objects::state::StateUpdate; diff --git a/crates/starknet_client/src/writer/objects/response.rs b/crates/starknet_client/src/writer/objects/response.rs index 73f13f8bc1..fd3f36032d 100644 --- a/crates/starknet_client/src/writer/objects/response.rs +++ b/crates/starknet_client/src/writer/objects/response.rs @@ -8,7 +8,7 @@ mod response_test; use serde::{Deserialize, Serialize}; use starknet_api::core::{ClassHash, ContractAddress}; -use starknet_api::transaction::TransactionHash; +use starknet_api::transaction::fields::TransactionHash; /// A Starknet error code that reports success. #[derive(Debug, Default, Deserialize, Serialize, Clone, Eq, PartialEq)] diff --git a/crates/starknet_client/src/writer/objects/test_utils.rs b/crates/starknet_client/src/writer/objects/test_utils.rs index c929fc589b..413fa3f3cd 100644 --- a/crates/starknet_client/src/writer/objects/test_utils.rs +++ b/crates/starknet_client/src/writer/objects/test_utils.rs @@ -7,7 +7,7 @@ use starknet_api::deprecated_contract_class::{ ContractClassAbiEntry as DeprecatedContractClassAbiEntry, EntryPointV0 as DeprecatedEntryPoint, }; -use starknet_api::transaction::TransactionHash; +use starknet_api::transaction::fields::TransactionHash; use crate::writer::objects::response::{ DeclareResponse, diff --git a/crates/starknet_client/src/writer/objects/transaction.rs b/crates/starknet_client/src/writer/objects/transaction.rs index d7feec2193..d00a36c750 100644 --- a/crates/starknet_client/src/writer/objects/transaction.rs +++ b/crates/starknet_client/src/writer/objects/transaction.rs @@ -27,7 +27,7 @@ use starknet_api::deprecated_contract_class::{ EntryPointV0 as DeprecatedEntryPoint, }; use starknet_api::state::EntryPoint; -use starknet_api::transaction::{ +use starknet_api::transaction::fields::{ AccountDeploymentData, Calldata, ContractAddressSalt, diff --git a/crates/tests-integration/src/integration_test_setup.rs b/crates/tests-integration/src/integration_test_setup.rs index 969001e723..7d9b633cbe 100644 --- a/crates/tests-integration/src/integration_test_setup.rs +++ b/crates/tests-integration/src/integration_test_setup.rs @@ -3,7 +3,7 @@ use std::net::SocketAddr; use mempool_test_utils::starknet_api_test_utils::MultiAccountTransactionGenerator; use starknet_api::executable_transaction::Transaction; use starknet_api::rpc_transaction::RpcTransaction; -use starknet_api::transaction::TransactionHash; +use starknet_api::transaction::fields::TransactionHash; use starknet_batcher_types::communication::SharedBatcherClient; use starknet_gateway_types::errors::GatewaySpecError; use starknet_http_server::config::HttpServerConfig; diff --git a/crates/tests-integration/src/integration_test_utils.rs b/crates/tests-integration/src/integration_test_utils.rs index 1201251c09..b88f555277 100644 --- a/crates/tests-integration/src/integration_test_utils.rs +++ b/crates/tests-integration/src/integration_test_utils.rs @@ -14,7 +14,7 @@ use papyrus_storage::StorageConfig; use reqwest::{Client, Response}; use starknet_api::block::BlockNumber; use starknet_api::rpc_transaction::RpcTransaction; -use starknet_api::transaction::TransactionHash; +use starknet_api::transaction::fields::TransactionHash; use starknet_batcher::block_builder::BlockBuilderConfig; use starknet_batcher::config::BatcherConfig; use starknet_consensus_manager::config::ConsensusManagerConfig; diff --git a/crates/tests-integration/src/state_reader.rs b/crates/tests-integration/src/state_reader.rs index bbf70b1a6e..d563f7b024 100644 --- a/crates/tests-integration/src/state_reader.rs +++ b/crates/tests-integration/src/state_reader.rs @@ -45,7 +45,7 @@ use starknet_api::core::{ }; use starknet_api::deprecated_contract_class::ContractClass as DeprecatedContractClass; use starknet_api::state::{StorageKey, ThinStateDiff}; -use starknet_api::transaction::Fee; +use starknet_api::transaction::fields::Fee; use starknet_api::{contract_address, felt, patricia_key}; use starknet_client::reader::PendingData; use starknet_types_core::felt::Felt; diff --git a/crates/tests-integration/tests/end_to_end_test.rs b/crates/tests-integration/tests/end_to_end_test.rs index 4942f80fdd..ba26e47dde 100644 --- a/crates/tests-integration/tests/end_to_end_test.rs +++ b/crates/tests-integration/tests/end_to_end_test.rs @@ -2,7 +2,7 @@ use mempool_test_utils::starknet_api_test_utils::MultiAccountTransactionGenerato use pretty_assertions::assert_eq; use rstest::{fixture, rstest}; use starknet_api::block::BlockNumber; -use starknet_api::transaction::TransactionHash; +use starknet_api::transaction::fields::TransactionHash; use starknet_batcher_types::batcher_types::{BuildProposalInput, ProposalId, StartHeightInput}; use starknet_batcher_types::communication::SharedBatcherClient; use starknet_integration_tests::integration_test_setup::IntegrationTestSetup;