diff --git a/crates/blockifier/bench/blockifier_bench.rs b/crates/blockifier/bench/blockifier_bench.rs index 2097bb1cec..a59d71d6c0 100644 --- a/crates/blockifier/bench/blockifier_bench.rs +++ b/crates/blockifier/bench/blockifier_bench.rs @@ -8,9 +8,7 @@ //! Run the benchmarks using `cargo bench --bench blockifier_bench`. use blockifier::test_utils::transfers_generator::{ - RecipientGeneratorType, - TransfersGenerator, - TransfersGeneratorConfig, + RecipientGeneratorType, TransfersGenerator, TransfersGeneratorConfig, }; use criterion::{criterion_group, criterion_main, Criterion}; diff --git a/crates/blockifier/src/blockifier/block.rs b/crates/blockifier/src/blockifier/block.rs index 2fb14b404b..099d1228a2 100644 --- a/crates/blockifier/src/blockifier/block.rs +++ b/crates/blockifier/src/blockifier/block.rs @@ -1,11 +1,6 @@ use log::warn; use starknet_api::block::{ - BlockHashAndNumber, - BlockNumber, - GasPrice, - GasPriceVector, - GasPrices, - NonzeroGasPrice, + BlockHashAndNumber, BlockNumber, GasPrice, GasPriceVector, GasPrices, NonzeroGasPrice, }; use starknet_api::state::StorageKey; diff --git a/crates/blockifier/src/blockifier/stateful_validator.rs b/crates/blockifier/src/blockifier/stateful_validator.rs index df1caf9edb..b43a659c49 100644 --- a/crates/blockifier/src/blockifier/stateful_validator.rs +++ b/crates/blockifier/src/blockifier/stateful_validator.rs @@ -6,9 +6,7 @@ use thiserror::Error; use crate::blockifier::config::TransactionExecutorConfig; use crate::blockifier::transaction_executor::{ - TransactionExecutor, - TransactionExecutorError, - BLOCK_STATE_ACCESS_ERR, + TransactionExecutor, TransactionExecutorError, BLOCK_STATE_ACCESS_ERR, }; use crate::context::{BlockContext, TransactionContext}; use crate::execution::call_info::CallInfo; diff --git a/crates/blockifier/src/blockifier/stateful_validator_test.rs b/crates/blockifier/src/blockifier/stateful_validator_test.rs index 6e5b519dea..d1293b811d 100644 --- a/crates/blockifier/src/blockifier/stateful_validator_test.rs +++ b/crates/blockifier/src/blockifier/stateful_validator_test.rs @@ -10,13 +10,8 @@ use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::{fund_account, test_state}; use crate::test_utils::{CairoVersion, RunnableCairo1, BALANCE}; use crate::transaction::test_utils::{ - block_context, - create_account_tx_for_validate_test_nonce_0, - default_all_resource_bounds, - default_l1_resource_bounds, - FaultyAccountTxCreatorArgs, - INVALID, - VALID, + block_context, create_account_tx_for_validate_test_nonce_0, default_all_resource_bounds, + default_l1_resource_bounds, FaultyAccountTxCreatorArgs, INVALID, VALID, }; use crate::transaction::transaction_types::TransactionType; diff --git a/crates/blockifier/src/blockifier/transaction_executor_test.rs b/crates/blockifier/src/blockifier/transaction_executor_test.rs index e1e9e1ce82..88c2845520 100644 --- a/crates/blockifier/src/blockifier/transaction_executor_test.rs +++ b/crates/blockifier/src/blockifier/transaction_executor_test.rs @@ -12,9 +12,7 @@ use starknet_types_core::felt::Felt; use crate::blockifier::config::TransactionExecutorConfig; use crate::blockifier::transaction_executor::{ - TransactionExecutor, - TransactionExecutorError, - BLOCK_STATE_ACCESS_ERR, + TransactionExecutor, TransactionExecutorError, BLOCK_STATE_ACCESS_ERR, }; use crate::bouncer::{Bouncer, BouncerWeights}; use crate::context::BlockContext; @@ -24,22 +22,14 @@ use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; use crate::test_utils::l1_handler::l1handler_tx; use crate::test_utils::{ - create_calldata, - maybe_dummy_block_hash_and_number, - CairoVersion, - RunnableCairo1, - BALANCE, + create_calldata, maybe_dummy_block_hash_and_number, CairoVersion, RunnableCairo1, BALANCE, DEFAULT_STRK_L1_GAS_PRICE, }; use crate::transaction::account_transaction::AccountTransaction; use crate::transaction::errors::TransactionExecutionError; use crate::transaction::test_utils::{ - block_context, - calculate_class_info_for_testing, - create_test_init_data, - emit_n_events_tx, - l1_resource_bounds, - TestInitData, + block_context, calculate_class_info_for_testing, create_test_init_data, emit_n_events_tx, + l1_resource_bounds, TestInitData, }; use crate::transaction::transaction_execution::Transaction; fn tx_executor_test_body( diff --git a/crates/blockifier/src/blockifier/transfers_flow_test.rs b/crates/blockifier/src/blockifier/transfers_flow_test.rs index 94cd27518c..039410d1a5 100644 --- a/crates/blockifier/src/blockifier/transfers_flow_test.rs +++ b/crates/blockifier/src/blockifier/transfers_flow_test.rs @@ -2,9 +2,7 @@ use rstest::rstest; use crate::blockifier::config::ConcurrencyConfig; use crate::test_utils::transfers_generator::{ - RecipientGeneratorType, - TransfersGenerator, - TransfersGeneratorConfig, + RecipientGeneratorType, TransfersGenerator, TransfersGeneratorConfig, }; #[rstest] diff --git a/crates/blockifier/src/bouncer.rs b/crates/blockifier/src/bouncer.rs index 99c9345184..86ed48ef87 100644 --- a/crates/blockifier/src/bouncer.rs +++ b/crates/blockifier/src/bouncer.rs @@ -9,8 +9,7 @@ use starknet_api::core::ClassHash; use starknet_api::execution_resources::GasAmount; use crate::blockifier::transaction_executor::{ - TransactionExecutorError, - TransactionExecutorResult, + TransactionExecutorError, TransactionExecutorResult, }; use crate::execution::call_info::ExecutionSummary; use crate::fee::gas_usage::get_onchain_data_segment_length; diff --git a/crates/blockifier/src/bouncer_test.rs b/crates/blockifier/src/bouncer_test.rs index 32a5f22e35..d00b1610ed 100644 --- a/crates/blockifier/src/bouncer_test.rs +++ b/crates/blockifier/src/bouncer_test.rs @@ -11,10 +11,7 @@ use starknet_api::{class_hash, contract_address, storage_key}; use super::BouncerConfig; use crate::blockifier::transaction_executor::TransactionExecutorError; use crate::bouncer::{ - verify_tx_weights_within_max_capacity, - Bouncer, - BouncerWeights, - BuiltinCount, + verify_tx_weights_within_max_capacity, Bouncer, BouncerWeights, BuiltinCount, }; use crate::context::BlockContext; use crate::execution::call_info::ExecutionSummary; diff --git a/crates/blockifier/src/concurrency/fee_utils_test.rs b/crates/blockifier/src/concurrency/fee_utils_test.rs index cb458c46f3..26154ba4fb 100644 --- a/crates/blockifier/src/concurrency/fee_utils_test.rs +++ b/crates/blockifier/src/concurrency/fee_utils_test.rs @@ -14,9 +14,7 @@ use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::{fund_account, test_state, test_state_inner}; use crate::test_utils::{create_trivial_calldata, CairoVersion, RunnableCairo1, BALANCE}; use crate::transaction::test_utils::{ - block_context, - default_all_resource_bounds, - invoke_tx_with_default_flags, + block_context, default_all_resource_bounds, invoke_tx_with_default_flags, }; #[rstest] diff --git a/crates/blockifier/src/concurrency/versioned_state_test.rs b/crates/blockifier/src/concurrency/versioned_state_test.rs index 0c26cb760b..7479478bee 100644 --- a/crates/blockifier/src/concurrency/versioned_state_test.rs +++ b/crates/blockifier/src/concurrency/versioned_state_test.rs @@ -10,33 +10,20 @@ use starknet_api::test_utils::deploy_account::executable_deploy_account_tx; use starknet_api::test_utils::NonceManager; use starknet_api::transaction::fields::{ContractAddressSalt, ValidResourceBounds}; use starknet_api::{ - calldata, - class_hash, - compiled_class_hash, - contract_address, - deploy_account_tx_args, - felt, - nonce, - storage_key, + calldata, class_hash, compiled_class_hash, contract_address, deploy_account_tx_args, felt, + nonce, storage_key, }; use crate::concurrency::test_utils::{ - class_hash, - contract_address, - safe_versioned_state_for_testing, + class_hash, contract_address, safe_versioned_state_for_testing, }; use crate::concurrency::versioned_state::{ - ThreadSafeVersionedState, - VersionedState, - VersionedStateProxy, + ThreadSafeVersionedState, VersionedState, VersionedStateProxy, }; use crate::concurrency::TxIndex; use crate::context::BlockContext; use crate::state::cached_state::{ - CachedState, - ContractClassMapping, - StateMaps, - TransactionalState, + CachedState, ContractClassMapping, StateMaps, TransactionalState, }; use crate::state::errors::StateError; use crate::state::state_api::{State, StateReader, UpdatableState}; @@ -104,9 +91,11 @@ fn test_versioned_state_proxy() { StateError::UndeclaredClassHash(class_hash) if another_class_hash == class_hash ); - assert!( - !versioned_state_proxys[0].state().declared_contracts.read(0, another_class_hash).unwrap() - ); + assert!(!versioned_state_proxys[0] + .state() + .declared_contracts + .read(0, another_class_hash) + .unwrap()); // Write to the state. let new_key = storage_key!(0x11_u8); @@ -176,12 +165,16 @@ fn test_versioned_state_proxy() { versioned_state_proxys[9].get_class_hash_at(contract_address).unwrap(), class_hash_v7 ); - assert!( - !versioned_state_proxys[0].state().declared_contracts.read(0, another_class_hash).unwrap() - ); - assert!( - versioned_state_proxys[4].state().declared_contracts.read(4, another_class_hash).unwrap() - ); + assert!(!versioned_state_proxys[0] + .state() + .declared_contracts + .read(0, another_class_hash) + .unwrap()); + assert!(versioned_state_proxys[4] + .state() + .declared_contracts + .read(4, another_class_hash) + .unwrap()); // Include the writes in the current transaction. assert_eq!( versioned_state_proxys[10].get_class_hash_at(contract_address).unwrap(), @@ -331,11 +324,9 @@ fn test_validate_reads( assert_eq!(transactional_state.cache.borrow().initial_reads.declared_contracts.len(), 1); - assert!( - safe_versioned_state - .pin_version(1) - .validate_reads(&transactional_state.cache.borrow().initial_reads) - ); + assert!(safe_versioned_state + .pin_version(1) + .validate_reads(&transactional_state.cache.borrow().initial_reads)); } #[rstest] diff --git a/crates/blockifier/src/concurrency/worker_logic_test.rs b/crates/blockifier/src/concurrency/worker_logic_test.rs index bf1b29647a..b5e067c5d8 100644 --- a/crates/blockifier/src/concurrency/worker_logic_test.rs +++ b/crates/blockifier/src/concurrency/worker_logic_test.rs @@ -26,21 +26,14 @@ use crate::state::state_api::StateReader; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; use crate::test_utils::{ - create_calldata, - create_trivial_calldata, - CairoVersion, - RunnableCairo1, - BALANCE, + create_calldata, create_trivial_calldata, CairoVersion, RunnableCairo1, BALANCE, TEST_ERC20_CONTRACT_ADDRESS2, }; use crate::transaction::account_transaction::AccountTransaction; use crate::transaction::objects::HasRelatedFeeType; use crate::transaction::test_utils::{ - calculate_class_info_for_testing, - default_all_resource_bounds, - emit_n_events_tx, - invoke_tx_with_default_flags, - max_fee, + calculate_class_info_for_testing, default_all_resource_bounds, emit_n_events_tx, + invoke_tx_with_default_flags, max_fee, }; use crate::transaction::transaction_execution::Transaction; diff --git a/crates/blockifier/src/context.rs b/crates/blockifier/src/context.rs index bd69be574f..007be96b31 100644 --- a/crates/blockifier/src/context.rs +++ b/crates/blockifier/src/context.rs @@ -6,17 +6,12 @@ use serde::{Deserialize, Serialize}; use starknet_api::block::{BlockInfo, FeeType, GasPriceVector}; use starknet_api::core::{ChainId, ContractAddress}; use starknet_api::transaction::fields::{ - AllResourceBounds, - GasVectorComputationMode, - ValidResourceBounds, + AllResourceBounds, GasVectorComputationMode, ValidResourceBounds, }; use crate::bouncer::BouncerConfig; use crate::transaction::objects::{ - CurrentTransactionInfo, - HasRelatedFeeType, - TransactionInfo, - TransactionInfoCreator, + CurrentTransactionInfo, HasRelatedFeeType, TransactionInfo, TransactionInfoCreator, }; use crate::versioned_constants::VersionedConstants; diff --git a/crates/blockifier/src/execution/common_hints.rs b/crates/blockifier/src/execution/common_hints.rs index ae188fa307..962984c0c8 100644 --- a/crates/blockifier/src/execution/common_hints.rs +++ b/crates/blockifier/src/execution/common_hints.rs @@ -3,12 +3,10 @@ use std::ops::Shl; use std::rc::Rc; use cairo_vm::hint_processor::builtin_hint_processor::builtin_hint_processor_definition::{ - BuiltinHintProcessor, - HintFunc, + BuiltinHintProcessor, HintFunc, }; use cairo_vm::hint_processor::builtin_hint_processor::hint_utils::{ - get_integer_from_var_name, - insert_value_from_var_name, + get_integer_from_var_name, insert_value_from_var_name, }; use cairo_vm::hint_processor::hint_processor_definition::HintReference; use cairo_vm::serde::deserialize_program::ApTracking; @@ -20,8 +18,7 @@ use num_bigint::BigUint; use starknet_types_core::felt::Felt; use crate::execution::hint_code::{ - NORMALIZE_ADDRESS_SET_IS_250_HINT, - NORMALIZE_ADDRESS_SET_IS_SMALL_HINT, + NORMALIZE_ADDRESS_SET_IS_250_HINT, NORMALIZE_ADDRESS_SET_IS_SMALL_HINT, }; /// Transaction execution mode. diff --git a/crates/blockifier/src/execution/contract_class.rs b/crates/blockifier/src/execution/contract_class.rs index 36f6b97887..a70fdaf2f9 100644 --- a/crates/blockifier/src/execution/contract_class.rs +++ b/crates/blockifier/src/execution/contract_class.rs @@ -7,10 +7,7 @@ use cairo_lang_casm::hints::Hint; use cairo_lang_starknet_classes::casm_contract_class::{CasmContractClass, CasmContractEntryPoint}; use cairo_lang_starknet_classes::NestedIntList; use cairo_vm::serde::deserialize_program::{ - ApTracking, - FlowTrackingData, - HintParams, - ReferenceManager, + ApTracking, FlowTrackingData, HintParams, ReferenceManager, }; use cairo_vm::types::builtin_name::BuiltinName; use cairo_vm::types::errors::program_errors::ProgramError; @@ -24,9 +21,7 @@ use serde::{Deserialize, Deserializer, Serialize}; use starknet_api::contract_class::{ContractClass, EntryPointType}; use starknet_api::core::EntryPointSelector; use starknet_api::deprecated_contract_class::{ - ContractClass as DeprecatedContractClass, - EntryPointOffset, - EntryPointV0, + ContractClass as DeprecatedContractClass, EntryPointOffset, EntryPointV0, Program as DeprecatedProgram, }; use starknet_types_core::felt::Felt; @@ -187,7 +182,7 @@ impl CompiledClassV0 { + self.n_builtins() + self.bytecode_length() + 1; // Hinted class hash. - // The hashed data size is approximately the number of hashes (invoked in hash chains). + // The hashed data size is approximately the number of hashes (invoked in hash chains). let n_steps = constants::N_STEPS_PER_PEDERSEN * hashed_data_size; ExecutionResources { diff --git a/crates/blockifier/src/execution/deprecated_entry_point_execution.rs b/crates/blockifier/src/execution/deprecated_entry_point_execution.rs index bee02bedd5..d87e4e46e4 100644 --- a/crates/blockifier/src/execution/deprecated_entry_point_execution.rs +++ b/crates/blockifier/src/execution/deprecated_entry_point_execution.rs @@ -17,9 +17,7 @@ use crate::execution::call_info::{CallExecution, CallInfo, ChargedResources}; use crate::execution::contract_class::{CompiledClassV0, TrackedResource}; use crate::execution::deprecated_syscalls::hint_processor::DeprecatedSyscallHintProcessor; use crate::execution::entry_point::{ - CallEntryPoint, - EntryPointExecutionContext, - EntryPointExecutionResult, + CallEntryPoint, EntryPointExecutionContext, EntryPointExecutionResult, }; use crate::execution::errors::{PostExecutionError, PreExecutionError}; use crate::execution::execution_utils::{read_execution_retdata, Args, ReadOnlySegments}; 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 7f04bb9abd..5d5e58a90c 100644 --- a/crates/blockifier/src/execution/deprecated_syscalls/deprecated_syscalls_test.rs +++ b/crates/blockifier/src/execution/deprecated_syscalls/deprecated_syscalls_test.rs @@ -9,11 +9,7 @@ use starknet_api::core::{calculate_contract_address, ChainId}; use starknet_api::state::StorageKey; use starknet_api::transaction::fields::{Calldata, ContractAddressSalt, Fee}; use starknet_api::transaction::{ - EventContent, - EventData, - EventKey, - TransactionVersion, - QUERY_VERSION_BASE, + EventContent, EventData, EventKey, TransactionVersion, QUERY_VERSION_BASE, }; use starknet_api::{calldata, felt, nonce, storage_key, tx_hash}; use starknet_types_core::felt::Felt; @@ -30,20 +26,12 @@ use crate::state::state_api::StateReader; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; use crate::test_utils::{ - calldata_for_deploy_test, - get_syscall_resources, - trivial_external_entry_point_new, - CairoVersion, - CURRENT_BLOCK_NUMBER, - CURRENT_BLOCK_NUMBER_FOR_VALIDATE, - CURRENT_BLOCK_TIMESTAMP, - CURRENT_BLOCK_TIMESTAMP_FOR_VALIDATE, - TEST_SEQUENCER_ADDRESS, + calldata_for_deploy_test, get_syscall_resources, trivial_external_entry_point_new, + CairoVersion, CURRENT_BLOCK_NUMBER, CURRENT_BLOCK_NUMBER_FOR_VALIDATE, CURRENT_BLOCK_TIMESTAMP, + CURRENT_BLOCK_TIMESTAMP_FOR_VALIDATE, TEST_SEQUENCER_ADDRESS, }; use crate::transaction::objects::{ - CommonAccountFields, - DeprecatedTransactionInfo, - TransactionInfo, + CommonAccountFields, DeprecatedTransactionInfo, TransactionInfo, }; use crate::versioned_constants::VersionedConstants; use crate::{check_entry_point_execution_error_for_custom_hint, retdata}; diff --git a/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs b/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs index 201bdad740..02a0409e42 100644 --- a/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs +++ b/crates/blockifier/src/execution/deprecated_syscalls/hint_processor.rs @@ -2,8 +2,7 @@ use std::any::Any; use std::collections::{HashMap, HashSet}; use cairo_vm::hint_processor::builtin_hint_processor::builtin_hint_processor_definition::{ - BuiltinHintProcessor, - HintProcessorData, + BuiltinHintProcessor, HintProcessorData, }; use cairo_vm::hint_processor::builtin_hint_processor::hint_utils::get_ptr_from_var_name; use cairo_vm::hint_processor::hint_processor_definition::{HintProcessorLogic, HintReference}; @@ -29,43 +28,20 @@ use thiserror::Error; use crate::context::TransactionContext; use crate::execution::call_info::{CallInfo, OrderedEvent, OrderedL2ToL1Message}; use crate::execution::common_hints::{ - extended_builtin_hint_processor, - ExecutionMode, - HintExecutionResult, + extended_builtin_hint_processor, ExecutionMode, HintExecutionResult, }; use crate::execution::deprecated_syscalls::{ - call_contract, - delegate_call, - delegate_l1_handler, - deploy, - emit_event, - get_block_number, - get_block_timestamp, - get_caller_address, - get_contract_address, - get_sequencer_address, - get_tx_info, - get_tx_signature, - library_call, - library_call_l1_handler, - replace_class, - send_message_to_l1, - storage_read, - storage_write, - DeprecatedSyscallResult, - DeprecatedSyscallSelector, - StorageReadResponse, - StorageWriteResponse, - SyscallRequest, + call_contract, delegate_call, delegate_l1_handler, deploy, emit_event, get_block_number, + get_block_timestamp, get_caller_address, get_contract_address, get_sequencer_address, + get_tx_info, get_tx_signature, library_call, library_call_l1_handler, replace_class, + send_message_to_l1, storage_read, storage_write, DeprecatedSyscallResult, + DeprecatedSyscallSelector, StorageReadResponse, StorageWriteResponse, SyscallRequest, SyscallResponse, }; use crate::execution::entry_point::{CallEntryPoint, CallType, EntryPointExecutionContext}; use crate::execution::errors::{ConstructorEntryPointExecutionError, EntryPointExecutionError}; use crate::execution::execution_utils::{ - felt_from_ptr, - felt_range_from_ptr, - ReadOnlySegment, - ReadOnlySegments, + felt_from_ptr, felt_range_from_ptr, ReadOnlySegment, ReadOnlySegments, }; use crate::execution::hint_code; use crate::execution::syscalls::hint_processor::EmitEventError; diff --git a/crates/blockifier/src/execution/deprecated_syscalls/mod.rs b/crates/blockifier/src/execution/deprecated_syscalls/mod.rs index b921789774..4d3cf4c06a 100644 --- a/crates/blockifier/src/execution/deprecated_syscalls/mod.rs +++ b/crates/blockifier/src/execution/deprecated_syscalls/mod.rs @@ -4,11 +4,7 @@ use serde::Deserialize; use starknet_api::block::{BlockNumber, BlockTimestamp}; use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ - calculate_contract_address, - ClassHash, - ContractAddress, - EntryPointSelector, - EthAddress, + calculate_contract_address, ClassHash, ContractAddress, EntryPointSelector, EthAddress, }; use starknet_api::state::StorageKey; use starknet_api::transaction::fields::{Calldata, ContractAddressSalt}; @@ -17,25 +13,15 @@ use starknet_types_core::felt::Felt; use strum_macros::EnumIter; use self::hint_processor::{ - execute_inner_call, - execute_library_call, - felt_to_bool, - read_call_params, - read_calldata, - read_felt_array, - DeprecatedSyscallExecutionError, - DeprecatedSyscallHintProcessor, + execute_inner_call, execute_library_call, felt_to_bool, read_call_params, read_calldata, + read_felt_array, DeprecatedSyscallExecutionError, DeprecatedSyscallHintProcessor, }; use super::syscalls::exceeds_event_size_limit; use crate::execution::call_info::{MessageToL1, OrderedEvent, OrderedL2ToL1Message}; use crate::execution::common_hints::ExecutionMode; use crate::execution::entry_point::{CallEntryPoint, CallType, ConstructorContext}; use crate::execution::execution_utils::{ - execute_deployment, - felt_from_ptr, - write_felt, - write_maybe_relocatable, - ReadOnlySegment, + execute_deployment, felt_from_ptr, write_felt, write_maybe_relocatable, ReadOnlySegment, }; #[cfg(test)] diff --git a/crates/blockifier/src/execution/entry_point.rs b/crates/blockifier/src/execution/entry_point.rs index fc6eeb3d5e..c7773ec403 100644 --- a/crates/blockifier/src/execution/entry_point.rs +++ b/crates/blockifier/src/execution/entry_point.rs @@ -12,10 +12,7 @@ use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector}; use starknet_api::state::StorageKey; use starknet_api::transaction::fields::{ - AllResourceBounds, - Calldata, - ResourceBounds, - ValidResourceBounds, + AllResourceBounds, Calldata, ResourceBounds, ValidResourceBounds, }; use starknet_api::transaction::TransactionVersion; use starknet_types_core::felt::Felt; @@ -25,9 +22,7 @@ use crate::execution::call_info::CallInfo; use crate::execution::common_hints::ExecutionMode; use crate::execution::contract_class::TrackedResource; use crate::execution::errors::{ - ConstructorEntryPointExecutionError, - EntryPointExecutionError, - PreExecutionError, + ConstructorEntryPointExecutionError, EntryPointExecutionError, PreExecutionError, }; use crate::execution::execution_utils::execute_entry_point_call_wrapper; use crate::execution::stack_trace::{extract_trailing_cairo1_revert_trace, Cairo1RevertHeader}; diff --git a/crates/blockifier/src/execution/entry_point_execution.rs b/crates/blockifier/src/execution/entry_point_execution.rs index cdb9c8c7dc..57d118b4c6 100644 --- a/crates/blockifier/src/execution/entry_point_execution.rs +++ b/crates/blockifier/src/execution/entry_point_execution.rs @@ -16,17 +16,11 @@ use starknet_types_core::felt::Felt; use crate::execution::call_info::{CallExecution, CallInfo, ChargedResources, Retdata}; use crate::execution::contract_class::{CompiledClassV1, EntryPointV1, TrackedResource}; use crate::execution::entry_point::{ - CallEntryPoint, - EntryPointExecutionContext, - EntryPointExecutionResult, + CallEntryPoint, EntryPointExecutionContext, EntryPointExecutionResult, }; use crate::execution::errors::{EntryPointExecutionError, PostExecutionError, PreExecutionError}; use crate::execution::execution_utils::{ - read_execution_retdata, - write_felt, - write_maybe_relocatable, - Args, - ReadOnlySegments, + read_execution_retdata, write_felt, write_maybe_relocatable, Args, ReadOnlySegments, SEGMENT_ARENA_BUILTIN_SIZE, }; use crate::execution::syscalls::hint_processor::SyscallHintProcessor; diff --git a/crates/blockifier/src/execution/execution_utils.rs b/crates/blockifier/src/execution/execution_utils.rs index 171d8e5001..c3a05f8cfe 100644 --- a/crates/blockifier/src/execution/execution_utils.rs +++ b/crates/blockifier/src/execution/execution_utils.rs @@ -1,11 +1,7 @@ use std::collections::HashMap; use cairo_vm::serde::deserialize_program::{ - deserialize_array_of_bigint_hex, - Attribute, - HintParams, - Identifier, - ReferenceManager, + deserialize_array_of_bigint_hex, Attribute, HintParams, Identifier, ReferenceManager, }; use cairo_vm::types::builtin_name::BuiltinName; use cairo_vm::types::errors::program_errors::ProgramError; @@ -24,17 +20,11 @@ use starknet_types_core::felt::Felt; use crate::execution::call_info::{CallExecution, CallInfo, Retdata}; use crate::execution::contract_class::{RunnableCompiledClass, TrackedResource}; use crate::execution::entry_point::{ - execute_constructor_entry_point, - CallEntryPoint, - ConstructorContext, - ConstructorEntryPointExecutionResult, - EntryPointExecutionContext, - EntryPointExecutionResult, + execute_constructor_entry_point, CallEntryPoint, ConstructorContext, + ConstructorEntryPointExecutionResult, EntryPointExecutionContext, EntryPointExecutionResult, }; use crate::execution::errors::{ - ConstructorEntryPointExecutionError, - EntryPointExecutionError, - PostExecutionError, + ConstructorEntryPointExecutionError, EntryPointExecutionError, PostExecutionError, PreExecutionError, }; #[cfg(feature = "cairo_native")] diff --git a/crates/blockifier/src/execution/native/entry_point_execution.rs b/crates/blockifier/src/execution/native/entry_point_execution.rs index 37c7cf55db..4335f4f4b9 100644 --- a/crates/blockifier/src/execution/native/entry_point_execution.rs +++ b/crates/blockifier/src/execution/native/entry_point_execution.rs @@ -7,9 +7,7 @@ use starknet_api::execution_resources::GasAmount; use crate::execution::call_info::{CallExecution, CallInfo, ChargedResources, Retdata}; use crate::execution::contract_class::TrackedResource; use crate::execution::entry_point::{ - CallEntryPoint, - EntryPointExecutionContext, - EntryPointExecutionResult, + CallEntryPoint, EntryPointExecutionContext, EntryPointExecutionResult, }; use crate::execution::errors::{EntryPointExecutionError, PostExecutionError}; use crate::execution::native::contract_class::NativeCompiledClassV1; diff --git a/crates/blockifier/src/execution/native/syscall_handler.rs b/crates/blockifier/src/execution/native/syscall_handler.rs index dd37ced09c..bf67c415af 100644 --- a/crates/blockifier/src/execution/native/syscall_handler.rs +++ b/crates/blockifier/src/execution/native/syscall_handler.rs @@ -5,16 +5,8 @@ use std::sync::Arc; use ark_ec::short_weierstrass::{Affine, Projective, SWCurveConfig}; use ark_ff::{BigInt, PrimeField}; use cairo_native::starknet::{ - BlockInfo, - ExecutionInfo, - ExecutionInfoV2, - Secp256k1Point, - Secp256r1Point, - StarknetSyscallHandler, - SyscallResult, - TxInfo, - TxV2Info, - U256, + BlockInfo, ExecutionInfo, ExecutionInfoV2, Secp256k1Point, Secp256r1Point, + StarknetSyscallHandler, SyscallResult, TxInfo, TxV2Info, U256, }; use num_bigint::BigUint; use starknet_api::contract_class::EntryPointType; @@ -89,10 +81,8 @@ impl<'state> NativeSyscallHandler<'state> { if *remaining_gas < required_gas { // Out of gas failure. - return Err(vec![ - Felt::from_hex(OUT_OF_GAS_ERROR) - .expect("Failed to parse OUT_OF_GAS_ERROR hex string"), - ]); + return Err(vec![Felt::from_hex(OUT_OF_GAS_ERROR) + .expect("Failed to parse OUT_OF_GAS_ERROR hex string")]); } *remaining_gas -= required_gas; diff --git a/crates/blockifier/src/execution/native/utils_test.rs b/crates/blockifier/src/execution/native/utils_test.rs index 553409e251..ab5f305ada 100644 --- a/crates/blockifier/src/execution/native/utils_test.rs +++ b/crates/blockifier/src/execution/native/utils_test.rs @@ -6,8 +6,7 @@ use starknet_api::execution_utils::format_panic_data; use starknet_types_core::felt::Felt; use crate::execution::native::utils::{ - contract_entrypoint_to_entrypoint_selector, - encode_str_as_felts, + contract_entrypoint_to_entrypoint_selector, encode_str_as_felts, }; #[test] diff --git a/crates/blockifier/src/execution/secp.rs b/crates/blockifier/src/execution/secp.rs index f96bb11633..d37d54f018 100644 --- a/crates/blockifier/src/execution/secp.rs +++ b/crates/blockifier/src/execution/secp.rs @@ -17,7 +17,11 @@ where let maybe_ec_point = Affine::::get_ys_from_x_unchecked(x) .map(|(smaller, greater)| { // Return the correct y coordinate based on the parity. - if smaller.into_bigint().is_odd() == y_parity { smaller } else { greater } + if smaller.into_bigint().is_odd() == y_parity { + smaller + } else { + greater + } }) .map(|y| Affine::::new_unchecked(x, y)) .filter(|p| p.is_in_correct_subgroup_assuming_on_curve()); diff --git a/crates/blockifier/src/execution/stack_trace_test.rs b/crates/blockifier/src/execution/stack_trace_test.rs index 1a4868880c..9d7c4bb004 100644 --- a/crates/blockifier/src/execution/stack_trace_test.rs +++ b/crates/blockifier/src/execution/stack_trace_test.rs @@ -5,26 +5,15 @@ use rstest::rstest; use starknet_api::abi::abi_utils::selector_from_name; use starknet_api::abi::constants::CONSTRUCTOR_ENTRY_POINT_NAME; use starknet_api::core::{ - calculate_contract_address, - ClassHash, - ContractAddress, - EntryPointSelector, - Nonce, + calculate_contract_address, ClassHash, ContractAddress, EntryPointSelector, Nonce, }; use starknet_api::executable_transaction::AccountTransaction as Transaction; use starknet_api::transaction::constants::{ - DEPLOY_CONTRACT_FUNCTION_ENTRY_POINT_NAME, - EXECUTE_ENTRY_POINT_NAME, - FELT_TRUE, - VALIDATE_DECLARE_ENTRY_POINT_NAME, - VALIDATE_DEPLOY_ENTRY_POINT_NAME, - VALIDATE_ENTRY_POINT_NAME, + DEPLOY_CONTRACT_FUNCTION_ENTRY_POINT_NAME, EXECUTE_ENTRY_POINT_NAME, FELT_TRUE, + VALIDATE_DECLARE_ENTRY_POINT_NAME, VALIDATE_DEPLOY_ENTRY_POINT_NAME, VALIDATE_ENTRY_POINT_NAME, }; use starknet_api::transaction::fields::{ - ContractAddressSalt, - Fee, - TransactionSignature, - ValidResourceBounds, + ContractAddressSalt, Fee, TransactionSignature, ValidResourceBounds, }; use starknet_api::transaction::TransactionVersion; use starknet_api::{calldata, felt, invoke_tx_args}; @@ -35,11 +24,8 @@ use crate::execution::call_info::{CallExecution, CallInfo, Retdata}; use crate::execution::entry_point::CallEntryPoint; use crate::execution::errors::EntryPointExecutionError; use crate::execution::stack_trace::{ - extract_trailing_cairo1_revert_trace, - Cairo1RevertHeader, - Cairo1RevertSummary, - MIN_CAIRO1_FRAME_LENGTH, - TRACE_LENGTH_CAP, + extract_trailing_cairo1_revert_trace, Cairo1RevertHeader, Cairo1RevertSummary, + MIN_CAIRO1_FRAME_LENGTH, TRACE_LENGTH_CAP, }; use crate::execution::syscalls::hint_processor::ENTRYPOINT_FAILED_ERROR; use crate::test_utils::contracts::FeatureContract; @@ -47,13 +33,8 @@ use crate::test_utils::initial_test_state::{fund_account, test_state}; use crate::test_utils::{create_calldata, CairoVersion, RunnableCairo1, BALANCE}; use crate::transaction::account_transaction::{AccountTransaction, ExecutionFlags}; use crate::transaction::test_utils::{ - block_context, - create_account_tx_for_validate_test_nonce_0, - default_all_resource_bounds, - invoke_tx_with_default_flags, - run_invoke_tx, - FaultyAccountTxCreatorArgs, - INVALID, + block_context, create_account_tx_for_validate_test_nonce_0, default_all_resource_bounds, + invoke_tx_with_default_flags, run_invoke_tx, FaultyAccountTxCreatorArgs, INVALID, }; use crate::transaction::transaction_types::TransactionType; use crate::transaction::transactions::ExecutableTransaction; diff --git a/crates/blockifier/src/execution/syscalls/hint_processor.rs b/crates/blockifier/src/execution/syscalls/hint_processor.rs index c7e0972457..99b3bbca66 100644 --- a/crates/blockifier/src/execution/syscalls/hint_processor.rs +++ b/crates/blockifier/src/execution/syscalls/hint_processor.rs @@ -15,10 +15,7 @@ use cairo_vm::vm::runners::cairo_runner::{ResourceTracker, RunResources}; use cairo_vm::vm::vm_core::VirtualMachine; use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector}; use starknet_api::transaction::fields::{ - AllResourceBounds, - Calldata, - Resource, - ValidResourceBounds, + AllResourceBounds, Calldata, Resource, ValidResourceBounds, }; use starknet_api::StarknetApiError; use starknet_types_core::felt::{Felt, FromStrError}; @@ -29,46 +26,19 @@ use crate::execution::common_hints::{ExecutionMode, HintExecutionResult}; use crate::execution::entry_point::{CallEntryPoint, EntryPointExecutionContext}; use crate::execution::errors::{ConstructorEntryPointExecutionError, EntryPointExecutionError}; use crate::execution::execution_utils::{ - felt_from_ptr, - felt_range_from_ptr, - write_maybe_relocatable, - ReadOnlySegment, - ReadOnlySegments, + felt_from_ptr, felt_range_from_ptr, write_maybe_relocatable, ReadOnlySegment, ReadOnlySegments, }; use crate::execution::syscalls::secp::{ - secp256k1_add, - secp256k1_get_point_from_x, - secp256k1_get_xy, - secp256k1_mul, - secp256k1_new, - secp256r1_add, - secp256r1_get_point_from_x, - secp256r1_get_xy, - secp256r1_mul, - secp256r1_new, + secp256k1_add, secp256k1_get_point_from_x, secp256k1_get_xy, secp256k1_mul, secp256k1_new, + secp256r1_add, secp256r1_get_point_from_x, secp256r1_get_xy, secp256r1_mul, secp256r1_new, SecpHintProcessor, }; use crate::execution::syscalls::syscall_base::SyscallHandlerBase; use crate::execution::syscalls::{ - call_contract, - deploy, - emit_event, - get_block_hash, - get_class_hash_at, - get_execution_info, - keccak, - library_call, - replace_class, - send_message_to_l1, - sha_256_process_block, - storage_read, - storage_write, - SyscallRequest, - SyscallRequestWrapper, - SyscallResponse, - SyscallResponseWrapper, - SyscallResult, - SyscallSelector, + call_contract, deploy, emit_event, get_block_hash, get_class_hash_at, get_execution_info, + keccak, library_call, replace_class, send_message_to_l1, sha_256_process_block, storage_read, + storage_write, SyscallRequest, SyscallRequestWrapper, SyscallResponse, SyscallResponseWrapper, + SyscallResult, SyscallSelector, }; use crate::state::errors::StateError; use crate::state::state_api::State; diff --git a/crates/blockifier/src/execution/syscalls/mod.rs b/crates/blockifier/src/execution/syscalls/mod.rs index 9d6f412b72..76d73531d5 100644 --- a/crates/blockifier/src/execution/syscalls/mod.rs +++ b/crates/blockifier/src/execution/syscalls/mod.rs @@ -10,25 +10,14 @@ use starknet_api::transaction::{EventContent, EventData, EventKey, L2ToL1Payload use starknet_types_core::felt::Felt; use self::hint_processor::{ - create_retdata_segment, - execute_inner_call, - felt_to_bool, - read_call_params, - read_calldata, - read_felt_array, - write_segment, - EmitEventError, - SyscallExecutionError, - SyscallHintProcessor, + create_retdata_segment, execute_inner_call, felt_to_bool, read_call_params, read_calldata, + read_felt_array, write_segment, EmitEventError, SyscallExecutionError, SyscallHintProcessor, }; use crate::execution::call_info::MessageToL1; use crate::execution::deprecated_syscalls::DeprecatedSyscallSelector; use crate::execution::entry_point::{CallEntryPoint, CallType}; use crate::execution::execution_utils::{ - felt_from_ptr, - write_felt, - write_maybe_relocatable, - ReadOnlySegment, + felt_from_ptr, write_felt, write_maybe_relocatable, ReadOnlySegment, }; use crate::execution::syscalls::syscall_base::SyscallResult; use crate::versioned_constants::{EventLimits, VersionedConstants}; diff --git a/crates/blockifier/src/execution/syscalls/secp.rs b/crates/blockifier/src/execution/syscalls/secp.rs index fd73bd1831..f42c2033f9 100644 --- a/crates/blockifier/src/execution/syscalls/secp.rs +++ b/crates/blockifier/src/execution/syscalls/secp.rs @@ -11,11 +11,7 @@ use crate::execution::execution_utils::{felt_from_ptr, write_maybe_relocatable, use crate::execution::secp::new_affine; use crate::execution::syscalls::hint_processor::{felt_to_bool, SyscallHintProcessor}; use crate::execution::syscalls::{ - SyscallExecutionError, - SyscallRequest, - SyscallResponse, - SyscallResult, - WriteResponseResult, + SyscallExecutionError, SyscallRequest, SyscallResponse, SyscallResult, WriteResponseResult, }; #[derive(Debug, Default, Eq, PartialEq)] diff --git a/crates/blockifier/src/execution/syscalls/syscall_base.rs b/crates/blockifier/src/execution/syscalls/syscall_base.rs index 7e172065f1..14c021beb3 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_base.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_base.rs @@ -13,17 +13,12 @@ use crate::abi::constants; use crate::execution::call_info::{CallInfo, MessageToL1, OrderedEvent, OrderedL2ToL1Message}; use crate::execution::common_hints::ExecutionMode; use crate::execution::entry_point::{ - CallEntryPoint, - ConstructorContext, - EntryPointExecutionContext, + CallEntryPoint, ConstructorContext, EntryPointExecutionContext, }; use crate::execution::execution_utils::execute_deployment; use crate::execution::syscalls::hint_processor::{ - SyscallExecutionError, - BLOCK_NUMBER_OUT_OF_RANGE_ERROR, - ENTRYPOINT_FAILED_ERROR, - INVALID_INPUT_LENGTH_ERROR, - OUT_OF_GAS_ERROR, + SyscallExecutionError, BLOCK_NUMBER_OUT_OF_RANGE_ERROR, ENTRYPOINT_FAILED_ERROR, + INVALID_INPUT_LENGTH_ERROR, OUT_OF_GAS_ERROR, }; use crate::state::state_api::State; use crate::transaction::account_transaction::is_cairo1; @@ -269,10 +264,8 @@ impl<'state> SyscallHandlerBase<'state> { if remainder != 0 { return Err(SyscallExecutionError::SyscallError { - error_data: vec![ - Felt::from_hex(INVALID_INPUT_LENGTH_ERROR) - .expect("Failed to parse INVALID_INPUT_LENGTH_ERROR hex string"), - ], + error_data: vec![Felt::from_hex(INVALID_INPUT_LENGTH_ERROR) + .expect("Failed to parse INVALID_INPUT_LENGTH_ERROR hex string")], }); } // TODO(Ori, 1/2/2024): Write an indicative expect message explaining why the conversion 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 dc5daa41a3..c8fce38c7b 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/call_contract.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/call_contract.rs @@ -20,12 +20,8 @@ use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; use crate::test_utils::syscall::build_recurse_calldata; use crate::test_utils::{ - create_calldata, - trivial_external_entry_point_new, - CairoVersion, - CompilerBasedVersion, - RunnableCairo1, - BALANCE, + create_calldata, trivial_external_entry_point_new, CairoVersion, CompilerBasedVersion, + RunnableCairo1, BALANCE, }; #[cfg_attr(feature = "cairo_native", test_case(RunnableCairo1::Native; "Native"))] diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs index c2428bfeaf..3eba4267e9 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/deploy.rs @@ -13,10 +13,7 @@ use crate::state::state_api::StateReader; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; use crate::test_utils::{ - calldata_for_deploy_test, - trivial_external_entry_point_new, - CairoVersion, - RunnableCairo1, + calldata_for_deploy_test, trivial_external_entry_point_new, CairoVersion, RunnableCairo1, }; #[test_case(RunnableCairo1::Casm;"VM")] 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 09ffe2619b..2265d7148a 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 @@ -16,11 +16,7 @@ use crate::test_utils::contracts::FeatureContract; use crate::test_utils::dict_state_reader::DictStateReader; use crate::test_utils::initial_test_state::test_state; use crate::test_utils::{ - trivial_external_entry_point_new, - CairoVersion, - RunnableCairo1, - BALANCE, - CURRENT_BLOCK_NUMBER, + trivial_external_entry_point_new, CairoVersion, RunnableCairo1, BALANCE, CURRENT_BLOCK_NUMBER, }; use crate::versioned_constants::VersionedConstants; use crate::{check_entry_point_execution_error_for_custom_hint, retdata}; @@ -81,11 +77,9 @@ fn negative_flow_execution_mode_validate(runnable_version: RunnableCairo1) { test_contract, FeatureContract::TestContract(CairoVersion::Cairo1(RunnableCairo1::Native)) ) { - assert!( - error - .to_string() - .contains("Unauthorized syscall get_block_hash in execution mode Validate.") - ); + assert!(error + .to_string() + .contains("Unauthorized syscall get_block_hash in execution mode Validate.")); } else { check_entry_point_execution_error_for_custom_hint!( &error, 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 47f351467d..5cd981b518 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,13 +4,7 @@ use starknet_api::core::ChainId; use starknet_api::data_availability::DataAvailabilityMode; use starknet_api::execution_resources::GasAmount; use starknet_api::transaction::fields::{ - AccountDeploymentData, - Calldata, - Fee, - PaymasterData, - Resource, - ResourceBounds, - Tip, + AccountDeploymentData, Calldata, Fee, PaymasterData, Resource, ResourceBounds, Tip, ValidResourceBounds, }; use starknet_api::transaction::{TransactionVersion, QUERY_VERSION_BASE}; @@ -24,21 +18,12 @@ use crate::execution::entry_point::CallEntryPoint; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; use crate::test_utils::{ - trivial_external_entry_point_with_address, - CairoVersion, - RunnableCairo1, - BALANCE, - CURRENT_BLOCK_NUMBER, - CURRENT_BLOCK_NUMBER_FOR_VALIDATE, - CURRENT_BLOCK_TIMESTAMP, - CURRENT_BLOCK_TIMESTAMP_FOR_VALIDATE, - TEST_SEQUENCER_ADDRESS, + trivial_external_entry_point_with_address, CairoVersion, RunnableCairo1, BALANCE, + CURRENT_BLOCK_NUMBER, CURRENT_BLOCK_NUMBER_FOR_VALIDATE, CURRENT_BLOCK_TIMESTAMP, + CURRENT_BLOCK_TIMESTAMP_FOR_VALIDATE, TEST_SEQUENCER_ADDRESS, }; use crate::transaction::objects::{ - CommonAccountFields, - CurrentTransactionInfo, - DeprecatedTransactionInfo, - TransactionInfo, + CommonAccountFields, CurrentTransactionInfo, DeprecatedTransactionInfo, TransactionInfo, }; #[cfg_attr( 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 1017a5f664..e73da1deb5 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/library_call.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/library_call.rs @@ -12,19 +12,14 @@ use crate::context::ChainInfo; use crate::execution::call_info::{CallExecution, CallInfo, ChargedResources, Retdata}; use crate::execution::entry_point::{CallEntryPoint, CallType}; use crate::execution::syscalls::syscall_tests::constants::{ - REQUIRED_GAS_LIBRARY_CALL_TEST, - REQUIRED_GAS_STORAGE_READ_WRITE_TEST, + REQUIRED_GAS_LIBRARY_CALL_TEST, REQUIRED_GAS_STORAGE_READ_WRITE_TEST, }; use crate::execution::syscalls::SyscallSelector; use crate::retdata; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; use crate::test_utils::{ - get_syscall_resources, - trivial_external_entry_point_new, - CairoVersion, - RunnableCairo1, - BALANCE, + get_syscall_resources, trivial_external_entry_point_new, CairoVersion, RunnableCairo1, BALANCE, }; use crate::versioned_constants::VersionedConstants; diff --git a/crates/blockifier/src/fee/fee_checks.rs b/crates/blockifier/src/fee/fee_checks.rs index 6ec555b8ee..830fc97530 100644 --- a/crates/blockifier/src/fee/fee_checks.rs +++ b/crates/blockifier/src/fee/fee_checks.rs @@ -2,10 +2,7 @@ use starknet_api::block::FeeType; use starknet_api::execution_resources::{GasAmount, GasVector}; use starknet_api::transaction::fields::Resource::{self, L1DataGas, L1Gas, L2Gas}; use starknet_api::transaction::fields::{ - AllResourceBounds, - Fee, - ResourceBounds, - ValidResourceBounds, + 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 2719791e22..c57d274ea9 100644 --- a/crates/blockifier/src/fee/fee_test.rs +++ b/crates/blockifier/src/fee/fee_test.rs @@ -5,12 +5,7 @@ use starknet_api::block::{FeeType, GasPrice, NonzeroGasPrice}; use starknet_api::execution_resources::{GasAmount, GasVector}; use starknet_api::invoke_tx_args; use starknet_api::transaction::fields::{ - AllResourceBounds, - Fee, - GasVectorComputationMode, - Resource, - ResourceBounds, - ValidResourceBounds, + AllResourceBounds, Fee, GasVectorComputationMode, Resource, ResourceBounds, ValidResourceBounds, }; use crate::blockifier::block::validated_gas_prices; @@ -21,22 +16,12 @@ use crate::fee::receipt::TransactionReceipt; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; use crate::test_utils::{ - gas_vector_from_vm_usage, - get_vm_resource_usage, - CairoVersion, - BALANCE, - DEFAULT_ETH_L1_DATA_GAS_PRICE, - DEFAULT_ETH_L1_GAS_PRICE, - DEFAULT_L1_DATA_GAS_MAX_AMOUNT, - DEFAULT_L1_GAS_AMOUNT, - DEFAULT_L2_GAS_MAX_AMOUNT, - DEFAULT_STRK_L1_GAS_PRICE, + gas_vector_from_vm_usage, get_vm_resource_usage, CairoVersion, BALANCE, + DEFAULT_ETH_L1_DATA_GAS_PRICE, DEFAULT_ETH_L1_GAS_PRICE, DEFAULT_L1_DATA_GAS_MAX_AMOUNT, + DEFAULT_L1_GAS_AMOUNT, DEFAULT_L2_GAS_MAX_AMOUNT, DEFAULT_STRK_L1_GAS_PRICE, }; use crate::transaction::test_utils::{ - all_resource_bounds, - block_context, - invoke_tx_with_default_flags, - l1_resource_bounds, + all_resource_bounds, block_context, invoke_tx_with_default_flags, l1_resource_bounds, }; use crate::utils::u64_from_usize; use crate::versioned_constants::VersionedConstants; diff --git a/crates/blockifier/src/fee/gas_usage_test.rs b/crates/blockifier/src/fee/gas_usage_test.rs index f6fe3e315a..3ab516967a 100644 --- a/crates/blockifier/src/fee/gas_usage_test.rs +++ b/crates/blockifier/src/fee/gas_usage_test.rs @@ -17,16 +17,11 @@ use crate::fee::eth_gas_constants; use crate::fee::fee_utils::get_fee_by_gas_vector; use crate::fee::gas_usage::{get_da_gas_cost, get_message_segment_length}; use crate::fee::resources::{ - ComputationResources, - StarknetResources, - StateResources, - TransactionResources, + ComputationResources, StarknetResources, StateResources, TransactionResources, }; use crate::state::cached_state::StateChangesCount; use crate::test_utils::{ - get_vm_resource_usage, - DEFAULT_ETH_L1_DATA_GAS_PRICE, - DEFAULT_ETH_L1_GAS_PRICE, + get_vm_resource_usage, DEFAULT_ETH_L1_DATA_GAS_PRICE, DEFAULT_ETH_L1_GAS_PRICE, }; use crate::transaction::test_utils::invoke_tx_with_default_flags; use crate::utils::u64_from_usize; @@ -129,16 +124,14 @@ fn test_get_event_gas_cost( events: vec![create_event_for_testing(0, 1)], ..Default::default() }, - inner_calls: vec![ - CallInfo { - execution: CallExecution { - events: vec![create_event_for_testing(5, 5)], - ..Default::default() - }, + inner_calls: vec![CallInfo { + execution: CallExecution { + events: vec![create_event_for_testing(5, 5)], ..Default::default() - } - .with_some_class_hash(), - ], + }, + ..Default::default() + } + .with_some_class_hash()], ..Default::default() }; let call_infos: Vec = vec![call_info_1, call_info_2, call_info_3] diff --git a/crates/blockifier/src/fee/receipt.rs b/crates/blockifier/src/fee/receipt.rs index 0c7a13d4d9..6e24c15727 100644 --- a/crates/blockifier/src/fee/receipt.rs +++ b/crates/blockifier/src/fee/receipt.rs @@ -5,10 +5,7 @@ use starknet_api::transaction::fields::Fee; use crate::context::TransactionContext; use crate::execution::call_info::ExecutionSummary; use crate::fee::resources::{ - ComputationResources, - StarknetResources, - StateResources, - TransactionResources, + ComputationResources, StarknetResources, StateResources, TransactionResources, }; use crate::state::cached_state::StateChanges; use crate::transaction::account_transaction::AccountTransaction; diff --git a/crates/blockifier/src/fee/receipt_test.rs b/crates/blockifier/src/fee/receipt_test.rs index ae75a355a4..4dd7ea0db2 100644 --- a/crates/blockifier/src/fee/receipt_test.rs +++ b/crates/blockifier/src/fee/receipt_test.rs @@ -7,16 +7,11 @@ use starknet_types_core::felt::Felt; use crate::context::BlockContext; use crate::execution::call_info::{ - CallExecution, - CallInfo, - ExecutionSummary, - MessageToL1, - OrderedL2ToL1Message, + CallExecution, CallInfo, ExecutionSummary, MessageToL1, OrderedL2ToL1Message, }; use crate::fee::eth_gas_constants; use crate::fee::gas_usage::{ - get_consumed_message_to_l2_emissions_cost, - get_log_message_to_l1_emissions_cost, + get_consumed_message_to_l2_emissions_cost, get_log_message_to_l1_emissions_cost, get_message_segment_length, }; use crate::fee::resources::{StarknetResources, StateResources}; @@ -24,17 +19,11 @@ use crate::state::cached_state::StateChangesCount; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; use crate::test_utils::{ - create_calldata, - create_trivial_calldata, - CairoVersion, - RunnableCairo1, - BALANCE, + create_calldata, create_trivial_calldata, CairoVersion, RunnableCairo1, BALANCE, }; use crate::transaction::objects::HasRelatedFeeType; use crate::transaction::test_utils::{ - calculate_class_info_for_testing, - create_resource_bounds, - invoke_tx_with_default_flags, + calculate_class_info_for_testing, create_resource_bounds, invoke_tx_with_default_flags, }; use crate::transaction::transactions::ExecutableTransaction; use crate::utils::{u64_from_usize, usize_from_u64}; diff --git a/crates/blockifier/src/fee/resources.rs b/crates/blockifier/src/fee/resources.rs index edc1d9249e..aebc579fcc 100644 --- a/crates/blockifier/src/fee/resources.rs +++ b/crates/blockifier/src/fee/resources.rs @@ -7,10 +7,8 @@ use crate::execution::call_info::{EventSummary, ExecutionSummary}; use crate::fee::eth_gas_constants; use crate::fee::fee_utils::get_vm_resources_cost; use crate::fee::gas_usage::{ - get_consumed_message_to_l2_emissions_cost, - get_da_gas_cost, - get_log_message_to_l1_emissions_cost, - get_message_segment_length, + get_consumed_message_to_l2_emissions_cost, get_da_gas_cost, + get_log_message_to_l1_emissions_cost, get_message_segment_length, get_onchain_data_segment_length, }; use crate::state::cached_state::{StateChanges, StateChangesCountForFee}; diff --git a/crates/blockifier/src/state/cached_state.rs b/crates/blockifier/src/state/cached_state.rs index f7b2a6b9b6..8dc40ca38d 100644 --- a/crates/blockifier/src/state/cached_state.rs +++ b/crates/blockifier/src/state/cached_state.rs @@ -741,7 +741,11 @@ impl AllocatedKeys { .iter() .filter_map(|(k, v)| { let base_value = base_storage.get(k).unwrap_or(&Felt::ZERO); - if *v != Felt::ZERO && *base_value == Felt::ZERO { Some(*k) } else { None } + if *v != Felt::ZERO && *base_value == Felt::ZERO { + Some(*k) + } else { + None + } }) .collect(), ) diff --git a/crates/blockifier/src/state/cached_state_test.rs b/crates/blockifier/src/state/cached_state_test.rs index 160f1822fa..78d01a6107 100644 --- a/crates/blockifier/src/state/cached_state_test.rs +++ b/crates/blockifier/src/state/cached_state_test.rs @@ -6,13 +6,7 @@ use pretty_assertions::assert_eq; use rstest::rstest; use starknet_api::transaction::fields::{Fee, TransactionSignature, ValidResourceBounds}; use starknet_api::{ - class_hash, - compiled_class_hash, - contract_address, - felt, - invoke_tx_args, - nonce, - storage_key, + class_hash, compiled_class_hash, contract_address, felt, invoke_tx_args, nonce, storage_key, }; use crate::context::{BlockContext, ChainInfo}; @@ -382,7 +376,7 @@ fn test_state_cache_merge( assert_eq!(state_cache2, StateCache::default()); assert_eq!(StateCache::squash_state_caches(vec![&state_cache1, &state_cache2]), state_cache1); assert_eq!(StateCache::squash_state_caches(vec![&state_cache2, &state_cache1]), state_cache1); - + // Get the storage updates addresses and keys from the state_cache1, to overwrite. let state_changes1 = state_cache1.to_state_diff(); let mut storage_updates_keys = state_changes1.state_maps.storage.keys(); diff --git a/crates/blockifier/src/test_utils.rs b/crates/blockifier/src/test_utils.rs index 5d1265cf72..dca8884480 100644 --- a/crates/blockifier/src/test_utils.rs +++ b/crates/blockifier/src/test_utils.rs @@ -21,10 +21,7 @@ use starknet_api::execution_resources::{GasAmount, GasVector}; use starknet_api::hash::StarkHash; use starknet_api::state::StorageKey; use starknet_api::transaction::fields::{ - Calldata, - ContractAddressSalt, - Fee, - GasVectorComputationMode, + Calldata, ContractAddressSalt, Fee, GasVectorComputationMode, }; use starknet_api::transaction::TransactionVersion; use starknet_api::{contract_address, felt}; diff --git a/crates/blockifier/src/test_utils/contracts.rs b/crates/blockifier/src/test_utils/contracts.rs index e4128f7b84..8e14e902a6 100644 --- a/crates/blockifier/src/test_utils/contracts.rs +++ b/crates/blockifier/src/test_utils/contracts.rs @@ -8,8 +8,7 @@ use starknet_api::abi::constants::CONSTRUCTOR_ENTRY_POINT_NAME; use starknet_api::contract_class::{ContractClass, EntryPointType}; use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, EntryPointSelector}; use starknet_api::deprecated_contract_class::{ - ContractClass as DeprecatedContractClass, - EntryPointOffset, + ContractClass as DeprecatedContractClass, EntryPointOffset, }; use starknet_api::state::SierraContractClass; use starknet_api::{class_hash, contract_address, felt}; diff --git a/crates/blockifier/src/test_utils/struct_impls.rs b/crates/blockifier/src/test_utils/struct_impls.rs index fe9fdebff5..8995be676b 100644 --- a/crates/blockifier/src/test_utils/struct_impls.rs +++ b/crates/blockifier/src/test_utils/struct_impls.rs @@ -16,9 +16,7 @@ use starknet_api::core::{ChainId, ClassHash}; use starknet_api::deprecated_contract_class::ContractClass as DeprecatedContractClass; use super::{ - update_json_value, - TEST_ERC20_CONTRACT_ADDRESS, - TEST_ERC20_CONTRACT_ADDRESS2, + update_json_value, TEST_ERC20_CONTRACT_ADDRESS, TEST_ERC20_CONTRACT_ADDRESS2, TEST_SEQUENCER_ADDRESS, }; use crate::blockifier::block::validated_gas_prices; @@ -29,32 +27,21 @@ use crate::execution::common_hints::ExecutionMode; #[cfg(feature = "cairo_native")] use crate::execution::contract_class::CompiledClassV1; use crate::execution::entry_point::{ - CallEntryPoint, - EntryPointExecutionContext, - EntryPointExecutionResult, + CallEntryPoint, EntryPointExecutionContext, EntryPointExecutionResult, }; #[cfg(feature = "cairo_native")] use crate::execution::native::contract_class::NativeCompiledClassV1; use crate::state::state_api::State; use crate::test_utils::{ - get_raw_contract_class, - CURRENT_BLOCK_NUMBER, - CURRENT_BLOCK_TIMESTAMP, - DEFAULT_ETH_L1_DATA_GAS_PRICE, - DEFAULT_ETH_L1_GAS_PRICE, - DEFAULT_STRK_L1_DATA_GAS_PRICE, + get_raw_contract_class, CURRENT_BLOCK_NUMBER, CURRENT_BLOCK_TIMESTAMP, + DEFAULT_ETH_L1_DATA_GAS_PRICE, DEFAULT_ETH_L1_GAS_PRICE, DEFAULT_STRK_L1_DATA_GAS_PRICE, DEFAULT_STRK_L1_GAS_PRICE, }; use crate::transaction::objects::{ - CurrentTransactionInfo, - DeprecatedTransactionInfo, - TransactionInfo, + CurrentTransactionInfo, DeprecatedTransactionInfo, TransactionInfo, }; use crate::versioned_constants::{ - GasCosts, - OsConstants, - VersionedConstants, - VERSIONED_CONSTANTS_LATEST_JSON, + GasCosts, OsConstants, VersionedConstants, VERSIONED_CONSTANTS_LATEST_JSON, }; impl CallEntryPoint { diff --git a/crates/blockifier/src/transaction/account_transaction.rs b/crates/blockifier/src/transaction/account_transaction.rs index f5e02fed6c..3082cc0918 100644 --- a/crates/blockifier/src/transaction/account_transaction.rs +++ b/crates/blockifier/src/transaction/account_transaction.rs @@ -9,14 +9,8 @@ use starknet_api::data_availability::DataAvailabilityMode; use starknet_api::executable_transaction::AccountTransaction as Transaction; use starknet_api::transaction::fields::Resource::{L1DataGas, L1Gas, L2Gas}; use starknet_api::transaction::fields::{ - AccountDeploymentData, - AllResourceBounds, - Calldata, - Fee, - PaymasterData, - Tip, - TransactionSignature, - ValidResourceBounds, + AccountDeploymentData, AllResourceBounds, Calldata, Fee, PaymasterData, Tip, + TransactionSignature, ValidResourceBounds, }; use starknet_api::transaction::{constants, TransactionHash, TransactionVersion}; use starknet_types_core::felt::Felt; @@ -26,15 +20,11 @@ use crate::execution::call_info::CallInfo; use crate::execution::contract_class::RunnableCompiledClass; use crate::execution::entry_point::{CallEntryPoint, CallType, EntryPointExecutionContext}; use crate::execution::stack_trace::{ - extract_trailing_cairo1_revert_trace, - gen_tx_execution_error_trace, - Cairo1RevertHeader, + extract_trailing_cairo1_revert_trace, gen_tx_execution_error_trace, Cairo1RevertHeader, }; use crate::fee::fee_checks::{FeeCheckReportFields, PostExecutionReport}; use crate::fee::fee_utils::{ - get_fee_by_gas_vector, - get_sequencer_balance_keys, - verify_can_pay_committed_bounds, + get_fee_by_gas_vector, get_sequencer_balance_keys, verify_can_pay_committed_bounds, }; use crate::fee::gas_usage::estimate_minimal_gas_vector; use crate::fee::receipt::TransactionReceipt; @@ -42,27 +32,16 @@ use crate::retdata; use crate::state::cached_state::{StateCache, TransactionalState}; use crate::state::state_api::{State, StateReader, UpdatableState}; use crate::transaction::errors::{ - TransactionExecutionError, - TransactionFeeError, - TransactionPreValidationError, + TransactionExecutionError, TransactionFeeError, TransactionPreValidationError, }; use crate::transaction::objects::{ - DeprecatedTransactionInfo, - HasRelatedFeeType, - RevertError, - TransactionExecutionInfo, - TransactionExecutionResult, - TransactionInfo, - TransactionInfoCreator, - TransactionInfoCreatorInner, - TransactionPreValidationResult, + DeprecatedTransactionInfo, HasRelatedFeeType, RevertError, TransactionExecutionInfo, + TransactionExecutionResult, TransactionInfo, TransactionInfoCreator, + TransactionInfoCreatorInner, TransactionPreValidationResult, }; use crate::transaction::transaction_types::TransactionType; use crate::transaction::transactions::{ - enforce_fee, - Executable, - ExecutableTransaction, - ValidatableTransaction, + enforce_fee, Executable, ExecutableTransaction, ValidatableTransaction, }; #[cfg(test)] @@ -697,7 +676,11 @@ impl AccountTransaction { /// Returns 0 on non-declare transactions; for declare transactions, returns the class code /// size. pub(crate) fn declare_code_size(&self) -> usize { - if let Transaction::Declare(tx) = &self.tx { tx.class_info.code_size() } else { 0 } + if let Transaction::Declare(tx) = &self.tx { + tx.class_info.code_size() + } else { + 0 + } } fn is_non_revertible(&self, tx_info: &TransactionInfo) -> bool { diff --git a/crates/blockifier/src/transaction/account_transactions_test.rs b/crates/blockifier/src/transaction/account_transactions_test.rs index c902dd7c70..1037b6a153 100644 --- a/crates/blockifier/src/transaction/account_transactions_test.rs +++ b/crates/blockifier/src/transaction/account_transactions_test.rs @@ -7,9 +7,7 @@ use num_traits::Inv; use pretty_assertions::{assert_eq, assert_ne}; use rstest::rstest; use starknet_api::abi::abi_utils::{ - get_fee_token_var_address, - get_storage_var_address, - selector_from_name, + get_fee_token_var_address, get_storage_var_address, selector_from_name, }; use starknet_api::block::{FeeType, GasPrice}; use starknet_api::core::{calculate_contract_address, ClassHash, ContractAddress}; @@ -26,31 +24,15 @@ use starknet_api::test_utils::invoke::{executable_invoke_tx, InvokeTxArgs}; use starknet_api::test_utils::NonceManager; use starknet_api::transaction::constants::TRANSFER_ENTRY_POINT_NAME; use starknet_api::transaction::fields::{ - AllResourceBounds, - Calldata, - ContractAddressSalt, - Fee, - GasVectorComputationMode, - Resource, - ResourceBounds, - ValidResourceBounds, + AllResourceBounds, Calldata, ContractAddressSalt, Fee, GasVectorComputationMode, Resource, + ResourceBounds, ValidResourceBounds, }; use starknet_api::transaction::{ - DeclareTransaction, - DeclareTransactionV2, - TransactionHash, - TransactionVersion, + DeclareTransaction, DeclareTransactionV2, TransactionHash, TransactionVersion, }; use starknet_api::{ - calldata, - class_hash, - contract_address, - declare_tx_args, - deploy_account_tx_args, - felt, - invoke_tx_args, - nonce, - storage_key, + calldata, class_hash, contract_address, declare_tx_args, deploy_account_tx_args, felt, + invoke_tx_args, nonce, storage_key, }; use starknet_types_core::felt::Felt; @@ -68,44 +50,21 @@ use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::{fund_account, test_state}; use crate::test_utils::syscall::build_recurse_calldata; use crate::test_utils::{ - create_calldata, - create_trivial_calldata, - get_syscall_resources, - get_tx_resources, - CairoVersion, - CompilerBasedVersion, - RunnableCairo1, - BALANCE, - DEFAULT_L1_DATA_GAS_MAX_AMOUNT, - DEFAULT_L1_GAS_AMOUNT, - DEFAULT_L2_GAS_MAX_AMOUNT, - DEFAULT_STRK_L1_DATA_GAS_PRICE, - DEFAULT_STRK_L1_GAS_PRICE, - DEFAULT_STRK_L2_GAS_PRICE, - MAX_FEE, + create_calldata, create_trivial_calldata, get_syscall_resources, get_tx_resources, + CairoVersion, CompilerBasedVersion, RunnableCairo1, BALANCE, DEFAULT_L1_DATA_GAS_MAX_AMOUNT, + DEFAULT_L1_GAS_AMOUNT, DEFAULT_L2_GAS_MAX_AMOUNT, DEFAULT_STRK_L1_DATA_GAS_PRICE, + DEFAULT_STRK_L1_GAS_PRICE, DEFAULT_STRK_L2_GAS_PRICE, MAX_FEE, }; use crate::transaction::account_transaction::{ - AccountTransaction, - ExecutionFlags as AccountExecutionFlags, + AccountTransaction, ExecutionFlags as AccountExecutionFlags, }; use crate::transaction::objects::{HasRelatedFeeType, TransactionInfoCreator}; use crate::transaction::test_utils::{ - all_resource_bounds, - block_context, - calculate_class_info_for_testing, - create_account_tx_for_validate_test_nonce_0, - create_all_resource_bounds, - create_test_init_data, - default_all_resource_bounds, - default_l1_resource_bounds, - deploy_and_fund_account, - invoke_tx_with_default_flags, - l1_resource_bounds, - max_fee, - run_invoke_tx, - FaultyAccountTxCreatorArgs, - TestInitData, - INVALID, + all_resource_bounds, block_context, calculate_class_info_for_testing, + create_account_tx_for_validate_test_nonce_0, create_all_resource_bounds, create_test_init_data, + default_all_resource_bounds, default_l1_resource_bounds, deploy_and_fund_account, + invoke_tx_with_default_flags, l1_resource_bounds, max_fee, run_invoke_tx, + FaultyAccountTxCreatorArgs, TestInitData, INVALID, }; use crate::transaction::transaction_types::TransactionType; use crate::transaction::transactions::ExecutableTransaction; @@ -426,13 +385,11 @@ fn test_infinite_recursion( if success { assert!(tx_execution_info.revert_error.is_none()); } else { - assert!( - tx_execution_info - .revert_error - .unwrap() - .to_string() - .contains("RunResources has no remaining steps.") - ); + assert!(tx_execution_info + .revert_error + .unwrap() + .to_string() + .contains("RunResources has no remaining steps.")); } } @@ -642,14 +599,12 @@ fn test_recursion_depth_exceeded( InvokeTxArgs { calldata, nonce: nonce_manager.next(account_address), ..invoke_args }; let tx_execution_info = run_invoke_tx(&mut state, &block_context, invoke_args); - assert!( - tx_execution_info - .unwrap() - .revert_error - .unwrap() - .to_string() - .contains("recursion depth exceeded") - ); + assert!(tx_execution_info + .unwrap() + .revert_error + .unwrap() + .to_string() + .contains("recursion depth exceeded")); } #[rstest] @@ -1251,13 +1206,11 @@ fn test_insufficient_max_fee_reverts( // snapping to bounds). assert_eq!(tx_execution_info2.receipt.da_gas, tx_execution_info1.receipt.da_gas); assert_eq!(tx_execution_info2.receipt.fee, tx_execution_info1.receipt.fee); - assert!( - tx_execution_info2 - .revert_error - .unwrap() - .to_string() - .contains(&format!("Insufficient max {overdraft_resource}")) - ); + assert!(tx_execution_info2 + .revert_error + .unwrap() + .to_string() + .contains(&format!("Insufficient max {overdraft_resource}"))); // Invoke the `recurse` function with depth of 824 and the actual fee of depth 1 as max_fee. // This call should fail due to no remaining steps (execution steps based on max_fee are bounded @@ -1788,13 +1741,11 @@ fn test_revert_in_execute( let tx_execution_info = account_tx.execute(state, &block_context).unwrap(); assert!(tx_execution_info.is_reverted()); - assert!( - tx_execution_info - .revert_error - .unwrap() - .to_string() - .contains("Failed to deserialize param #1") - ); + assert!(tx_execution_info + .revert_error + .unwrap() + .to_string() + .contains("Failed to deserialize param #1")); } #[rstest] diff --git a/crates/blockifier/src/transaction/execution_flavors_test.rs b/crates/blockifier/src/transaction/execution_flavors_test.rs index e13abc1a1d..1301213098 100644 --- a/crates/blockifier/src/transaction/execution_flavors_test.rs +++ b/crates/blockifier/src/transaction/execution_flavors_test.rs @@ -7,12 +7,7 @@ use starknet_api::execution_resources::{GasAmount, GasVector}; use starknet_api::test_utils::invoke::{executable_invoke_tx, InvokeTxArgs}; use starknet_api::test_utils::NonceManager; use starknet_api::transaction::fields::{ - Calldata, - Fee, - GasVectorComputationMode, - Resource, - TransactionSignature, - ValidResourceBounds, + Calldata, Fee, GasVectorComputationMode, Resource, TransactionSignature, ValidResourceBounds, }; use starknet_api::transaction::TransactionVersion; use starknet_api::{felt, invoke_tx_args, nonce}; @@ -27,28 +22,16 @@ use crate::test_utils::contracts::FeatureContract; use crate::test_utils::dict_state_reader::DictStateReader; use crate::test_utils::initial_test_state::test_state; use crate::test_utils::{ - create_calldata, - create_trivial_calldata, - get_syscall_resources, - get_tx_resources, - CairoVersion, - BALANCE, - DEFAULT_L1_GAS_AMOUNT, - DEFAULT_STRK_L1_GAS_PRICE, - MAX_FEE, + create_calldata, create_trivial_calldata, get_syscall_resources, get_tx_resources, + CairoVersion, BALANCE, DEFAULT_L1_GAS_AMOUNT, DEFAULT_STRK_L1_GAS_PRICE, MAX_FEE, }; use crate::transaction::account_transaction::{AccountTransaction, ExecutionFlags}; use crate::transaction::errors::{ - TransactionExecutionError, - TransactionFeeError, - TransactionPreValidationError, + TransactionExecutionError, TransactionFeeError, TransactionPreValidationError, }; use crate::transaction::objects::{TransactionExecutionInfo, TransactionExecutionResult}; use crate::transaction::test_utils::{ - default_l1_resource_bounds, - invoke_tx_with_default_flags, - l1_resource_bounds, - INVALID, + default_l1_resource_bounds, invoke_tx_with_default_flags, l1_resource_bounds, INVALID, }; use crate::transaction::transaction_types::TransactionType; use crate::transaction::transactions::ExecutableTransaction; @@ -496,19 +479,17 @@ fn test_simulate_charge_fee_with_validation_fail_validate( default_l1_resource_bounds: ValidResourceBounds, ) { let validate = true; - assert!( - execute_fail_validation( - only_query, - validate, - charge_fee, - cairo_version, - version, - default_l1_resource_bounds, - ) - .unwrap_err() - .to_string() - .contains("An ASSERT_EQ instruction failed: 1 != 0.") - ); + assert!(execute_fail_validation( + only_query, + validate, + charge_fee, + cairo_version, + version, + default_l1_resource_bounds, + ) + .unwrap_err() + .to_string() + .contains("An ASSERT_EQ instruction failed: 1 != 0.")); } /// Test gas and fee with simulate / charge_fee flag combinations in (fallible) validation stage, @@ -660,14 +641,12 @@ fn test_simulate_validate_charge_fee_mid_execution( let tx_execution_info = account_tx.execute(&mut state, &block_context).unwrap(); assert_eq!(tx_execution_info.is_reverted(), charge_fee); if charge_fee { - assert!( - tx_execution_info - .revert_error - .clone() - .unwrap() - .to_string() - .contains("no remaining steps") - ); + assert!(tx_execution_info + .revert_error + .clone() + .unwrap() + .to_string() + .contains("no remaining steps")); } check_gas_and_fee( &block_context, @@ -715,9 +694,12 @@ fn test_simulate_validate_charge_fee_mid_execution( execution_flags: ExecutionFlags { only_query, charge_fee, validate }, }; let tx_execution_info = account_tx.execute(&mut state, &low_step_block_context).unwrap(); - assert!( - tx_execution_info.revert_error.clone().unwrap().to_string().contains("no remaining steps") - ); + assert!(tx_execution_info + .revert_error + .clone() + .unwrap() + .to_string() + .contains("no remaining steps")); // Complete resources used are reported as receipt.resources; but only the charged // final fee is shown in actual_fee. As a sanity check, verify that the fee derived directly // from the consumed resources is also equal to the expected fee. @@ -869,14 +851,12 @@ fn test_simulate_validate_charge_fee_post_execution( assert_eq!(tx_execution_info.is_reverted(), charge_fee); if charge_fee { - assert!( - tx_execution_info - .revert_error - .clone() - .unwrap() - .to_string() - .contains("Insufficient fee token balance.") - ); + assert!(tx_execution_info + .revert_error + .clone() + .unwrap() + .to_string() + .contains("Insufficient fee token balance.")); } check_gas_and_fee( &block_context, diff --git a/crates/blockifier/src/transaction/objects.rs b/crates/blockifier/src/transaction/objects.rs index 4cfef890e6..1d450514e4 100644 --- a/crates/blockifier/src/transaction/objects.rs +++ b/crates/blockifier/src/transaction/objects.rs @@ -7,21 +7,11 @@ use starknet_api::core::{ContractAddress, Nonce}; use starknet_api::data_availability::DataAvailabilityMode; use starknet_api::execution_resources::GasVector; use starknet_api::transaction::fields::{ - AccountDeploymentData, - AllResourceBounds, - Fee, - GasVectorComputationMode, - PaymasterData, - ResourceBounds, - Tip, - TransactionSignature, - ValidResourceBounds, + AccountDeploymentData, AllResourceBounds, Fee, GasVectorComputationMode, PaymasterData, + ResourceBounds, Tip, TransactionSignature, ValidResourceBounds, }; use starknet_api::transaction::{ - signed_tx_version, - TransactionHash, - TransactionOptions, - TransactionVersion, + signed_tx_version, TransactionHash, TransactionOptions, TransactionVersion, }; use crate::abi::constants as abi_constants; diff --git a/crates/blockifier/src/transaction/objects_test.rs b/crates/blockifier/src/transaction/objects_test.rs index 29ef00aed6..a4c7a972ae 100644 --- a/crates/blockifier/src/transaction/objects_test.rs +++ b/crates/blockifier/src/transaction/objects_test.rs @@ -7,14 +7,8 @@ use starknet_api::{class_hash, contract_address, storage_key}; use starknet_types_core::felt::Felt; use crate::execution::call_info::{ - CallExecution, - CallInfo, - ChargedResources, - EventSummary, - ExecutionSummary, - MessageToL1, - OrderedEvent, - OrderedL2ToL1Message, + CallExecution, CallInfo, ChargedResources, EventSummary, ExecutionSummary, MessageToL1, + OrderedEvent, OrderedL2ToL1Message, }; use crate::execution::entry_point::CallEntryPoint; use crate::transaction::objects::TransactionExecutionInfo; diff --git a/crates/blockifier/src/transaction/post_execution_test.rs b/crates/blockifier/src/transaction/post_execution_test.rs index 8718ee7bb9..1a85386b6e 100644 --- a/crates/blockifier/src/transaction/post_execution_test.rs +++ b/crates/blockifier/src/transaction/post_execution_test.rs @@ -5,12 +5,7 @@ use starknet_api::core::ContractAddress; use starknet_api::execution_resources::GasAmount; use starknet_api::state::StorageKey; use starknet_api::transaction::fields::{ - AllResourceBounds, - Calldata, - Fee, - GasVectorComputationMode, - Resource, - ResourceBounds, + AllResourceBounds, Calldata, Fee, GasVectorComputationMode, Resource, ResourceBounds, ValidResourceBounds, }; use starknet_api::transaction::TransactionVersion; @@ -23,26 +18,16 @@ use crate::state::state_api::StateReader; use crate::test_utils::contracts::FeatureContract; use crate::test_utils::initial_test_state::test_state; use crate::test_utils::{ - create_calldata, - CairoVersion, - BALANCE, - DEFAULT_STRK_L1_DATA_GAS_PRICE, - DEFAULT_STRK_L1_GAS_PRICE, - DEFAULT_STRK_L2_GAS_PRICE, + create_calldata, CairoVersion, BALANCE, DEFAULT_STRK_L1_DATA_GAS_PRICE, + DEFAULT_STRK_L1_GAS_PRICE, DEFAULT_STRK_L2_GAS_PRICE, }; use crate::transaction::account_transaction::AccountTransaction; use crate::transaction::errors::TransactionExecutionError; use crate::transaction::objects::{HasRelatedFeeType, TransactionInfoCreator}; use crate::transaction::test_utils::{ - block_context, - create_all_resource_bounds, - default_all_resource_bounds, - default_l1_resource_bounds, - invoke_tx_with_default_flags, - l1_resource_bounds, - max_fee, - run_invoke_tx, - TestInitData, + block_context, create_all_resource_bounds, default_all_resource_bounds, + default_l1_resource_bounds, invoke_tx_with_default_flags, l1_resource_bounds, max_fee, + run_invoke_tx, TestInitData, }; use crate::transaction::transactions::ExecutableTransaction; use crate::versioned_constants::AllocationCost; @@ -196,13 +181,11 @@ fn test_revert_on_overdraft( // Verify the execution was reverted (including nonce bump) with the correct error. assert!(execution_info.is_reverted()); - assert!( - execution_info - .revert_error - .unwrap() - .to_string() - .starts_with("Insufficient fee token balance") - ); + assert!(execution_info + .revert_error + .unwrap() + .to_string() + .starts_with("Insufficient fee token balance")); assert_eq!(state.get_nonce_at(account_address).unwrap(), nonce_manager.next(account_address)); // Verify the storage key/value were not updated in the last tx. @@ -407,14 +390,12 @@ fn test_revert_on_resource_overuse( &format!("Insufficient max {}", resource_to_decrement.unwrap()) }; if is_revertible { - assert!( - execution_info_result - .unwrap() - .revert_error - .unwrap() - .to_string() - .starts_with(expected_error_prefix) - ); + assert!(execution_info_result + .unwrap() + .revert_error + .unwrap() + .to_string() + .starts_with(expected_error_prefix)); } else { assert_matches!( execution_info_result.unwrap_err(), diff --git a/crates/blockifier/src/transaction/test_utils.rs b/crates/blockifier/src/transaction/test_utils.rs index f19affdd2b..8eb560d3f7 100644 --- a/crates/blockifier/src/transaction/test_utils.rs +++ b/crates/blockifier/src/transaction/test_utils.rs @@ -9,13 +9,8 @@ use starknet_api::test_utils::deploy_account::{executable_deploy_account_tx, Dep use starknet_api::test_utils::invoke::{executable_invoke_tx, InvokeTxArgs}; use starknet_api::test_utils::NonceManager; use starknet_api::transaction::fields::{ - AllResourceBounds, - ContractAddressSalt, - Fee, - GasVectorComputationMode, - ResourceBounds, - TransactionSignature, - ValidResourceBounds, + AllResourceBounds, ContractAddressSalt, Fee, GasVectorComputationMode, ResourceBounds, + TransactionSignature, ValidResourceBounds, }; use starknet_api::transaction::{constants, TransactionVersion}; use starknet_api::{calldata, declare_tx_args, deploy_account_tx_args, felt, invoke_tx_args}; @@ -29,16 +24,9 @@ use crate::test_utils::contracts::FeatureContract; use crate::test_utils::dict_state_reader::DictStateReader; use crate::test_utils::initial_test_state::test_state; use crate::test_utils::{ - create_calldata, - CairoVersion, - BALANCE, - DEFAULT_L1_DATA_GAS_MAX_AMOUNT, - DEFAULT_L1_GAS_AMOUNT, - DEFAULT_L2_GAS_MAX_AMOUNT, - DEFAULT_STRK_L1_DATA_GAS_PRICE, - DEFAULT_STRK_L1_GAS_PRICE, - DEFAULT_STRK_L2_GAS_PRICE, - MAX_FEE, + create_calldata, CairoVersion, BALANCE, DEFAULT_L1_DATA_GAS_MAX_AMOUNT, DEFAULT_L1_GAS_AMOUNT, + DEFAULT_L2_GAS_MAX_AMOUNT, DEFAULT_STRK_L1_DATA_GAS_PRICE, DEFAULT_STRK_L1_GAS_PRICE, + DEFAULT_STRK_L2_GAS_PRICE, MAX_FEE, }; use crate::transaction::account_transaction::{AccountTransaction, ExecutionFlags}; use crate::transaction::objects::{TransactionExecutionInfo, TransactionExecutionResult}; diff --git a/crates/blockifier/src/transaction/transaction_execution.rs b/crates/blockifier/src/transaction/transaction_execution.rs index 19f2675867..312cfbbf4f 100644 --- a/crates/blockifier/src/transaction/transaction_execution.rs +++ b/crates/blockifier/src/transaction/transaction_execution.rs @@ -3,11 +3,8 @@ use std::sync::Arc; use starknet_api::contract_class::ClassInfo; use starknet_api::core::{calculate_contract_address, ContractAddress, Nonce}; use starknet_api::executable_transaction::{ - AccountTransaction as ApiExecutableTransaction, - DeclareTransaction, - DeployAccountTransaction, - InvokeTransaction, - L1HandlerTransaction, + AccountTransaction as ApiExecutableTransaction, DeclareTransaction, DeployAccountTransaction, + InvokeTransaction, L1HandlerTransaction, }; use starknet_api::transaction::fields::Fee; use starknet_api::transaction::{Transaction as StarknetApiTransaction, TransactionHash}; @@ -20,15 +17,11 @@ use crate::fee::receipt::TransactionReceipt; use crate::state::cached_state::TransactionalState; use crate::state::state_api::UpdatableState; use crate::transaction::account_transaction::{ - AccountTransaction, - ExecutionFlags as AccountExecutionFlags, + AccountTransaction, ExecutionFlags as AccountExecutionFlags, }; use crate::transaction::errors::TransactionFeeError; use crate::transaction::objects::{ - TransactionExecutionInfo, - TransactionExecutionResult, - TransactionInfo, - TransactionInfoCreator, + TransactionExecutionInfo, TransactionExecutionResult, TransactionInfo, TransactionInfoCreator, }; use crate::transaction::transactions::{Executable, ExecutableTransaction}; diff --git a/crates/blockifier/src/transaction/transactions.rs b/crates/blockifier/src/transaction/transactions.rs index b6cb607500..e3f00ed3dd 100644 --- a/crates/blockifier/src/transaction/transactions.rs +++ b/crates/blockifier/src/transaction/transactions.rs @@ -4,32 +4,20 @@ use starknet_api::abi::abi_utils::selector_from_name; use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress}; use starknet_api::executable_transaction::{ - AccountTransaction, - DeclareTransaction, - DeployAccountTransaction, - InvokeTransaction, + AccountTransaction, DeclareTransaction, DeployAccountTransaction, InvokeTransaction, L1HandlerTransaction, }; use starknet_api::transaction::fields::{ - AccountDeploymentData, - Calldata, - Fee, - TransactionSignature, + AccountDeploymentData, Calldata, Fee, TransactionSignature, }; use starknet_api::transaction::{ - constants, - DeclareTransactionV2, - DeclareTransactionV3, - TransactionVersion, + constants, DeclareTransactionV2, DeclareTransactionV3, TransactionVersion, }; use crate::context::{BlockContext, TransactionContext}; use crate::execution::call_info::CallInfo; use crate::execution::entry_point::{ - CallEntryPoint, - CallType, - ConstructorContext, - EntryPointExecutionContext, + CallEntryPoint, CallType, ConstructorContext, EntryPointExecutionContext, }; use crate::execution::execution_utils::execute_deployment; use crate::state::cached_state::TransactionalState; @@ -37,14 +25,8 @@ use crate::state::errors::StateError; use crate::state::state_api::{State, UpdatableState}; use crate::transaction::errors::TransactionExecutionError; use crate::transaction::objects::{ - CommonAccountFields, - CurrentTransactionInfo, - DeprecatedTransactionInfo, - HasRelatedFeeType, - TransactionExecutionInfo, - TransactionExecutionResult, - TransactionInfo, - TransactionInfoCreator, + CommonAccountFields, CurrentTransactionInfo, DeprecatedTransactionInfo, HasRelatedFeeType, + TransactionExecutionInfo, TransactionExecutionResult, TransactionInfo, TransactionInfoCreator, TransactionInfoCreatorInner, }; #[cfg(test)] diff --git a/crates/blockifier/src/transaction/transactions_test.rs b/crates/blockifier/src/transaction/transactions_test.rs index 479ba7104a..1bf7266837 100644 --- a/crates/blockifier/src/transaction/transactions_test.rs +++ b/crates/blockifier/src/transaction/transactions_test.rs @@ -8,9 +8,7 @@ use num_bigint::BigUint; use pretty_assertions::assert_eq; use rstest::{fixture, rstest}; use starknet_api::abi::abi_utils::{ - get_fee_token_var_address, - get_storage_var_address, - selector_from_name, + get_fee_token_var_address, get_storage_var_address, selector_from_name, }; use starknet_api::abi::constants::CONSTRUCTOR_ENTRY_POINT_NAME; use starknet_api::block::{FeeType, GasPriceVector}; @@ -25,47 +23,24 @@ use starknet_api::test_utils::invoke::{executable_invoke_tx, InvokeTxArgs}; use starknet_api::test_utils::NonceManager; use starknet_api::transaction::fields::Resource::{L1DataGas, L1Gas, L2Gas}; use starknet_api::transaction::fields::{ - AllResourceBounds, - Calldata, - Fee, - GasVectorComputationMode, - Resource, - ResourceBounds, - TransactionSignature, - ValidResourceBounds, + AllResourceBounds, Calldata, Fee, GasVectorComputationMode, Resource, ResourceBounds, + TransactionSignature, ValidResourceBounds, }; use starknet_api::transaction::{ - constants, - EventContent, - EventData, - EventKey, - L2ToL1Payload, - TransactionVersion, + constants, EventContent, EventData, EventKey, L2ToL1Payload, TransactionVersion, QUERY_VERSION_BASE, }; use starknet_api::{ - calldata, - class_hash, - contract_address, - declare_tx_args, - deploy_account_tx_args, - felt, - invoke_tx_args, - nonce, + calldata, class_hash, contract_address, declare_tx_args, deploy_account_tx_args, felt, + invoke_tx_args, nonce, }; use starknet_types_core::felt::Felt; use strum::IntoEnumIterator; use crate::context::{BlockContext, ChainInfo, FeeTokenAddresses, TransactionContext}; use crate::execution::call_info::{ - CallExecution, - CallInfo, - ChargedResources, - ExecutionSummary, - MessageToL1, - OrderedEvent, - OrderedL2ToL1Message, - Retdata, + CallExecution, CallInfo, ChargedResources, ExecutionSummary, MessageToL1, OrderedEvent, + OrderedL2ToL1Message, Retdata, }; use crate::execution::contract_class::TrackedResource; use crate::execution::entry_point::{CallEntryPoint, CallType}; @@ -74,16 +49,11 @@ use crate::execution::syscalls::hint_processor::EmitEventError; use crate::execution::syscalls::SyscallSelector; use crate::fee::fee_utils::{balance_to_big_uint, get_fee_by_gas_vector}; use crate::fee::gas_usage::{ - estimate_minimal_gas_vector, - get_da_gas_cost, - get_onchain_data_segment_length, + estimate_minimal_gas_vector, get_da_gas_cost, get_onchain_data_segment_length, }; use crate::fee::receipt::TransactionReceipt; use crate::fee::resources::{ - ComputationResources, - StarknetResources, - StateResources, - TransactionResources, + ComputationResources, StarknetResources, StateResources, TransactionResources, }; use crate::state::cached_state::{CachedState, StateChangesCount, TransactionalState}; use crate::state::errors::StateError; @@ -94,66 +64,33 @@ use crate::test_utils::initial_test_state::test_state; use crate::test_utils::l1_handler::l1handler_tx; use crate::test_utils::prices::Prices; use crate::test_utils::{ - create_calldata, - create_trivial_calldata, - get_syscall_resources, - get_tx_resources, - test_erc20_sequencer_balance_key, - CairoVersion, - RunnableCairo1, - SaltManager, - BALANCE, - CURRENT_BLOCK_NUMBER, - CURRENT_BLOCK_NUMBER_FOR_VALIDATE, - CURRENT_BLOCK_TIMESTAMP, - CURRENT_BLOCK_TIMESTAMP_FOR_VALIDATE, - DEFAULT_L1_DATA_GAS_MAX_AMOUNT, - DEFAULT_L1_GAS_AMOUNT, - DEFAULT_L2_GAS_MAX_AMOUNT, - DEFAULT_STRK_L1_DATA_GAS_PRICE, - DEFAULT_STRK_L1_GAS_PRICE, - DEFAULT_STRK_L2_GAS_PRICE, - MAX_FEE, - TEST_SEQUENCER_ADDRESS, + create_calldata, create_trivial_calldata, get_syscall_resources, get_tx_resources, + test_erc20_sequencer_balance_key, CairoVersion, RunnableCairo1, SaltManager, BALANCE, + CURRENT_BLOCK_NUMBER, CURRENT_BLOCK_NUMBER_FOR_VALIDATE, CURRENT_BLOCK_TIMESTAMP, + CURRENT_BLOCK_TIMESTAMP_FOR_VALIDATE, DEFAULT_L1_DATA_GAS_MAX_AMOUNT, DEFAULT_L1_GAS_AMOUNT, + DEFAULT_L2_GAS_MAX_AMOUNT, DEFAULT_STRK_L1_DATA_GAS_PRICE, DEFAULT_STRK_L1_GAS_PRICE, + DEFAULT_STRK_L2_GAS_PRICE, MAX_FEE, TEST_SEQUENCER_ADDRESS, }; use crate::transaction::account_transaction::{AccountTransaction, ExecutionFlags}; use crate::transaction::errors::{ - TransactionExecutionError, - TransactionFeeError, - TransactionPreValidationError, + TransactionExecutionError, TransactionFeeError, TransactionPreValidationError, }; use crate::transaction::objects::{ - HasRelatedFeeType, - TransactionExecutionInfo, - TransactionInfo, - TransactionInfoCreator, + HasRelatedFeeType, TransactionExecutionInfo, TransactionInfo, TransactionInfoCreator, }; use crate::transaction::test_utils::{ - block_context, - calculate_class_info_for_testing, - create_account_tx_for_validate_test, - create_account_tx_for_validate_test_nonce_0, - create_all_resource_bounds, - default_all_resource_bounds, - default_l1_resource_bounds, - invoke_tx_with_default_flags, - l1_resource_bounds, - FaultyAccountTxCreatorArgs, - CALL_CONTRACT, - GET_BLOCK_HASH, - GET_BLOCK_NUMBER, - GET_BLOCK_TIMESTAMP, - GET_EXECUTION_INFO, - GET_SEQUENCER_ADDRESS, - INVALID, + block_context, calculate_class_info_for_testing, create_account_tx_for_validate_test, + create_account_tx_for_validate_test_nonce_0, create_all_resource_bounds, + default_all_resource_bounds, default_l1_resource_bounds, invoke_tx_with_default_flags, + l1_resource_bounds, FaultyAccountTxCreatorArgs, CALL_CONTRACT, GET_BLOCK_HASH, + GET_BLOCK_NUMBER, GET_BLOCK_TIMESTAMP, GET_EXECUTION_INFO, GET_SEQUENCER_ADDRESS, INVALID, VALID, }; use crate::transaction::transaction_types::TransactionType; use crate::transaction::transactions::ExecutableTransaction; use crate::versioned_constants::{AllocationCost, VersionedConstants}; use crate::{ - check_tx_execution_error_for_custom_hint, - check_tx_execution_error_for_invalid_scenario, + check_tx_execution_error_for_custom_hint, check_tx_execution_error_for_invalid_scenario, retdata, }; @@ -209,11 +146,19 @@ fn expected_validate_call_info( usize::from(entry_point_selector_name == constants::VALIDATE_ENTRY_POINT_NAME) } CairoVersion::Cairo1(RunnableCairo1::Casm) => { - if entry_point_selector_name == constants::VALIDATE_ENTRY_POINT_NAME { 7 } else { 2 } + if entry_point_selector_name == constants::VALIDATE_ENTRY_POINT_NAME { + 7 + } else { + 2 + } } #[cfg(feature = "cairo_native")] CairoVersion::Cairo1(RunnableCairo1::Native) => { - if entry_point_selector_name == constants::VALIDATE_ENTRY_POINT_NAME { 7 } else { 2 } + if entry_point_selector_name == constants::VALIDATE_ENTRY_POINT_NAME { + 7 + } else { + 2 + } } }; let n_steps = match (entry_point_selector_name, cairo_version) { @@ -1372,9 +1317,9 @@ fn test_actual_fee_gt_resource_bounds( // Test error and that fee was charged. Should be at most the fee charged in a successful // execution. - assert!( - execution_error.to_string().starts_with(&format!("Insufficient max {overdraft_resource}")) - ); + assert!(execution_error + .to_string() + .starts_with(&format!("Insufficient max {overdraft_resource}"))); assert_eq!(execution_result.receipt.fee, expected_fee); } @@ -2425,7 +2370,7 @@ fn test_l1_handler(#[values(false, true)] use_kzg_da: bool) { state.set_storage_at(contract_address, StorageKey::try_from(key).unwrap(), Felt::ZERO).unwrap(); let tx_no_fee = l1handler_tx(Fee(0), contract_address); let error = tx_no_fee.execute(state, block_context).unwrap_err(); // Do not charge fee as L1Handler's resource bounds (/max fee) is 0. - // Today, we check that the paid_fee is positive, no matter what was the actual fee. + // Today, we check that the paid_fee is positive, no matter what was the actual fee. let expected_actual_fee = get_fee_by_gas_vector(&block_context.block_info, total_gas, &FeeType::Eth); @@ -2462,13 +2407,11 @@ fn test_execute_tx_with_invalid_tx_version( }); let execution_info = account_tx.execute(state, block_context).unwrap(); - assert!( - execution_info - .revert_error - .unwrap() - .to_string() - .contains(format!("ASSERT_EQ instruction failed: {} != 3.", invalid_version).as_str()) - ); + assert!(execution_info + .revert_error + .unwrap() + .to_string() + .contains(format!("ASSERT_EQ instruction failed: {} != 3.", invalid_version).as_str())); } fn max_n_emitted_events() -> usize { diff --git a/crates/blockifier/src/versioned_constants.rs b/crates/blockifier/src/versioned_constants.rs index 1bf86ff6df..25fb444600 100644 --- a/crates/blockifier/src/versioned_constants.rs +++ b/crates/blockifier/src/versioned_constants.rs @@ -152,7 +152,11 @@ impl AllocationCost { AllocationCost { blob_cost: GasVector::ZERO, gas_cost: GasVector::ZERO }; pub fn get_cost(&self, use_kzg_da: bool) -> &GasVector { - if use_kzg_da { &self.blob_cost } else { &self.gas_cost } + if use_kzg_da { + &self.blob_cost + } else { + &self.gas_cost + } } } diff --git a/crates/blockifier/tests/feature_contracts_compatibility_test.rs b/crates/blockifier/tests/feature_contracts_compatibility_test.rs index c8ec6f41eb..d89a3526d1 100644 --- a/crates/blockifier/tests/feature_contracts_compatibility_test.rs +++ b/crates/blockifier/tests/feature_contracts_compatibility_test.rs @@ -1,13 +1,10 @@ use std::fs; use blockifier::test_utils::cairo_compile::{ - prepare_group_tag_compiler_deps, - CompilationArtifacts, + prepare_group_tag_compiler_deps, CompilationArtifacts, }; use blockifier::test_utils::contracts::{ - FeatureContract, - CAIRO1_FEATURE_CONTRACTS_DIR, - SIERRA_CONTRACTS_SUBDIR, + FeatureContract, CAIRO1_FEATURE_CONTRACTS_DIR, SIERRA_CONTRACTS_SUBDIR, }; use blockifier::test_utils::{CairoVersion, RunnableCairo1}; use pretty_assertions::assert_eq; diff --git a/crates/blockifier_reexecution/src/main.rs b/crates/blockifier_reexecution/src/main.rs index fa99d0ecc2..2cdc9b346c 100644 --- a/crates/blockifier_reexecution/src/main.rs +++ b/crates/blockifier_reexecution/src/main.rs @@ -4,11 +4,8 @@ use std::path::Path; use blockifier_reexecution::state_reader::offline_state_reader::OfflineConsecutiveStateReaders; use blockifier_reexecution::state_reader::test_state_reader::ConsecutiveTestStateReaders; use blockifier_reexecution::state_reader::utils::{ - get_block_numbers_for_reexecution, - guess_chain_id_from_node_url, - reexecute_and_verify_correctness, - write_block_reexecution_data_to_file, - JSON_RPC_VERSION, + get_block_numbers_for_reexecution, guess_chain_id_from_node_url, + reexecute_and_verify_correctness, write_block_reexecution_data_to_file, JSON_RPC_VERSION, }; use clap::{Args, Parser, Subcommand}; use google_cloud_storage::client::{Client, ClientConfig}; diff --git a/crates/blockifier_reexecution/src/state_reader/compile.rs b/crates/blockifier_reexecution/src/state_reader/compile.rs index 4088dcea60..2650ec8d87 100644 --- a/crates/blockifier_reexecution/src/state_reader/compile.rs +++ b/crates/blockifier_reexecution/src/state_reader/compile.rs @@ -13,16 +13,11 @@ use serde::Deserialize; use starknet_api::contract_class::{ContractClass, EntryPointType}; use starknet_api::core::EntryPointSelector; use starknet_api::deprecated_contract_class::{ - ContractClass as DeprecatedContractClass, - EntryPointOffset, - EntryPointV0, - Program, + ContractClass as DeprecatedContractClass, EntryPointOffset, EntryPointV0, Program, }; use starknet_api::hash::StarkHash; use starknet_core::types::{ - CompressedLegacyContractClass, - FlattenedSierraClass, - LegacyContractEntryPoint, + CompressedLegacyContractClass, FlattenedSierraClass, LegacyContractEntryPoint, LegacyEntryPointsByType, }; use starknet_gateway::errors::serde_err_to_state_err; diff --git a/crates/blockifier_reexecution/src/state_reader/offline_state_reader.rs b/crates/blockifier_reexecution/src/state_reader/offline_state_reader.rs index d3f9b3ce89..080e043581 100644 --- a/crates/blockifier_reexecution/src/state_reader/offline_state_reader.rs +++ b/crates/blockifier_reexecution/src/state_reader/offline_state_reader.rs @@ -22,8 +22,7 @@ use starknet_types_core::felt::Felt; use crate::state_reader::compile::{legacy_to_contract_class_v0, sierra_to_contact_class_v1}; use crate::state_reader::errors::ReexecutionResult; use crate::state_reader::reexecution_state_reader::{ - ConsecutiveReexecutionStateReaders, - ReexecutionStateReader, + ConsecutiveReexecutionStateReaders, ReexecutionStateReader, }; use crate::state_reader::test_state_reader::StarknetContractClassMapping; use crate::state_reader::utils::{get_chain_info, ReexecutionStateMaps}; diff --git a/crates/blockifier_reexecution/src/state_reader/raw_rpc_json_test.rs b/crates/blockifier_reexecution/src/state_reader/raw_rpc_json_test.rs index 04a422b9c8..5886820bb7 100644 --- a/crates/blockifier_reexecution/src/state_reader/raw_rpc_json_test.rs +++ b/crates/blockifier_reexecution/src/state_reader/raw_rpc_json_test.rs @@ -7,10 +7,7 @@ use rstest::{fixture, rstest}; use starknet_api::block::{BlockInfo, BlockNumber}; use starknet_api::test_utils::read_json_file; use starknet_api::transaction::{ - DeclareTransaction, - DeployAccountTransaction, - InvokeTransaction, - Transaction, + DeclareTransaction, DeployAccountTransaction, InvokeTransaction, Transaction, }; use starknet_api::{class_hash, compiled_class_hash, contract_address, felt, nonce, storage_key}; use starknet_core::types::ContractClass; diff --git a/crates/blockifier_reexecution/src/state_reader/rpc_https_test.rs b/crates/blockifier_reexecution/src/state_reader/rpc_https_test.rs index 55e48c3911..2d863c440a 100644 --- a/crates/blockifier_reexecution/src/state_reader/rpc_https_test.rs +++ b/crates/blockifier_reexecution/src/state_reader/rpc_https_test.rs @@ -18,10 +18,7 @@ use starknet_api::block::{BlockInfo, BlockNumber}; use starknet_api::class_hash; use starknet_api::core::ChainId; use starknet_api::transaction::{ - DeclareTransaction, - DeployAccountTransaction, - Transaction, - TransactionVersion, + DeclareTransaction, DeployAccountTransaction, Transaction, TransactionVersion, }; use starknet_core::types::ContractClass::{Legacy, Sierra}; use starknet_gateway::config::RpcStateReaderConfig; diff --git a/crates/blockifier_reexecution/src/state_reader/serde_utils.rs b/crates/blockifier_reexecution/src/state_reader/serde_utils.rs index 95d5f4937a..564813d809 100644 --- a/crates/blockifier_reexecution/src/state_reader/serde_utils.rs +++ b/crates/blockifier_reexecution/src/state_reader/serde_utils.rs @@ -2,10 +2,7 @@ use indexmap::IndexMap; use serde::Deserialize; use serde_json::Value; use starknet_api::transaction::{ - DeclareTransaction, - DeployAccountTransaction, - InvokeTransaction, - Transaction, + DeclareTransaction, DeployAccountTransaction, InvokeTransaction, Transaction, }; use crate::state_reader::errors::ReexecutionResult; 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 a17432379a..533669f56a 100644 --- a/crates/blockifier_reexecution/src/state_reader/test_state_reader.rs +++ b/crates/blockifier_reexecution/src/state_reader/test_state_reader.rs @@ -23,10 +23,7 @@ use starknet_core::types::ContractClass as StarknetContractClass; use starknet_gateway::config::RpcStateReaderConfig; use starknet_gateway::errors::{serde_err_to_state_err, RPCStateReaderError}; use starknet_gateway::rpc_objects::{ - BlockHeader, - BlockId, - GetBlockWithTxHashesParams, - ResourcePrice, + BlockHeader, BlockId, GetBlockWithTxHashesParams, ResourcePrice, }; use starknet_gateway::rpc_state_reader::RpcStateReader; use starknet_types_core::felt::Felt; @@ -36,18 +33,13 @@ use crate::state_reader::compile::{legacy_to_contract_class_v0, sierra_to_contac use crate::state_reader::errors::ReexecutionResult; use crate::state_reader::offline_state_reader::SerializableDataNextBlock; use crate::state_reader::reexecution_state_reader::{ - ConsecutiveReexecutionStateReaders, - ReexecutionStateReader, + ConsecutiveReexecutionStateReaders, ReexecutionStateReader, }; use crate::state_reader::serde_utils::{ - deserialize_transaction_json_to_starknet_api_tx, - hashmap_from_raw, - nested_hashmap_from_raw, + deserialize_transaction_json_to_starknet_api_tx, hashmap_from_raw, nested_hashmap_from_raw, }; use crate::state_reader::utils::{ - disjoint_hashmap_union, - get_chain_info, - get_rpc_state_reader_config, + disjoint_hashmap_union, get_chain_info, get_rpc_state_reader_config, }; pub const DEFAULT_RETRY_COUNT: usize = 3; diff --git a/crates/blockifier_reexecution/src/state_reader/utils.rs b/crates/blockifier_reexecution/src/state_reader/utils.rs index 3742e1e033..e615ed755f 100644 --- a/crates/blockifier_reexecution/src/state_reader/utils.rs +++ b/crates/blockifier_reexecution/src/state_reader/utils.rs @@ -20,9 +20,7 @@ use starknet_types_core::felt::Felt; use crate::assert_eq_state_diff; use crate::state_reader::errors::{ReexecutionError, ReexecutionResult}; use crate::state_reader::offline_state_reader::{ - OfflineConsecutiveStateReaders, - SerializableDataPrevBlock, - SerializableOfflineReexecutionData, + OfflineConsecutiveStateReaders, SerializableDataPrevBlock, SerializableOfflineReexecutionData, }; use crate::state_reader::reexecution_state_reader::ConsecutiveReexecutionStateReaders; use crate::state_reader::test_state_reader::ConsecutiveTestStateReaders; diff --git a/crates/committer_cli/src/block_hash.rs b/crates/committer_cli/src/block_hash.rs index ba4418ecbf..cb9f9a5cf4 100644 --- a/crates/committer_cli/src/block_hash.rs +++ b/crates/committer_cli/src/block_hash.rs @@ -1,8 +1,7 @@ use serde::Deserialize; use starknet_api::block::{BlockHeaderWithoutHash, StarknetVersion}; use starknet_api::block_hash::block_hash_calculator::{ - BlockHeaderCommitments, - TransactionHashingData, + BlockHeaderCommitments, TransactionHashingData, }; use starknet_api::data_availability::L1DataAvailabilityMode; use starknet_api::state::ThinStateDiff; diff --git a/crates/committer_cli/src/main.rs b/crates/committer_cli/src/main.rs index 4cb7116bfb..c46969f5e6 100644 --- a/crates/committer_cli/src/main.rs +++ b/crates/committer_cli/src/main.rs @@ -5,8 +5,7 @@ use committer_cli::parse_input::read::{load_from_stdin, read_from_stdin, write_t use committer_cli::tests::python_tests::PythonTest; use committer_cli::tracing_utils::configure_tracing; use starknet_api::block_hash::block_hash_calculator::{ - calculate_block_commitments, - calculate_block_hash, + calculate_block_commitments, calculate_block_hash, }; use tracing::info; diff --git a/crates/committer_cli/src/parse_input/cast.rs b/crates/committer_cli/src/parse_input/cast.rs index 155cd9db3c..39e68dd656 100644 --- a/crates/committer_cli/src/parse_input/cast.rs +++ b/crates/committer_cli/src/parse_input/cast.rs @@ -1,12 +1,7 @@ use std::collections::HashMap; use starknet_committer::block_committer::input::{ - ConfigImpl, - ContractAddress, - Input, - StarknetStorageKey, - StarknetStorageValue, - StateDiff, + ConfigImpl, ContractAddress, Input, StarknetStorageKey, StarknetStorageValue, StateDiff, }; use starknet_committer::patricia_merkle_tree::types::{ClassHash, CompiledClassHash, Nonce}; use starknet_patricia::felt::Felt; diff --git a/crates/committer_cli/src/parse_input/read_test.rs b/crates/committer_cli/src/parse_input/read_test.rs index 781d17d43f..0e8770ad5c 100644 --- a/crates/committer_cli/src/parse_input/read_test.rs +++ b/crates/committer_cli/src/parse_input/read_test.rs @@ -2,12 +2,7 @@ use std::collections::HashMap; use pretty_assertions::assert_eq; use starknet_committer::block_committer::input::{ - ConfigImpl, - ContractAddress, - Input, - StarknetStorageKey, - StarknetStorageValue, - StateDiff, + ConfigImpl, ContractAddress, Input, StarknetStorageKey, StarknetStorageValue, StateDiff, }; use starknet_committer::patricia_merkle_tree::types::{ClassHash, CompiledClassHash, Nonce}; use starknet_patricia::felt::Felt; diff --git a/crates/committer_cli/src/tests/python_tests.rs b/crates/committer_cli/src/tests/python_tests.rs index 1ed5e4d21d..003d99b413 100644 --- a/crates/committer_cli/src/tests/python_tests.rs +++ b/crates/committer_cli/src/tests/python_tests.rs @@ -4,16 +4,12 @@ use std::fmt::Debug; use ethnum::U256; use serde_json::json; use starknet_api::block_hash::block_hash_calculator::{ - TransactionHashingData, - TransactionOutputForHash, + TransactionHashingData, TransactionOutputForHash, }; use starknet_api::state::ThinStateDiff; use starknet_api::transaction::TransactionExecutionStatus; use starknet_committer::block_committer::input::{ - ContractAddress, - StarknetStorageKey, - StarknetStorageValue, - StateDiff, + ContractAddress, StarknetStorageKey, StarknetStorageValue, StateDiff, }; use starknet_committer::forest::filled_forest::FilledForest; use starknet_committer::hash_function::hash::TreeHashFunctionImpl; @@ -25,11 +21,7 @@ use starknet_patricia::hash::hash_trait::HashOutput; use starknet_patricia::patricia_merkle_tree::external_test_utils::single_tree_flow_test; use starknet_patricia::patricia_merkle_tree::filled_tree::node::FilledNode; use starknet_patricia::patricia_merkle_tree::node_data::inner_node::{ - BinaryData, - EdgeData, - EdgePathLength, - NodeData, - PathToBottom, + BinaryData, EdgeData, EdgePathLength, NodeData, PathToBottom, }; use starknet_patricia::patricia_merkle_tree::types::SubTreeHeight; use starknet_patricia::storage::db_object::DBObject; diff --git a/crates/committer_cli/src/tests/utils/objects.rs b/crates/committer_cli/src/tests/utils/objects.rs index 25bcb4ef6e..b56a34eb77 100644 --- a/crates/committer_cli/src/tests/utils/objects.rs +++ b/crates/committer_cli/src/tests/utils/objects.rs @@ -1,29 +1,16 @@ use indexmap::indexmap; use starknet_api::block_hash::block_hash_calculator::{ - TransactionHashingData, - TransactionOutputForHash, + TransactionHashingData, TransactionOutputForHash, }; use starknet_api::core::{ - ClassHash, - CompiledClassHash, - ContractAddress, - EthAddress, - Nonce, - PatriciaKey, + ClassHash, CompiledClassHash, ContractAddress, EthAddress, Nonce, PatriciaKey, }; use starknet_api::execution_resources::{GasAmount, GasVector}; use starknet_api::state::{StorageKey, ThinStateDiff}; use starknet_api::transaction::fields::{Fee, TransactionSignature}; use starknet_api::transaction::{ - Event, - EventContent, - EventData, - EventKey, - L2ToL1Payload, - MessageToL1, - RevertedTransactionExecutionStatus, - TransactionExecutionStatus, - TransactionHash, + Event, EventContent, EventData, EventKey, L2ToL1Payload, MessageToL1, + RevertedTransactionExecutionStatus, TransactionExecutionStatus, TransactionHash, }; use starknet_types_core::felt::Felt; diff --git a/crates/committer_cli/src/tests/utils/random_structs.rs b/crates/committer_cli/src/tests/utils/random_structs.rs index 5f175acb93..6a6009cf05 100644 --- a/crates/committer_cli/src/tests/utils/random_structs.rs +++ b/crates/committer_cli/src/tests/utils/random_structs.rs @@ -10,26 +10,15 @@ use starknet_committer::block_committer::input::{ContractAddress, StarknetStorag use starknet_committer::forest::filled_forest::FilledForest; use starknet_committer::patricia_merkle_tree::leaf::leaf_impl::ContractState; use starknet_committer::patricia_merkle_tree::types::{ - ClassHash, - ClassesTrie, - CompiledClassHash, - ContractsTrie, - Nonce, - StorageTrie, - StorageTrieMap, + ClassHash, ClassesTrie, CompiledClassHash, ContractsTrie, Nonce, StorageTrie, StorageTrieMap, }; use starknet_patricia::felt::Felt; use starknet_patricia::hash::hash_trait::HashOutput; use starknet_patricia::patricia_merkle_tree::external_test_utils::get_random_u256; use starknet_patricia::patricia_merkle_tree::filled_tree::node::FilledNode; use starknet_patricia::patricia_merkle_tree::node_data::inner_node::{ - BinaryData, - EdgeData, - EdgePath, - EdgePathLength, - NodeData, - NodeDataDiscriminants as NodeDataVariants, - PathToBottom, + BinaryData, EdgeData, EdgePath, EdgePathLength, NodeData, + NodeDataDiscriminants as NodeDataVariants, PathToBottom, }; use starknet_patricia::patricia_merkle_tree::types::NodeIndex; use strum::IntoEnumIterator; 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 ba46f766cc..1697f655f9 100644 --- a/crates/mempool_test_utils/src/starknet_api_test_utils.rs +++ b/crates/mempool_test_utils/src/starknet_api_test_utils.rs @@ -21,11 +21,7 @@ use starknet_api::test_utils::deploy_account::rpc_deploy_account_tx; use starknet_api::test_utils::invoke::{rpc_invoke_tx, InvokeTxArgs}; use starknet_api::test_utils::NonceManager; use starknet_api::transaction::fields::{ - AllResourceBounds, - ContractAddressSalt, - ResourceBounds, - Tip, - TransactionSignature, + AllResourceBounds, ContractAddressSalt, ResourceBounds, Tip, TransactionSignature, ValidResourceBounds, }; use starknet_api::{declare_tx_args, deploy_account_tx_args, felt, invoke_tx_args, nonce}; diff --git a/crates/native_blockifier/src/errors.rs b/crates/native_blockifier/src/errors.rs index 2128f41748..c6835614e6 100644 --- a/crates/native_blockifier/src/errors.rs +++ b/crates/native_blockifier/src/errors.rs @@ -3,9 +3,7 @@ use blockifier::blockifier::transaction_executor::TransactionExecutorError; use blockifier::bouncer::BuiltinCount; use blockifier::state::errors::StateError; use blockifier::transaction::errors::{ - ParseError, - TransactionExecutionError, - TransactionPreValidationError, + ParseError, TransactionExecutionError, TransactionPreValidationError, }; use blockifier::transaction::transaction_types::TransactionType; use cairo_vm::types::errors::program_errors::ProgramError; diff --git a/crates/native_blockifier/src/lib.rs b/crates/native_blockifier/src/lib.rs index 0524d52fa3..33913a2a70 100644 --- a/crates/native_blockifier/src/lib.rs +++ b/crates/native_blockifier/src/lib.rs @@ -32,8 +32,7 @@ use crate::py_objects::PyVersionedConstantsOverrides; use crate::py_state_diff::PyStateDiff; use crate::py_testing_wrappers::{ estimate_casm_hash_computation_resources_for_testing_list, - estimate_casm_hash_computation_resources_for_testing_single, - raise_error_for_testing, + estimate_casm_hash_computation_resources_for_testing_single, raise_error_for_testing, }; #[pymodule] diff --git a/crates/native_blockifier/src/py_block_executor.rs b/crates/native_blockifier/src/py_block_executor.rs index d515e3a2da..22e294824f 100644 --- a/crates/native_blockifier/src/py_block_executor.rs +++ b/crates/native_blockifier/src/py_block_executor.rs @@ -28,19 +28,14 @@ use starknet_types_core::felt::Felt; use crate::errors::{NativeBlockifierError, NativeBlockifierResult}; use crate::py_objects::{ - PyBouncerConfig, - PyConcurrencyConfig, - PyContractClassManagerConfig, + PyBouncerConfig, PyConcurrencyConfig, PyContractClassManagerConfig, PyVersionedConstantsOverrides, }; use crate::py_state_diff::{PyBlockInfo, PyStateDiff}; use crate::py_transaction::{py_tx, PyClassInfo, PY_TX_PARSING_ERR}; use crate::py_utils::{int_to_chain_id, into_block_number_hash_pair, PyFelt}; use crate::storage::{ - PapyrusStorage, - RawDeclaredClassMapping, - RawDeprecatedDeclaredClassMapping, - Storage, + PapyrusStorage, RawDeclaredClassMapping, RawDeprecatedDeclaredClassMapping, Storage, StorageConfig, }; diff --git a/crates/native_blockifier/src/py_declare.rs b/crates/native_blockifier/src/py_declare.rs index 55cf53c4be..8b058c6741 100644 --- a/crates/native_blockifier/src/py_declare.rs +++ b/crates/native_blockifier/src/py_declare.rs @@ -6,17 +6,10 @@ use starknet_api::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce}; use starknet_api::data_availability::DataAvailabilityMode; use starknet_api::executable_transaction::DeclareTransaction; use starknet_api::transaction::fields::{ - AccountDeploymentData, - Fee, - PaymasterData, - Tip, - TransactionSignature, + AccountDeploymentData, Fee, PaymasterData, Tip, TransactionSignature, }; use starknet_api::transaction::{ - DeclareTransactionV0V1, - DeclareTransactionV2, - DeclareTransactionV3, - TransactionHash, + DeclareTransactionV0V1, DeclareTransactionV2, DeclareTransactionV3, TransactionHash, }; use starknet_types_core::felt::Felt; diff --git a/crates/native_blockifier/src/py_deploy_account.rs b/crates/native_blockifier/src/py_deploy_account.rs index 9d4dbdb930..246dad3f2b 100644 --- a/crates/native_blockifier/src/py_deploy_account.rs +++ b/crates/native_blockifier/src/py_deploy_account.rs @@ -6,17 +6,10 @@ use starknet_api::core::{ClassHash, ContractAddress, Nonce}; use starknet_api::data_availability::DataAvailabilityMode; use starknet_api::executable_transaction::DeployAccountTransaction; use starknet_api::transaction::fields::{ - Calldata, - ContractAddressSalt, - Fee, - PaymasterData, - Tip, - TransactionSignature, + Calldata, ContractAddressSalt, Fee, PaymasterData, Tip, TransactionSignature, }; use starknet_api::transaction::{ - DeployAccountTransactionV1, - DeployAccountTransactionV3, - TransactionHash, + DeployAccountTransactionV1, DeployAccountTransactionV3, TransactionHash, }; use starknet_types_core::felt::Felt; diff --git a/crates/native_blockifier/src/py_invoke_function.rs b/crates/native_blockifier/src/py_invoke_function.rs index bad90021ca..c00e2e89a4 100644 --- a/crates/native_blockifier/src/py_invoke_function.rs +++ b/crates/native_blockifier/src/py_invoke_function.rs @@ -7,18 +7,10 @@ use starknet_api::core::{ContractAddress, EntryPointSelector, Nonce}; use starknet_api::data_availability::DataAvailabilityMode; use starknet_api::executable_transaction::InvokeTransaction; use starknet_api::transaction::fields::{ - AccountDeploymentData, - Calldata, - Fee, - PaymasterData, - Tip, - TransactionSignature, + AccountDeploymentData, Calldata, Fee, PaymasterData, Tip, TransactionSignature, }; use starknet_api::transaction::{ - InvokeTransactionV0, - InvokeTransactionV1, - InvokeTransactionV3, - TransactionHash, + InvokeTransactionV0, InvokeTransactionV1, InvokeTransactionV3, TransactionHash, }; use starknet_types_core::felt::Felt; diff --git a/crates/native_blockifier/src/py_objects.rs b/crates/native_blockifier/src/py_objects.rs index d2390eeaec..6222c9475b 100644 --- a/crates/native_blockifier/src/py_objects.rs +++ b/crates/native_blockifier/src/py_objects.rs @@ -13,9 +13,7 @@ use pyo3::prelude::*; use starknet_api::execution_resources::GasAmount; use crate::errors::{ - InvalidNativeBlockifierInputError, - NativeBlockifierError, - NativeBlockifierInputError, + InvalidNativeBlockifierInputError, NativeBlockifierError, NativeBlockifierInputError, NativeBlockifierResult, }; diff --git a/crates/native_blockifier/src/py_state_diff.rs b/crates/native_blockifier/src/py_state_diff.rs index 76a6063cbe..7d15b07fcd 100644 --- a/crates/native_blockifier/src/py_state_diff.rs +++ b/crates/native_blockifier/src/py_state_diff.rs @@ -4,9 +4,7 @@ use std::convert::TryFrom; use blockifier::blockifier::block::validated_gas_prices; use blockifier::state::cached_state::CommitmentStateDiff; use blockifier::test_utils::{ - DEFAULT_ETH_L1_DATA_GAS_PRICE, - DEFAULT_ETH_L1_GAS_PRICE, - DEFAULT_STRK_L1_DATA_GAS_PRICE, + DEFAULT_ETH_L1_DATA_GAS_PRICE, DEFAULT_ETH_L1_GAS_PRICE, DEFAULT_STRK_L1_DATA_GAS_PRICE, DEFAULT_STRK_L1_GAS_PRICE, }; use blockifier::versioned_constants::VersionedConstants; @@ -18,9 +16,7 @@ use starknet_api::core::{ClassHash, ContractAddress, Nonce}; use starknet_api::state::{StateDiff, StorageKey}; use crate::errors::{ - InvalidNativeBlockifierInputError, - NativeBlockifierError, - NativeBlockifierInputError, + InvalidNativeBlockifierInputError, NativeBlockifierError, NativeBlockifierInputError, NativeBlockifierResult, }; use crate::py_utils::PyFelt; diff --git a/crates/native_blockifier/src/py_transaction.rs b/crates/native_blockifier/src/py_transaction.rs index 10fc32a1d1..28c23da222 100644 --- a/crates/native_blockifier/src/py_transaction.rs +++ b/crates/native_blockifier/src/py_transaction.rs @@ -10,10 +10,7 @@ use starknet_api::contract_class::{ClassInfo, ContractClass, SierraVersion}; use starknet_api::executable_transaction::AccountTransaction as ExecutableTransaction; use starknet_api::execution_resources::GasAmount; use starknet_api::transaction::fields::{ - DeprecatedResourceBoundsMapping, - Resource, - ResourceBounds, - ValidResourceBounds, + DeprecatedResourceBoundsMapping, Resource, ResourceBounds, ValidResourceBounds, }; use starknet_api::StarknetApiError; diff --git a/crates/native_blockifier/src/state_readers/py_state_reader.rs b/crates/native_blockifier/src/state_readers/py_state_reader.rs index 35cdde1d91..a4916020e3 100644 --- a/crates/native_blockifier/src/state_readers/py_state_reader.rs +++ b/crates/native_blockifier/src/state_readers/py_state_reader.rs @@ -1,7 +1,5 @@ use blockifier::execution::contract_class::{ - CompiledClassV0, - CompiledClassV1, - RunnableCompiledClass, + CompiledClassV0, CompiledClassV1, RunnableCompiledClass, }; use blockifier::state::errors::StateError; use blockifier::state::state_api::{StateReader, StateResult}; @@ -11,9 +9,7 @@ use starknet_api::state::StorageKey; use starknet_types_core::felt::Felt; use crate::errors::{ - NativeBlockifierError, - NativeBlockifierInputError, - NativeBlockifierResult, + NativeBlockifierError, NativeBlockifierInputError, NativeBlockifierResult, UndeclaredClassHashError, }; use crate::py_utils::PyFelt; diff --git a/crates/papyrus_common/src/python_json.rs b/crates/papyrus_common/src/python_json.rs index 220a874bb0..69649fe8e5 100644 --- a/crates/papyrus_common/src/python_json.rs +++ b/crates/papyrus_common/src/python_json.rs @@ -11,7 +11,11 @@ impl Formatter for PythonJsonFormatter { W: ?Sized + Write, { CompactFormatter.begin_array_value(writer, first)?; - if first { Ok(()) } else { writer.write_all(b" ") } + if first { + Ok(()) + } else { + writer.write_all(b" ") + } } fn begin_object_key(&mut self, writer: &mut W, first: bool) -> IOResult<()> @@ -19,7 +23,11 @@ impl Formatter for PythonJsonFormatter { W: ?Sized + Write, { CompactFormatter.begin_object_key(writer, first)?; - if first { Ok(()) } else { writer.write_all(b" ") } + if first { + Ok(()) + } else { + writer.write_all(b" ") + } } fn begin_object_value(&mut self, writer: &mut W) -> IOResult<()> diff --git a/crates/papyrus_config/src/config_test.rs b/crates/papyrus_config/src/config_test.rs index cdcdcd8a51..d5ba39df85 100644 --- a/crates/papyrus_config/src/config_test.rs +++ b/crates/papyrus_config/src/config_test.rs @@ -17,36 +17,18 @@ use validator::Validate; use crate::command::{get_command_matches, update_config_map_by_command_args}; use crate::converters::deserialize_milliseconds_to_duration; use crate::dumping::{ - append_sub_config_name, - combine_config_map_and_pointers, - generate_struct_pointer, - required_param_description, - ser_generated_param, - ser_optional_param, - ser_optional_sub_config, - ser_param, - ser_pointer_target_param, - ser_pointer_target_required_param, - ser_required_param, - set_pointing_param_paths, - SerializeConfig, + append_sub_config_name, combine_config_map_and_pointers, generate_struct_pointer, + required_param_description, ser_generated_param, ser_optional_param, ser_optional_sub_config, + ser_param, ser_pointer_target_param, ser_pointer_target_required_param, ser_required_param, + set_pointing_param_paths, SerializeConfig, }; use crate::loading::{ - load, - load_and_process_config, - split_pointers_map, - split_values_and_types, - update_config_map_by_pointers, - update_optional_values, + load, load_and_process_config, split_pointers_map, split_values_and_types, + update_config_map_by_pointers, update_optional_values, }; use crate::presentation::get_config_presentation; use crate::{ - ConfigError, - ParamPath, - ParamPrivacy, - ParamPrivacyInput, - SerializationType, - SerializedContent, + ConfigError, ParamPath, ParamPrivacy, ParamPrivacyInput, SerializationType, SerializedContent, SerializedParam, }; diff --git a/crates/papyrus_config/src/dumping.rs b/crates/papyrus_config/src/dumping.rs index 1acddda112..f452ddaee4 100644 --- a/crates/papyrus_config/src/dumping.rs +++ b/crates/papyrus_config/src/dumping.rs @@ -43,15 +43,8 @@ use serde::Serialize; use serde_json::{json, Value}; use crate::{ - ConfigError, - ParamPath, - ParamPrivacy, - ParamPrivacyInput, - SerializationType, - SerializedContent, - SerializedParam, - FIELD_SEPARATOR, - IS_NONE_MARK, + ConfigError, ParamPath, ParamPrivacy, ParamPrivacyInput, SerializationType, SerializedContent, + SerializedParam, FIELD_SEPARATOR, IS_NONE_MARK, }; /// Type alias for a pointer parameter and its serialized representation. diff --git a/crates/papyrus_config/src/loading.rs b/crates/papyrus_config/src/loading.rs index 50df585217..ec9bd4cb87 100644 --- a/crates/papyrus_config/src/loading.rs +++ b/crates/papyrus_config/src/loading.rs @@ -18,12 +18,7 @@ use serde_json::{json, Map, Value}; use crate::validators::validate_path_exists; use crate::{ - command, - ConfigError, - ParamPath, - SerializationType, - SerializedContent, - SerializedParam, + command, ConfigError, ParamPath, SerializationType, SerializedContent, SerializedParam, IS_NONE_MARK, }; diff --git a/crates/papyrus_execution/src/execution_test.rs b/crates/papyrus_execution/src/execution_test.rs index f100c7d1fa..04296ff61e 100644 --- a/crates/papyrus_execution/src/execution_test.rs +++ b/crates/papyrus_execution/src/execution_test.rs @@ -21,37 +21,19 @@ use starknet_types_core::felt::Felt; use crate::execution_utils::selector_from_name; use crate::objects::{ - DeclareTransactionTrace, - DeployAccountTransactionTrace, - FeeEstimation, - FunctionInvocationResult, - InvokeTransactionTrace, - PriceUnit, - TransactionSimulationOutput, + DeclareTransactionTrace, DeployAccountTransactionTrace, FeeEstimation, + FunctionInvocationResult, InvokeTransactionTrace, PriceUnit, TransactionSimulationOutput, TransactionTrace, }; use crate::test_utils::{ - execute_simulate_transactions, - prepare_storage, - TxsScenarioBuilder, - ACCOUNT_ADDRESS, - ACCOUNT_CLASS_HASH, - ACCOUNT_INITIAL_BALANCE, - CHAIN_ID, - CONTRACT_ADDRESS, - DEPRECATED_CONTRACT_ADDRESS, - GAS_PRICE, - NEW_ACCOUNT_ADDRESS, - SEQUENCER_ADDRESS, + execute_simulate_transactions, prepare_storage, TxsScenarioBuilder, ACCOUNT_ADDRESS, + ACCOUNT_CLASS_HASH, ACCOUNT_INITIAL_BALANCE, CHAIN_ID, CONTRACT_ADDRESS, + DEPRECATED_CONTRACT_ADDRESS, GAS_PRICE, NEW_ACCOUNT_ADDRESS, SEQUENCER_ADDRESS, TEST_ERC20_CONTRACT_ADDRESS, }; use crate::testing_instances::get_test_execution_config; use crate::{ - estimate_fee, - execute_call, - ExecutableTransactionInput, - ExecutionError, - FeeEstimationResult, + estimate_fee, execute_call, ExecutableTransactionInput, ExecutionError, FeeEstimationResult, RevertedTransaction, }; diff --git a/crates/papyrus_execution/src/execution_utils.rs b/crates/papyrus_execution/src/execution_utils.rs index 9a6f34ffb7..51bc4bbba6 100644 --- a/crates/papyrus_execution/src/execution_utils.rs +++ b/crates/papyrus_execution/src/execution_utils.rs @@ -3,9 +3,7 @@ use std::fs::File; use std::path::PathBuf; use blockifier::execution::contract_class::{ - CompiledClassV0, - CompiledClassV1, - RunnableCompiledClass, + CompiledClassV0, CompiledClassV1, RunnableCompiledClass, }; use blockifier::state::cached_state::{CachedState, CommitmentStateDiff, MutRefState}; use blockifier::state::state_api::StateReader; @@ -27,11 +25,7 @@ use thiserror::Error; use crate::objects::TransactionTrace; use crate::state_reader::ExecutionStateReader; use crate::{ - BlockifierError, - ExecutableTransactionInput, - ExecutionConfig, - ExecutionError, - ExecutionResult, + BlockifierError, ExecutableTransactionInput, ExecutionConfig, ExecutionError, ExecutionResult, }; // An error that can occur during the use of the execution utils. diff --git a/crates/papyrus_execution/src/lib.rs b/crates/papyrus_execution/src/lib.rs index bb16e097a8..4b47931bde 100644 --- a/crates/papyrus_execution/src/lib.rs +++ b/crates/papyrus_execution/src/lib.rs @@ -27,17 +27,13 @@ use blockifier::bouncer::BouncerConfig; use blockifier::context::{BlockContext, ChainInfo, FeeTokenAddresses, TransactionContext}; use blockifier::execution::call_info::CallExecution; use blockifier::execution::entry_point::{ - CallEntryPoint, - CallType as BlockifierCallType, - EntryPointExecutionContext, + CallEntryPoint, CallType as BlockifierCallType, EntryPointExecutionContext, }; use blockifier::state::cached_state::CachedState; use blockifier::transaction::account_transaction::ExecutionFlags; use blockifier::transaction::errors::TransactionExecutionError as BlockifierTransactionExecutionError; use blockifier::transaction::objects::{ - DeprecatedTransactionInfo, - TransactionExecutionInfo, - TransactionInfo, + DeprecatedTransactionInfo, TransactionExecutionInfo, TransactionInfo, }; use blockifier::transaction::transaction_execution::Transaction as BlockifierTransaction; use blockifier::transaction::transactions::ExecutableTransaction; @@ -52,11 +48,7 @@ use papyrus_storage::header::HeaderStorageReader; use papyrus_storage::{StorageError, StorageReader}; use serde::{Deserialize, Serialize}; use starknet_api::block::{ - BlockHashAndNumber, - BlockInfo, - BlockNumber, - NonzeroGasPrice, - StarknetVersion, + BlockHashAndNumber, BlockInfo, BlockNumber, NonzeroGasPrice, StarknetVersion, }; use starknet_api::contract_class::{ClassInfo, EntryPointType, SierraVersion}; use starknet_api::core::{ChainId, ClassHash, ContractAddress, EntryPointSelector}; @@ -65,17 +57,9 @@ use starknet_api::deprecated_contract_class::ContractClass as DeprecatedContract use starknet_api::state::{StateNumber, ThinStateDiff}; use starknet_api::transaction::fields::{Calldata, Fee}; use starknet_api::transaction::{ - DeclareTransaction, - DeclareTransactionV0V1, - DeclareTransactionV2, - DeclareTransactionV3, - DeployAccountTransaction, - InvokeTransaction, - L1HandlerTransaction, - Transaction, - TransactionHash, - TransactionOptions, - TransactionVersion, + DeclareTransaction, DeclareTransactionV0V1, DeclareTransactionV2, DeclareTransactionV3, + DeployAccountTransaction, InvokeTransaction, L1HandlerTransaction, Transaction, + TransactionHash, TransactionOptions, TransactionVersion, }; use starknet_api::transaction_hash::get_transaction_hash; use starknet_api::StarknetApiError; diff --git a/crates/papyrus_execution/src/objects.rs b/crates/papyrus_execution/src/objects.rs index 8be701059e..122fe980e6 100644 --- a/crates/papyrus_execution/src/objects.rs +++ b/crates/papyrus_execution/src/objects.rs @@ -3,10 +3,8 @@ use std::collections::HashMap; use blockifier::context::BlockContext; use blockifier::execution::call_info::{ - CallInfo, - OrderedEvent as BlockifierOrderedEvent, - OrderedL2ToL1Message as BlockifierOrderedL2ToL1Message, - Retdata as BlockifierRetdata, + CallInfo, OrderedEvent as BlockifierOrderedEvent, + OrderedL2ToL1Message as BlockifierOrderedL2ToL1Message, Retdata as BlockifierRetdata, }; use blockifier::execution::entry_point::CallType as BlockifierCallType; use blockifier::transaction::objects::TransactionExecutionInfo; @@ -17,27 +15,17 @@ use indexmap::IndexMap; use itertools::Itertools; use papyrus_common::pending_classes::PendingClasses; use papyrus_common::state::{ - DeclaredClassHashEntry, - DeployedContract, - ReplacedClass, - StorageEntry, + DeclaredClassHashEntry, DeployedContract, ReplacedClass, StorageEntry, }; use serde::{Deserialize, Serialize}; use starknet_api::block::{BlockTimestamp, FeeType, GasPrice, GasPricePerToken}; use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ - ClassHash, - ContractAddress, - EntryPointSelector, - Nonce, - SequencerContractAddress, + ClassHash, ContractAddress, EntryPointSelector, Nonce, SequencerContractAddress, }; use starknet_api::data_availability::L1DataAvailabilityMode; use starknet_api::execution_resources::{ - Builtin, - ExecutionResources, - GasVector, - GasVector as StarknetApiGasVector, + Builtin, ExecutionResources, GasVector, GasVector as StarknetApiGasVector, }; use starknet_api::state::ThinStateDiff; use starknet_api::transaction::fields::{Calldata, Fee}; diff --git a/crates/papyrus_execution/src/state_reader.rs b/crates/papyrus_execution/src/state_reader.rs index b67aaa170e..2841b4df02 100644 --- a/crates/papyrus_execution/src/state_reader.rs +++ b/crates/papyrus_execution/src/state_reader.rs @@ -5,9 +5,7 @@ mod state_reader_test; use std::cell::Cell; use blockifier::execution::contract_class::{ - CompiledClassV0, - CompiledClassV1, - RunnableCompiledClass, + CompiledClassV0, CompiledClassV1, RunnableCompiledClass, }; use blockifier::state::errors::StateError; use blockifier::state::state_api::{StateReader as BlockifierStateReader, StateResult}; diff --git a/crates/papyrus_execution/src/state_reader_test.rs b/crates/papyrus_execution/src/state_reader_test.rs index 8e6a3c9558..39c16fd179 100644 --- a/crates/papyrus_execution/src/state_reader_test.rs +++ b/crates/papyrus_execution/src/state_reader_test.rs @@ -2,9 +2,7 @@ use std::cell::Cell; use assert_matches::assert_matches; use blockifier::execution::contract_class::{ - CompiledClassV0, - CompiledClassV1, - RunnableCompiledClass, + CompiledClassV0, CompiledClassV1, RunnableCompiledClass, }; use blockifier::state::errors::StateError; use blockifier::state::state_api::StateReader; @@ -12,10 +10,7 @@ use cairo_lang_utils::bigint::BigUintAsHex; use indexmap::indexmap; use papyrus_common::pending_classes::{ApiContractClass, PendingClasses, PendingClassesTrait}; use papyrus_common::state::{ - DeclaredClassHashEntry, - DeployedContract, - ReplacedClass, - StorageEntry, + DeclaredClassHashEntry, DeployedContract, ReplacedClass, StorageEntry, }; use papyrus_storage::body::BodyStorageWriter; use papyrus_storage::class::ClassStorageWriter; diff --git a/crates/papyrus_execution/src/test_utils.rs b/crates/papyrus_execution/src/test_utils.rs index 6cf362dbe0..354a4136c6 100644 --- a/crates/papyrus_execution/src/test_utils.rs +++ b/crates/papyrus_execution/src/test_utils.rs @@ -12,36 +12,20 @@ use papyrus_storage::{StorageReader, StorageWriter}; use serde::de::DeserializeOwned; use starknet_api::abi::abi_utils::get_storage_var_address; use starknet_api::block::{ - BlockBody, - BlockHash, - BlockHeader, - BlockHeaderWithoutHash, - BlockNumber, - BlockTimestamp, - GasPrice, - GasPricePerToken, + BlockBody, BlockHash, BlockHeader, BlockHeaderWithoutHash, BlockNumber, BlockTimestamp, + GasPrice, GasPricePerToken, }; use starknet_api::contract_class::SierraVersion; use starknet_api::core::{ - ChainId, - ClassHash, - CompiledClassHash, - ContractAddress, - Nonce, - SequencerContractAddress, + ChainId, ClassHash, CompiledClassHash, ContractAddress, Nonce, SequencerContractAddress, }; use starknet_api::deprecated_contract_class::ContractClass as DeprecatedContractClass; use starknet_api::state::{SierraContractClass, StateNumber, ThinStateDiff}; use starknet_api::test_utils::read_json_file; use starknet_api::transaction::fields::Fee; use starknet_api::transaction::{ - DeclareTransactionV0V1, - DeclareTransactionV2, - DeployAccountTransaction, - DeployAccountTransactionV1, - InvokeTransaction, - InvokeTransactionV1, - TransactionHash, + DeclareTransactionV0V1, DeclareTransactionV2, DeployAccountTransaction, + DeployAccountTransactionV1, InvokeTransaction, InvokeTransactionV1, TransactionHash, }; use starknet_api::{calldata, class_hash, contract_address, felt, nonce}; 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 e680629a6f..7b6fb61fe6 100644 --- a/crates/papyrus_execution/src/testing_instances.rs +++ b/crates/papyrus_execution/src/testing_instances.rs @@ -14,21 +14,10 @@ use starknet_api::transaction::{EventContent, MessageToL1}; use starknet_types_core::felt::Felt; use crate::objects::{ - CallType, - DeclareTransactionTrace, - DeployAccountTransactionTrace, - FeeEstimation, - FunctionCall, - FunctionInvocation, - FunctionInvocationResult, - InvokeTransactionTrace, - L1HandlerTransactionTrace, - OrderedEvent, - OrderedL2ToL1Message, - PriceUnit, - Retdata, - RevertReason, - TransactionTrace, + CallType, DeclareTransactionTrace, DeployAccountTransactionTrace, FeeEstimation, FunctionCall, + FunctionInvocation, FunctionInvocationResult, InvokeTransactionTrace, + L1HandlerTransactionTrace, OrderedEvent, OrderedL2ToL1Message, PriceUnit, Retdata, + RevertReason, TransactionTrace, }; use crate::ExecutionConfig; diff --git a/crates/papyrus_load_test/src/create_files.rs b/crates/papyrus_load_test/src/create_files.rs index 7ca7f56b1b..128508cb8d 100644 --- a/crates/papyrus_load_test/src/create_files.rs +++ b/crates/papyrus_load_test/src/create_files.rs @@ -9,31 +9,18 @@ use serde_json::Value as jsonVal; use starknet_api::test_utils::path_in_resources; use crate::{ - get_last_block_number, - get_random_block_number, - GET_BLOCK_TRANSACTION_COUNT_BY_HASH_WEIGHT, - GET_BLOCK_TRANSACTION_COUNT_BY_NUMBER_WEIGHT, - GET_BLOCK_WITH_FULL_TRANSACTIONS_BY_HASH_WEIGHT, + get_last_block_number, get_random_block_number, GET_BLOCK_TRANSACTION_COUNT_BY_HASH_WEIGHT, + GET_BLOCK_TRANSACTION_COUNT_BY_NUMBER_WEIGHT, GET_BLOCK_WITH_FULL_TRANSACTIONS_BY_HASH_WEIGHT, GET_BLOCK_WITH_FULL_TRANSACTIONS_BY_NUMBER_WEIGHT, GET_BLOCK_WITH_TRANSACTION_HASHES_BY_HASH_WEIGHT, - GET_BLOCK_WITH_TRANSACTION_HASHES_BY_NUMBER_WEIGHT, - GET_CLASS_AT_BY_HASH_WEIGHT, - GET_CLASS_AT_BY_NUMBER_WEIGHT, - GET_CLASS_BY_HASH_WEIGHT, - GET_CLASS_BY_NUMBER_WEIGHT, - GET_CLASS_HASH_AT_BY_HASH_WEIGHT, - GET_CLASS_HASH_AT_BY_NUMBER_WEIGHT, - GET_EVENTS_WITHOUT_ADDRESS_WEIGHT, - GET_EVENTS_WITH_ADDRESS_WEIGHT, - GET_NONCE_BY_HASH_WEIGHT, - GET_NONCE_BY_NUMBER_WEIGHT, - GET_STATE_UPDATE_BY_HASH_WEIGHT, - GET_STATE_UPDATE_BY_NUMBER_WEIGHT, - GET_STORAGE_AT_BY_HASH_WEIGHT, - GET_STORAGE_AT_BY_NUMBER_WEIGHT, + GET_BLOCK_WITH_TRANSACTION_HASHES_BY_NUMBER_WEIGHT, GET_CLASS_AT_BY_HASH_WEIGHT, + GET_CLASS_AT_BY_NUMBER_WEIGHT, GET_CLASS_BY_HASH_WEIGHT, GET_CLASS_BY_NUMBER_WEIGHT, + GET_CLASS_HASH_AT_BY_HASH_WEIGHT, GET_CLASS_HASH_AT_BY_NUMBER_WEIGHT, + GET_EVENTS_WITHOUT_ADDRESS_WEIGHT, GET_EVENTS_WITH_ADDRESS_WEIGHT, GET_NONCE_BY_HASH_WEIGHT, + GET_NONCE_BY_NUMBER_WEIGHT, GET_STATE_UPDATE_BY_HASH_WEIGHT, GET_STATE_UPDATE_BY_NUMBER_WEIGHT, + GET_STORAGE_AT_BY_HASH_WEIGHT, GET_STORAGE_AT_BY_NUMBER_WEIGHT, GET_TRANSACTION_BY_BLOCK_ID_AND_INDEX_BY_HASH_WEIGHT, - GET_TRANSACTION_BY_BLOCK_ID_AND_INDEX_BY_NUMBER_WEIGHT, - GET_TRANSACTION_BY_HASH_WEIGHT, + GET_TRANSACTION_BY_BLOCK_ID_AND_INDEX_BY_NUMBER_WEIGHT, GET_TRANSACTION_BY_HASH_WEIGHT, GET_TRANSACTION_RECEIPT_WEIGHT, }; diff --git a/crates/papyrus_load_test/src/scenarios.rs b/crates/papyrus_load_test/src/scenarios.rs index 61b7df4f9c..73c748fcfd 100644 --- a/crates/papyrus_load_test/src/scenarios.rs +++ b/crates/papyrus_load_test/src/scenarios.rs @@ -1,38 +1,21 @@ use goose::goose::Scenario; use crate::{ - transactions as txs, - BLOCK_HASH_AND_NUMBER_WEIGHT, - BLOCK_NUMBER_WEIGHT, - CHAIN_ID_WEIGHT, - GET_BLOCK_TRANSACTION_COUNT_BY_HASH_WEIGHT, - GET_BLOCK_TRANSACTION_COUNT_BY_NUMBER_WEIGHT, + transactions as txs, BLOCK_HASH_AND_NUMBER_WEIGHT, BLOCK_NUMBER_WEIGHT, CHAIN_ID_WEIGHT, + GET_BLOCK_TRANSACTION_COUNT_BY_HASH_WEIGHT, GET_BLOCK_TRANSACTION_COUNT_BY_NUMBER_WEIGHT, GET_BLOCK_WITH_FULL_TRANSACTIONS_BY_HASH_WEIGHT, GET_BLOCK_WITH_FULL_TRANSACTIONS_BY_NUMBER_WEIGHT, GET_BLOCK_WITH_TRANSACTION_HASHES_BY_HASH_WEIGHT, - GET_BLOCK_WITH_TRANSACTION_HASHES_BY_NUMBER_WEIGHT, - GET_CLASS_AT_BY_HASH_WEIGHT, - GET_CLASS_AT_BY_NUMBER_WEIGHT, - GET_CLASS_BY_HASH_WEIGHT, - GET_CLASS_BY_NUMBER_WEIGHT, - GET_CLASS_HASH_AT_BY_HASH_WEIGHT, - GET_CLASS_HASH_AT_BY_NUMBER_WEIGHT, - GET_EVENTS_WITHOUT_ADDRESS_WEIGHT, - GET_EVENTS_WITH_ADDRESS_WEIGHT, - GET_NONCE_BY_HASH_WEIGHT, - GET_NONCE_BY_NUMBER_WEIGHT, - GET_STATE_UPDATE_BY_HASH_WEIGHT, - GET_STATE_UPDATE_BY_NUMBER_WEIGHT, - GET_STORAGE_AT_BY_HASH_WEIGHT, - GET_STORAGE_AT_BY_NUMBER_WEIGHT, + GET_BLOCK_WITH_TRANSACTION_HASHES_BY_NUMBER_WEIGHT, GET_CLASS_AT_BY_HASH_WEIGHT, + GET_CLASS_AT_BY_NUMBER_WEIGHT, GET_CLASS_BY_HASH_WEIGHT, GET_CLASS_BY_NUMBER_WEIGHT, + GET_CLASS_HASH_AT_BY_HASH_WEIGHT, GET_CLASS_HASH_AT_BY_NUMBER_WEIGHT, + GET_EVENTS_WITHOUT_ADDRESS_WEIGHT, GET_EVENTS_WITH_ADDRESS_WEIGHT, GET_NONCE_BY_HASH_WEIGHT, + GET_NONCE_BY_NUMBER_WEIGHT, GET_STATE_UPDATE_BY_HASH_WEIGHT, GET_STATE_UPDATE_BY_NUMBER_WEIGHT, + GET_STORAGE_AT_BY_HASH_WEIGHT, GET_STORAGE_AT_BY_NUMBER_WEIGHT, GET_TRANSACTION_BY_BLOCK_ID_AND_INDEX_BY_HASH_WEIGHT, - GET_TRANSACTION_BY_BLOCK_ID_AND_INDEX_BY_NUMBER_WEIGHT, - GET_TRANSACTION_BY_HASH_WEIGHT, - GET_TRANSACTION_RECEIPT_WEIGHT, - SYNCING_WEIGHT, - TRACE_BLOCK_TRANSACTIONS_BY_HASH_WEIGHT, - TRACE_BLOCK_TRANSACTIONS_BY_NUMBER_WEIGHT, - TRACE_TRANSACTION_WEIGHT, + GET_TRANSACTION_BY_BLOCK_ID_AND_INDEX_BY_NUMBER_WEIGHT, GET_TRANSACTION_BY_HASH_WEIGHT, + GET_TRANSACTION_RECEIPT_WEIGHT, SYNCING_WEIGHT, TRACE_BLOCK_TRANSACTIONS_BY_HASH_WEIGHT, + TRACE_BLOCK_TRANSACTIONS_BY_NUMBER_WEIGHT, TRACE_TRANSACTION_WEIGHT, }; // TODO(dvir): add also traceTransaction, simulateTransactions, estimateFee and call endpoints. diff --git a/crates/papyrus_network/src/discovery/discovery_test.rs b/crates/papyrus_network/src/discovery/discovery_test.rs index fbdc94fd88..0df82e001f 100644 --- a/crates/papyrus_network/src/discovery/discovery_test.rs +++ b/crates/papyrus_network/src/discovery/discovery_test.rs @@ -9,13 +9,7 @@ use futures::{FutureExt, Stream, StreamExt}; use libp2p::core::{ConnectedPoint, Endpoint}; use libp2p::swarm::behaviour::ConnectionEstablished; use libp2p::swarm::{ - ConnectionClosed, - ConnectionId, - DialError, - DialFailure, - FromSwarm, - NetworkBehaviour, - ToSwarm, + ConnectionClosed, ConnectionId, DialError, DialFailure, FromSwarm, NetworkBehaviour, ToSwarm, }; use libp2p::{Multiaddr, PeerId}; use tokio::time::timeout; diff --git a/crates/papyrus_network/src/discovery/mod.rs b/crates/papyrus_network/src/discovery/mod.rs index 54c5b3896e..0e1eb6e8fd 100644 --- a/crates/papyrus_network/src/discovery/mod.rs +++ b/crates/papyrus_network/src/discovery/mod.rs @@ -15,21 +15,12 @@ use libp2p::core::Endpoint; use libp2p::swarm::behaviour::ConnectionEstablished; use libp2p::swarm::dial_opts::{DialOpts, PeerCondition}; use libp2p::swarm::{ - dummy, - AddressChange, - ConnectionClosed, - ConnectionDenied, - ConnectionHandler, - ConnectionId, - DialFailure, - FromSwarm, - NetworkBehaviour, - ToSwarm, + dummy, AddressChange, ConnectionClosed, ConnectionDenied, ConnectionHandler, ConnectionId, + DialFailure, FromSwarm, NetworkBehaviour, ToSwarm, }; use libp2p::{Multiaddr, PeerId}; use papyrus_config::converters::{ - deserialize_milliseconds_to_duration, - deserialize_seconds_to_duration, + deserialize_milliseconds_to_duration, deserialize_seconds_to_duration, }; use papyrus_config::dumping::{append_sub_config_name, ser_param, SerializeConfig}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; diff --git a/crates/papyrus_network/src/lib.rs b/crates/papyrus_network/src/lib.rs index 136010f92e..d156e7be7f 100644 --- a/crates/papyrus_network/src/lib.rs +++ b/crates/papyrus_network/src/lib.rs @@ -21,15 +21,10 @@ use std::time::Duration; use discovery::DiscoveryConfig; use libp2p::Multiaddr; use papyrus_config::converters::{ - deserialize_optional_vec_u8, - deserialize_seconds_to_duration, - serialize_optional_vec_u8, + deserialize_optional_vec_u8, deserialize_seconds_to_duration, serialize_optional_vec_u8, }; use papyrus_config::dumping::{ - append_sub_config_name, - ser_optional_param, - ser_param, - SerializeConfig, + append_sub_config_name, ser_optional_param, ser_param, SerializeConfig, }; use papyrus_config::validators::validate_vec_u256; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; diff --git a/crates/papyrus_network/src/mixed_behaviour.rs b/crates/papyrus_network/src/mixed_behaviour.rs index a67576103a..7395c6e022 100644 --- a/crates/papyrus_network/src/mixed_behaviour.rs +++ b/crates/papyrus_network/src/mixed_behaviour.rs @@ -70,10 +70,11 @@ impl MixedBehaviour { let public_key = keypair.public(); let local_peer_id = PeerId::from_public_key(&public_key); let mut kademlia_config = kad::Config::default(); - kademlia_config.set_protocol_names(vec![ - StreamProtocol::try_from_owned(format!("/starknet/kad/{}/1.0.0", chain_id)) - .expect("Failed to create StreamProtocol from a string that starts with /"), - ]); + kademlia_config.set_protocol_names(vec![StreamProtocol::try_from_owned(format!( + "/starknet/kad/{}/1.0.0", + chain_id + )) + .expect("Failed to create StreamProtocol from a string that starts with /")]); Self { peer_manager: peer_manager::PeerManager::new(peer_manager_config), discovery: bootstrap_peer_multiaddr diff --git a/crates/papyrus_network/src/network_manager/test_utils.rs b/crates/papyrus_network/src/network_manager/test_utils.rs index be1f65427b..b3a3af5d02 100644 --- a/crates/papyrus_network/src/network_manager/test_utils.rs +++ b/crates/papyrus_network/src/network_manager/test_utils.rs @@ -14,17 +14,9 @@ use libp2p::{Multiaddr, PeerId}; use papyrus_common::tcp::find_n_free_ports; use super::{ - BroadcastTopicClient, - BroadcastedMessageMetadata, - GenericReceiver, - NetworkManager, - ReportReceiver, - ServerQueryManager, - ServerResponsesSender, - SqmrClientPayload, - SqmrClientSender, - SqmrServerReceiver, - Topic, + BroadcastTopicClient, BroadcastedMessageMetadata, GenericReceiver, NetworkManager, + ReportReceiver, ServerQueryManager, ServerResponsesSender, SqmrClientPayload, SqmrClientSender, + SqmrServerReceiver, Topic, }; use crate::network_manager::{BroadcastReceivedMessagesConverterFn, BroadcastTopicChannels}; use crate::sqmr::Bytes; diff --git a/crates/papyrus_network/src/peer_manager/behaviour_impl.rs b/crates/papyrus_network/src/peer_manager/behaviour_impl.rs index efdcbf59e6..2bce533af0 100644 --- a/crates/papyrus_network/src/peer_manager/behaviour_impl.rs +++ b/crates/papyrus_network/src/peer_manager/behaviour_impl.rs @@ -2,13 +2,7 @@ use std::task::{ready, Poll}; use libp2p::swarm::behaviour::ConnectionEstablished; use libp2p::swarm::{ - dummy, - ConnectionClosed, - ConnectionId, - DialError, - DialFailure, - NetworkBehaviour, - ToSwarm, + dummy, ConnectionClosed, ConnectionId, DialError, DialFailure, NetworkBehaviour, ToSwarm, }; use libp2p::{Multiaddr, PeerId}; use tracing::{debug, error, warn}; @@ -112,7 +106,11 @@ impl NetworkBehaviour for PeerManager { self.session_to_peer_map .iter() .filter_map(|(outbound_session_id, p_id)| { - if *p_id == peer_id { Some(*outbound_session_id) } else { None } + if *p_id == peer_id { + Some(*outbound_session_id) + } else { + None + } }) .collect::>(); for outbound_session_id in queries_to_assign { diff --git a/crates/papyrus_network/src/peer_manager/mod.rs b/crates/papyrus_network/src/peer_manager/mod.rs index 7c5818643d..b9593ef1c0 100644 --- a/crates/papyrus_network/src/peer_manager/mod.rs +++ b/crates/papyrus_network/src/peer_manager/mod.rs @@ -7,8 +7,7 @@ use libp2p::swarm::dial_opts::DialOpts; use libp2p::swarm::ToSwarm; use libp2p::PeerId; use papyrus_config::converters::{ - deserialize_milliseconds_to_duration, - deserialize_seconds_to_duration, + deserialize_milliseconds_to_duration, deserialize_seconds_to_duration, }; use papyrus_config::dumping::{ser_param, SerializeConfig}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; diff --git a/crates/papyrus_network/src/sqmr/behaviour.rs b/crates/papyrus_network/src/sqmr/behaviour.rs index 88787ceeb0..144edbc5b9 100644 --- a/crates/papyrus_network/src/sqmr/behaviour.rs +++ b/crates/papyrus_network/src/sqmr/behaviour.rs @@ -11,22 +11,14 @@ use std::time::Duration; use libp2p::core::Endpoint; use libp2p::swarm::{ - ConnectionClosed, - ConnectionDenied, - ConnectionHandler, - ConnectionId, - FromSwarm, - NetworkBehaviour, - NotifyHandler, - ToSwarm, + ConnectionClosed, ConnectionDenied, ConnectionHandler, ConnectionId, FromSwarm, + NetworkBehaviour, NotifyHandler, ToSwarm, }; use libp2p::{Multiaddr, PeerId, StreamProtocol}; use tracing::{error, info}; use super::handler::{ - Handler, - RequestFromBehaviourEvent, - RequestToBehaviourEvent, + Handler, RequestFromBehaviourEvent, RequestToBehaviourEvent, SessionError as HandlerSessionError, }; use super::{Bytes, Config, GenericEvent, InboundSessionId, OutboundSessionId, SessionId}; diff --git a/crates/papyrus_network/src/sqmr/handler.rs b/crates/papyrus_network/src/sqmr/handler.rs index 5a6dc3bee0..552b7c26df 100644 --- a/crates/papyrus_network/src/sqmr/handler.rs +++ b/crates/papyrus_network/src/sqmr/handler.rs @@ -14,16 +14,10 @@ use async_stream::stream; use futures::stream::BoxStream; use futures::{FutureExt, StreamExt}; use libp2p::swarm::handler::{ - ConnectionEvent, - DialUpgradeError, - FullyNegotiatedInbound, - FullyNegotiatedOutbound, + ConnectionEvent, DialUpgradeError, FullyNegotiatedInbound, FullyNegotiatedOutbound, }; use libp2p::swarm::{ - ConnectionHandler, - ConnectionHandlerEvent, - StreamUpgradeError, - SubstreamProtocol, + ConnectionHandler, ConnectionHandlerEvent, StreamUpgradeError, SubstreamProtocol, }; use libp2p::{PeerId, StreamProtocol}; use tracing::debug; diff --git a/crates/papyrus_network/src/sqmr/handler_test.rs b/crates/papyrus_network/src/sqmr/handler_test.rs index 22d34afe99..69a358faec 100644 --- a/crates/papyrus_network/src/sqmr/handler_test.rs +++ b/crates/papyrus_network/src/sqmr/handler_test.rs @@ -9,10 +9,7 @@ use futures::task::{Context, Poll}; use futures::{select, AsyncReadExt, AsyncWriteExt, FutureExt, Stream as StreamTrait, StreamExt}; use lazy_static::lazy_static; use libp2p::swarm::handler::{ - ConnectionEvent, - DialUpgradeError, - FullyNegotiatedInbound, - FullyNegotiatedOutbound, + ConnectionEvent, DialUpgradeError, FullyNegotiatedInbound, FullyNegotiatedOutbound, }; use libp2p::swarm::{ConnectionHandler, ConnectionHandlerEvent, Stream, StreamUpgradeError}; use libp2p::{PeerId, StreamProtocol}; @@ -20,11 +17,7 @@ use libp2p::{PeerId, StreamProtocol}; use super::super::messages::{read_message, write_message}; use super::super::{Bytes, Config, GenericEvent, InboundSessionId, OutboundSessionId, SessionId}; use super::{ - Handler, - HandlerEvent, - RequestFromBehaviourEvent, - RequestToBehaviourEvent, - SessionError, + Handler, HandlerEvent, RequestFromBehaviourEvent, RequestToBehaviourEvent, SessionError, }; use crate::sqmr::handler; use crate::test_utils::{dummy_data, get_connected_streams}; diff --git a/crates/papyrus_network/src/sqmr/messages_test.rs b/crates/papyrus_network/src/sqmr/messages_test.rs index 72545b5904..a30132605e 100644 --- a/crates/papyrus_network/src/sqmr/messages_test.rs +++ b/crates/papyrus_network/src/sqmr/messages_test.rs @@ -4,9 +4,7 @@ use futures::{AsyncReadExt, AsyncWriteExt}; use pretty_assertions::assert_eq; use super::{ - read_message, - read_message_without_length_prefix, - write_message, + read_message, read_message_without_length_prefix, write_message, write_message_without_length_prefix, }; use crate::test_utils::{dummy_data, get_connected_streams}; @@ -43,7 +41,7 @@ async fn read_message_returns_none_when_other_stream_is_closed() { #[tokio::test] async fn read_message_is_pending_when_other_stream_didnt_send() { let (_stream1, mut stream2, _) = get_connected_streams().await; - assert!( - tokio::time::timeout(Duration::from_millis(10), read_message(&mut stream2)).await.is_err() - ); + assert!(tokio::time::timeout(Duration::from_millis(10), read_message(&mut stream2)) + .await + .is_err()); } diff --git a/crates/papyrus_network/src/test_utils/get_stream.rs b/crates/papyrus_network/src/test_utils/get_stream.rs index 62ca75a029..173f7f82dd 100644 --- a/crates/papyrus_network/src/test_utils/get_stream.rs +++ b/crates/papyrus_network/src/test_utils/get_stream.rs @@ -7,15 +7,8 @@ use libp2p::core::upgrade::{InboundUpgrade, OutboundUpgrade, UpgradeInfo}; use libp2p::core::Endpoint; use libp2p::swarm::handler::{ConnectionEvent, FullyNegotiatedInbound, FullyNegotiatedOutbound}; use libp2p::swarm::{ - ConnectionDenied, - ConnectionHandler, - ConnectionHandlerEvent, - ConnectionId, - FromSwarm, - NetworkBehaviour, - Stream, - SubstreamProtocol, - ToSwarm, + ConnectionDenied, ConnectionHandler, ConnectionHandlerEvent, ConnectionId, FromSwarm, + NetworkBehaviour, Stream, SubstreamProtocol, ToSwarm, }; use libp2p::{Multiaddr, PeerId, StreamProtocol}; diff --git a/crates/papyrus_network/src/test_utils/mod.rs b/crates/papyrus_network/src/test_utils/mod.rs index ebdc3148fb..498d8b9f9a 100644 --- a/crates/papyrus_network/src/test_utils/mod.rs +++ b/crates/papyrus_network/src/test_utils/mod.rs @@ -28,7 +28,11 @@ pub(crate) async fn get_connected_streams() -> (Stream, Stream, JoinHandle<()>) let merged_swarm = swarm1.merge(swarm2); let mut filtered_swarm = merged_swarm.filter_map(|event| { - if let SwarmEvent::Behaviour(stream) = event { Some(stream) } else { None } + if let SwarmEvent::Behaviour(stream) = event { + Some(stream) + } else { + None + } }); ( filtered_swarm.next().await.unwrap(), diff --git a/crates/papyrus_node/examples/get_transaction_hash.rs b/crates/papyrus_node/examples/get_transaction_hash.rs index fce8f48485..bf91ba0f95 100644 --- a/crates/papyrus_node/examples/get_transaction_hash.rs +++ b/crates/papyrus_node/examples/get_transaction_hash.rs @@ -247,14 +247,12 @@ fn create_map_of_transaction( // insert the only_query_transaction_hash into the json file. transaction_info.insert( "only_query_transaction_hash".to_string(), - json!( - get_transaction_hash( - transaction, - &chain_id, - &TransactionOptions { only_query: true } - ) - .expect("Couldn't get only query transaction hash") - ), + json!(get_transaction_hash( + transaction, + &chain_id, + &TransactionOptions { only_query: true } + ) + .expect("Couldn't get only query transaction hash")), ); } transaction_info diff --git a/crates/papyrus_node/src/config/mod.rs b/crates/papyrus_node/src/config/mod.rs index e185710e53..9d94183f07 100644 --- a/crates/papyrus_node/src/config/mod.rs +++ b/crates/papyrus_node/src/config/mod.rs @@ -17,10 +17,7 @@ use itertools::{chain, Itertools}; use lazy_static::lazy_static; use papyrus_base_layer::ethereum_base_layer_contract::EthereumBaseLayerConfig; use papyrus_config::dumping::{ - append_sub_config_name, - ser_optional_sub_config, - ser_param, - ser_pointer_target_param, + append_sub_config_name, ser_optional_sub_config, ser_param, ser_pointer_target_param, SerializeConfig, }; use papyrus_config::loading::load_and_process_config; diff --git a/crates/papyrus_node/src/config/pointers.rs b/crates/papyrus_node/src/config/pointers.rs index e1ee0ef10b..e87d2e9680 100644 --- a/crates/papyrus_node/src/config/pointers.rs +++ b/crates/papyrus_node/src/config/pointers.rs @@ -15,13 +15,8 @@ use papyrus_base_layer::ethereum_base_layer_contract::EthereumBaseLayerConfig; #[cfg(not(feature = "rpc"))] use papyrus_config::dumping::ser_param; use papyrus_config::dumping::{ - append_sub_config_name, - ser_optional_sub_config, - ser_pointer_target_param, - set_pointing_param_paths, - ConfigPointers, - Pointers, - SerializeConfig, + append_sub_config_name, ser_optional_sub_config, ser_pointer_target_param, + set_pointing_param_paths, ConfigPointers, Pointers, SerializeConfig, }; use papyrus_config::loading::load_and_process_config; #[cfg(not(feature = "rpc"))] diff --git a/crates/papyrus_node/src/run_test.rs b/crates/papyrus_node/src/run_test.rs index b7e906018a..c1fec1be70 100644 --- a/crates/papyrus_node/src/run_test.rs +++ b/crates/papyrus_node/src/run_test.rs @@ -7,10 +7,7 @@ use tempfile::TempDir; use crate::config::NodeConfig; use crate::run::{ - run_threads, - spawn_storage_metrics_collector, - PapyrusResources, - PapyrusTaskHandles, + run_threads, spawn_storage_metrics_collector, PapyrusResources, PapyrusTaskHandles, }; // The mission of this test is to ensure that if an error is returned from one of the spawned tasks, diff --git a/crates/papyrus_p2p_sync/src/client/class.rs b/crates/papyrus_p2p_sync/src/client/class.rs index 9cb5dfaa39..7418d4e010 100644 --- a/crates/papyrus_p2p_sync/src/client/class.rs +++ b/crates/papyrus_p2p_sync/src/client/class.rs @@ -13,11 +13,7 @@ use starknet_api::core::ClassHash; use starknet_api::state::{DeclaredClasses, DeprecatedDeclaredClasses}; use super::stream_builder::{ - BadPeerError, - BlockData, - BlockNumberLimit, - DataStreamBuilder, - ParseDataError, + BadPeerError, BlockData, BlockNumberLimit, DataStreamBuilder, ParseDataError, }; use super::{P2PSyncClientError, NETWORK_DATA_TIMEOUT}; diff --git a/crates/papyrus_p2p_sync/src/client/class_test.rs b/crates/papyrus_p2p_sync/src/client/class_test.rs index 6e9e6629bd..69b5ffafb6 100644 --- a/crates/papyrus_p2p_sync/src/client/class_test.rs +++ b/crates/papyrus_p2p_sync/src/client/class_test.rs @@ -3,14 +3,8 @@ use std::cmp::min; use futures::{FutureExt, StreamExt}; use papyrus_common::pending_classes::ApiContractClass; use papyrus_protobuf::sync::{ - BlockHashOrNumber, - ClassQuery, - DataOrFin, - DeclaredClass, - DeprecatedDeclaredClass, - Direction, - Query, - StateDiffChunk, + BlockHashOrNumber, ClassQuery, DataOrFin, DeclaredClass, DeprecatedDeclaredClass, Direction, + Query, StateDiffChunk, }; use papyrus_storage::class::ClassStorageReader; use papyrus_test_utils::{get_rng, GetTestInstance}; @@ -22,14 +16,8 @@ use starknet_api::deprecated_contract_class::ContractClass as DeprecatedContract use starknet_api::state::SierraContractClass; use super::test_utils::{ - setup, - wait_for_marker, - DataType, - TestArgs, - CLASS_DIFF_QUERY_LENGTH, - HEADER_QUERY_LENGTH, - SLEEP_DURATION_TO_LET_SYNC_ADVANCE, - TIMEOUT_FOR_TEST, + setup, wait_for_marker, DataType, TestArgs, CLASS_DIFF_QUERY_LENGTH, HEADER_QUERY_LENGTH, + SLEEP_DURATION_TO_LET_SYNC_ADVANCE, TIMEOUT_FOR_TEST, }; use crate::client::state_diff_test::run_state_diff_sync; diff --git a/crates/papyrus_p2p_sync/src/client/header.rs b/crates/papyrus_p2p_sync/src/client/header.rs index 947f8ede25..5c21d411d4 100644 --- a/crates/papyrus_p2p_sync/src/client/header.rs +++ b/crates/papyrus_p2p_sync/src/client/header.rs @@ -11,11 +11,7 @@ use starknet_api::block::BlockNumber; use tracing::debug; use super::stream_builder::{ - BadPeerError, - BlockData, - BlockNumberLimit, - DataStreamBuilder, - ParseDataError, + BadPeerError, BlockData, BlockNumberLimit, DataStreamBuilder, ParseDataError, }; use super::{P2PSyncClientError, ALLOWED_SIGNATURES_LENGTH, NETWORK_DATA_TIMEOUT}; diff --git a/crates/papyrus_p2p_sync/src/client/header_test.rs b/crates/papyrus_p2p_sync/src/client/header_test.rs index ff2f660127..8d41a86588 100644 --- a/crates/papyrus_p2p_sync/src/client/header_test.rs +++ b/crates/papyrus_p2p_sync/src/client/header_test.rs @@ -2,12 +2,7 @@ use std::collections::HashMap; use futures::{FutureExt, StreamExt}; use papyrus_protobuf::sync::{ - BlockHashOrNumber, - DataOrFin, - Direction, - HeaderQuery, - Query, - SignedBlockHeader, + BlockHashOrNumber, DataOrFin, Direction, HeaderQuery, Query, SignedBlockHeader, }; use papyrus_storage::header::HeaderStorageReader; use papyrus_test_utils::get_rng; @@ -15,19 +10,9 @@ use starknet_api::block::{BlockHeader, BlockHeaderWithoutHash, BlockNumber}; use tokio::time::timeout; use super::test_utils::{ - create_block_hashes_and_signatures, - random_header, - run_test, - setup, - wait_for_marker, - Action, - DataType, - TestArgs, - HEADER_QUERY_LENGTH, - SLEEP_DURATION_TO_LET_SYNC_ADVANCE, - TIMEOUT_FOR_NEW_QUERY_AFTER_PARTIAL_RESPONSE, - TIMEOUT_FOR_TEST, - WAIT_PERIOD_FOR_NEW_DATA, + create_block_hashes_and_signatures, random_header, run_test, setup, wait_for_marker, Action, + DataType, TestArgs, HEADER_QUERY_LENGTH, SLEEP_DURATION_TO_LET_SYNC_ADVANCE, + TIMEOUT_FOR_NEW_QUERY_AFTER_PARTIAL_RESPONSE, TIMEOUT_FOR_TEST, WAIT_PERIOD_FOR_NEW_DATA, }; #[tokio::test] diff --git a/crates/papyrus_p2p_sync/src/client/mod.rs b/crates/papyrus_p2p_sync/src/client/mod.rs index 01e13465f7..d31936360d 100644 --- a/crates/papyrus_p2p_sync/src/client/mod.rs +++ b/crates/papyrus_p2p_sync/src/client/mod.rs @@ -27,12 +27,7 @@ use papyrus_config::dumping::{ser_optional_param, ser_param, SerializeConfig}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use papyrus_network::network_manager::SqmrClientSender; use papyrus_protobuf::sync::{ - ClassQuery, - DataOrFin, - HeaderQuery, - SignedBlockHeader, - StateDiffChunk, - StateDiffQuery, + ClassQuery, DataOrFin, HeaderQuery, SignedBlockHeader, StateDiffChunk, StateDiffQuery, TransactionQuery, }; use papyrus_storage::{StorageError, StorageReader, StorageWriter}; diff --git a/crates/papyrus_p2p_sync/src/client/state_diff.rs b/crates/papyrus_p2p_sync/src/client/state_diff.rs index 4eeebd36c4..63394874fc 100644 --- a/crates/papyrus_p2p_sync/src/client/state_diff.rs +++ b/crates/papyrus_p2p_sync/src/client/state_diff.rs @@ -15,10 +15,7 @@ use starknet_api::state::ThinStateDiff; use super::stream_builder::BadPeerError; use crate::client::stream_builder::{ - BlockData, - BlockNumberLimit, - DataStreamBuilder, - ParseDataError, + BlockData, BlockNumberLimit, DataStreamBuilder, ParseDataError, }; use crate::client::{P2PSyncClientError, NETWORK_DATA_TIMEOUT}; diff --git a/crates/papyrus_p2p_sync/src/client/state_diff_test.rs b/crates/papyrus_p2p_sync/src/client/state_diff_test.rs index 04175a7568..011199c94e 100644 --- a/crates/papyrus_p2p_sync/src/client/state_diff_test.rs +++ b/crates/papyrus_p2p_sync/src/client/state_diff_test.rs @@ -5,15 +5,8 @@ use futures::{FutureExt, StreamExt}; use indexmap::indexmap; use papyrus_network::network_manager::GenericReceiver; use papyrus_protobuf::sync::{ - BlockHashOrNumber, - ContractDiff, - DataOrFin, - DeclaredClass, - DeprecatedDeclaredClass, - Direction, - Query, - SignedBlockHeader, - StateDiffChunk, + BlockHashOrNumber, ContractDiff, DataOrFin, DeclaredClass, DeprecatedDeclaredClass, Direction, + Query, SignedBlockHeader, StateDiffChunk, }; use papyrus_storage::state::StateStorageReader; use papyrus_test_utils::{get_rng, GetTestInstance}; @@ -27,18 +20,9 @@ use static_assertions::const_assert; use tokio::sync::mpsc::{channel, Receiver}; use super::test_utils::{ - create_block_hashes_and_signatures, - setup, - wait_for_marker, - DataType, - HeaderTestPayload, - StateDiffTestPayload, - TestArgs, - HEADER_QUERY_LENGTH, - SLEEP_DURATION_TO_LET_SYNC_ADVANCE, - STATE_DIFF_QUERY_LENGTH, - TIMEOUT_FOR_TEST, - WAIT_PERIOD_FOR_NEW_DATA, + create_block_hashes_and_signatures, setup, wait_for_marker, DataType, HeaderTestPayload, + StateDiffTestPayload, TestArgs, HEADER_QUERY_LENGTH, SLEEP_DURATION_TO_LET_SYNC_ADVANCE, + STATE_DIFF_QUERY_LENGTH, TIMEOUT_FOR_TEST, WAIT_PERIOD_FOR_NEW_DATA, }; use super::{P2PSyncClientConfig, StateDiffQuery}; diff --git a/crates/papyrus_p2p_sync/src/client/test_utils.rs b/crates/papyrus_p2p_sync/src/client/test_utils.rs index 006ce510f9..6cb6676920 100644 --- a/crates/papyrus_p2p_sync/src/client/test_utils.rs +++ b/crates/papyrus_p2p_sync/src/client/test_utils.rs @@ -7,18 +7,11 @@ use futures::StreamExt; use lazy_static::lazy_static; use papyrus_common::pending_classes::ApiContractClass; use papyrus_network::network_manager::test_utils::{ - mock_register_sqmr_protocol_client, - MockClientResponsesManager, + mock_register_sqmr_protocol_client, MockClientResponsesManager, }; use papyrus_network::network_manager::GenericReceiver; use papyrus_protobuf::sync::{ - ClassQuery, - DataOrFin, - HeaderQuery, - Query, - SignedBlockHeader, - StateDiffChunk, - StateDiffQuery, + ClassQuery, DataOrFin, HeaderQuery, Query, SignedBlockHeader, StateDiffChunk, StateDiffQuery, TransactionQuery, }; use papyrus_storage::body::BodyStorageReader; @@ -31,11 +24,7 @@ use papyrus_test_utils::GetTestInstance; use rand::{Rng, RngCore}; use rand_chacha::ChaCha8Rng; use starknet_api::block::{ - BlockHash, - BlockHeader, - BlockHeaderWithoutHash, - BlockNumber, - BlockSignature, + BlockHash, BlockHeader, BlockHeaderWithoutHash, BlockNumber, BlockSignature, }; use starknet_api::core::ClassHash; use starknet_api::crypto::utils::Signature; diff --git a/crates/papyrus_p2p_sync/src/client/transaction.rs b/crates/papyrus_p2p_sync/src/client/transaction.rs index e3c11a8df8..e9d4513494 100644 --- a/crates/papyrus_p2p_sync/src/client/transaction.rs +++ b/crates/papyrus_p2p_sync/src/client/transaction.rs @@ -9,11 +9,7 @@ use starknet_api::block::{BlockBody, BlockNumber}; use starknet_api::transaction::FullTransaction; use super::stream_builder::{ - BadPeerError, - BlockData, - BlockNumberLimit, - DataStreamBuilder, - ParseDataError, + BadPeerError, BlockData, BlockNumberLimit, DataStreamBuilder, ParseDataError, }; use super::{P2PSyncClientError, NETWORK_DATA_TIMEOUT}; diff --git a/crates/papyrus_p2p_sync/src/client/transaction_test.rs b/crates/papyrus_p2p_sync/src/client/transaction_test.rs index 77d340ccf3..3bc53f122b 100644 --- a/crates/papyrus_p2p_sync/src/client/transaction_test.rs +++ b/crates/papyrus_p2p_sync/src/client/transaction_test.rs @@ -2,12 +2,7 @@ use std::cmp::min; use futures::{FutureExt, StreamExt}; use papyrus_protobuf::sync::{ - BlockHashOrNumber, - DataOrFin, - Direction, - Query, - SignedBlockHeader, - TransactionQuery, + BlockHashOrNumber, DataOrFin, Direction, Query, SignedBlockHeader, TransactionQuery, }; use papyrus_storage::body::BodyStorageReader; use papyrus_test_utils::get_test_body; @@ -15,13 +10,8 @@ use starknet_api::block::{BlockBody, BlockHeader, BlockHeaderWithoutHash, BlockN use starknet_api::transaction::FullTransaction; use super::test_utils::{ - create_block_hashes_and_signatures, - setup, - TestArgs, - HEADER_QUERY_LENGTH, - SLEEP_DURATION_TO_LET_SYNC_ADVANCE, - TRANSACTION_QUERY_LENGTH, - WAIT_PERIOD_FOR_NEW_DATA, + create_block_hashes_and_signatures, setup, TestArgs, HEADER_QUERY_LENGTH, + SLEEP_DURATION_TO_LET_SYNC_ADVANCE, TRANSACTION_QUERY_LENGTH, WAIT_PERIOD_FOR_NEW_DATA, }; use crate::client::test_utils::{wait_for_marker, DataType, TIMEOUT_FOR_TEST}; diff --git a/crates/papyrus_p2p_sync/src/server/mod.rs b/crates/papyrus_p2p_sync/src/server/mod.rs index 205a10239a..40a090ec28 100644 --- a/crates/papyrus_p2p_sync/src/server/mod.rs +++ b/crates/papyrus_p2p_sync/src/server/mod.rs @@ -5,18 +5,8 @@ use papyrus_common::pending_classes::ApiContractClass; use papyrus_network::network_manager::{ServerQueryManager, SqmrServerReceiver}; use papyrus_protobuf::converters::ProtobufConversionError; use papyrus_protobuf::sync::{ - BlockHashOrNumber, - ClassQuery, - ContractDiff, - DataOrFin, - DeclaredClass, - DeprecatedDeclaredClass, - EventQuery, - HeaderQuery, - Query, - SignedBlockHeader, - StateDiffChunk, - StateDiffQuery, + BlockHashOrNumber, ClassQuery, ContractDiff, DataOrFin, DeclaredClass, DeprecatedDeclaredClass, + EventQuery, HeaderQuery, Query, SignedBlockHeader, StateDiffChunk, StateDiffQuery, TransactionQuery, }; use papyrus_storage::body::BodyStorageReader; diff --git a/crates/papyrus_p2p_sync/src/server/test.rs b/crates/papyrus_p2p_sync/src/server/test.rs index 29f74535cf..1a4f392017 100644 --- a/crates/papyrus_p2p_sync/src/server/test.rs +++ b/crates/papyrus_p2p_sync/src/server/test.rs @@ -6,23 +6,13 @@ use lazy_static::lazy_static; use papyrus_common::pending_classes::ApiContractClass; use papyrus_common::state::create_random_state_diff; use papyrus_network::network_manager::test_utils::{ - create_test_server_query_manager, - mock_register_sqmr_protocol_server, + create_test_server_query_manager, mock_register_sqmr_protocol_server, }; use papyrus_network::network_manager::ServerQueryManager; use papyrus_protobuf::converters::ProtobufConversionError; use papyrus_protobuf::sync::{ - BlockHashOrNumber, - ClassQuery, - DataOrFin, - Direction, - EventQuery, - HeaderQuery, - Query, - SignedBlockHeader, - StateDiffChunk, - StateDiffQuery, - TransactionQuery, + BlockHashOrNumber, ClassQuery, DataOrFin, Direction, EventQuery, HeaderQuery, Query, + SignedBlockHeader, StateDiffChunk, StateDiffQuery, TransactionQuery, }; use papyrus_storage::body::BodyStorageWriter; use papyrus_storage::class::ClassStorageWriter; @@ -33,21 +23,12 @@ use papyrus_storage::{StorageReader, StorageWriter}; use papyrus_test_utils::{get_rng, get_test_body, GetTestInstance}; use rand::random; use starknet_api::block::{ - BlockBody, - BlockHash, - BlockHeader, - BlockHeaderWithoutHash, - BlockNumber, - BlockSignature, + BlockBody, BlockHash, BlockHeader, BlockHeaderWithoutHash, BlockNumber, BlockSignature, }; use starknet_api::deprecated_contract_class::ContractClass as DeprecatedContractClass; use starknet_api::state::SierraContractClass; use starknet_api::transaction::{ - Event, - FullTransaction, - Transaction, - TransactionHash, - TransactionOutput, + Event, FullTransaction, Transaction, TransactionHash, TransactionOutput, }; use super::{split_thin_state_diff, FetchBlockDataFromDb, P2PSyncServer, P2PSyncServerChannels}; diff --git a/crates/papyrus_proc_macros/src/lib.rs b/crates/papyrus_proc_macros/src/lib.rs index 69c0fe3e1a..ed9ecb4311 100644 --- a/crates/papyrus_proc_macros/src/lib.rs +++ b/crates/papyrus_proc_macros/src/lib.rs @@ -4,17 +4,8 @@ use proc_macro::TokenStream; use quote::{quote, ToTokens}; use syn::parse::{Parse, ParseStream, Result}; use syn::{ - parse_macro_input, - DeriveInput, - ExprLit, - Ident, - ItemFn, - ItemTrait, - LitBool, - LitStr, - Meta, - Token, - TraitItem, + parse_macro_input, DeriveInput, ExprLit, Ident, ItemFn, ItemTrait, LitBool, LitStr, Meta, + Token, TraitItem, }; /// This macro is a wrapper around the "rpc" macro supplied by the jsonrpsee library that generates diff --git a/crates/papyrus_protobuf/build.rs b/crates/papyrus_protobuf/build.rs index f6da55625d..f0e6ca9848 100644 --- a/crates/papyrus_protobuf/build.rs +++ b/crates/papyrus_protobuf/build.rs @@ -18,7 +18,11 @@ fn get_valid_preinstalled_protoc_version() -> Option<(u32, u32)> { }; let (major, minor) = parse_protoc_version(protoc_version_str)?; // Protoc versions before 3.15 are not supported. - if (major < 3) || (major == 3 && minor < 15) { None } else { Some((major, minor)) } + if (major < 3) || (major == 3 && minor < 15) { + None + } else { + Some((major, minor)) + } } /// Return Result<(major, minor)> numbers. If the minor doesn't exist, return 0 as minor. If diff --git a/crates/papyrus_protobuf/src/converters/consensus.rs b/crates/papyrus_protobuf/src/converters/consensus.rs index 708a9ee3b9..51241fbf7f 100644 --- a/crates/papyrus_protobuf/src/converters/consensus.rs +++ b/crates/papyrus_protobuf/src/converters/consensus.rs @@ -10,16 +10,8 @@ use starknet_api::transaction::{Transaction, TransactionHash}; use starknet_types_core::felt::Felt; use crate::consensus::{ - ConsensusMessage, - Proposal, - ProposalFin, - ProposalInit, - ProposalPart, - StreamMessage, - StreamMessageBody, - TransactionBatch, - Vote, - VoteType, + ConsensusMessage, Proposal, ProposalFin, ProposalInit, ProposalPart, StreamMessage, + StreamMessageBody, TransactionBatch, Vote, VoteType, }; use crate::converters::ProtobufConversionError; use crate::{auto_impl_into_and_try_from_vec_u8, protobuf}; diff --git a/crates/papyrus_protobuf/src/converters/consensus_test.rs b/crates/papyrus_protobuf/src/converters/consensus_test.rs index 57e328a7fa..fa75b54b23 100644 --- a/crates/papyrus_protobuf/src/converters/consensus_test.rs +++ b/crates/papyrus_protobuf/src/converters/consensus_test.rs @@ -2,25 +2,13 @@ use papyrus_test_utils::{get_rng, GetTestInstance}; use starknet_api::execution_resources::GasAmount; use starknet_api::transaction::fields::ValidResourceBounds; use starknet_api::transaction::{ - DeclareTransaction, - DeclareTransactionV3, - DeployAccountTransaction, - DeployAccountTransactionV3, - InvokeTransaction, - InvokeTransactionV3, - Transaction, + DeclareTransaction, DeclareTransactionV3, DeployAccountTransaction, DeployAccountTransactionV3, + InvokeTransaction, InvokeTransactionV3, Transaction, }; use crate::consensus::{ - ConsensusMessage, - Proposal, - ProposalFin, - ProposalInit, - ProposalPart, - StreamMessage, - StreamMessageBody, - TransactionBatch, - Vote, + ConsensusMessage, Proposal, ProposalFin, ProposalInit, ProposalPart, StreamMessage, + StreamMessageBody, TransactionBatch, Vote, }; // If all the fields of `AllResources` are 0 upon serialization, diff --git a/crates/papyrus_protobuf/src/converters/header.rs b/crates/papyrus_protobuf/src/converters/header.rs index cd01db6ad9..359d0a15cf 100644 --- a/crates/papyrus_protobuf/src/converters/header.rs +++ b/crates/papyrus_protobuf/src/converters/header.rs @@ -4,20 +4,11 @@ mod header_test; use prost::Message; use starknet_api::block::{ - BlockHash, - BlockHeader, - BlockHeaderWithoutHash, - BlockNumber, - BlockSignature, - GasPricePerToken, + BlockHash, BlockHeader, BlockHeaderWithoutHash, BlockNumber, BlockSignature, GasPricePerToken, StarknetVersion, }; use starknet_api::core::{ - EventCommitment, - GlobalRoot, - ReceiptCommitment, - SequencerContractAddress, - StateDiffCommitment, + EventCommitment, GlobalRoot, ReceiptCommitment, SequencerContractAddress, StateDiffCommitment, TransactionCommitment, }; use starknet_api::crypto::utils::Signature; @@ -255,7 +246,7 @@ impl From<(BlockHeader, Vec)> for protobuf::SignedBlockHeader { .expect("Converting usize to u64 failed"), root: header .state_diff_commitment - .map(|state_diff_commitment| state_diff_commitment.0.0.into()), + .map(|state_diff_commitment| state_diff_commitment.0 .0.into()), }); Self { block_hash: Some(header.block_hash.into()), diff --git a/crates/papyrus_protobuf/src/converters/receipt.rs b/crates/papyrus_protobuf/src/converters/receipt.rs index 1caac6cc1c..436039031e 100644 --- a/crates/papyrus_protobuf/src/converters/receipt.rs +++ b/crates/papyrus_protobuf/src/converters/receipt.rs @@ -4,16 +4,9 @@ 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, - InvokeTransactionOutput, - L1HandlerTransactionOutput, - L2ToL1Payload, - MessageToL1, - RevertedTransactionExecutionStatus, - TransactionExecutionStatus, - TransactionOutput, + DeclareTransactionOutput, DeployAccountTransactionOutput, DeployTransactionOutput, + InvokeTransactionOutput, L1HandlerTransactionOutput, L2ToL1Payload, MessageToL1, + RevertedTransactionExecutionStatus, TransactionExecutionStatus, TransactionOutput, }; use starknet_types_core::felt::Felt; diff --git a/crates/papyrus_protobuf/src/converters/rpc_transaction.rs b/crates/papyrus_protobuf/src/converters/rpc_transaction.rs index 55998e14e8..4a52638af1 100644 --- a/crates/papyrus_protobuf/src/converters/rpc_transaction.rs +++ b/crates/papyrus_protobuf/src/converters/rpc_transaction.rs @@ -4,19 +4,12 @@ mod rpc_transaction_test; use prost::Message; use starknet_api::rpc_transaction::{ - RpcDeclareTransaction, - RpcDeclareTransactionV3, - RpcDeployAccountTransaction, - RpcDeployAccountTransactionV3, - RpcInvokeTransaction, - RpcInvokeTransactionV3, - RpcTransaction, + RpcDeclareTransaction, RpcDeclareTransactionV3, RpcDeployAccountTransaction, + RpcDeployAccountTransactionV3, RpcInvokeTransaction, RpcInvokeTransactionV3, RpcTransaction, }; use starknet_api::transaction::fields::{AllResourceBounds, ValidResourceBounds}; use starknet_api::transaction::{ - DeclareTransactionV3, - DeployAccountTransactionV3, - InvokeTransactionV3, + DeclareTransactionV3, DeployAccountTransactionV3, InvokeTransactionV3, }; use super::ProtobufConversionError; diff --git a/crates/papyrus_protobuf/src/converters/rpc_transaction_test.rs b/crates/papyrus_protobuf/src/converters/rpc_transaction_test.rs index 081cbf1910..54bbc7b0d2 100644 --- a/crates/papyrus_protobuf/src/converters/rpc_transaction_test.rs +++ b/crates/papyrus_protobuf/src/converters/rpc_transaction_test.rs @@ -3,13 +3,8 @@ use papyrus_test_utils::{get_rng, GetTestInstance}; use starknet_api::block::GasPrice; use starknet_api::execution_resources::GasAmount; use starknet_api::rpc_transaction::{ - RpcDeclareTransaction, - RpcDeclareTransactionV3, - RpcDeployAccountTransaction, - RpcDeployAccountTransactionV3, - RpcInvokeTransaction, - RpcInvokeTransactionV3, - RpcTransaction, + RpcDeclareTransaction, RpcDeclareTransactionV3, RpcDeployAccountTransaction, + RpcDeployAccountTransactionV3, RpcInvokeTransaction, RpcInvokeTransactionV3, RpcTransaction, }; use starknet_api::transaction::fields::{AllResourceBounds, ResourceBounds}; diff --git a/crates/papyrus_protobuf/src/converters/state_diff.rs b/crates/papyrus_protobuf/src/converters/state_diff.rs index 070d85cc82..234ae7dd4b 100644 --- a/crates/papyrus_protobuf/src/converters/state_diff.rs +++ b/crates/papyrus_protobuf/src/converters/state_diff.rs @@ -11,12 +11,7 @@ use starknet_types_core::felt::Felt; use super::common::volition_domain_to_enum_int; use super::ProtobufConversionError; use crate::sync::{ - ContractDiff, - DataOrFin, - DeclaredClass, - DeprecatedDeclaredClass, - Query, - StateDiffChunk, + ContractDiff, DataOrFin, DeclaredClass, DeprecatedDeclaredClass, Query, StateDiffChunk, StateDiffQuery, }; use crate::{auto_impl_into_and_try_from_vec_u8, auto_impl_try_from_vec_u8, protobuf}; diff --git a/crates/papyrus_protobuf/src/converters/state_diff_test.rs b/crates/papyrus_protobuf/src/converters/state_diff_test.rs index 3cc84b420b..3e472ba02e 100644 --- a/crates/papyrus_protobuf/src/converters/state_diff_test.rs +++ b/crates/papyrus_protobuf/src/converters/state_diff_test.rs @@ -1,12 +1,7 @@ use papyrus_test_utils::{get_rng, GetTestInstance}; use crate::sync::{ - ContractDiff, - DataOrFin, - DeclaredClass, - DeprecatedDeclaredClass, - StateDiffChunk, - StateDiffQuery, + ContractDiff, DataOrFin, DeclaredClass, DeprecatedDeclaredClass, StateDiffChunk, StateDiffQuery, }; #[test] diff --git a/crates/papyrus_protobuf/src/converters/test_instances.rs b/crates/papyrus_protobuf/src/converters/test_instances.rs index 01c9c1903a..1ed71e3614 100644 --- a/crates/papyrus_protobuf/src/converters/test_instances.rs +++ b/crates/papyrus_protobuf/src/converters/test_instances.rs @@ -5,16 +5,8 @@ use starknet_api::core::ContractAddress; use starknet_api::transaction::{Transaction, TransactionHash}; use crate::consensus::{ - ConsensusMessage, - Proposal, - ProposalFin, - ProposalInit, - ProposalPart, - StreamMessage, - StreamMessageBody, - TransactionBatch, - Vote, - VoteType, + ConsensusMessage, Proposal, ProposalFin, ProposalInit, ProposalPart, StreamMessage, + StreamMessageBody, TransactionBatch, Vote, VoteType, }; auto_impl_get_test_instance! { diff --git a/crates/papyrus_protobuf/src/converters/transaction.rs b/crates/papyrus_protobuf/src/converters/transaction.rs index 2e43b8ccf6..a2288dd8a0 100644 --- a/crates/papyrus_protobuf/src/converters/transaction.rs +++ b/crates/papyrus_protobuf/src/converters/transaction.rs @@ -8,43 +8,20 @@ use starknet_api::block::GasPrice; use starknet_api::core::{ClassHash, CompiledClassHash, EntryPointSelector, Nonce}; use starknet_api::execution_resources::GasAmount; use starknet_api::transaction::fields::{ - AccountDeploymentData, - AllResourceBounds, - Calldata, - ContractAddressSalt, - Fee, - PaymasterData, - ResourceBounds, - Tip, - TransactionSignature, - ValidResourceBounds, + AccountDeploymentData, AllResourceBounds, Calldata, ContractAddressSalt, Fee, PaymasterData, + ResourceBounds, Tip, TransactionSignature, ValidResourceBounds, }; use starknet_api::transaction::{ - DeclareTransaction, - DeclareTransactionV0V1, - DeclareTransactionV2, - DeclareTransactionV3, - DeployAccountTransaction, - DeployAccountTransactionV1, - DeployAccountTransactionV3, - DeployTransaction, - FullTransaction, - InvokeTransaction, - InvokeTransactionV0, - InvokeTransactionV1, - InvokeTransactionV3, - L1HandlerTransaction, - Transaction, - TransactionHash, - TransactionOutput, - TransactionVersion, + DeclareTransaction, DeclareTransactionV0V1, DeclareTransactionV2, DeclareTransactionV3, + DeployAccountTransaction, DeployAccountTransactionV1, DeployAccountTransactionV3, + DeployTransaction, FullTransaction, InvokeTransaction, InvokeTransactionV0, + InvokeTransactionV1, InvokeTransactionV3, L1HandlerTransaction, Transaction, TransactionHash, + TransactionOutput, TransactionVersion, }; use starknet_types_core::felt::Felt; use super::common::{ - enum_int_to_volition_domain, - try_from_starkfelt_to_u128, - try_from_starkfelt_to_u32, + enum_int_to_volition_domain, try_from_starkfelt_to_u128, try_from_starkfelt_to_u32, volition_domain_to_enum_int, }; use super::ProtobufConversionError; diff --git a/crates/papyrus_protobuf/src/converters/transaction_test.rs b/crates/papyrus_protobuf/src/converters/transaction_test.rs index 6f03abf290..f04f9d0637 100644 --- a/crates/papyrus_protobuf/src/converters/transaction_test.rs +++ b/crates/papyrus_protobuf/src/converters/transaction_test.rs @@ -5,16 +5,9 @@ use starknet_api::block::GasPrice; use starknet_api::execution_resources::{Builtin, ExecutionResources, GasAmount, GasVector}; use starknet_api::transaction::fields::{AllResourceBounds, ResourceBounds, ValidResourceBounds}; use starknet_api::transaction::{ - DeclareTransaction, - DeclareTransactionOutput, - DeployAccountTransaction, - DeployAccountTransactionOutput, - DeployTransactionOutput, - FullTransaction, - InvokeTransaction, - InvokeTransactionOutput, - L1HandlerTransactionOutput, - Transaction as StarknetApiTransaction, + DeclareTransaction, DeclareTransactionOutput, DeployAccountTransaction, + DeployAccountTransactionOutput, DeployTransactionOutput, FullTransaction, InvokeTransaction, + InvokeTransactionOutput, L1HandlerTransactionOutput, Transaction as StarknetApiTransaction, TransactionOutput, }; use starknet_api::tx_hash; diff --git a/crates/papyrus_rpc/src/lib.rs b/crates/papyrus_rpc/src/lib.rs index d38dae8b61..70e5abf222 100644 --- a/crates/papyrus_rpc/src/lib.rs +++ b/crates/papyrus_rpc/src/lib.rs @@ -52,8 +52,7 @@ use crate::api::get_methods_from_supported_apis; use crate::middleware::{deny_requests_with_unsupported_path, proxy_rpc_request}; use crate::syncing_state::get_last_synced_block; pub use crate::v0_8::transaction::{ - InvokeTransaction as InvokeTransactionRPC0_8, - InvokeTransactionV1 as InvokeTransactionV1RPC0_8, + InvokeTransaction as InvokeTransactionRPC0_8, InvokeTransactionV1 as InvokeTransactionV1RPC0_8, TransactionVersion1 as TransactionVersion1RPC0_8, }; pub use crate::v0_8::write_api_result::AddInvokeOkResult as AddInvokeOkResultRPC0_8; diff --git a/crates/papyrus_rpc/src/rpc_metrics/rpc_metrics_test.rs b/crates/papyrus_rpc/src/rpc_metrics/rpc_metrics_test.rs index fffd0e1d7e..378ce49c56 100644 --- a/crates/papyrus_rpc/src/rpc_metrics/rpc_metrics_test.rs +++ b/crates/papyrus_rpc/src/rpc_metrics/rpc_metrics_test.rs @@ -16,20 +16,12 @@ use starknet_api::block::{BlockBody, BlockHeader, BlockNumber}; use starknet_api::state::ThinStateDiff; use crate::rpc_metrics::{ - get_method_and_version, - MetricLogger, - FAILED_REQUESTS, - ILLEGAL_METHOD, - INCOMING_REQUEST, - METHOD_LABEL, - VERSION_LABEL, + get_method_and_version, MetricLogger, FAILED_REQUESTS, ILLEGAL_METHOD, INCOMING_REQUEST, + METHOD_LABEL, VERSION_LABEL, }; use crate::run_server; use crate::test_utils::{ - get_test_highest_block, - get_test_pending_classes, - get_test_pending_data, - get_test_rpc_config, + get_test_highest_block, get_test_pending_classes, get_test_pending_data, get_test_rpc_config, }; #[test] diff --git a/crates/papyrus_rpc/src/rpc_test.rs b/crates/papyrus_rpc/src/rpc_test.rs index b0a72935f2..7259b65a38 100644 --- a/crates/papyrus_rpc/src/rpc_test.rs +++ b/crates/papyrus_rpc/src/rpc_test.rs @@ -16,20 +16,13 @@ use papyrus_test_utils::get_rng; use pretty_assertions::assert_eq; use rand::seq::SliceRandom; use starknet_api::block::{ - BlockHash, - BlockHeader, - BlockHeaderWithoutHash, - BlockNumber, - BlockStatus, + BlockHash, BlockHeader, BlockHeaderWithoutHash, BlockNumber, BlockStatus, }; use tower::BoxError; use crate::middleware::proxy_rpc_request; use crate::test_utils::{ - get_test_highest_block, - get_test_pending_classes, - get_test_pending_data, - get_test_rpc_config, + get_test_highest_block, get_test_pending_classes, get_test_pending_data, get_test_rpc_config, }; use crate::version_config::VERSION_CONFIG; use crate::{get_block_status, run_server, SERVER_MAX_BODY_SIZE}; diff --git a/crates/papyrus_rpc/src/test_utils.rs b/crates/papyrus_rpc/src/test_utils.rs index 3a641c5f43..3f7716506f 100644 --- a/crates/papyrus_rpc/src/test_utils.rs +++ b/crates/papyrus_rpc/src/test_utils.rs @@ -54,8 +54,8 @@ pub(crate) fn get_test_pending_classes() -> Arc> { Arc::new(RwLock::new(PendingClasses::default())) } -pub(crate) fn get_test_rpc_server_and_storage_writer() --> (RpcModule, StorageWriter) { +pub(crate) fn get_test_rpc_server_and_storage_writer( +) -> (RpcModule, StorageWriter) { get_test_rpc_server_and_storage_writer_from_params(None, None, None, None, None) } 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 ad9094da1a..a2495dbd6a 100644 --- a/crates/papyrus_rpc/src/v0_8/api/api_impl.rs +++ b/crates/papyrus_rpc/src/v0_8/api/api_impl.rs @@ -7,11 +7,8 @@ use jsonrpsee::RpcModule; use papyrus_common::pending_classes::{PendingClasses, PendingClassesTrait}; use papyrus_execution::objects::{FeeEstimation, PendingData as ExecutionPendingData}; use papyrus_execution::{ - estimate_fee as exec_estimate_fee, - execute_call, - execution_utils, - simulate_transactions as exec_simulate_transactions, - ExecutableTransactionInput, + estimate_fee as exec_estimate_fee, execute_call, execution_utils, + simulate_transactions as exec_simulate_transactions, ExecutableTransactionInput, ExecutionConfig, }; use papyrus_storage::body::events::{EventIndex, EventsReader}; @@ -22,33 +19,22 @@ use papyrus_storage::state::StateStorageReader; use papyrus_storage::{StorageError, StorageReader, StorageTxn}; use starknet_api::block::{BlockHash, BlockHeaderWithoutHash, BlockNumber, BlockStatus}; use starknet_api::core::{ - ChainId, - ClassHash, - ContractAddress, - GlobalRoot, - Nonce, - BLOCK_HASH_TABLE_ADDRESS, + ChainId, ClassHash, ContractAddress, GlobalRoot, Nonce, BLOCK_HASH_TABLE_ADDRESS, }; 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; use starknet_api::transaction::{ - EventContent, - EventIndexInTransactionOutput, - Transaction as StarknetApiTransaction, - TransactionHash, - TransactionOffsetInBlock, - TransactionVersion, + EventContent, EventIndexInTransactionOutput, Transaction as StarknetApiTransaction, + TransactionHash, TransactionOffsetInBlock, TransactionVersion, }; use starknet_client::reader::objects::pending_data::{ - DeprecatedPendingBlock, - PendingBlockOrDeprecated, + DeprecatedPendingBlock, PendingBlockOrDeprecated, PendingStateUpdate as ClientPendingStateUpdate, }; use starknet_client::reader::objects::transaction::{ - Transaction as ClientTransaction, - TransactionReceipt as ClientTransactionReceipt, + Transaction as ClientTransaction, TransactionReceipt as ClientTransactionReceipt, }; use starknet_client::reader::PendingData; use starknet_client::writer::{StarknetWriter, WriterClientError}; @@ -58,80 +44,37 @@ use tokio::sync::RwLock; use tracing::{instrument, trace, warn}; use super::super::block::{ - get_accepted_block_number, - get_block_header_by_number, - Block, - BlockHeader, - BlockNotRevertedValidator, - GeneralBlockHeader, - PendingBlockHeader, - ResourcePrice, + get_accepted_block_number, get_block_header_by_number, Block, BlockHeader, + BlockNotRevertedValidator, GeneralBlockHeader, PendingBlockHeader, ResourcePrice, }; use super::super::broadcasted_transaction::{ - BroadcastedDeclareTransaction, - BroadcastedTransaction, + BroadcastedDeclareTransaction, BroadcastedTransaction, }; use super::super::error::{ - ContractError, - JsonRpcError, - TransactionExecutionError, - BLOCK_NOT_FOUND, - CLASS_HASH_NOT_FOUND, - CONTRACT_NOT_FOUND, - INVALID_TRANSACTION_HASH, - INVALID_TRANSACTION_INDEX, - NO_BLOCKS, - PAGE_SIZE_TOO_BIG, - TOO_MANY_KEYS_IN_FILTER, - TRANSACTION_HASH_NOT_FOUND, + ContractError, JsonRpcError, TransactionExecutionError, BLOCK_NOT_FOUND, CLASS_HASH_NOT_FOUND, + CONTRACT_NOT_FOUND, INVALID_TRANSACTION_HASH, INVALID_TRANSACTION_INDEX, NO_BLOCKS, + PAGE_SIZE_TOO_BIG, TOO_MANY_KEYS_IN_FILTER, TRANSACTION_HASH_NOT_FOUND, }; use super::super::execution::TransactionTrace; use super::super::state::{AcceptedStateUpdate, PendingStateUpdate, StateUpdate}; use super::super::transaction::{ - get_block_tx_hashes_by_number, - get_block_txs_by_number, - Event, - GeneralTransactionReceipt, - L1HandlerMsgHash, - L1L2MsgHash, - MessageFromL1, - PendingTransactionFinalityStatus, - PendingTransactionOutput, - PendingTransactionReceipt, - Transaction, - TransactionOutput, - TransactionReceipt, - TransactionStatus, - TransactionWithHash, - TransactionWithReceipt, - Transactions, - TypedDeployAccountTransaction, - TypedInvokeTransaction, + get_block_tx_hashes_by_number, get_block_txs_by_number, Event, GeneralTransactionReceipt, + L1HandlerMsgHash, L1L2MsgHash, MessageFromL1, PendingTransactionFinalityStatus, + PendingTransactionOutput, PendingTransactionReceipt, Transaction, TransactionOutput, + TransactionReceipt, TransactionStatus, TransactionWithHash, TransactionWithReceipt, + Transactions, TypedDeployAccountTransaction, TypedInvokeTransaction, }; use super::super::write_api_error::{ - starknet_error_to_declare_error, - starknet_error_to_deploy_account_error, + starknet_error_to_declare_error, starknet_error_to_deploy_account_error, starknet_error_to_invoke_error, }; use super::super::write_api_result::{ - AddDeclareOkResult, - AddDeployAccountOkResult, - AddInvokeOkResult, + AddDeclareOkResult, AddDeployAccountOkResult, AddInvokeOkResult, }; use super::{ - execution_error_to_error_object_owned, - stored_txn_to_executable_txn, - BlockHashAndNumber, - BlockId, - CallRequest, - CompiledContractClass, - ContinuationToken, - EventFilter, - EventsChunk, - GatewayContractClass, - JsonRpcV0_8Server as JsonRpcServer, - SimulatedTransaction, - SimulationFlag, + execution_error_to_error_object_owned, stored_txn_to_executable_txn, BlockHashAndNumber, + BlockId, CallRequest, CompiledContractClass, ContinuationToken, EventFilter, EventsChunk, + GatewayContractClass, JsonRpcV0_8Server as JsonRpcServer, SimulatedTransaction, SimulationFlag, TransactionTraceWithHash, }; use crate::api::{BlockHashOrNumber, JsonRpcServerTrait, Tag}; @@ -139,12 +82,8 @@ use crate::pending::client_pending_data_to_execution_pending_data; use crate::syncing_state::{get_last_synced_block, SyncStatus, SyncingState}; use crate::version_config::VERSION_0_8 as VERSION; use crate::{ - get_block_status, - get_latest_block_number, - internal_server_error, - verify_storage_scope, - ContinuationTokenAsStruct, - GENESIS_HASH, + get_block_status, get_latest_block_number, internal_server_error, verify_storage_scope, + ContinuationTokenAsStruct, GENESIS_HASH, }; const DONT_IGNORE_L1_DA_MODE: bool = false; @@ -746,7 +685,7 @@ impl JsonRpcServer for JsonRpcServerImpl { // corresponding to the requested filter. If there are, we return a continuation token // pointing to the next relevant event. Otherwise, we return a continuation token None. let mut filtered_events = vec![]; - if start_event_index.0.0 <= latest_block_number { + if start_event_index.0 .0 <= latest_block_number { for ((from_address, event_index), content) in txn .iter_events(filter.address, start_event_index, to_block_number) .map_err(internal_server_error)? @@ -795,8 +734,8 @@ impl JsonRpcServer for JsonRpcServerImpl { let pending_block = read_pending_data(&self.pending_data, &txn).await?.block; let pending_transaction_receipts = pending_block.transaction_receipts(); // Extract the first transaction offset and event offset from the starting EventIndex. - let (transaction_start, event_start) = if start_event_index.0.0 > latest_block_number { - (start_event_index.0.1.0, start_event_index.1.0) + let (transaction_start, event_start) = if start_event_index.0 .0 > latest_block_number { + (start_event_index.0 .1 .0, start_event_index.1 .0) } else { (0, 0) }; diff --git a/crates/papyrus_rpc/src/v0_8/api/mod.rs b/crates/papyrus_rpc/src/v0_8/api/mod.rs index 5e45ff1386..2ea7103113 100644 --- a/crates/papyrus_rpc/src/v0_8/api/mod.rs +++ b/crates/papyrus_rpc/src/v0_8/api/mod.rs @@ -21,8 +21,7 @@ use starknet_api::block::{BlockHashAndNumber, BlockNumber}; use starknet_api::contract_class::SierraVersion; use starknet_api::core::{ClassHash, ContractAddress, Nonce}; use starknet_api::deprecated_contract_class::{ - ContractClass as StarknetApiDeprecatedContractClass, - Program, + ContractClass as StarknetApiDeprecatedContractClass, Program, }; use starknet_api::state::{StateNumber, StorageKey}; use starknet_api::transaction::fields::Fee; @@ -32,35 +31,19 @@ use tracing::debug; use super::block::Block; use super::broadcasted_transaction::{ - BroadcastedDeclareTransaction, - BroadcastedDeclareV1Transaction, - BroadcastedTransaction, + BroadcastedDeclareTransaction, BroadcastedDeclareV1Transaction, BroadcastedTransaction, }; use super::deprecated_contract_class::ContractClass as DeprecatedContractClass; use super::error::{ - ContractError, - JsonRpcError, - BLOCK_NOT_FOUND, - CONTRACT_NOT_FOUND, - INVALID_CONTINUATION_TOKEN, + ContractError, JsonRpcError, BLOCK_NOT_FOUND, CONTRACT_NOT_FOUND, INVALID_CONTINUATION_TOKEN, }; use super::execution::TransactionTrace; use super::state::{ContractClass, StateUpdate}; use super::transaction::{ - DeployAccountTransaction, - DeployAccountTransactionV1, - DeployAccountTransactionV3, - Event, - GeneralTransactionReceipt, - InvokeTransaction, - InvokeTransactionV0, - InvokeTransactionV1, - InvokeTransactionV3, - MessageFromL1, - TransactionStatus, - TransactionWithHash, - TypedDeployAccountTransaction, - TypedInvokeTransaction, + DeployAccountTransaction, DeployAccountTransactionV1, DeployAccountTransactionV3, Event, + GeneralTransactionReceipt, InvokeTransaction, InvokeTransactionV0, InvokeTransactionV1, + InvokeTransactionV3, MessageFromL1, TransactionStatus, TransactionWithHash, + TypedDeployAccountTransaction, TypedInvokeTransaction, }; use super::write_api_result::{AddDeclareOkResult, AddDeployAccountOkResult, AddInvokeOkResult}; use crate::api::{BlockId, CallRequest}; diff --git a/crates/papyrus_rpc/src/v0_8/api/test.rs b/crates/papyrus_rpc/src/v0_8/api/test.rs index fe2b144322..439f7166dc 100644 --- a/crates/papyrus_rpc/src/v0_8/api/test.rs +++ b/crates/papyrus_rpc/src/v0_8/api/test.rs @@ -25,14 +25,8 @@ use papyrus_storage::state::StateStorageWriter; use papyrus_storage::test_utils::get_test_storage; use papyrus_storage::StorageScope; use papyrus_test_utils::{ - auto_impl_get_test_instance, - get_number_of_variants, - get_rng, - get_test_block, - get_test_body, - get_test_state_diff, - send_request, - GetTestInstance, + auto_impl_get_test_instance, get_number_of_variants, get_rng, get_test_block, get_test_body, + get_test_state_diff, send_request, GetTestInstance, }; use pretty_assertions::assert_eq; use rand::{random, RngCore}; @@ -40,68 +34,40 @@ use rand_chacha::ChaCha8Rng; use reqwest::StatusCode; use serde::{Deserialize, Serialize}; use starknet_api::block::{ - Block as StarknetApiBlock, - BlockHash, - BlockHashAndNumber, - BlockHeader, - BlockHeaderWithoutHash, - BlockNumber, - BlockStatus, - BlockTimestamp, - GasPrice, - GasPricePerToken, - StarknetVersion, + Block as StarknetApiBlock, BlockHash, BlockHashAndNumber, BlockHeader, BlockHeaderWithoutHash, + BlockNumber, BlockStatus, BlockTimestamp, GasPrice, GasPricePerToken, StarknetVersion, }; use starknet_api::core::{ - ClassHash, - CompiledClassHash, - ContractAddress, - GlobalRoot, - Nonce, - SequencerContractAddress, + ClassHash, CompiledClassHash, ContractAddress, GlobalRoot, Nonce, SequencerContractAddress, BLOCK_HASH_TABLE_ADDRESS, }; use starknet_api::data_availability::L1DataAvailabilityMode; use starknet_api::deprecated_contract_class::{ - ContractClass as StarknetApiDeprecatedContractClass, - ContractClassAbiEntry, - FunctionAbiEntry, + ContractClass as StarknetApiDeprecatedContractClass, ContractClassAbiEntry, FunctionAbiEntry, FunctionStateMutability, }; use starknet_api::state::{SierraContractClass as StarknetApiContractClass, StateDiff}; use starknet_api::transaction::{ - Event as StarknetApiEvent, - EventContent, - EventData, - EventIndexInTransactionOutput, - EventKey, - Transaction as StarknetApiTransaction, - TransactionHash, - TransactionOffsetInBlock, + Event as StarknetApiEvent, EventContent, EventData, EventIndexInTransactionOutput, EventKey, + Transaction as StarknetApiTransaction, TransactionHash, TransactionOffsetInBlock, TransactionOutput as StarknetApiTransactionOutput, }; use starknet_api::{class_hash, contract_address, felt, storage_key, tx_hash}; use starknet_client::reader::objects::pending_data::{ - DeprecatedPendingBlock, - PendingBlockOrDeprecated, + DeprecatedPendingBlock, PendingBlockOrDeprecated, PendingStateUpdate as ClientPendingStateUpdate, }; use starknet_client::reader::objects::state::{ DeclaredClassHashEntry as ClientDeclaredClassHashEntry, - DeployedContract as ClientDeployedContract, - ReplacedClass as ClientReplacedClass, - StateDiff as ClientStateDiff, - StorageEntry as ClientStorageEntry, + DeployedContract as ClientDeployedContract, ReplacedClass as ClientReplacedClass, + StateDiff as ClientStateDiff, StorageEntry as ClientStorageEntry, }; use starknet_client::reader::objects::transaction::{ - Transaction as ClientTransaction, - TransactionReceipt as ClientTransactionReceipt, + Transaction as ClientTransaction, TransactionReceipt as ClientTransactionReceipt, }; use starknet_client::starknet_error::{KnownStarknetErrorCode, StarknetError, StarknetErrorCode}; use starknet_client::writer::objects::response::{ - DeclareResponse, - DeployAccountResponse, - InvokeResponse, + DeclareResponse, DeployAccountResponse, InvokeResponse, }; use starknet_client::writer::objects::transaction::{ DeclareTransaction as ClientDeclareTransaction, @@ -117,88 +83,40 @@ use super::super::block::{Block, GeneralBlockHeader, PendingBlockHeader, Resourc use super::super::broadcasted_transaction::BroadcastedDeclareTransaction; use super::super::deprecated_contract_class::ContractClass as DeprecatedContractClass; use super::super::error::{ - unexpected_error, - JsonRpcError, - BLOCK_NOT_FOUND, - CLASS_HASH_NOT_FOUND, - COMPILATION_FAILED, - CONTRACT_NOT_FOUND, - DUPLICATE_TX, - INVALID_CONTINUATION_TOKEN, - INVALID_TRANSACTION_INDEX, - NO_BLOCKS, - PAGE_SIZE_TOO_BIG, - TOO_MANY_KEYS_IN_FILTER, - TRANSACTION_HASH_NOT_FOUND, + unexpected_error, JsonRpcError, BLOCK_NOT_FOUND, CLASS_HASH_NOT_FOUND, COMPILATION_FAILED, + CONTRACT_NOT_FOUND, DUPLICATE_TX, INVALID_CONTINUATION_TOKEN, INVALID_TRANSACTION_INDEX, + NO_BLOCKS, PAGE_SIZE_TOO_BIG, TOO_MANY_KEYS_IN_FILTER, TRANSACTION_HASH_NOT_FOUND, }; use super::super::state::{ - AcceptedStateUpdate, - ClassHashes, - ContractClass, - ContractNonce, - DeployedContract, - PendingStateUpdate, - ReplacedClasses, - StateUpdate, - StorageDiff, - StorageEntry, - ThinStateDiff, + AcceptedStateUpdate, ClassHashes, ContractClass, ContractNonce, DeployedContract, + PendingStateUpdate, ReplacedClasses, StateUpdate, StorageDiff, StorageEntry, ThinStateDiff, }; use super::super::transaction::{ - DeployAccountTransaction, - Event, - GeneralTransactionReceipt, - InvokeTransaction, - L1HandlerMsgHash, - L1L2MsgHash, - PendingTransactionFinalityStatus, - PendingTransactionOutput, - PendingTransactionReceipt, - Transaction, - TransactionFinalityStatus, - TransactionOutput, - TransactionReceipt, - TransactionStatus, - TransactionWithHash, - TransactionWithReceipt, - Transactions, - TypedDeployAccountTransaction, - TypedInvokeTransaction, + DeployAccountTransaction, Event, GeneralTransactionReceipt, InvokeTransaction, + L1HandlerMsgHash, L1L2MsgHash, PendingTransactionFinalityStatus, PendingTransactionOutput, + PendingTransactionReceipt, Transaction, TransactionFinalityStatus, TransactionOutput, + TransactionReceipt, TransactionStatus, TransactionWithHash, TransactionWithReceipt, + Transactions, TypedDeployAccountTransaction, TypedInvokeTransaction, }; use super::super::write_api_result::{ - AddDeclareOkResult, - AddDeployAccountOkResult, - AddInvokeOkResult, + AddDeclareOkResult, AddDeployAccountOkResult, AddInvokeOkResult, }; use super::api_impl::JsonRpcServerImpl; use super::{ContinuationToken, EventFilter, GatewayContractClass}; use crate::api::{BlockHashOrNumber, BlockId, Tag}; use crate::syncing_state::SyncStatus; use crate::test_utils::{ - call_and_validate_schema_for_result, - call_api_then_assert_and_validate_schema_for_err, - call_api_then_assert_and_validate_schema_for_result, - get_method_names_from_spec, - get_starknet_spec_api_schema_for_components, - get_starknet_spec_api_schema_for_method_results, - get_test_highest_block, - get_test_pending_classes, - get_test_pending_data, - get_test_rpc_config, - get_test_rpc_server_and_storage_writer, - get_test_rpc_server_and_storage_writer_from_params, - method_name_to_spec_method_name, - raw_call, - validate_schema, - SpecFile, + call_and_validate_schema_for_result, call_api_then_assert_and_validate_schema_for_err, + call_api_then_assert_and_validate_schema_for_result, get_method_names_from_spec, + get_starknet_spec_api_schema_for_components, get_starknet_spec_api_schema_for_method_results, + get_test_highest_block, get_test_pending_classes, get_test_pending_data, get_test_rpc_config, + get_test_rpc_server_and_storage_writer, get_test_rpc_server_and_storage_writer_from_params, + method_name_to_spec_method_name, raw_call, validate_schema, SpecFile, }; use crate::v0_8::api::CompiledContractClass; use crate::version_config::VERSION_0_8 as VERSION; use crate::{ - internal_server_error, - internal_server_error_with_msg, - run_server, - ContinuationTokenAsStruct, + internal_server_error, internal_server_error_with_msg, run_server, ContinuationTokenAsStruct, GENESIS_HASH, }; diff --git a/crates/papyrus_rpc/src/v0_8/block.rs b/crates/papyrus_rpc/src/v0_8/block.rs index 2659535a3b..7aab0728c0 100644 --- a/crates/papyrus_rpc/src/v0_8/block.rs +++ b/crates/papyrus_rpc/src/v0_8/block.rs @@ -173,6 +173,10 @@ impl BlockNotRevertedValidator { .map_err(internal_server_error)? .ok_or(error.clone())? .block_hash; - if new_block_hash == self.old_block_hash { Ok(()) } else { Err(error) } + if new_block_hash == self.old_block_hash { + Ok(()) + } else { + Err(error) + } } } diff --git a/crates/papyrus_rpc/src/v0_8/broadcasted_transaction.rs b/crates/papyrus_rpc/src/v0_8/broadcasted_transaction.rs index 0d802e3272..3fdf490a5d 100644 --- a/crates/papyrus_rpc/src/v0_8/broadcasted_transaction.rs +++ b/crates/papyrus_rpc/src/v0_8/broadcasted_transaction.rs @@ -16,11 +16,7 @@ use serde::{Deserialize, Serialize}; use starknet_api::core::{CompiledClassHash, ContractAddress, Nonce}; use starknet_api::data_availability::DataAvailabilityMode; use starknet_api::transaction::fields::{ - AccountDeploymentData, - Fee, - PaymasterData, - Tip, - TransactionSignature, + AccountDeploymentData, Fee, PaymasterData, Tip, TransactionSignature, }; use starknet_api::transaction::TransactionVersion; use starknet_client::writer::objects::transaction as client_transaction; 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 806581ba01..394ceda496 100644 --- a/crates/papyrus_rpc/src/v0_8/broadcasted_transaction_test.rs +++ b/crates/papyrus_rpc/src/v0_8/broadcasted_transaction_test.rs @@ -3,40 +3,26 @@ use std::collections::HashMap; use jsonschema::JSONSchema; use lazy_static::lazy_static; use papyrus_test_utils::{ - auto_impl_get_test_instance, - get_number_of_variants, - get_rng, - GetTestInstance, + auto_impl_get_test_instance, get_number_of_variants, get_rng, GetTestInstance, }; use starknet_api::contract_class::EntryPointType; use starknet_api::core::{CompiledClassHash, ContractAddress, Nonce}; use starknet_api::data_availability::DataAvailabilityMode; use starknet_api::deprecated_contract_class::{ - ContractClassAbiEntry as DeprecatedContractClassAbiEntry, - EntryPointV0 as DeprecatedEntryPoint, - EventAbiEntry, - FunctionAbiEntry, - StructAbiEntry, + ContractClassAbiEntry as DeprecatedContractClassAbiEntry, EntryPointV0 as DeprecatedEntryPoint, + EventAbiEntry, FunctionAbiEntry, StructAbiEntry, }; use starknet_api::state::EntryPoint; use starknet_api::transaction::fields::{ - AccountDeploymentData, - Fee, - PaymasterData, - ResourceBounds, - Tip, - TransactionSignature, + AccountDeploymentData, Fee, PaymasterData, ResourceBounds, Tip, TransactionSignature, }; use starknet_client::writer::objects::transaction::DeprecatedContractClass; use starknet_types_core::felt::Felt; use super::super::state::{ContractClass, EntryPointByType}; use super::{ - BroadcastedDeclareTransaction, - BroadcastedDeclareV1Transaction, - BroadcastedDeclareV2Transaction, - BroadcastedDeclareV3Transaction, - DeclareType, + BroadcastedDeclareTransaction, BroadcastedDeclareV1Transaction, + BroadcastedDeclareV2Transaction, BroadcastedDeclareV3Transaction, DeclareType, ResourceBoundsMapping, }; use crate::test_utils::{get_starknet_spec_api_schema_for_components, SpecFile}; diff --git a/crates/papyrus_rpc/src/v0_8/execution.rs b/crates/papyrus_rpc/src/v0_8/execution.rs index 1e8c03700e..a2c188b5ed 100644 --- a/crates/papyrus_rpc/src/v0_8/execution.rs +++ b/crates/papyrus_rpc/src/v0_8/execution.rs @@ -1,13 +1,7 @@ use papyrus_execution::objects::{ - CallType, - FunctionCall, - FunctionInvocation as ExecutionFunctionInvocation, - FunctionInvocationResult as ExecutionFunctionInvocationResult, - OrderedEvent, - OrderedL2ToL1Message, - Retdata, - RevertReason, - TransactionTrace as ExecutionTransactionTrace, + CallType, FunctionCall, FunctionInvocation as ExecutionFunctionInvocation, + FunctionInvocationResult as ExecutionFunctionInvocationResult, OrderedEvent, + OrderedL2ToL1Message, Retdata, RevertReason, TransactionTrace as ExecutionTransactionTrace, }; use serde::{Deserialize, Serialize}; use starknet_api::contract_class::EntryPointType; diff --git a/crates/papyrus_rpc/src/v0_8/execution_test.rs b/crates/papyrus_rpc/src/v0_8/execution_test.rs index 732525a62f..e059359466 100644 --- a/crates/papyrus_rpc/src/v0_8/execution_test.rs +++ b/crates/papyrus_rpc/src/v0_8/execution_test.rs @@ -9,19 +9,12 @@ use jsonrpsee::RpcModule; use lazy_static::lazy_static; use papyrus_common::pending_classes::{ApiContractClass, PendingClasses, PendingClassesTrait}; use papyrus_common::state::{ - DeclaredClassHashEntry, - DeployedContract as CommonDeployedContract, + DeclaredClassHashEntry, DeployedContract as CommonDeployedContract, StorageEntry as CommonStorageEntry, }; use papyrus_execution::execution_utils::selector_from_name; use papyrus_execution::objects::{ - CallType, - FeeEstimation, - FunctionCall, - OrderedEvent, - OrderedL2ToL1Message, - PriceUnit, - Retdata, + CallType, FeeEstimation, FunctionCall, OrderedEvent, OrderedL2ToL1Message, PriceUnit, Retdata, RevertReason, }; use papyrus_execution::testing_instances::get_storage_var_address; @@ -33,31 +26,17 @@ use papyrus_storage::header::HeaderStorageWriter; use papyrus_storage::state::StateStorageWriter; use papyrus_storage::StorageWriter; use papyrus_test_utils::{ - auto_impl_get_test_instance, - get_number_of_variants, - get_rng, - GetTestInstance, + auto_impl_get_test_instance, get_number_of_variants, get_rng, GetTestInstance, }; use pretty_assertions::assert_eq; use starknet_api::block::{ - BlockBody, - BlockHash, - BlockHeader, - BlockHeaderWithoutHash, - BlockNumber, - BlockTimestamp, + BlockBody, BlockHash, BlockHeader, BlockHeaderWithoutHash, BlockNumber, BlockTimestamp, GasPricePerToken, }; use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ - ClassHash, - CompiledClassHash, - ContractAddress, - EntryPointSelector, - EthAddress, - Nonce, - PatriciaKey, - SequencerContractAddress, + ClassHash, CompiledClassHash, ContractAddress, EntryPointSelector, EthAddress, Nonce, + PatriciaKey, SequencerContractAddress, }; use starknet_api::data_availability::L1DataAvailabilityMode; use starknet_api::deprecated_contract_class::ContractClass as SN_API_DeprecatedContractClass; @@ -66,21 +45,15 @@ use starknet_api::state::{StorageKey, ThinStateDiff as StarknetApiStateDiff}; use starknet_api::test_utils::{path_in_resources, read_json_file}; use starknet_api::transaction::fields::{Calldata, Fee}; use starknet_api::transaction::{ - L1HandlerTransaction, - TransactionHash, - TransactionOffsetInBlock, - TransactionVersion, + L1HandlerTransaction, TransactionHash, TransactionOffsetInBlock, TransactionVersion, }; use starknet_api::{calldata, class_hash, contract_address, felt, nonce, tx_hash}; use starknet_client::reader::objects::pending_data::{ - PendingBlock, - PendingBlockOrDeprecated, - PendingStateUpdate, + PendingBlock, PendingBlockOrDeprecated, PendingStateUpdate, }; use starknet_client::reader::objects::state::StateDiff as ClientStateDiff; use starknet_client::reader::objects::transaction::{ - IntermediateInvokeTransaction as ClientInvokeTransaction, - Transaction as ClientTransaction, + IntermediateInvokeTransaction as ClientInvokeTransaction, Transaction as ClientTransaction, TransactionReceipt as ClientTransactionReceipt, }; use starknet_client::reader::PendingData; @@ -89,57 +62,31 @@ use tokio::sync::RwLock; use super::api::api_impl::JsonRpcServerImpl; use super::api::{ - decompress_program, - SimulatedTransaction, - SimulationFlag, - TransactionTraceWithHash, + decompress_program, SimulatedTransaction, SimulationFlag, TransactionTraceWithHash, }; use super::broadcasted_transaction::{ - BroadcastedDeclareTransaction, - BroadcastedDeclareV1Transaction, - BroadcastedTransaction, + BroadcastedDeclareTransaction, BroadcastedDeclareV1Transaction, BroadcastedTransaction, }; use super::error::{TransactionExecutionError, BLOCK_NOT_FOUND, CONTRACT_NOT_FOUND}; use super::execution::{ - DeclareTransactionTrace, - DeployAccountTransactionTrace, - FunctionInvocation, - FunctionInvocationResult, - InvokeTransactionTrace, - L1HandlerTransactionTrace, - TransactionTrace, + DeclareTransactionTrace, DeployAccountTransactionTrace, FunctionInvocation, + FunctionInvocationResult, InvokeTransactionTrace, L1HandlerTransactionTrace, TransactionTrace, }; use super::state::{ - ClassHashes, - ContractNonce, - DeployedContract, - ReplacedClasses, - StorageDiff, - StorageEntry, + ClassHashes, ContractNonce, DeployedContract, ReplacedClasses, StorageDiff, StorageEntry, ThinStateDiff, }; use super::transaction::{ - Builtin, - DeployAccountTransaction, - ExecutionResources, - InvokeTransaction, - InvokeTransactionV1, - MessageFromL1, - TransactionVersion1, + Builtin, DeployAccountTransaction, ExecutionResources, InvokeTransaction, InvokeTransactionV1, + MessageFromL1, TransactionVersion1, }; use crate::api::{BlockHashOrNumber, BlockId, CallRequest, Tag}; use crate::test_utils::{ - call_and_validate_schema_for_result, - call_api_then_assert_and_validate_schema_for_result, - get_starknet_spec_api_schema_for_components, - get_starknet_spec_api_schema_for_method_results, - get_test_pending_classes, - get_test_pending_data, - get_test_rpc_config, - get_test_rpc_server_and_storage_writer, - get_test_rpc_server_and_storage_writer_from_params, - validate_schema, - SpecFile, + call_and_validate_schema_for_result, call_api_then_assert_and_validate_schema_for_result, + get_starknet_spec_api_schema_for_components, get_starknet_spec_api_schema_for_method_results, + get_test_pending_classes, get_test_pending_data, get_test_rpc_config, + get_test_rpc_server_and_storage_writer, get_test_rpc_server_and_storage_writer_from_params, + validate_schema, SpecFile, }; use crate::version_config::VERSION_0_8 as VERSION; @@ -1486,7 +1433,7 @@ fn get_calldata_for_test_execution_info( let entry_point_selector = selector_from_name("test_get_execution_info"); let expected_block_number = felt!(expected_block_number.0); let expected_block_timestamp = felt!(expected_block_timestamp.0); - let expected_sequencer_address = *(expected_sequencer_address.0.0.key()); + let expected_sequencer_address = *(expected_sequencer_address.0 .0.key()); let expected_caller_address = *(invoke_tx.sender_address.0.key()); let expected_contract_address = *CONTRACT_ADDRESS.0.key(); let expected_transaction_version = override_tx_version.unwrap_or(Felt::ONE); diff --git a/crates/papyrus_rpc/src/v0_8/state.rs b/crates/papyrus_rpc/src/v0_8/state.rs index 7e0cd096e2..1695aae4cc 100644 --- a/crates/papyrus_rpc/src/v0_8/state.rs +++ b/crates/papyrus_rpc/src/v0_8/state.rs @@ -8,10 +8,8 @@ use starknet_api::rpc_transaction::EntryPointByType as starknet_api_EntryPointBy use starknet_api::state::{EntryPoint, StorageKey, ThinStateDiff as starknet_api_ThinStateDiff}; use starknet_client::reader::objects::state::{ DeclaredClassHashEntry as ClientDeclaredClassHashEntry, - DeployedContract as ClientDeployedContract, - ReplacedClass as ClientReplacedClass, - StateDiff as ClientStateDiff, - StorageEntry as ClientStorageEntry, + DeployedContract as ClientDeployedContract, ReplacedClass as ClientReplacedClass, + StateDiff as ClientStateDiff, StorageEntry as ClientStorageEntry, }; use starknet_types_core::felt::Felt; diff --git a/crates/papyrus_rpc/src/v0_8/transaction.rs b/crates/papyrus_rpc/src/v0_8/transaction.rs index 1637542041..0b6a4a650d 100644 --- a/crates/papyrus_rpc/src/v0_8/transaction.rs +++ b/crates/papyrus_rpc/src/v0_8/transaction.rs @@ -17,35 +17,18 @@ use papyrus_storage::StorageTxn; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use starknet_api::block::{BlockHash, BlockNumber, BlockStatus}; use starknet_api::core::{ - ClassHash, - CompiledClassHash, - ContractAddress, - EntryPointSelector, - EthAddress, - Nonce, + ClassHash, CompiledClassHash, ContractAddress, EntryPointSelector, EthAddress, Nonce, }; 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::fields::{ - AccountDeploymentData, - AllResourceBounds, - Calldata, - ContractAddressSalt, - Fee, - PaymasterData, - Resource, - ResourceBounds, - Tip, - TransactionSignature, + AccountDeploymentData, AllResourceBounds, Calldata, ContractAddressSalt, Fee, PaymasterData, + Resource, ResourceBounds, Tip, TransactionSignature, }; use starknet_api::transaction::{ - DeployTransaction, - L1HandlerTransaction, - MessageToL1, - TransactionExecutionStatus, - TransactionHash, - TransactionVersion, + DeployTransaction, L1HandlerTransaction, MessageToL1, TransactionExecutionStatus, + TransactionHash, TransactionVersion, }; use starknet_client::writer::objects::transaction as client_transaction; use starknet_types_core::felt::Felt; diff --git a/crates/papyrus_rpc/src/v0_8/transaction_test.rs b/crates/papyrus_rpc/src/v0_8/transaction_test.rs index 965656b6f8..f9543bd518 100644 --- a/crates/papyrus_rpc/src/v0_8/transaction_test.rs +++ b/crates/papyrus_rpc/src/v0_8/transaction_test.rs @@ -1,19 +1,11 @@ use papyrus_test_utils::{ - auto_impl_get_test_instance, - get_number_of_variants, - get_rng, - GetTestInstance, + auto_impl_get_test_instance, get_number_of_variants, get_rng, GetTestInstance, }; use pretty_assertions::assert_eq; use starknet_api::core::{ClassHash, ContractAddress, EntryPointSelector, Nonce}; use starknet_api::data_availability::DataAvailabilityMode; use starknet_api::transaction::fields::{ - AccountDeploymentData, - Calldata, - ContractAddressSalt, - Fee, - PaymasterData, - Tip, + AccountDeploymentData, Calldata, ContractAddressSalt, Fee, PaymasterData, Tip, TransactionSignature, }; use starknet_api::transaction::{L1HandlerTransaction, Transaction, TransactionVersion}; @@ -22,17 +14,9 @@ use starknet_client::writer::objects::transaction as client_transaction; use super::super::transaction::{L1HandlerMsgHash, L1L2MsgHash}; use super::{ - DeployAccountTransaction, - DeployAccountTransactionV1, - DeployAccountTransactionV3, - InvokeTransaction, - InvokeTransactionV0, - InvokeTransactionV1, - InvokeTransactionV3, - ResourceBoundsMapping, - TransactionVersion0, - TransactionVersion1, - TransactionVersion3, + DeployAccountTransaction, DeployAccountTransactionV1, DeployAccountTransactionV3, + InvokeTransaction, InvokeTransactionV0, InvokeTransactionV1, InvokeTransactionV3, + ResourceBoundsMapping, TransactionVersion0, TransactionVersion1, TransactionVersion3, }; lazy_static::lazy_static! { diff --git a/crates/papyrus_rpc/src/v0_8/write_api_error.rs b/crates/papyrus_rpc/src/v0_8/write_api_error.rs index ba977c0411..5b7db6963b 100644 --- a/crates/papyrus_rpc/src/v0_8/write_api_error.rs +++ b/crates/papyrus_rpc/src/v0_8/write_api_error.rs @@ -1,21 +1,11 @@ use starknet_client::starknet_error::{KnownStarknetErrorCode, StarknetError, StarknetErrorCode}; use super::error::{ - unexpected_error, - validation_failure, - JsonRpcError, - CLASS_ALREADY_DECLARED, - CLASS_HASH_NOT_FOUND, - COMPILATION_FAILED, - COMPILED_CLASS_HASH_MISMATCH, - CONTRACT_CLASS_SIZE_IS_TOO_LARGE, - DUPLICATE_TX, - INSUFFICIENT_ACCOUNT_BALANCE, - INSUFFICIENT_MAX_FEE, - INVALID_TRANSACTION_NONCE, - NON_ACCOUNT, - UNSUPPORTED_CONTRACT_CLASS_VERSION, - UNSUPPORTED_TX_VERSION, + unexpected_error, validation_failure, JsonRpcError, CLASS_ALREADY_DECLARED, + CLASS_HASH_NOT_FOUND, COMPILATION_FAILED, COMPILED_CLASS_HASH_MISMATCH, + CONTRACT_CLASS_SIZE_IS_TOO_LARGE, DUPLICATE_TX, INSUFFICIENT_ACCOUNT_BALANCE, + INSUFFICIENT_MAX_FEE, INVALID_TRANSACTION_NONCE, NON_ACCOUNT, + UNSUPPORTED_CONTRACT_CLASS_VERSION, UNSUPPORTED_TX_VERSION, }; #[cfg(test)] diff --git a/crates/papyrus_rpc/src/v0_8/write_api_error_test.rs b/crates/papyrus_rpc/src/v0_8/write_api_error_test.rs index 1fa9006a64..e19ad6e6a1 100644 --- a/crates/papyrus_rpc/src/v0_8/write_api_error_test.rs +++ b/crates/papyrus_rpc/src/v0_8/write_api_error_test.rs @@ -6,8 +6,7 @@ use starknet_client::starknet_error::{KnownStarknetErrorCode, StarknetError, Sta use super::super::error::JsonRpcError; use super::{ - starknet_error_to_declare_error, - starknet_error_to_deploy_account_error, + starknet_error_to_declare_error, starknet_error_to_deploy_account_error, starknet_error_to_invoke_error, }; use crate::test_utils::{get_starknet_spec_api_schema_for_method_errors, SpecFile}; 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..1d3ae8d731 100644 --- a/crates/papyrus_rpc/src/v0_8/write_api_result.rs +++ b/crates/papyrus_rpc/src/v0_8/write_api_result.rs @@ -2,9 +2,7 @@ use serde::{Deserialize, Serialize}; use starknet_api::core::{ClassHash, ContractAddress}; use starknet_api::transaction::TransactionHash; use starknet_client::writer::objects::response::{ - DeclareResponse, - DeployAccountResponse, - InvokeResponse, + DeclareResponse, DeployAccountResponse, InvokeResponse, }; #[cfg(test)] 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 7be59678c2..ea6ff39f90 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 @@ -4,10 +4,7 @@ use starknet_api::core::{ClassHash, ContractAddress, PatriciaKey}; use starknet_api::transaction::TransactionHash; use starknet_api::{class_hash, felt, tx_hash}; use starknet_client::writer::objects::response::{ - DeclareResponse, - DeployAccountResponse, - InvokeResponse, - SuccessfulStarknetErrorCode, + DeclareResponse, DeployAccountResponse, InvokeResponse, SuccessfulStarknetErrorCode, }; use super::{AddDeclareOkResult, AddDeployAccountOkResult, AddInvokeOkResult}; diff --git a/crates/papyrus_rpc/tests/gateway_integration_test.rs b/crates/papyrus_rpc/tests/gateway_integration_test.rs index a4e24cb698..0eceff191d 100644 --- a/crates/papyrus_rpc/tests/gateway_integration_test.rs +++ b/crates/papyrus_rpc/tests/gateway_integration_test.rs @@ -4,9 +4,7 @@ use jsonrpsee::core::client::ClientT; use jsonrpsee::http_client::{HttpClient, HttpClientBuilder}; use jsonrpsee::rpc_params; use papyrus_rpc::{ - AddInvokeOkResultRPC0_8, - InvokeTransactionRPC0_8, - InvokeTransactionV1RPC0_8, + AddInvokeOkResultRPC0_8, InvokeTransactionRPC0_8, InvokeTransactionV1RPC0_8, TransactionVersion1RPC0_8, }; use starknet_api::core::{ChainId, ContractAddress, EntryPointSelector, Nonce}; diff --git a/crates/papyrus_state_reader/src/papyrus_state.rs b/crates/papyrus_state_reader/src/papyrus_state.rs index 2af2651d10..14bc9887c4 100644 --- a/crates/papyrus_state_reader/src/papyrus_state.rs +++ b/crates/papyrus_state_reader/src/papyrus_state.rs @@ -1,7 +1,5 @@ use blockifier::execution::contract_class::{ - CompiledClassV0, - CompiledClassV1, - RunnableCompiledClass, + CompiledClassV0, CompiledClassV1, RunnableCompiledClass, }; use blockifier::state::errors::StateError; use blockifier::state::global_cache::GlobalContractCache; diff --git a/crates/papyrus_storage/src/body/body_test.rs b/crates/papyrus_storage/src/body/body_test.rs index 052d549b12..36b2609236 100644 --- a/crates/papyrus_storage/src/body/body_test.rs +++ b/crates/papyrus_storage/src/body/body_test.rs @@ -246,46 +246,44 @@ async fn get_reverted_body_returns_none() { append_2_bodies(&mut writer); // Verify that we can get block 1's transactions before the revert. - assert!( - reader.begin_ro_txn().unwrap().get_block_transactions(BlockNumber(1)).unwrap().is_some() - ); - assert!( - reader - .begin_ro_txn() - .unwrap() - .get_block_transaction_hashes(BlockNumber(1)) - .unwrap() - .is_some() - ); - assert!( - reader - .begin_ro_txn() - .unwrap() - .get_block_transaction_outputs(BlockNumber(1)) - .unwrap() - .is_some() - ); + assert!(reader + .begin_ro_txn() + .unwrap() + .get_block_transactions(BlockNumber(1)) + .unwrap() + .is_some()); + assert!(reader + .begin_ro_txn() + .unwrap() + .get_block_transaction_hashes(BlockNumber(1)) + .unwrap() + .is_some()); + assert!(reader + .begin_ro_txn() + .unwrap() + .get_block_transaction_outputs(BlockNumber(1)) + .unwrap() + .is_some()); writer.begin_rw_txn().unwrap().revert_body(BlockNumber(1)).unwrap().0.commit().unwrap(); - assert!( - reader.begin_ro_txn().unwrap().get_block_transactions(BlockNumber(1)).unwrap().is_none() - ); - assert!( - reader - .begin_ro_txn() - .unwrap() - .get_block_transaction_hashes(BlockNumber(1)) - .unwrap() - .is_none() - ); - assert!( - reader - .begin_ro_txn() - .unwrap() - .get_block_transaction_outputs(BlockNumber(1)) - .unwrap() - .is_none() - ); + assert!(reader + .begin_ro_txn() + .unwrap() + .get_block_transactions(BlockNumber(1)) + .unwrap() + .is_none()); + assert!(reader + .begin_ro_txn() + .unwrap() + .get_block_transaction_hashes(BlockNumber(1)) + .unwrap() + .is_none()); + assert!(reader + .begin_ro_txn() + .unwrap() + .get_block_transaction_outputs(BlockNumber(1)) + .unwrap() + .is_none()); } #[tokio::test] @@ -315,25 +313,24 @@ async fn revert_transactions() { tx_hash ); } - assert!( - reader.begin_ro_txn().unwrap().get_block_transactions(BlockNumber(0)).unwrap().is_some() - ); - assert!( - reader - .begin_ro_txn() - .unwrap() - .get_block_transaction_hashes(BlockNumber(0)) - .unwrap() - .is_some() - ); - assert!( - reader - .begin_ro_txn() - .unwrap() - .get_block_transaction_outputs(BlockNumber(0)) - .unwrap() - .is_some() - ); + assert!(reader + .begin_ro_txn() + .unwrap() + .get_block_transactions(BlockNumber(0)) + .unwrap() + .is_some()); + assert!(reader + .begin_ro_txn() + .unwrap() + .get_block_transaction_hashes(BlockNumber(0)) + .unwrap() + .is_some()); + assert!(reader + .begin_ro_txn() + .unwrap() + .get_block_transaction_outputs(BlockNumber(0)) + .unwrap() + .is_some()); writer.begin_rw_txn().unwrap().revert_body(BlockNumber(0)).unwrap().0.commit().unwrap(); @@ -343,37 +340,37 @@ async fn revert_transactions() { assert!(reader.begin_ro_txn().unwrap().get_transaction(tx_index).unwrap().is_none()); assert!(reader.begin_ro_txn().unwrap().get_transaction_output(tx_index).unwrap().is_none()); - assert!( - reader.begin_ro_txn().unwrap().get_transaction_idx_by_hash(&tx_hash).unwrap().is_none() - ); - assert!( - reader - .begin_ro_txn() - .unwrap() - .get_transaction_hash_by_idx(&tx_index) - .unwrap() - .is_none() - ); - } - assert!( - reader.begin_ro_txn().unwrap().get_block_transactions(BlockNumber(0)).unwrap().is_none() - ); - assert!( - reader + assert!(reader .begin_ro_txn() .unwrap() - .get_block_transaction_hashes(BlockNumber(0)) + .get_transaction_idx_by_hash(&tx_hash) .unwrap() - .is_none() - ); - assert!( - reader + .is_none()); + assert!(reader .begin_ro_txn() .unwrap() - .get_block_transaction_outputs(BlockNumber(0)) + .get_transaction_hash_by_idx(&tx_index) .unwrap() - .is_none() - ); + .is_none()); + } + assert!(reader + .begin_ro_txn() + .unwrap() + .get_block_transactions(BlockNumber(0)) + .unwrap() + .is_none()); + assert!(reader + .begin_ro_txn() + .unwrap() + .get_block_transaction_hashes(BlockNumber(0)) + .unwrap() + .is_none()); + assert!(reader + .begin_ro_txn() + .unwrap() + .get_block_transaction_outputs(BlockNumber(0)) + .unwrap() + .is_none()); } fn append_2_bodies(writer: &mut StorageWriter) { diff --git a/crates/papyrus_storage/src/body/events.rs b/crates/papyrus_storage/src/body/events.rs index b4cfe849c3..acba70b006 100644 --- a/crates/papyrus_storage/src/body/events.rs +++ b/crates/papyrus_storage/src/body/events.rs @@ -54,10 +54,7 @@ use serde::{Deserialize, Serialize}; use starknet_api::block::BlockNumber; use starknet_api::core::ContractAddress; use starknet_api::transaction::{ - Event, - EventContent, - EventIndexInTransactionOutput, - TransactionOutput, + Event, EventContent, EventIndexInTransactionOutput, TransactionOutput, }; use super::TransactionMetadataTable; @@ -268,7 +265,7 @@ where let events_table = self.open_table(&self.tables.events)?; let mut cursor = events_table.cursor(&self.txn)?; let events_queue = if let Some((contract_address, tx_index)) = - cursor.lower_bound(&(key.0, key.1.0))?.map(|(key, _)| key) + cursor.lower_bound(&(key.0, key.1 .0))?.map(|(key, _)| key) { let tx_metadata = transaction_metadata_table.get(&self.txn, &tx_index)?.unwrap_or_else(|| { @@ -280,7 +277,7 @@ where // In case of we get tx_index different from the key, it means we need to start a new // transaction which means the first event. - let start_event_index = if tx_index == key.1.0 { key.1.1.0 } else { 0 }; + let start_event_index = if tx_index == key.1 .0 { key.1 .1 .0 } else { 0 }; // TODO(dvir): don't clone the events here. get_events_from_tx( tx_output.events().into(), diff --git a/crates/papyrus_storage/src/body/events_test.rs b/crates/papyrus_storage/src/body/events_test.rs index 9bf024b4b4..388d4dd655 100644 --- a/crates/papyrus_storage/src/body/events_test.rs +++ b/crates/papyrus_storage/src/body/events_test.rs @@ -5,11 +5,7 @@ use papyrus_test_utils::get_test_block; use pretty_assertions::assert_eq; use starknet_api::block::BlockNumber; use starknet_api::transaction::{ - Event, - EventContent, - EventData, - EventIndexInTransactionOutput, - TransactionOffsetInBlock, + Event, EventContent, EventData, EventIndexInTransactionOutput, TransactionOffsetInBlock, }; use crate::body::events::{get_events_from_tx, EventIndex, EventsReader}; @@ -150,15 +146,13 @@ fn revert_events() { ); // Test iter events using the storage reader. - assert!( - storage_reader - .begin_ro_txn() - .unwrap() - .iter_events(None, event_index, block_number) - .unwrap() - .last() - .is_some() - ); + assert!(storage_reader + .begin_ro_txn() + .unwrap() + .iter_events(None, event_index, block_number) + .unwrap() + .last() + .is_some()); // Test events raw table. let txn = storage_reader.begin_ro_txn().unwrap(); @@ -184,15 +178,13 @@ fn revert_events() { .0 .commit() .unwrap(); - assert!( - storage_reader - .begin_ro_txn() - .unwrap() - .iter_events(None, event_index, block_number) - .unwrap() - .last() - .is_none() - ); + assert!(storage_reader + .begin_ro_txn() + .unwrap() + .iter_events(None, event_index, block_number) + .unwrap() + .last() + .is_none()); let txn = storage_reader.begin_ro_txn().unwrap(); let events_table = txn.txn.open_table(&txn.tables.events).unwrap(); diff --git a/crates/papyrus_storage/src/body/mod.rs b/crates/papyrus_storage/src/body/mod.rs index 4a560715f1..7122ce6ab7 100644 --- a/crates/papyrus_storage/src/body/mod.rs +++ b/crates/papyrus_storage/src/body/mod.rs @@ -50,10 +50,7 @@ use serde::{Deserialize, Serialize}; use starknet_api::block::{BlockBody, BlockNumber}; use starknet_api::core::ContractAddress; use starknet_api::transaction::{ - Transaction, - TransactionHash, - TransactionOffsetInBlock, - TransactionOutput, + Transaction, TransactionHash, TransactionOffsetInBlock, TransactionOutput, }; use tracing::debug; @@ -61,15 +58,8 @@ use crate::db::serialization::{NoVersionValueWrapper, VersionZeroWrapper}; use crate::db::table_types::{CommonPrefix, DbCursorTrait, NoValue, SimpleTable, Table}; use crate::db::{DbTransaction, TableHandle, TransactionKind, RW}; use crate::{ - FileHandlers, - MarkerKind, - MarkersTable, - OffsetKind, - StorageError, - StorageResult, - StorageScope, - StorageTxn, - TransactionMetadata, + FileHandlers, MarkerKind, MarkersTable, OffsetKind, StorageError, StorageResult, StorageScope, + StorageTxn, TransactionMetadata, }; type FileOffsetsTable<'env> = diff --git a/crates/papyrus_storage/src/class.rs b/crates/papyrus_storage/src/class.rs index 193529d7c9..cc12fe22f4 100644 --- a/crates/papyrus_storage/src/class.rs +++ b/crates/papyrus_storage/src/class.rs @@ -77,14 +77,8 @@ use crate::db::table_types::Table; use crate::db::{TransactionKind, RW}; use crate::state::{DeclaredClassesTable, DeprecatedDeclaredClassesTable, FileOffsetTable}; use crate::{ - DbTransaction, - FileHandlers, - IndexedDeprecatedContractClass, - MarkerKind, - OffsetKind, - StorageError, - StorageResult, - StorageTxn, + DbTransaction, FileHandlers, IndexedDeprecatedContractClass, MarkerKind, OffsetKind, + StorageError, StorageResult, StorageTxn, }; /// Interface for reading data related to classes or deprecated classes. diff --git a/crates/papyrus_storage/src/class_test.rs b/crates/papyrus_storage/src/class_test.rs index 8d569a78b0..d9e6bff074 100644 --- a/crates/papyrus_storage/src/class_test.rs +++ b/crates/papyrus_storage/src/class_test.rs @@ -105,12 +105,10 @@ fn append_deprecated_class_not_in_state_diff() { let statetxn = txn.get_state_reader().unwrap(); let state0 = StateNumber::right_after_block(BlockNumber(0)).unwrap(); - assert!( - statetxn - .get_deprecated_class_definition_at(state0, &deprecated_class_hash) - .unwrap() - .is_none() - ); + assert!(statetxn + .get_deprecated_class_definition_at(state0, &deprecated_class_hash) + .unwrap() + .is_none()); let state1 = StateNumber::right_after_block(BlockNumber(1)).unwrap(); assert_eq!( diff --git a/crates/papyrus_storage/src/compression_utils.rs b/crates/papyrus_storage/src/compression_utils.rs index a23ccc40d8..66c5d789f1 100644 --- a/crates/papyrus_storage/src/compression_utils.rs +++ b/crates/papyrus_storage/src/compression_utils.rs @@ -12,7 +12,7 @@ use crate::db::serialization::{StorageSerde, StorageSerdeError}; // TODO(Dvir): consider defining this for each type separately and pass it as an argument to the // decompress function. pub(crate) const MAX_DECOMPRESSED_SIZE: usize = 1 << 28; // 256 MB -// The compression level to use. Higher levels are slower but compress better. + // The compression level to use. Higher levels are slower but compress better. const COMPRESSION_LEVEL: i32 = zstd::DEFAULT_COMPRESSION_LEVEL; /// Returns the compressed data in a vector. diff --git a/crates/papyrus_storage/src/db/table_types/dup_sort_tables.rs b/crates/papyrus_storage/src/db/table_types/dup_sort_tables.rs index 7596a39553..5d267f9dba 100644 --- a/crates/papyrus_storage/src/db/table_types/dup_sort_tables.rs +++ b/crates/papyrus_storage/src/db/table_types/dup_sort_tables.rs @@ -11,18 +11,8 @@ use libmdbx::{TableFlags, WriteFlags}; use super::{DbResult, Table, TableType}; use crate::db::serialization::{Key as KeyTrait, StorageSerde, StorageSerdeEx, ValueSerde}; use crate::db::{ - DbCursor, - DbCursorTrait, - DbError, - DbKeyType, - DbTransaction, - DbValueType, - DbWriter, - KeyAlreadyExistsError, - TableHandle, - TableIdentifier, - TransactionKind, - RW, + DbCursor, DbCursorTrait, DbError, DbKeyType, DbTransaction, DbValueType, DbWriter, + KeyAlreadyExistsError, TableHandle, TableIdentifier, TransactionKind, RW, }; // NOTICE: If a write operation fails (insert, upsert, append, delete, append_greater_sub_key), the @@ -154,8 +144,12 @@ impl DbWriter { } } -impl<'env, K: KeyTrait + Debug, V: ValueSerde + Debug, T: DupSortTableType + DupSortUtils> - Table<'env> for TableHandle<'env, K, V, T> +impl< + 'env, + K: KeyTrait + Debug, + V: ValueSerde + Debug, + T: DupSortTableType + DupSortUtils, + > Table<'env> for TableHandle<'env, K, V, T> { type Key = K; type Value = V; @@ -367,8 +361,12 @@ impl<'env, K: KeyTrait + Debug, V: ValueSerde + Debug, T: DupSortTableType + Dup // TODO(dvir): consider adding unchecked version of the append function. #[allow(private_bounds)] -impl<'env, K: KeyTrait + Debug, V: ValueSerde + Debug, T: DupSortTableType + DupSortUtils> - TableHandle<'env, K, V, T> +impl< + 'env, + K: KeyTrait + Debug, + V: ValueSerde + Debug, + T: DupSortTableType + DupSortUtils, + > TableHandle<'env, K, V, T> { // Append a new value to the given key. The sub-key must be bigger than the last sub-key for the // given main-key, otherwise an error will be returned. @@ -409,11 +407,11 @@ impl<'env, K: KeyTrait + Debug, V: ValueSerde + Debug, T: DupSortTableType + Dup } impl< - Mode: TransactionKind, - K: KeyTrait + Debug, - V: ValueSerde + Debug, - T: DupSortTableType + DupSortUtils, -> DbCursorTrait for DbCursor<'_, Mode, K, V, T> + Mode: TransactionKind, + K: KeyTrait + Debug, + V: ValueSerde + Debug, + T: DupSortTableType + DupSortUtils, + > DbCursorTrait for DbCursor<'_, Mode, K, V, T> { type Key = K; type Value = V; diff --git a/crates/papyrus_storage/src/db/table_types/simple_table.rs b/crates/papyrus_storage/src/db/table_types/simple_table.rs index d583c930a4..4d70965fd1 100644 --- a/crates/papyrus_storage/src/db/table_types/simple_table.rs +++ b/crates/papyrus_storage/src/db/table_types/simple_table.rs @@ -12,17 +12,8 @@ use super::{DbResult, Table, TableType}; use crate::db::serialization::{Key as KeyTrait, ValueSerde}; use crate::db::table_types::DbCursorTrait; use crate::db::{ - DbCursor, - DbError, - DbKeyType, - DbTransaction, - DbValueType, - DbWriter, - KeyAlreadyExistsError, - TableHandle, - TableIdentifier, - TransactionKind, - RW, + DbCursor, DbError, DbKeyType, DbTransaction, DbValueType, DbWriter, KeyAlreadyExistsError, + TableHandle, TableIdentifier, TransactionKind, RW, }; // A simple mapping between key and value. diff --git a/crates/papyrus_storage/src/header.rs b/crates/papyrus_storage/src/header.rs index 33cbae1bd6..e8c24fed0a 100644 --- a/crates/papyrus_storage/src/header.rs +++ b/crates/papyrus_storage/src/header.rs @@ -40,21 +40,11 @@ mod header_test; use serde::{Deserialize, Serialize}; use starknet_api::block::{ - BlockHash, - BlockHeader, - BlockHeaderWithoutHash, - BlockNumber, - BlockSignature, - BlockTimestamp, - GasPricePerToken, - StarknetVersion, + BlockHash, BlockHeader, BlockHeaderWithoutHash, BlockNumber, BlockSignature, BlockTimestamp, + GasPricePerToken, StarknetVersion, }; use starknet_api::core::{ - EventCommitment, - GlobalRoot, - ReceiptCommitment, - SequencerContractAddress, - StateDiffCommitment, + EventCommitment, GlobalRoot, ReceiptCommitment, SequencerContractAddress, StateDiffCommitment, TransactionCommitment, }; use starknet_api::data_availability::L1DataAvailabilityMode; diff --git a/crates/papyrus_storage/src/header_test.rs b/crates/papyrus_storage/src/header_test.rs index ed75acf0c9..d6ee6c0bf2 100644 --- a/crates/papyrus_storage/src/header_test.rs +++ b/crates/papyrus_storage/src/header_test.rs @@ -1,11 +1,7 @@ use assert_matches::assert_matches; use pretty_assertions::assert_eq; use starknet_api::block::{ - BlockHash, - BlockHeader, - BlockHeaderWithoutHash, - BlockNumber, - BlockSignature, + BlockHash, BlockHeader, BlockHeaderWithoutHash, BlockNumber, BlockSignature, }; use starknet_api::felt; @@ -118,14 +114,20 @@ async fn get_reverted_block_number_by_hash_returns_none() { let block_hash = BlockHash(felt!("0x1")); // Verify that we can get block 1 by hash before the revert. - assert!( - reader.begin_ro_txn().unwrap().get_block_number_by_hash(&block_hash).unwrap().is_some() - ); + assert!(reader + .begin_ro_txn() + .unwrap() + .get_block_number_by_hash(&block_hash) + .unwrap() + .is_some()); writer.begin_rw_txn().unwrap().revert_header(BlockNumber(1)).unwrap().0.commit().unwrap(); - assert!( - reader.begin_ro_txn().unwrap().get_block_number_by_hash(&block_hash).unwrap().is_none() - ); + assert!(reader + .begin_ro_txn() + .unwrap() + .get_block_number_by_hash(&block_hash) + .unwrap() + .is_none()); } fn append_2_headers(writer: &mut StorageWriter) { diff --git a/crates/papyrus_storage/src/lib.rs b/crates/papyrus_storage/src/lib.rs index e932d0d0db..31968b03dd 100644 --- a/crates/papyrus_storage/src/lib.rs +++ b/crates/papyrus_storage/src/lib.rs @@ -110,13 +110,7 @@ use db::db_stats::{DbTableStats, DbWholeStats}; use db::serialization::{Key, NoVersionValueWrapper, ValueSerde, VersionZeroWrapper}; use db::table_types::{CommonPrefix, NoValue, Table, TableType}; use mmap_file::{ - open_file, - FileHandler, - LocationInFile, - MMapFileError, - MmapFileConfig, - Reader, - Writer, + open_file, FileHandler, LocationInFile, MMapFileError, MmapFileConfig, Reader, Writer, }; use papyrus_config::dumping::{append_sub_config_name, ser_param, SerializeConfig}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; @@ -135,17 +129,8 @@ use version::{StorageVersionError, Version}; use crate::body::TransactionIndex; use crate::db::table_types::SimpleTable; use crate::db::{ - open_env, - DbConfig, - DbError, - DbReader, - DbTransaction, - DbWriter, - TableHandle, - TableIdentifier, - TransactionKind, - RO, - RW, + open_env, DbConfig, DbError, DbReader, DbTransaction, DbWriter, TableHandle, TableIdentifier, + TransactionKind, RO, RW, }; use crate::header::StorageBlockHeader; use crate::mmap_file::MMapFileStats; diff --git a/crates/papyrus_storage/src/serialization/serializers.rs b/crates/papyrus_storage/src/serialization/serializers.rs index 8daf2510c2..57d3bf8384 100644 --- a/crates/papyrus_storage/src/serialization/serializers.rs +++ b/crates/papyrus_storage/src/serialization/serializers.rs @@ -7,9 +7,7 @@ use std::sync::Arc; use byteorder::BigEndian; use cairo_lang_casm::hints::Hint; use cairo_lang_starknet_classes::casm_contract_class::{ - CasmContractClass, - CasmContractEntryPoint, - CasmContractEntryPoints, + CasmContractClass, CasmContractEntryPoint, CasmContractEntryPoints, }; use cairo_lang_starknet_classes::NestedIntList; use cairo_lang_utils::bigint::BigUintAsHex; @@ -19,108 +17,42 @@ use num_bigint::BigUint; use parity_scale_codec::{Decode, Encode}; use primitive_types::H160; use starknet_api::block::{ - BlockHash, - BlockNumber, - BlockSignature, - BlockStatus, - BlockTimestamp, - GasPrice, - GasPricePerToken, - StarknetVersion, + BlockHash, BlockNumber, BlockSignature, BlockStatus, BlockTimestamp, GasPrice, + GasPricePerToken, StarknetVersion, }; use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ - ClassHash, - CompiledClassHash, - ContractAddress, - EntryPointSelector, - EthAddress, - EventCommitment, - GlobalRoot, - Nonce, - PatriciaKey, - ReceiptCommitment, - SequencerContractAddress, - StateDiffCommitment, - TransactionCommitment, + ClassHash, CompiledClassHash, ContractAddress, EntryPointSelector, EthAddress, EventCommitment, + GlobalRoot, Nonce, PatriciaKey, ReceiptCommitment, SequencerContractAddress, + StateDiffCommitment, TransactionCommitment, }; use starknet_api::crypto::utils::Signature; use starknet_api::data_availability::{DataAvailabilityMode, L1DataAvailabilityMode}; use starknet_api::deprecated_contract_class::{ - ConstructorType, - ContractClass as DeprecatedContractClass, - ContractClassAbiEntry, - EntryPointOffset, - EntryPointV0 as DeprecatedEntryPoint, - EventAbiEntry, - EventType, - FunctionAbiEntry, - FunctionStateMutability, - FunctionType, - L1HandlerType, - Program, - StructAbiEntry, - StructMember, - StructType, - TypedParameter, + ConstructorType, ContractClass as DeprecatedContractClass, ContractClassAbiEntry, + EntryPointOffset, EntryPointV0 as DeprecatedEntryPoint, EventAbiEntry, EventType, + FunctionAbiEntry, FunctionStateMutability, FunctionType, L1HandlerType, Program, + StructAbiEntry, StructMember, StructType, TypedParameter, }; use starknet_api::execution_resources::{Builtin, ExecutionResources, GasAmount, GasVector}; use starknet_api::hash::{PoseidonHash, StarkHash}; use starknet_api::rpc_transaction::EntryPointByType; use starknet_api::state::{ - EntryPoint, - FunctionIndex, - SierraContractClass, - StorageKey, - ThinStateDiff, + EntryPoint, FunctionIndex, SierraContractClass, StorageKey, ThinStateDiff, }; use starknet_api::transaction::fields::{ - AccountDeploymentData, - AllResourceBounds, - Calldata, - ContractAddressSalt, - Fee, - PaymasterData, - Resource, - ResourceBounds, - Tip, - TransactionSignature, - ValidResourceBounds, + AccountDeploymentData, AllResourceBounds, Calldata, ContractAddressSalt, Fee, PaymasterData, + Resource, ResourceBounds, Tip, TransactionSignature, ValidResourceBounds, }; use starknet_api::transaction::{ - DeclareTransaction, - DeclareTransactionOutput, - DeclareTransactionV0V1, - DeclareTransactionV2, - DeclareTransactionV3, - DeployAccountTransaction, - DeployAccountTransactionOutput, - DeployAccountTransactionV1, - DeployAccountTransactionV3, - DeployTransaction, - DeployTransactionOutput, - Event, - EventContent, - EventData, - EventIndexInTransactionOutput, - EventKey, - InvokeTransaction, - InvokeTransactionOutput, - InvokeTransactionV0, - InvokeTransactionV1, - InvokeTransactionV3, - L1HandlerTransaction, - L1HandlerTransactionOutput, - L1ToL2Payload, - L2ToL1Payload, - MessageToL1, - MessageToL2, - RevertedTransactionExecutionStatus, - Transaction, - TransactionExecutionStatus, - TransactionHash, - TransactionOffsetInBlock, - TransactionOutput, + DeclareTransaction, DeclareTransactionOutput, DeclareTransactionV0V1, DeclareTransactionV2, + DeclareTransactionV3, DeployAccountTransaction, DeployAccountTransactionOutput, + DeployAccountTransactionV1, DeployAccountTransactionV3, DeployTransaction, + DeployTransactionOutput, Event, EventContent, EventData, EventIndexInTransactionOutput, + EventKey, InvokeTransaction, InvokeTransactionOutput, InvokeTransactionV0, InvokeTransactionV1, + InvokeTransactionV3, L1HandlerTransaction, L1HandlerTransactionOutput, L1ToL2Payload, + L2ToL1Payload, MessageToL1, MessageToL2, RevertedTransactionExecutionStatus, Transaction, + TransactionExecutionStatus, TransactionHash, TransactionOffsetInBlock, TransactionOutput, TransactionVersion, }; use starknet_types_core::felt::Felt; @@ -129,11 +61,7 @@ use tracing::warn; use crate::body::events::EventIndex; use crate::body::TransactionIndex; use crate::compression_utils::{ - compress, - decompress, - decompress_from_reader, - serialize_and_compress, - IsCompressed, + compress, decompress, decompress_from_reader, serialize_and_compress, IsCompressed, }; use crate::db::serialization::{StorageSerde, StorageSerdeError}; use crate::db::table_types::NoValue; diff --git a/crates/papyrus_storage/src/state/mod.rs b/crates/papyrus_storage/src/state/mod.rs index 6b8704eb41..b184d3a49f 100644 --- a/crates/papyrus_storage/src/state/mod.rs +++ b/crates/papyrus_storage/src/state/mod.rs @@ -74,13 +74,7 @@ use crate::document_calls::{add_query, StorageQuery}; use crate::mmap_file::LocationInFile; use crate::state::data::IndexedDeprecatedContractClass; use crate::{ - FileHandlers, - MarkerKind, - MarkersTable, - OffsetKind, - StorageError, - StorageResult, - StorageTxn, + FileHandlers, MarkerKind, MarkersTable, OffsetKind, StorageError, StorageResult, StorageTxn, }; // TODO(shahak): Move the table aliases to the crate level. diff --git a/crates/papyrus_storage/src/state/state_test.rs b/crates/papyrus_storage/src/state/state_test.rs index 3f82f82f0f..cd0eac4e4e 100644 --- a/crates/papyrus_storage/src/state/state_test.rs +++ b/crates/papyrus_storage/src/state/state_test.rs @@ -291,12 +291,10 @@ fn test_get_class_after_append_thin_state_diff() { Some(BlockNumber(0)) ); assert!(state_reader.get_class_definition_at(state_number, &CLASS_HASH).unwrap().is_none()); - assert!( - state_reader - .get_deprecated_class_definition_at(state_number, &DEPRECATED_CLASS_HASH) - .unwrap() - .is_none() - ); + assert!(state_reader + .get_deprecated_class_definition_at(state_number, &DEPRECATED_CLASS_HASH) + .unwrap() + .is_none()); } #[test] @@ -742,12 +740,10 @@ fn declare_revert_declare_scenario() { let txn = reader.begin_ro_txn().unwrap(); let state_reader = txn.get_state_reader().unwrap(); assert!(state_reader.get_class_definition_at(state_number, &class_hash).unwrap().is_some()); - assert!( - state_reader - .get_deprecated_class_definition_at(state_number, &deprecated_class_hash) - .unwrap() - .is_some() - ); + assert!(state_reader + .get_deprecated_class_definition_at(state_number, &deprecated_class_hash) + .unwrap() + .is_some()); // Revert the block and assert that the classes are no longer declared. let (txn, _) = writer.begin_rw_txn().unwrap().revert_state_diff(BlockNumber(0)).unwrap(); @@ -755,12 +751,10 @@ fn declare_revert_declare_scenario() { let txn = reader.begin_ro_txn().unwrap(); let state_reader = txn.get_state_reader().unwrap(); assert!(state_reader.get_class_definition_at(state_number, &class_hash).unwrap().is_none()); - assert!( - state_reader - .get_deprecated_class_definition_at(state_number, &deprecated_class_hash) - .unwrap() - .is_none() - ); + assert!(state_reader + .get_deprecated_class_definition_at(state_number, &deprecated_class_hash) + .unwrap() + .is_none()); // Re-declaring reverted classes should be possible. writer @@ -782,10 +776,8 @@ fn declare_revert_declare_scenario() { let txn = reader.begin_ro_txn().unwrap(); let state_reader = txn.get_state_reader().unwrap(); assert!(state_reader.get_class_definition_at(state_number, &class_hash).unwrap().is_some()); - assert!( - state_reader - .get_deprecated_class_definition_at(state_number, &deprecated_class_hash) - .unwrap() - .is_some() - ); + assert!(state_reader + .get_deprecated_class_definition_at(state_number, &deprecated_class_hash) + .unwrap() + .is_some()); } diff --git a/crates/papyrus_storage/src/test_instances.rs b/crates/papyrus_storage/src/test_instances.rs index 583ce74f92..3ba2956242 100644 --- a/crates/papyrus_storage/src/test_instances.rs +++ b/crates/papyrus_storage/src/test_instances.rs @@ -1,18 +1,12 @@ use papyrus_test_utils::{auto_impl_get_test_instance, get_number_of_variants, GetTestInstance}; use starknet_api::block::{BlockHash, BlockNumber, BlockTimestamp, GasPricePerToken}; use starknet_api::core::{ - EventCommitment, - GlobalRoot, - ReceiptCommitment, - SequencerContractAddress, - StateDiffCommitment, + EventCommitment, GlobalRoot, ReceiptCommitment, SequencerContractAddress, StateDiffCommitment, TransactionCommitment, }; use starknet_api::data_availability::L1DataAvailabilityMode; use starknet_api::transaction::{ - EventIndexInTransactionOutput, - TransactionHash, - TransactionOffsetInBlock, + EventIndexInTransactionOutput, TransactionHash, TransactionOffsetInBlock, }; use crate::body::TransactionIndex; diff --git a/crates/papyrus_storage/src/version_test.rs b/crates/papyrus_storage/src/version_test.rs index 8a0b64d1ae..6a879af1cc 100644 --- a/crates/papyrus_storage/src/version_test.rs +++ b/crates/papyrus_storage/src/version_test.rs @@ -4,27 +4,15 @@ use rand::Rng; use crate::db::table_types::Table; use crate::test_utils::{ - get_test_storage, - get_test_storage_by_scope, - get_test_storage_with_config_by_scope, + get_test_storage, get_test_storage_by_scope, get_test_storage_with_config_by_scope, }; use crate::version::{ - StorageVersionError, - Version, - VersionStorageReader, - VersionStorageWriter, - VERSION_BLOCKS_KEY, + StorageVersionError, Version, VersionStorageReader, VersionStorageWriter, VERSION_BLOCKS_KEY, VERSION_STATE_KEY, }; use crate::{ - open_storage, - set_version_if_needed, - verify_storage_version, - StorageError, - StorageScope, - StorageWriter, - STORAGE_VERSION_BLOCKS, - STORAGE_VERSION_STATE, + open_storage, set_version_if_needed, verify_storage_version, StorageError, StorageScope, + StorageWriter, STORAGE_VERSION_BLOCKS, STORAGE_VERSION_STATE, }; // TODO: Add this test for set_blocks_version or combine the logic. diff --git a/crates/papyrus_sync/src/lib.rs b/crates/papyrus_sync/src/lib.rs index b1e1f4165c..c9553823cf 100644 --- a/crates/papyrus_sync/src/lib.rs +++ b/crates/papyrus_sync/src/lib.rs @@ -227,10 +227,10 @@ pub enum SyncEvent { } impl< - TCentralSource: CentralSourceTrait + Sync + Send + 'static, - TPendingSource: PendingSourceTrait + Sync + Send + 'static, - TBaseLayerSource: BaseLayerSourceTrait + Sync + Send, -> GenericStateSync + TCentralSource: CentralSourceTrait + Sync + Send + 'static, + TPendingSource: PendingSourceTrait + Sync + Send + 'static, + TBaseLayerSource: BaseLayerSourceTrait + Sync + Send, + > GenericStateSync { pub async fn run(mut self) -> StateSyncResult { info!("State sync started."); diff --git a/crates/papyrus_sync/src/sources/base_layer.rs b/crates/papyrus_sync/src/sources/base_layer.rs index 2ecac3b8c4..c76b8588c0 100644 --- a/crates/papyrus_sync/src/sources/base_layer.rs +++ b/crates/papyrus_sync/src/sources/base_layer.rs @@ -29,9 +29,9 @@ pub trait BaseLayerSourceTrait { #[async_trait] impl< - Error: std::error::Error + 'static + Sync + Send, - BaseLayerSource: BaseLayerContract + Sync + Send, -> BaseLayerSourceTrait for BaseLayerSource + Error: std::error::Error + 'static + Sync + Send, + BaseLayerSource: BaseLayerContract + Sync + Send, + > BaseLayerSourceTrait for BaseLayerSource { async fn latest_proved_block( &self, diff --git a/crates/papyrus_sync/src/sources/central.rs b/crates/papyrus_sync/src/sources/central.rs index a1fa122bf8..ebd6385e16 100644 --- a/crates/papyrus_sync/src/sources/central.rs +++ b/crates/papyrus_sync/src/sources/central.rs @@ -31,10 +31,7 @@ use starknet_api::deprecated_contract_class::ContractClass as DeprecatedContract use starknet_api::state::StateDiff; use starknet_api::StarknetApiError; use starknet_client::reader::{ - BlockSignatureData, - ReaderClientError, - StarknetFeederGatewayClient, - StarknetReader, + BlockSignatureData, ReaderClientError, StarknetFeederGatewayClient, StarknetReader, }; use starknet_client::{ClientCreationError, RetryConfig}; use tracing::{debug, trace}; diff --git a/crates/papyrus_sync/src/sources/central_sync_test.rs b/crates/papyrus_sync/src/sources/central_sync_test.rs index 581de1263e..68c46bc6d7 100644 --- a/crates/papyrus_sync/src/sources/central_sync_test.rs +++ b/crates/papyrus_sync/src/sources/central_sync_test.rs @@ -14,14 +14,8 @@ use papyrus_storage::state::StateStorageReader; use papyrus_storage::test_utils::get_test_storage; use papyrus_storage::{StorageError, StorageReader, StorageWriter}; use starknet_api::block::{ - Block, - BlockBody, - BlockHash, - BlockHashAndNumber, - BlockHeader, - BlockHeaderWithoutHash, - BlockNumber, - BlockSignature, + Block, BlockBody, BlockHash, BlockHashAndNumber, BlockHeader, BlockHeaderWithoutHash, + BlockNumber, BlockSignature, }; use starknet_api::core::{ClassHash, SequencerPublicKey}; use starknet_api::crypto::utils::PublicKey; @@ -34,18 +28,10 @@ use tracing::{debug, error}; use super::pending::MockPendingSourceTrait; use crate::sources::base_layer::{BaseLayerSourceTrait, MockBaseLayerSourceTrait}; use crate::sources::central::{ - BlocksStream, - CompiledClassesStream, - MockCentralSourceTrait, - StateUpdatesStream, + BlocksStream, CompiledClassesStream, MockCentralSourceTrait, StateUpdatesStream, }; use crate::{ - CentralError, - CentralSourceTrait, - GenericStateSync, - StateSyncError, - StateSyncResult, - SyncConfig, + CentralError, CentralSourceTrait, GenericStateSync, StateSyncError, StateSyncResult, SyncConfig, }; const SYNC_SLEEP_DURATION: Duration = Duration::from_millis(100); // 100ms diff --git a/crates/papyrus_sync/src/sources/central_test.rs b/crates/papyrus_sync/src/sources/central_test.rs index c8c593ee10..620e2ff3bb 100644 --- a/crates/papyrus_sync/src/sources/central_test.rs +++ b/crates/papyrus_sync/src/sources/central_test.rs @@ -21,16 +21,8 @@ use starknet_api::state::{SierraContractClass as sn_api_ContractClass, ThinState use starknet_api::{class_hash, contract_address, felt, storage_key}; use starknet_client::reader::objects::block::BlockPostV0_13_1; use starknet_client::reader::{ - Block, - BlockSignatureData, - ContractClass, - DeclaredClassHashEntry, - DeployedContract, - GenericContractClass, - MockStarknetReader, - ReaderClientError, - ReplacedClass, - StateUpdate, + Block, BlockSignatureData, ContractClass, DeclaredClassHashEntry, DeployedContract, + GenericContractClass, MockStarknetReader, ReaderClientError, ReplacedClass, StateUpdate, StorageEntry, }; use starknet_client::ClientError; diff --git a/crates/papyrus_sync/src/sources/pending.rs b/crates/papyrus_sync/src/sources/pending.rs index 44252b6f71..53b5cf53b1 100644 --- a/crates/papyrus_sync/src/sources/pending.rs +++ b/crates/papyrus_sync/src/sources/pending.rs @@ -8,10 +8,7 @@ use async_trait::async_trait; #[cfg(test)] use mockall::automock; use starknet_client::reader::{ - PendingData, - ReaderClientError, - StarknetFeederGatewayClient, - StarknetReader, + PendingData, ReaderClientError, StarknetFeederGatewayClient, StarknetReader, }; use starknet_client::ClientCreationError; diff --git a/crates/papyrus_sync/src/sync_test.rs b/crates/papyrus_sync/src/sync_test.rs index 7a2796d2f0..8e45bd2080 100644 --- a/crates/papyrus_sync/src/sync_test.rs +++ b/crates/papyrus_sync/src/sync_test.rs @@ -19,10 +19,7 @@ use starknet_api::hash::StarkHash; use starknet_api::state::{SierraContractClass, StateDiff}; use starknet_api::{contract_address, felt, storage_key}; use starknet_client::reader::objects::pending_data::{ - AcceptedOnL2ExtraData, - DeprecatedPendingBlock, - PendingBlockOrDeprecated, - PendingStateUpdate, + AcceptedOnL2ExtraData, DeprecatedPendingBlock, PendingBlockOrDeprecated, PendingStateUpdate, }; use starknet_client::reader::objects::state::StateDiff as ClientStateDiff; use starknet_client::reader::objects::transaction::Transaction as ClientTransaction; @@ -33,14 +30,8 @@ use crate::sources::base_layer::MockBaseLayerSourceTrait; use crate::sources::central::MockCentralSourceTrait; use crate::sources::pending::MockPendingSourceTrait; use crate::{ - sort_state_diff, - stream_new_base_layer_block, - sync_pending_data, - GenericStateSync, - StateSyncError, - SyncConfig, - SyncEvent, - GENESIS_HASH, + sort_state_diff, stream_new_base_layer_block, sync_pending_data, GenericStateSync, + StateSyncError, SyncConfig, SyncEvent, GENESIS_HASH, }; // TODO(anatg): Add a test to check that the sync calls the sort_state_diff function @@ -556,8 +547,8 @@ async fn pending_sync_doesnt_stop_when_data_has_block_hash_field_with_the_same_h } #[tokio::test] -async fn pending_sync_updates_when_data_has_block_hash_field_with_the_same_hash_and_more_transactions() - { +async fn pending_sync_updates_when_data_has_block_hash_field_with_the_same_hash_and_more_transactions( +) { const FIRST_BLOCK_HASH: BlockHash = BlockHash(StarkHash::ONE); let genesis_hash = BlockHash(felt!(GENESIS_HASH)); // Storage with one block header. diff --git a/crates/papyrus_test_utils/src/lib.rs b/crates/papyrus_test_utils/src/lib.rs index ababd0a831..a3808b00b4 100644 --- a/crates/papyrus_test_utils/src/lib.rs +++ b/crates/papyrus_test_utils/src/lib.rs @@ -13,17 +13,10 @@ use std::sync::Arc; use cairo_lang_casm::hints::{CoreHint, CoreHintBase, Hint}; use cairo_lang_casm::operand::{ - BinOpOperand, - CellRef, - DerefOrImmediate, - Operation, - Register, - ResOperand, + BinOpOperand, CellRef, DerefOrImmediate, Operation, Register, ResOperand, }; use cairo_lang_starknet_classes::casm_contract_class::{ - CasmContractClass, - CasmContractEntryPoint, - CasmContractEntryPoints, + CasmContractClass, CasmContractEntryPoint, CasmContractEntryPoints, }; use cairo_lang_starknet_classes::NestedIntList; use cairo_lang_utils::bigint::BigUintAsHex; @@ -36,123 +29,47 @@ use rand_chacha::ChaCha8Rng; use reqwest::Client; use serde::{Deserialize, Serialize}; use starknet_api::block::{ - Block, - BlockBody, - BlockHash, - BlockHeader, - BlockHeaderWithoutHash, - BlockNumber, - BlockSignature, - BlockStatus, - BlockTimestamp, - GasPrice, - GasPricePerToken, - StarknetVersion, + Block, BlockBody, BlockHash, BlockHeader, BlockHeaderWithoutHash, BlockNumber, BlockSignature, + BlockStatus, BlockTimestamp, GasPrice, GasPricePerToken, StarknetVersion, }; use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ - ClassHash, - CompiledClassHash, - ContractAddress, - EntryPointSelector, - EthAddress, - EventCommitment, - GlobalRoot, - Nonce, - ReceiptCommitment, - SequencerContractAddress, - StateDiffCommitment, + ClassHash, CompiledClassHash, ContractAddress, EntryPointSelector, EthAddress, EventCommitment, + GlobalRoot, Nonce, ReceiptCommitment, SequencerContractAddress, StateDiffCommitment, TransactionCommitment, }; use starknet_api::crypto::utils::Signature; use starknet_api::data_availability::{DataAvailabilityMode, L1DataAvailabilityMode}; use starknet_api::deprecated_contract_class::{ - ConstructorType, - ContractClass as DeprecatedContractClass, - ContractClassAbiEntry, - EntryPointOffset, - EntryPointV0 as DeprecatedEntryPoint, - EventAbiEntry, - EventType, - FunctionAbiEntry, - FunctionStateMutability, - FunctionType, - L1HandlerType, - Program, - StructAbiEntry, - StructMember, - StructType, - TypedParameter, + ConstructorType, ContractClass as DeprecatedContractClass, ContractClassAbiEntry, + EntryPointOffset, EntryPointV0 as DeprecatedEntryPoint, EventAbiEntry, EventType, + FunctionAbiEntry, FunctionStateMutability, FunctionType, L1HandlerType, Program, + StructAbiEntry, StructMember, StructType, TypedParameter, }; use starknet_api::execution_resources::{Builtin, ExecutionResources, GasAmount, GasVector}; use starknet_api::hash::{PoseidonHash, StarkHash}; use starknet_api::rpc_transaction::{ - EntryPointByType as RpcEntryPointByType, - EntryPointByType, - RpcDeclareTransaction, - RpcDeclareTransactionV3, - RpcDeployAccountTransaction, - RpcDeployAccountTransactionV3, - RpcInvokeTransaction, - RpcInvokeTransactionV3, - RpcTransaction, + EntryPointByType as RpcEntryPointByType, EntryPointByType, RpcDeclareTransaction, + RpcDeclareTransactionV3, RpcDeployAccountTransaction, RpcDeployAccountTransactionV3, + RpcInvokeTransaction, RpcInvokeTransactionV3, RpcTransaction, }; use starknet_api::state::{ - EntryPoint, - FunctionIndex, - SierraContractClass, - StateDiff, - StorageKey, - ThinStateDiff, + EntryPoint, FunctionIndex, SierraContractClass, StateDiff, StorageKey, ThinStateDiff, }; use starknet_api::test_utils::read_json_file; use starknet_api::transaction::fields::{ - AccountDeploymentData, - AllResourceBounds, - Calldata, - ContractAddressSalt, - Fee, - PaymasterData, - Resource, - ResourceBounds, - Tip, - TransactionSignature, - ValidResourceBounds, + AccountDeploymentData, AllResourceBounds, Calldata, ContractAddressSalt, Fee, PaymasterData, + Resource, ResourceBounds, Tip, TransactionSignature, ValidResourceBounds, }; use starknet_api::transaction::{ - DeclareTransaction, - DeclareTransactionOutput, - DeclareTransactionV0V1, - DeclareTransactionV2, - DeclareTransactionV3, - DeployAccountTransaction, - DeployAccountTransactionOutput, - DeployAccountTransactionV1, - DeployAccountTransactionV3, - DeployTransaction, - DeployTransactionOutput, - Event, - EventContent, - EventData, - EventIndexInTransactionOutput, - EventKey, - InvokeTransaction, - InvokeTransactionOutput, - InvokeTransactionV0, - InvokeTransactionV1, - InvokeTransactionV3, - L1HandlerTransaction, - L1HandlerTransactionOutput, - L1ToL2Payload, - L2ToL1Payload, - MessageToL1, - MessageToL2, - RevertedTransactionExecutionStatus, - Transaction, - TransactionExecutionStatus, - TransactionHash, - TransactionOffsetInBlock, - TransactionOutput, + DeclareTransaction, DeclareTransactionOutput, DeclareTransactionV0V1, DeclareTransactionV2, + DeclareTransactionV3, DeployAccountTransaction, DeployAccountTransactionOutput, + DeployAccountTransactionV1, DeployAccountTransactionV3, DeployTransaction, + DeployTransactionOutput, Event, EventContent, EventData, EventIndexInTransactionOutput, + EventKey, InvokeTransaction, InvokeTransactionOutput, InvokeTransactionV0, InvokeTransactionV1, + InvokeTransactionV3, L1HandlerTransaction, L1HandlerTransactionOutput, L1ToL2Payload, + L2ToL1Payload, MessageToL1, MessageToL2, RevertedTransactionExecutionStatus, Transaction, + TransactionExecutionStatus, TransactionHash, TransactionOffsetInBlock, TransactionOutput, TransactionVersion, }; use starknet_api::{class_hash, tx_hash}; diff --git a/crates/sequencing/papyrus_consensus/src/bin/run_simulation.rs b/crates/sequencing/papyrus_consensus/src/bin/run_simulation.rs index 4ebb40c8af..61aa381273 100644 --- a/crates/sequencing/papyrus_consensus/src/bin/run_simulation.rs +++ b/crates/sequencing/papyrus_consensus/src/bin/run_simulation.rs @@ -334,7 +334,7 @@ async fn build_all_nodes(data_dir: &str, logs_dir: &str, papyrus_args: &PapyrusA let mut nodes = Vec::new(); - nodes.push(build_node(data_dir, logs_dir, 1, papyrus_args).await); // Bootstrap + nodes.push(build_node(data_dir, logs_dir, 1, papyrus_args).await); // Bootstrap for i in 2..papyrus_args.num_validators { nodes.push(build_node(data_dir, logs_dir, i, papyrus_args).await); diff --git a/crates/sequencing/papyrus_consensus/src/config.rs b/crates/sequencing/papyrus_consensus/src/config.rs index e6016cea60..ce5f6e3adf 100644 --- a/crates/sequencing/papyrus_consensus/src/config.rs +++ b/crates/sequencing/papyrus_consensus/src/config.rs @@ -6,8 +6,7 @@ use std::collections::BTreeMap; use std::time::Duration; use papyrus_config::converters::{ - deserialize_float_seconds_to_duration, - deserialize_seconds_to_duration, + deserialize_float_seconds_to_duration, deserialize_seconds_to_duration, }; use papyrus_config::dumping::{append_sub_config_name, ser_param, SerializeConfig}; use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; diff --git a/crates/sequencing/papyrus_consensus/src/manager.rs b/crates/sequencing/papyrus_consensus/src/manager.rs index 880d71f877..00e8b8dc06 100644 --- a/crates/sequencing/papyrus_consensus/src/manager.rs +++ b/crates/sequencing/papyrus_consensus/src/manager.rs @@ -21,11 +21,7 @@ use tracing::{debug, info, instrument}; use crate::config::TimeoutsConfig; use crate::single_height_consensus::{ShcReturn, SingleHeightConsensus}; use crate::types::{ - BroadcastConsensusMessageChannel, - ConsensusContext, - ConsensusError, - Decision, - ValidatorId, + BroadcastConsensusMessageChannel, ConsensusContext, ConsensusError, Decision, ValidatorId, }; // TODO(dvir): add test for this. diff --git a/crates/sequencing/papyrus_consensus/src/manager_test.rs b/crates/sequencing/papyrus_consensus/src/manager_test.rs index 7d16c370db..026f650c25 100644 --- a/crates/sequencing/papyrus_consensus/src/manager_test.rs +++ b/crates/sequencing/papyrus_consensus/src/manager_test.rs @@ -8,17 +8,11 @@ use lazy_static::lazy_static; use mockall::mock; use mockall::predicate::eq; use papyrus_network::network_manager::test_utils::{ - mock_register_broadcast_topic, - MockBroadcastedMessagesSender, - TestSubscriberChannels, + mock_register_broadcast_topic, MockBroadcastedMessagesSender, TestSubscriberChannels, }; use papyrus_network_types::network_types::BroadcastedMessageMetadata; use papyrus_protobuf::consensus::{ - ConsensusMessage, - ProposalFin, - ProposalInit, - ProposalPart, - Vote, + ConsensusMessage, ProposalFin, ProposalInit, ProposalPart, Vote, }; use papyrus_test_utils::{get_rng, GetTestInstance}; use starknet_api::block::{BlockHash, BlockNumber}; @@ -28,12 +22,7 @@ use super::{run_consensus, MultiHeightManager}; use crate::config::TimeoutsConfig; use crate::test_utils::{precommit, prevote, proposal_init}; use crate::types::{ - ConsensusContext, - ConsensusError, - ProposalContentId, - Round, - ValidatorId, - DEFAULT_VALIDATOR_ID, + ConsensusContext, ConsensusError, ProposalContentId, Round, ValidatorId, DEFAULT_VALIDATOR_ID, }; lazy_static! { diff --git a/crates/sequencing/papyrus_consensus/src/simulation_network_receiver_test.rs b/crates/sequencing/papyrus_consensus/src/simulation_network_receiver_test.rs index ff2b49f467..f1c041d6eb 100644 --- a/crates/sequencing/papyrus_consensus/src/simulation_network_receiver_test.rs +++ b/crates/sequencing/papyrus_consensus/src/simulation_network_receiver_test.rs @@ -1,7 +1,6 @@ use futures::{SinkExt, StreamExt}; use papyrus_network::network_manager::test_utils::{ - mock_register_broadcast_topic, - TestSubscriberChannels, + mock_register_broadcast_topic, TestSubscriberChannels, }; use papyrus_network_types::network_types::BroadcastedMessageMetadata; use papyrus_protobuf::consensus::ConsensusMessage; diff --git a/crates/sequencing/papyrus_consensus/src/single_height_consensus.rs b/crates/sequencing/papyrus_consensus/src/single_height_consensus.rs index b6512adc4f..13ccb0152a 100644 --- a/crates/sequencing/papyrus_consensus/src/single_height_consensus.rs +++ b/crates/sequencing/papyrus_consensus/src/single_height_consensus.rs @@ -16,12 +16,7 @@ use tracing::{debug, info, instrument, trace, warn}; use crate::config::TimeoutsConfig; use crate::state_machine::{StateMachine, StateMachineEvent}; use crate::types::{ - ConsensusContext, - ConsensusError, - Decision, - ProposalContentId, - Round, - ValidatorId, + ConsensusContext, ConsensusError, Decision, ProposalContentId, Round, ValidatorId, }; #[derive(Debug, PartialEq)] @@ -578,7 +573,11 @@ impl SingleHeightConsensus { .iter() .filter_map(|v| { let vote = self.precommits.get(&(round, *v))?; - if vote.block_hash == Some(proposal_id) { Some(vote.clone()) } else { None } + if vote.block_hash == Some(proposal_id) { + Some(vote.clone()) + } else { + None + } }) .collect(); // TODO(matan): Check actual weights. diff --git a/crates/sequencing/papyrus_consensus/src/single_height_consensus_test.rs b/crates/sequencing/papyrus_consensus/src/single_height_consensus_test.rs index ee5f2cd062..dcbf36f7ac 100644 --- a/crates/sequencing/papyrus_consensus/src/single_height_consensus_test.rs +++ b/crates/sequencing/papyrus_consensus/src/single_height_consensus_test.rs @@ -149,12 +149,10 @@ async fn proposer() { panic!("Expected decision"); }; assert_eq!(decision.block, BLOCK.id); - assert!( - decision - .precommits - .into_iter() - .all(|item| precommits.contains(&ConsensusMessage::Vote(item))) - ); + assert!(decision + .precommits + .into_iter() + .all(|item| precommits.contains(&ConsensusMessage::Vote(item)))); } #[test_case(false; "single_proposal")] @@ -230,12 +228,10 @@ async fn validator(repeat_proposal: bool) { panic!("Expected decision"); }; assert_eq!(decision.block, BLOCK.id); - assert!( - decision - .precommits - .into_iter() - .all(|item| precommits.contains(&ConsensusMessage::Vote(item))) - ); + assert!(decision + .precommits + .into_iter() + .all(|item| precommits.contains(&ConsensusMessage::Vote(item)))); } #[test_case(true; "repeat")] @@ -459,10 +455,8 @@ async fn repropose() { panic!("Expected decision"); }; assert_eq!(decision.block, BLOCK.id); - assert!( - decision - .precommits - .into_iter() - .all(|item| precommits.contains(&ConsensusMessage::Vote(item))) - ); + assert!(decision + .precommits + .into_iter() + .all(|item| precommits.contains(&ConsensusMessage::Vote(item)))); } diff --git a/crates/sequencing/papyrus_consensus/src/stream_handler.rs b/crates/sequencing/papyrus_consensus/src/stream_handler.rs index aef64421c7..8bd0bcfe3c 100644 --- a/crates/sequencing/papyrus_consensus/src/stream_handler.rs +++ b/crates/sequencing/papyrus_consensus/src/stream_handler.rs @@ -8,9 +8,7 @@ use std::collections::{BTreeMap, HashMap}; use futures::channel::mpsc; use futures::StreamExt; use papyrus_network::network_manager::{ - BroadcastTopicClient, - BroadcastTopicClientTrait, - BroadcastTopicServer, + BroadcastTopicClient, BroadcastTopicClientTrait, BroadcastTopicServer, }; use papyrus_network::utils::StreamHashMap; use papyrus_network_types::network_types::{BroadcastedMessageMetadata, OpaquePeerId}; diff --git a/crates/sequencing/papyrus_consensus/src/stream_handler_test.rs b/crates/sequencing/papyrus_consensus/src/stream_handler_test.rs index 4bd575da8d..d061abb2b0 100644 --- a/crates/sequencing/papyrus_consensus/src/stream_handler_test.rs +++ b/crates/sequencing/papyrus_consensus/src/stream_handler_test.rs @@ -4,9 +4,7 @@ use futures::channel::mpsc; use futures::stream::StreamExt; use futures::SinkExt; use papyrus_network::network_manager::test_utils::{ - mock_register_broadcast_topic, - MockBroadcastedMessagesSender, - TestSubscriberChannels, + mock_register_broadcast_topic, MockBroadcastedMessagesSender, TestSubscriberChannels, }; use papyrus_network::network_manager::BroadcastTopicChannels; use papyrus_network_types::network_types::BroadcastedMessageMetadata; @@ -249,13 +247,11 @@ mod tests { let mut stream_handler = join_handle.await.expect("Task should succeed"); let values = [(peer_id.clone(), 1), (peer_id.clone(), 10), (peer_id.clone(), 127)]; - assert!( - stream_handler - .inbound_stream_data - .clone() - .into_keys() - .all(|item| values.contains(&item)) - ); + assert!(stream_handler + .inbound_stream_data + .clone() + .into_keys() + .all(|item| values.contains(&item))); // We have all message from 1 to 9 buffered. assert!(do_vecs_match( @@ -323,13 +319,11 @@ mod tests { // stream_id1 should be gone let values = [(peer_id.clone(), 1), (peer_id.clone(), 10)]; - assert!( - stream_handler - .inbound_stream_data - .clone() - .into_keys() - .all(|item| values.contains(&item)) - ); + assert!(stream_handler + .inbound_stream_data + .clone() + .into_keys() + .all(|item| values.contains(&item))); // Send the last message on stream_id2: send(&mut network_sender, &inbound_metadata, make_test_message(stream_id2, 0, false)).await; @@ -350,13 +344,11 @@ mod tests { // Stream_id2 should also be gone. let values = [(peer_id.clone(), 1)]; - assert!( - stream_handler - .inbound_stream_data - .clone() - .into_keys() - .all(|item| values.contains(&item)) - ); + assert!(stream_handler + .inbound_stream_data + .clone() + .into_keys() + .all(|item| values.contains(&item))); // Send the last message on stream_id3: send(&mut network_sender, &inbound_metadata, make_test_message(stream_id3, 0, false)).await; @@ -375,18 +367,16 @@ mod tests { // Stream_id3 should still be there, because we didn't send a fin. let values = [(peer_id.clone(), 1)]; - assert!( - stream_handler - .inbound_stream_data - .clone() - .into_keys() - .all(|item| values.contains(&item)) - ); + assert!(stream_handler + .inbound_stream_data + .clone() + .into_keys() + .all(|item| values.contains(&item))); // But the buffer should be empty, as we've successfully drained it all. - assert!( - stream_handler.inbound_stream_data[&(peer_id, stream_id3)].message_buffer.is_empty() - ); + assert!(stream_handler.inbound_stream_data[&(peer_id, stream_id3)] + .message_buffer + .is_empty()); } // This test does two things: diff --git a/crates/sequencing/papyrus_consensus/src/test_utils.rs b/crates/sequencing/papyrus_consensus/src/test_utils.rs index 8ee68c1427..6e4a06c1b5 100644 --- a/crates/sequencing/papyrus_consensus/src/test_utils.rs +++ b/crates/sequencing/papyrus_consensus/src/test_utils.rs @@ -9,12 +9,7 @@ use starknet_api::block::{BlockHash, BlockNumber}; use starknet_types_core::felt::Felt; use crate::types::{ - ConsensusContext, - ConsensusError, - ProposalContentId, - Round, - ValidatorId, - DEFAULT_VALIDATOR_ID, + ConsensusContext, ConsensusError, ProposalContentId, Round, ValidatorId, DEFAULT_VALIDATOR_ID, }; /// Define a consensus block which can be used to enable auto mocking Context. diff --git a/crates/sequencing/papyrus_consensus/src/types.rs b/crates/sequencing/papyrus_consensus/src/types.rs index 561aabd5e0..332ba95192 100644 --- a/crates/sequencing/papyrus_consensus/src/types.rs +++ b/crates/sequencing/papyrus_consensus/src/types.rs @@ -4,9 +4,7 @@ use std::time::Duration; use async_trait::async_trait; use futures::channel::{mpsc, oneshot}; use papyrus_network::network_manager::{ - BroadcastTopicChannels, - BroadcastTopicClient, - GenericReceiver, + BroadcastTopicChannels, BroadcastTopicClient, GenericReceiver, }; use papyrus_network_types::network_types::BroadcastedMessageMetadata; use papyrus_protobuf::consensus::{ConsensusMessage, ProposalFin, ProposalInit, Vote}; diff --git a/crates/sequencing/papyrus_consensus_orchestrator/src/papyrus_consensus_context.rs b/crates/sequencing/papyrus_consensus_orchestrator/src/papyrus_consensus_context.rs index 5581abac18..a7c61c21af 100644 --- a/crates/sequencing/papyrus_consensus_orchestrator/src/papyrus_consensus_context.rs +++ b/crates/sequencing/papyrus_consensus_orchestrator/src/papyrus_consensus_context.rs @@ -16,22 +16,11 @@ use async_trait::async_trait; use futures::channel::{mpsc, oneshot}; use futures::{SinkExt, StreamExt}; use papyrus_consensus::types::{ - ConsensusContext, - ConsensusError, - ProposalContentId, - Round, - ValidatorId, - DEFAULT_VALIDATOR_ID, + ConsensusContext, ConsensusError, ProposalContentId, Round, ValidatorId, DEFAULT_VALIDATOR_ID, }; use papyrus_network::network_manager::{BroadcastTopicClient, BroadcastTopicClientTrait}; use papyrus_protobuf::consensus::{ - ConsensusMessage, - Proposal, - ProposalFin, - ProposalInit, - ProposalPart, - TransactionBatch, - Vote, + ConsensusMessage, Proposal, ProposalFin, ProposalInit, ProposalPart, TransactionBatch, Vote, }; use papyrus_storage::body::BodyStorageReader; use papyrus_storage::header::HeaderStorageReader; diff --git a/crates/sequencing/papyrus_consensus_orchestrator/src/papyrus_consensus_context_test.rs b/crates/sequencing/papyrus_consensus_orchestrator/src/papyrus_consensus_context_test.rs index dc83ee01c7..b56fc2c582 100644 --- a/crates/sequencing/papyrus_consensus_orchestrator/src/papyrus_consensus_context_test.rs +++ b/crates/sequencing/papyrus_consensus_orchestrator/src/papyrus_consensus_context_test.rs @@ -5,18 +5,11 @@ use futures::StreamExt; use papyrus_consensus::stream_handler::StreamHandler; use papyrus_consensus::types::{ConsensusContext, ValidatorId, DEFAULT_VALIDATOR_ID}; use papyrus_network::network_manager::test_utils::{ - mock_register_broadcast_topic, - BroadcastNetworkMock, - TestSubscriberChannels, + mock_register_broadcast_topic, BroadcastNetworkMock, TestSubscriberChannels, }; use papyrus_network::network_manager::BroadcastTopicChannels; use papyrus_protobuf::consensus::{ - ConsensusMessage, - ProposalFin, - ProposalInit, - ProposalPart, - StreamMessage, - TransactionBatch, + ConsensusMessage, ProposalFin, ProposalInit, ProposalPart, StreamMessage, TransactionBatch, Vote, }; use papyrus_storage::body::BodyStorageWriter; diff --git a/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs b/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs index 92e45cd85d..3cc7566ffd 100644 --- a/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs +++ b/crates/sequencing/papyrus_consensus_orchestrator/src/sequencer_consensus_context.rs @@ -13,43 +13,20 @@ use async_trait::async_trait; use futures::channel::{mpsc, oneshot}; use futures::{SinkExt, StreamExt}; use papyrus_consensus::types::{ - ConsensusContext, - ConsensusError, - ProposalContentId, - Round, - ValidatorId, - DEFAULT_VALIDATOR_ID, + ConsensusContext, ConsensusError, ProposalContentId, Round, ValidatorId, DEFAULT_VALIDATOR_ID, }; use papyrus_network::network_manager::{BroadcastTopicClient, BroadcastTopicClientTrait}; use papyrus_protobuf::consensus::{ - ConsensusMessage, - ProposalFin, - ProposalInit, - ProposalPart, - TransactionBatch, - Vote, + ConsensusMessage, ProposalFin, ProposalInit, ProposalPart, TransactionBatch, Vote, }; use starknet_api::block::{ - BlockHash, - BlockHashAndNumber, - BlockInfo, - BlockNumber, - BlockTimestamp, - GasPriceVector, - GasPrices, - NonzeroGasPrice, + BlockHash, BlockHashAndNumber, BlockInfo, BlockNumber, BlockTimestamp, GasPriceVector, + GasPrices, NonzeroGasPrice, }; use starknet_api::executable_transaction::Transaction as ExecutableTransaction; use starknet_batcher_types::batcher_types::{ - DecisionReachedInput, - GetProposalContent, - GetProposalContentInput, - ProposalId, - ProposalStatus, - ProposeBlockInput, - SendProposalContent, - SendProposalContentInput, - StartHeightInput, + DecisionReachedInput, GetProposalContent, GetProposalContentInput, ProposalId, ProposalStatus, + ProposeBlockInput, SendProposalContent, SendProposalContentInput, StartHeightInput, ValidateBlockInput, }; use starknet_batcher_types::communication::BatcherClient; @@ -469,7 +446,7 @@ async fn stream_build_proposal( .expect("Failed to broadcast proposal content"); } GetProposalContent::Finished(id) => { - let proposal_content_id = BlockHash(id.state_diff_commitment.0.0); + let proposal_content_id = BlockHash(id.state_diff_commitment.0 .0); info!( "Finished building proposal {:?}: content_id = {:?}, num_txs = {:?}, height = \ {:?}", @@ -565,7 +542,7 @@ async fn stream_validate_proposal( } status => panic!("Unexpected status: for {proposal_id:?}, {status:?}"), }; - let batcher_block_id = BlockHash(response_id.state_diff_commitment.0.0); + let batcher_block_id = BlockHash(response_id.state_diff_commitment.0 .0); info!( "Finished validating proposal {:?}: network_block_id: {:?}, batcher_block_id = {:?}, \ num_txs = {:?}, height = {:?}", 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 085cfed39d..25eba811d0 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 @@ -8,18 +8,11 @@ use lazy_static::lazy_static; use papyrus_consensus::stream_handler::StreamHandler; use papyrus_consensus::types::{ConsensusContext, ValidatorId, DEFAULT_VALIDATOR_ID}; use papyrus_network::network_manager::test_utils::{ - mock_register_broadcast_topic, - BroadcastNetworkMock, - TestSubscriberChannels, + mock_register_broadcast_topic, BroadcastNetworkMock, TestSubscriberChannels, }; use papyrus_network::network_manager::BroadcastTopicChannels; use papyrus_protobuf::consensus::{ - ConsensusMessage, - ProposalFin, - ProposalInit, - ProposalPart, - StreamMessage, - TransactionBatch, + ConsensusMessage, ProposalFin, ProposalInit, ProposalPart, StreamMessage, TransactionBatch, }; use starknet_api::block::{BlockHash, BlockNumber}; use starknet_api::core::StateDiffCommitment; @@ -28,15 +21,8 @@ use starknet_api::hash::PoseidonHash; use starknet_api::test_utils::invoke::{executable_invoke_tx, invoke_tx, InvokeTxArgs}; use starknet_api::transaction::{Transaction, TransactionHash}; use starknet_batcher_types::batcher_types::{ - GetProposalContent, - GetProposalContentResponse, - ProposalCommitment, - ProposalId, - ProposalStatus, - ProposeBlockInput, - SendProposalContent, - SendProposalContentInput, - SendProposalContentResponse, + GetProposalContent, GetProposalContentResponse, ProposalCommitment, ProposalId, ProposalStatus, + ProposeBlockInput, SendProposalContent, SendProposalContentInput, SendProposalContentResponse, ValidateBlockInput, }; use starknet_batcher_types::communication::MockBatcherClient; @@ -134,7 +120,7 @@ async fn build_proposal() { ProposalInit { proposer: ValidatorId::from(DEFAULT_VALIDATOR_ID), ..Default::default() }; // TODO(Asmaa): Test proposal content. let fin_receiver = context.build_proposal(init, TIMEOUT).await; - assert_eq!(fin_receiver.await.unwrap().0, STATE_DIFF_COMMITMENT.0.0); + assert_eq!(fin_receiver.await.unwrap().0, STATE_DIFF_COMMITMENT.0 .0); } #[tokio::test] @@ -191,7 +177,7 @@ async fn validate_proposal_success() { .unwrap(); content_sender .send(ProposalPart::Fin(ProposalFin { - proposal_content_id: BlockHash(STATE_DIFF_COMMITMENT.0.0), + proposal_content_id: BlockHash(STATE_DIFF_COMMITMENT.0 .0), })) .await .unwrap(); @@ -205,7 +191,7 @@ async fn validate_proposal_success() { ) .await; content_sender.close_channel(); - assert_eq!(fin_receiver.await.unwrap().0.0, STATE_DIFF_COMMITMENT.0.0); + assert_eq!(fin_receiver.await.unwrap().0 .0, STATE_DIFF_COMMITMENT.0 .0); } #[tokio::test] @@ -249,7 +235,7 @@ async fn repropose() { .unwrap(); content_sender .send(ProposalPart::Fin(ProposalFin { - proposal_content_id: BlockHash(STATE_DIFF_COMMITMENT.0.0), + proposal_content_id: BlockHash(STATE_DIFF_COMMITMENT.0 .0), })) .await .unwrap(); @@ -263,12 +249,12 @@ async fn repropose() { ) .await; content_sender.close_channel(); - assert_eq!(fin_receiver.await.unwrap().0.0, STATE_DIFF_COMMITMENT.0.0); + assert_eq!(fin_receiver.await.unwrap().0 .0, STATE_DIFF_COMMITMENT.0 .0); // Re-proposal: Just asserts this is a known valid proposal. context .repropose( - BlockHash(STATE_DIFF_COMMITMENT.0.0), + BlockHash(STATE_DIFF_COMMITMENT.0 .0), ProposalInit { height: BlockNumber(0), ..Default::default() }, ) .await; @@ -321,7 +307,7 @@ async fn proposals_from_different_rounds() { tx_hashes: vec![TX_BATCH[0].tx_hash()], }); let prop_part_fin = ProposalPart::Fin(ProposalFin { - proposal_content_id: BlockHash(STATE_DIFF_COMMITMENT.0.0), + proposal_content_id: BlockHash(STATE_DIFF_COMMITMENT.0 .0), }); // The proposal from the past round is ignored. @@ -353,7 +339,7 @@ async fn proposals_from_different_rounds() { content_receiver, ) .await; - assert_eq!(fin_receiver_curr_round.await.unwrap().0.0, STATE_DIFF_COMMITMENT.0.0); + assert_eq!(fin_receiver_curr_round.await.unwrap().0 .0, STATE_DIFF_COMMITMENT.0 .0); // The proposal from the future round should not be processed. let (mut content_sender, content_receiver) = mpsc::channel(CHANNEL_SIZE); @@ -441,7 +427,7 @@ async fn interrupt_active_proposal() { .unwrap(); content_sender_1 .send(ProposalPart::Fin(ProposalFin { - proposal_content_id: BlockHash(STATE_DIFF_COMMITMENT.0.0), + proposal_content_id: BlockHash(STATE_DIFF_COMMITMENT.0 .0), })) .await .unwrap(); @@ -459,5 +445,5 @@ async fn interrupt_active_proposal() { // Interrupt active proposal. assert!(fin_receiver_0.await.is_err()); - assert_eq!(fin_receiver_1.await.unwrap().0.0, STATE_DIFF_COMMITMENT.0.0); + assert_eq!(fin_receiver_1.await.unwrap().0 .0, STATE_DIFF_COMMITMENT.0 .0); } diff --git a/crates/starknet_api/src/block.rs b/crates/starknet_api/src/block.rs index dbd0fe7896..177051838c 100644 --- a/crates/starknet_api/src/block.rs +++ b/crates/starknet_api/src/block.rs @@ -9,14 +9,8 @@ use starknet_types_core::hash::{Poseidon, StarkHash as CoreStarkHash}; use strum_macros::EnumIter; use crate::core::{ - ContractAddress, - EventCommitment, - GlobalRoot, - ReceiptCommitment, - SequencerContractAddress, - SequencerPublicKey, - StateDiffCommitment, - TransactionCommitment, + ContractAddress, EventCommitment, GlobalRoot, ReceiptCommitment, SequencerContractAddress, + SequencerPublicKey, StateDiffCommitment, TransactionCommitment, }; use crate::crypto::utils::{verify_message_hash_signature, CryptoError, Signature}; use crate::data_availability::L1DataAvailabilityMode; 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 e948bd4b39..ad452185c7 100644 --- a/crates/starknet_api/src/block_hash/block_hash_calculator.rs +++ b/crates/starknet_api/src/block_hash/block_hash_calculator.rs @@ -10,11 +10,7 @@ use super::state_diff_hash::calculate_state_diff_hash; use super::transaction_commitment::{calculate_transaction_commitment, TransactionLeafElement}; use crate::block::{BlockHash, BlockHeaderWithoutHash, GasPricePerToken, StarknetVersion}; use crate::core::{ - ascii_as_felt, - EventCommitment, - ReceiptCommitment, - StateDiffCommitment, - TransactionCommitment, + ascii_as_felt, EventCommitment, ReceiptCommitment, StateDiffCommitment, TransactionCommitment, }; use crate::crypto::utils::HashChain; use crate::data_availability::L1DataAvailabilityMode; @@ -126,7 +122,7 @@ pub fn calculate_block_hash( .chain(&header.sequencer.0) .chain(&header.timestamp.0.into()) .chain(&block_commitments.concatenated_counts) - .chain(&block_commitments.state_diff_commitment.0.0) + .chain(&block_commitments.state_diff_commitment.0 .0) .chain(&block_commitments.transaction_commitment.0) .chain(&block_commitments.event_commitment.0) .chain(&block_commitments.receipt_commitment.0) @@ -244,17 +240,15 @@ fn gas_prices_to_hash( block_hash_version: &BlockHashVersion, ) -> Vec { if block_hash_version >= &BlockHashVersion::V0_13_4 { - vec![ - HashChain::new() - .chain(&STARKNET_GAS_PRICES0) - .chain(&l1_gas_price.price_in_wei.0.into()) - .chain(&l1_gas_price.price_in_fri.0.into()) - .chain(&l1_data_gas_price.price_in_wei.0.into()) - .chain(&l1_data_gas_price.price_in_fri.0.into()) - .chain(&l2_gas_price.price_in_wei.0.into()) - .chain(&l2_gas_price.price_in_fri.0.into()) - .get_poseidon_hash(), - ] + vec![HashChain::new() + .chain(&STARKNET_GAS_PRICES0) + .chain(&l1_gas_price.price_in_wei.0.into()) + .chain(&l1_gas_price.price_in_fri.0.into()) + .chain(&l1_data_gas_price.price_in_wei.0.into()) + .chain(&l1_data_gas_price.price_in_fri.0.into()) + .chain(&l2_gas_price.price_in_wei.0.into()) + .chain(&l2_gas_price.price_in_fri.0.into()) + .get_poseidon_hash()] } else { vec![ l1_gas_price.price_in_wei.0.into(), 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 396273ddae..0d15c3444c 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 @@ -3,29 +3,16 @@ use starknet_types_core::felt::Felt; use super::concat_counts; use crate::block::{ - BlockHash, - BlockHeaderWithoutHash, - BlockNumber, - BlockTimestamp, - GasPricePerToken, + BlockHash, BlockHeaderWithoutHash, BlockNumber, BlockTimestamp, GasPricePerToken, }; use crate::block_hash::block_hash_calculator::{ - calculate_block_commitments, - calculate_block_hash, - BlockHashVersion, - BlockHeaderCommitments, + calculate_block_commitments, calculate_block_hash, BlockHashVersion, BlockHeaderCommitments, TransactionHashingData, }; use crate::block_hash::test_utils::{get_state_diff, get_transaction_output}; use crate::core::{ - ContractAddress, - EventCommitment, - GlobalRoot, - PatriciaKey, - ReceiptCommitment, - SequencerContractAddress, - StateDiffCommitment, - TransactionCommitment, + ContractAddress, EventCommitment, GlobalRoot, PatriciaKey, ReceiptCommitment, + SequencerContractAddress, StateDiffCommitment, TransactionCommitment, }; use crate::data_availability::L1DataAvailabilityMode; use crate::hash::PoseidonHash; 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 3d9c5c5720..359dc1e919 100644 --- a/crates/starknet_api/src/block_hash/receipt_commitment_test.rs +++ b/crates/starknet_api/src/block_hash/receipt_commitment_test.rs @@ -3,10 +3,7 @@ use starknet_types_core::hash::Poseidon; use super::calculate_messages_sent_hash; use crate::block_hash::receipt_commitment::{ - calculate_receipt_commitment, - calculate_receipt_hash, - get_revert_reason_hash, - ReceiptElement, + calculate_receipt_commitment, calculate_receipt_hash, get_revert_reason_hash, ReceiptElement, }; use crate::block_hash::test_utils::{generate_message_to_l1, get_transaction_output}; use crate::core::ReceiptCommitment; diff --git a/crates/starknet_api/src/block_hash/state_diff_hash.rs b/crates/starknet_api/src/block_hash/state_diff_hash.rs index 147f56a286..9fa4993a10 100644 --- a/crates/starknet_api/src/block_hash/state_diff_hash.rs +++ b/crates/starknet_api/src/block_hash/state_diff_hash.rs @@ -4,12 +4,7 @@ use indexmap::IndexMap; use starknet_types_core::felt::Felt; use crate::core::{ - ascii_as_felt, - ClassHash, - CompiledClassHash, - ContractAddress, - Nonce, - StateDiffCommitment, + ascii_as_felt, ClassHash, CompiledClassHash, ContractAddress, Nonce, StateDiffCommitment, }; use crate::crypto::utils::HashChain; use crate::hash::PoseidonHash; diff --git a/crates/starknet_api/src/block_hash/state_diff_hash_test.rs b/crates/starknet_api/src/block_hash/state_diff_hash_test.rs index c0cadf2ef2..ef11443742 100644 --- a/crates/starknet_api/src/block_hash/state_diff_hash_test.rs +++ b/crates/starknet_api/src/block_hash/state_diff_hash_test.rs @@ -1,12 +1,8 @@ use indexmap::indexmap; use crate::block_hash::state_diff_hash::{ - calculate_state_diff_hash, - chain_declared_classes, - chain_deprecated_declared_classes, - chain_nonces, - chain_storage_diffs, - chain_updated_contracts, + calculate_state_diff_hash, chain_declared_classes, chain_deprecated_declared_classes, + chain_nonces, chain_storage_diffs, chain_updated_contracts, }; use crate::block_hash::test_utils::get_state_diff; use crate::core::{ClassHash, CompiledClassHash, Nonce, StateDiffCommitment}; diff --git a/crates/starknet_api/src/block_hash/test_utils.rs b/crates/starknet_api/src/block_hash/test_utils.rs index 620a8e5210..52cca10e7f 100644 --- a/crates/starknet_api/src/block_hash/test_utils.rs +++ b/crates/starknet_api/src/block_hash/test_utils.rs @@ -8,10 +8,7 @@ use crate::execution_resources::{GasAmount, GasVector}; use crate::state::ThinStateDiff; use crate::transaction::fields::Fee; use crate::transaction::{ - L2ToL1Payload, - MessageToL1, - RevertedTransactionExecutionStatus, - TransactionExecutionStatus, + L2ToL1Payload, MessageToL1, RevertedTransactionExecutionStatus, TransactionExecutionStatus, }; pub(crate) fn get_transaction_output() -> TransactionOutputForHash { 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 df48e36013..0141555f29 100644 --- a/crates/starknet_api/src/block_hash/transaction_commitment_test.rs +++ b/crates/starknet_api/src/block_hash/transaction_commitment_test.rs @@ -3,8 +3,7 @@ use starknet_types_core::hash::Poseidon; use super::TransactionLeafElement; use crate::block_hash::transaction_commitment::{ - calculate_transaction_commitment, - calculate_transaction_leaf, + calculate_transaction_commitment, calculate_transaction_leaf, }; use crate::core::TransactionCommitment; use crate::transaction::fields::TransactionSignature; diff --git a/crates/starknet_api/src/block_test.rs b/crates/starknet_api/src/block_test.rs index 80c02c412a..fa7b6f526c 100644 --- a/crates/starknet_api/src/block_test.rs +++ b/crates/starknet_api/src/block_test.rs @@ -43,10 +43,8 @@ fn block_signature_verification() { "0x48253ff2c3bed7af18bde0b611b083b39445959102d4947c51c4db6aa4f4e58" ))); - assert!( - verify_block_signature(&sequencer_pub_key, &signature, &state_commitment, &block_hash) - .unwrap() - ); + assert!(verify_block_signature(&sequencer_pub_key, &signature, &state_commitment, &block_hash) + .unwrap()); } #[test] diff --git a/crates/starknet_api/src/core.rs b/crates/starknet_api/src/core.rs index 8b1a055462..d8298d6583 100644 --- a/crates/starknet_api/src/core.rs +++ b/crates/starknet_api/src/core.rs @@ -113,9 +113,9 @@ impl ContractAddress { /// The lower bound is above the special saved addresses and the upper bound is congruent with /// the storage var address upper bound. pub fn validate(&self) -> Result<(), StarknetApiError> { - let value = self.0.0; + let value = self.0 .0; let l2_address_upper_bound = Felt::from(*L2_ADDRESS_UPPER_BOUND); - if (value > BLOCK_HASH_TABLE_ADDRESS.0.0) && (value < l2_address_upper_bound) { + if (value > BLOCK_HASH_TABLE_ADDRESS.0 .0) && (value < l2_address_upper_bound) { return Ok(()); } diff --git a/crates/starknet_api/src/core_test.rs b/crates/starknet_api/src/core_test.rs index 81221cce44..705ce707ee 100644 --- a/crates/starknet_api/src/core_test.rs +++ b/crates/starknet_api/src/core_test.rs @@ -3,16 +3,8 @@ use starknet_types_core::felt::Felt; use starknet_types_core::hash::{Pedersen, StarkHash as CoreStarkHash}; use crate::core::{ - ascii_as_felt, - calculate_contract_address, - ChainId, - ContractAddress, - EthAddress, - Nonce, - PatriciaKey, - StarknetApiError, - CONTRACT_ADDRESS_PREFIX, - L2_ADDRESS_UPPER_BOUND, + ascii_as_felt, calculate_contract_address, ChainId, ContractAddress, EthAddress, Nonce, + PatriciaKey, StarknetApiError, CONTRACT_ADDRESS_PREFIX, L2_ADDRESS_UPPER_BOUND, }; use crate::hash::StarkHash; use crate::transaction::fields::{Calldata, ContractAddressSalt}; diff --git a/crates/starknet_api/src/executable_transaction.rs b/crates/starknet_api/src/executable_transaction.rs index a3e0f96f33..9bc79ada44 100644 --- a/crates/starknet_api/src/executable_transaction.rs +++ b/crates/starknet_api/src/executable_transaction.rs @@ -4,21 +4,12 @@ use crate::contract_class::{ClassInfo, ContractClass}; use crate::core::{calculate_contract_address, ChainId, ClassHash, ContractAddress, Nonce}; use crate::data_availability::DataAvailabilityMode; use crate::rpc_transaction::{ - RpcDeployAccountTransaction, - RpcDeployAccountTransactionV3, - RpcInvokeTransaction, + RpcDeployAccountTransaction, RpcDeployAccountTransactionV3, RpcInvokeTransaction, RpcInvokeTransactionV3, }; use crate::transaction::fields::{ - AccountDeploymentData, - AllResourceBounds, - Calldata, - ContractAddressSalt, - Fee, - PaymasterData, - Tip, - TransactionSignature, - ValidResourceBounds, + AccountDeploymentData, AllResourceBounds, Calldata, ContractAddressSalt, Fee, PaymasterData, + Tip, TransactionSignature, ValidResourceBounds, }; use crate::transaction::{TransactionHash, TransactionHasher, TransactionVersion}; use crate::StarknetApiError; diff --git a/crates/starknet_api/src/execution_utils.rs b/crates/starknet_api/src/execution_utils.rs index 70552e1588..087187c23d 100644 --- a/crates/starknet_api/src/execution_utils.rs +++ b/crates/starknet_api/src/execution_utils.rs @@ -7,5 +7,9 @@ pub fn format_panic_data(felts: &[Felt]) -> String { while let Some(item) = format_next_item(&mut felts) { items.push(item.quote_if_string()); } - if let [item] = &items[..] { item.clone() } else { format!("({})", items.join(", ")) } + if let [item] = &items[..] { + item.clone() + } else { + format!("({})", items.join(", ")) + } } diff --git a/crates/starknet_api/src/rpc_transaction.rs b/crates/starknet_api/src/rpc_transaction.rs index 0e1d7f37fd..5cbf80fc85 100644 --- a/crates/starknet_api/src/rpc_transaction.rs +++ b/crates/starknet_api/src/rpc_transaction.rs @@ -9,32 +9,17 @@ use serde::{Deserialize, Serialize}; use crate::contract_class::EntryPointType; use crate::core::{ - calculate_contract_address, - ClassHash, - CompiledClassHash, - ContractAddress, - Nonce, + calculate_contract_address, ClassHash, CompiledClassHash, ContractAddress, Nonce, }; use crate::data_availability::DataAvailabilityMode; use crate::state::{EntryPoint, SierraContractClass}; use crate::transaction::fields::{ - AccountDeploymentData, - AllResourceBounds, - Calldata, - ContractAddressSalt, - PaymasterData, - Tip, - TransactionSignature, - ValidResourceBounds, + AccountDeploymentData, AllResourceBounds, Calldata, ContractAddressSalt, PaymasterData, Tip, + TransactionSignature, ValidResourceBounds, }; use crate::transaction::{ - DeclareTransaction, - DeclareTransactionV3, - DeployAccountTransaction, - DeployAccountTransactionV3, - InvokeTransaction, - InvokeTransactionV3, - Transaction, + DeclareTransaction, DeclareTransactionV3, DeployAccountTransaction, DeployAccountTransactionV3, + InvokeTransaction, InvokeTransactionV3, Transaction, }; use crate::StarknetApiError; diff --git a/crates/starknet_api/src/rpc_transaction_test.rs b/crates/starknet_api/src/rpc_transaction_test.rs index 7854a5d929..5a7695f493 100644 --- a/crates/starknet_api/src/rpc_transaction_test.rs +++ b/crates/starknet_api/src/rpc_transaction_test.rs @@ -7,25 +7,14 @@ use crate::block::GasPrice; use crate::core::CompiledClassHash; use crate::execution_resources::GasAmount; use crate::rpc_transaction::{ - DataAvailabilityMode, - RpcDeclareTransaction, - RpcDeclareTransactionV3, - RpcDeployAccountTransaction, - RpcDeployAccountTransactionV3, - RpcTransaction, + DataAvailabilityMode, RpcDeclareTransaction, RpcDeclareTransactionV3, + RpcDeployAccountTransaction, RpcDeployAccountTransactionV3, RpcTransaction, }; use crate::state::SierraContractClass; use crate::test_utils::invoke::{rpc_invoke_tx, InvokeTxArgs}; use crate::transaction::fields::{ - AccountDeploymentData, - AllResourceBounds, - Calldata, - ContractAddressSalt, - PaymasterData, - ResourceBounds, - Tip, - TransactionSignature, - ValidResourceBounds, + AccountDeploymentData, AllResourceBounds, Calldata, ContractAddressSalt, PaymasterData, + ResourceBounds, Tip, TransactionSignature, ValidResourceBounds, }; use crate::{calldata, class_hash, contract_address, felt, nonce}; diff --git a/crates/starknet_api/src/serde_utils.rs b/crates/starknet_api/src/serde_utils.rs index c23b7f4ed7..d82ea6233e 100644 --- a/crates/starknet_api/src/serde_utils.rs +++ b/crates/starknet_api/src/serde_utils.rs @@ -131,7 +131,11 @@ pub fn hex_str_from_bytes(bytes: [u8; N]) let hex_str = hex::encode(bytes); let mut hex_str = hex_str.trim_start_matches('0'); hex_str = if hex_str.is_empty() { "0" } else { hex_str }; - if PREFIXED { format!("0x{hex_str}") } else { hex_str.to_string() } + if PREFIXED { + format!("0x{hex_str}") + } else { + hex_str.to_string() + } } pub fn deserialize_optional_contract_class_abi_entry_vector<'de, D>( diff --git a/crates/starknet_api/src/serde_utils_test.rs b/crates/starknet_api/src/serde_utils_test.rs index 2a94ae6379..711de14621 100644 --- a/crates/starknet_api/src/serde_utils_test.rs +++ b/crates/starknet_api/src/serde_utils_test.rs @@ -2,17 +2,11 @@ use assert_matches::assert_matches; use serde::Deserialize; use crate::deprecated_contract_class::{ - ConstructorType, - ContractClassAbiEntry, - FunctionAbiEntry, - TypedParameter, + ConstructorType, ContractClassAbiEntry, FunctionAbiEntry, TypedParameter, }; use crate::serde_utils::{ - bytes_from_hex_str, - deserialize_optional_contract_class_abi_entry_vector, - hex_str_from_bytes, - BytesAsHex, - InnerDeserializationError, + bytes_from_hex_str, deserialize_optional_contract_class_abi_entry_vector, hex_str_from_bytes, + BytesAsHex, InnerDeserializationError, }; #[test] diff --git a/crates/starknet_api/src/state.rs b/crates/starknet_api/src/state.rs index 782db70fad..d213c9d8cd 100644 --- a/crates/starknet_api/src/state.rs +++ b/crates/starknet_api/src/state.rs @@ -11,12 +11,7 @@ use starknet_types_core::felt::Felt; use crate::block::{BlockHash, BlockNumber}; use crate::core::{ - ClassHash, - CompiledClassHash, - ContractAddress, - EntryPointSelector, - GlobalRoot, - Nonce, + ClassHash, CompiledClassHash, ContractAddress, EntryPointSelector, GlobalRoot, Nonce, PatriciaKey, }; use crate::deprecated_contract_class::ContractClass as DeprecatedContractClass; diff --git a/crates/starknet_api/src/state_test.rs b/crates/starknet_api/src/state_test.rs index 47b9a56b15..09cc54f056 100644 --- a/crates/starknet_api/src/state_test.rs +++ b/crates/starknet_api/src/state_test.rs @@ -65,21 +65,17 @@ fn thin_state_diff_len() { #[test] fn thin_state_diff_is_empty() { assert!(ThinStateDiff::default().is_empty()); - assert!( - ThinStateDiff { - storage_diffs: indexmap! { Default::default() => IndexMap::new() }, - ..Default::default() - } - .is_empty() - ); + assert!(ThinStateDiff { + storage_diffs: indexmap! { Default::default() => IndexMap::new() }, + ..Default::default() + } + .is_empty()); - assert!( - !ThinStateDiff { - deployed_contracts: indexmap! { Default::default() => Default::default() }, - ..Default::default() - } - .is_empty() - ); + assert!(!ThinStateDiff { + deployed_contracts: indexmap! { Default::default() => Default::default() }, + ..Default::default() + } + .is_empty()); assert!( !ThinStateDiff { storage_diffs: indexmap! { Default::default() => indexmap! { Default::default() => Default::default() } }, @@ -87,32 +83,24 @@ fn thin_state_diff_is_empty() { } .is_empty() ); - assert!( - !ThinStateDiff { - declared_classes: indexmap! { Default::default() => Default::default() }, - ..Default::default() - } - .is_empty() - ); - assert!( - !ThinStateDiff { - deprecated_declared_classes: vec![Default::default()], - ..Default::default() - } - .is_empty() - ); - assert!( - !ThinStateDiff { - nonces: indexmap! { Default::default() => Default::default() }, - ..Default::default() - } - .is_empty() - ); - assert!( - !ThinStateDiff { - replaced_classes: indexmap! { Default::default() => Default::default() }, - ..Default::default() - } - .is_empty() - ); + assert!(!ThinStateDiff { + declared_classes: indexmap! { Default::default() => Default::default() }, + ..Default::default() + } + .is_empty()); + assert!(!ThinStateDiff { + deprecated_declared_classes: vec![Default::default()], + ..Default::default() + } + .is_empty()); + assert!(!ThinStateDiff { + nonces: indexmap! { Default::default() => Default::default() }, + ..Default::default() + } + .is_empty()); + assert!(!ThinStateDiff { + replaced_classes: indexmap! { Default::default() => Default::default() }, + ..Default::default() + } + .is_empty()); } diff --git a/crates/starknet_api/src/test_utils/declare.rs b/crates/starknet_api/src/test_utils/declare.rs index a1c57f88df..3ec46abe95 100644 --- a/crates/starknet_api/src/test_utils/declare.rs +++ b/crates/starknet_api/src/test_utils/declare.rs @@ -3,26 +3,16 @@ use crate::contract_class::ClassInfo; use crate::core::{ClassHash, CompiledClassHash, ContractAddress, Nonce}; use crate::data_availability::DataAvailabilityMode; use crate::executable_transaction::{ - AccountTransaction, - DeclareTransaction as ExecutableDeclareTransaction, + AccountTransaction, DeclareTransaction as ExecutableDeclareTransaction, }; use crate::rpc_transaction::{RpcDeclareTransaction, RpcDeclareTransactionV3, RpcTransaction}; use crate::state::SierraContractClass; use crate::transaction::fields::{ - AccountDeploymentData, - Fee, - PaymasterData, - Tip, - TransactionSignature, - ValidResourceBounds, + AccountDeploymentData, Fee, PaymasterData, Tip, TransactionSignature, ValidResourceBounds, }; use crate::transaction::{ - DeclareTransaction, - DeclareTransactionV0V1, - DeclareTransactionV2, - DeclareTransactionV3, - TransactionHash, - TransactionVersion, + DeclareTransaction, DeclareTransactionV0V1, DeclareTransactionV2, DeclareTransactionV3, + TransactionHash, TransactionVersion, }; pub const TEST_SENDER_ADDRESS: u128 = 0x1000; diff --git a/crates/starknet_api/src/test_utils/deploy_account.rs b/crates/starknet_api/src/test_utils/deploy_account.rs index 5c299f0396..30dad3dafe 100644 --- a/crates/starknet_api/src/test_utils/deploy_account.rs +++ b/crates/starknet_api/src/test_utils/deploy_account.rs @@ -2,29 +2,18 @@ use super::NonceManager; use crate::core::{calculate_contract_address, ClassHash, ContractAddress, Nonce}; use crate::data_availability::DataAvailabilityMode; use crate::executable_transaction::{ - AccountTransaction, - DeployAccountTransaction as ExecutableDeployAccountTransaction, + AccountTransaction, DeployAccountTransaction as ExecutableDeployAccountTransaction, }; use crate::rpc_transaction::{ - RpcDeployAccountTransaction, - RpcDeployAccountTransactionV3, - RpcTransaction, + RpcDeployAccountTransaction, RpcDeployAccountTransactionV3, RpcTransaction, }; use crate::transaction::fields::{ - Calldata, - ContractAddressSalt, - Fee, - PaymasterData, - Tip, - TransactionSignature, + Calldata, ContractAddressSalt, Fee, PaymasterData, Tip, TransactionSignature, ValidResourceBounds, }; use crate::transaction::{ - DeployAccountTransaction, - DeployAccountTransactionV1, - DeployAccountTransactionV3, - TransactionHash, - TransactionVersion, + DeployAccountTransaction, DeployAccountTransactionV1, DeployAccountTransactionV3, + TransactionHash, TransactionVersion, }; #[derive(Clone)] diff --git a/crates/starknet_api/src/test_utils/invoke.rs b/crates/starknet_api/src/test_utils/invoke.rs index 879df83f42..6ff8d2b64f 100644 --- a/crates/starknet_api/src/test_utils/invoke.rs +++ b/crates/starknet_api/src/test_utils/invoke.rs @@ -3,27 +3,17 @@ use crate::calldata; use crate::core::{ContractAddress, Nonce}; use crate::data_availability::DataAvailabilityMode; use crate::executable_transaction::{ - AccountTransaction, - InvokeTransaction as ExecutableInvokeTransaction, + AccountTransaction, InvokeTransaction as ExecutableInvokeTransaction, }; use crate::rpc_transaction::{RpcInvokeTransaction, RpcInvokeTransactionV3, RpcTransaction}; use crate::transaction::constants::EXECUTE_ENTRY_POINT_NAME; use crate::transaction::fields::{ - AccountDeploymentData, - Calldata, - Fee, - PaymasterData, - Tip, - TransactionSignature, + AccountDeploymentData, Calldata, Fee, PaymasterData, Tip, TransactionSignature, ValidResourceBounds, }; use crate::transaction::{ - InvokeTransaction, - InvokeTransactionV0, - InvokeTransactionV1, - InvokeTransactionV3, - TransactionHash, - TransactionVersion, + InvokeTransaction, InvokeTransactionV0, InvokeTransactionV1, InvokeTransactionV3, + TransactionHash, TransactionVersion, }; #[derive(Clone)] diff --git a/crates/starknet_api/src/transaction.rs b/crates/starknet_api/src/transaction.rs index 77d9b4747f..e92bfae590 100644 --- a/crates/starknet_api/src/transaction.rs +++ b/crates/starknet_api/src/transaction.rs @@ -6,39 +6,21 @@ use starknet_types_core::felt::Felt; use crate::block::{BlockHash, BlockNumber}; use crate::core::{ - ChainId, - ClassHash, - CompiledClassHash, - ContractAddress, - EntryPointSelector, - EthAddress, - Nonce, + ChainId, ClassHash, CompiledClassHash, ContractAddress, EntryPointSelector, EthAddress, Nonce, }; use crate::data_availability::DataAvailabilityMode; use crate::execution_resources::ExecutionResources; use crate::hash::StarkHash; use crate::transaction::fields::{ - AccountDeploymentData, - Calldata, - ContractAddressSalt, - Fee, - PaymasterData, - Tip, - TransactionSignature, - ValidResourceBounds, + AccountDeploymentData, Calldata, ContractAddressSalt, Fee, PaymasterData, Tip, + TransactionSignature, ValidResourceBounds, }; use crate::transaction_hash::{ - get_declare_transaction_v0_hash, - get_declare_transaction_v1_hash, - get_declare_transaction_v2_hash, - get_declare_transaction_v3_hash, - get_deploy_account_transaction_v1_hash, - get_deploy_account_transaction_v3_hash, - get_deploy_transaction_hash, - get_invoke_transaction_v0_hash, - get_invoke_transaction_v1_hash, - get_invoke_transaction_v3_hash, - get_l1_handler_transaction_hash, + get_declare_transaction_v0_hash, get_declare_transaction_v1_hash, + get_declare_transaction_v2_hash, get_declare_transaction_v3_hash, + get_deploy_account_transaction_v1_hash, get_deploy_account_transaction_v3_hash, + get_deploy_transaction_hash, get_invoke_transaction_v0_hash, get_invoke_transaction_v1_hash, + get_invoke_transaction_v3_hash, get_l1_handler_transaction_hash, }; use crate::{executable_transaction, StarknetApiError}; diff --git a/crates/starknet_api/src/transaction_hash.rs b/crates/starknet_api/src/transaction_hash.rs index e612e68f7a..09307a8323 100644 --- a/crates/starknet_api/src/transaction_hash.rs +++ b/crates/starknet_api/src/transaction_hash.rs @@ -8,24 +8,11 @@ use crate::crypto::utils::HashChain; use crate::data_availability::DataAvailabilityMode; use crate::transaction::fields::{ResourceBounds, Tip, ValidResourceBounds}; use crate::transaction::{ - signed_tx_version_from_tx, - DeclareTransaction, - DeclareTransactionV0V1, - DeclareTransactionV2, - DeclareTransactionV3, - DeployAccountTransaction, - DeployAccountTransactionV1, - DeployAccountTransactionV3, - DeployTransaction, - InvokeTransaction, - InvokeTransactionV0, - InvokeTransactionV1, - InvokeTransactionV3, - L1HandlerTransaction, - Transaction, - TransactionHash, - TransactionOptions, - TransactionVersion, + signed_tx_version_from_tx, DeclareTransaction, DeclareTransactionV0V1, DeclareTransactionV2, + DeclareTransactionV3, DeployAccountTransaction, DeployAccountTransactionV1, + DeployAccountTransactionV3, DeployTransaction, InvokeTransaction, InvokeTransactionV0, + InvokeTransactionV1, InvokeTransactionV3, L1HandlerTransaction, Transaction, TransactionHash, + TransactionOptions, TransactionVersion, }; use crate::StarknetApiError; diff --git a/crates/starknet_batcher/src/batcher.rs b/crates/starknet_batcher/src/batcher.rs index c6188a96de..de4194436e 100644 --- a/crates/starknet_batcher/src/batcher.rs +++ b/crates/starknet_batcher/src/batcher.rs @@ -11,20 +11,10 @@ use starknet_api::block::{BlockHashAndNumber, BlockNumber}; use starknet_api::executable_transaction::Transaction; use starknet_api::state::ThinStateDiff; use starknet_batcher_types::batcher_types::{ - BatcherResult, - DecisionReachedInput, - GetHeightResponse, - GetProposalContent, - GetProposalContentInput, - GetProposalContentResponse, - ProposalId, - ProposalStatus, - ProposeBlockInput, - SendProposalContent, - SendProposalContentInput, - SendProposalContentResponse, - StartHeightInput, - ValidateBlockInput, + BatcherResult, DecisionReachedInput, GetHeightResponse, GetProposalContent, + GetProposalContentInput, GetProposalContentResponse, ProposalId, ProposalStatus, + ProposeBlockInput, SendProposalContent, SendProposalContentInput, SendProposalContentResponse, + StartHeightInput, ValidateBlockInput, }; use starknet_batcher_types::errors::BatcherError; use starknet_mempool_types::communication::SharedMempoolClient; @@ -33,25 +23,16 @@ use starknet_sequencer_infra::component_definitions::ComponentStarter; use tracing::{debug, error, info, instrument, trace}; use crate::block_builder::{ - BlockBuilderError, - BlockBuilderExecutionParams, - BlockBuilderFactory, - BlockBuilderFactoryTrait, + BlockBuilderError, BlockBuilderExecutionParams, BlockBuilderFactory, BlockBuilderFactoryTrait, BlockMetadata, }; use crate::config::BatcherConfig; use crate::proposal_manager::{ - GenerateProposalError, - InternalProposalStatus, - ProposalError, - ProposalManager, - ProposalManagerTrait, - ProposalOutput, + GenerateProposalError, InternalProposalStatus, ProposalError, ProposalManager, + ProposalManagerTrait, ProposalOutput, }; use crate::transaction_provider::{ - DummyL1ProviderClient, - ProposeTransactionProvider, - ValidateTransactionProvider, + DummyL1ProviderClient, ProposeTransactionProvider, ValidateTransactionProvider, }; type OutputStreamReceiver = tokio::sync::mpsc::UnboundedReceiver; diff --git a/crates/starknet_batcher/src/batcher_test.rs b/crates/starknet_batcher/src/batcher_test.rs index f3d8f7d8da..af88d40efa 100644 --- a/crates/starknet_batcher/src/batcher_test.rs +++ b/crates/starknet_batcher/src/batcher_test.rs @@ -19,19 +19,9 @@ use starknet_api::state::ThinStateDiff; use starknet_api::transaction::TransactionHash; use starknet_api::{contract_address, felt, nonce, tx_hash}; use starknet_batcher_types::batcher_types::{ - DecisionReachedInput, - GetHeightResponse, - GetProposalContent, - GetProposalContentInput, - GetProposalContentResponse, - ProposalCommitment, - ProposalId, - ProposalStatus, - ProposeBlockInput, - SendProposalContent, - SendProposalContentInput, - SendProposalContentResponse, - StartHeightInput, + DecisionReachedInput, GetHeightResponse, GetProposalContent, GetProposalContentInput, + GetProposalContentResponse, ProposalCommitment, ProposalId, ProposalStatus, ProposeBlockInput, + SendProposalContent, SendProposalContentInput, SendProposalContentResponse, StartHeightInput, ValidateBlockInput, }; use starknet_batcher_types::errors::BatcherError; @@ -40,21 +30,13 @@ use starknet_mempool_types::mempool_types::CommitBlockArgs; use crate::batcher::{Batcher, MockBatcherStorageReaderTrait, MockBatcherStorageWriterTrait}; use crate::block_builder::{ - AbortSignalSender, - BlockBuilderError, - BlockBuilderTrait, - FailOnErrorCause, - MockBlockBuilderFactoryTrait, - MockBlockBuilderTrait, + AbortSignalSender, BlockBuilderError, BlockBuilderTrait, FailOnErrorCause, + MockBlockBuilderFactoryTrait, MockBlockBuilderTrait, }; use crate::config::BatcherConfig; use crate::proposal_manager::{ - GenerateProposalError, - InternalProposalStatus, - ProposalError, - ProposalManagerTrait, - ProposalOutput, - ProposalResult, + GenerateProposalError, InternalProposalStatus, ProposalError, ProposalManagerTrait, + ProposalOutput, ProposalResult, }; use crate::test_utils::test_txs; use crate::transaction_provider::NextTxs; diff --git a/crates/starknet_batcher/src/block_builder.rs b/crates/starknet_batcher/src/block_builder.rs index a76dc60358..03f23cbe60 100644 --- a/crates/starknet_batcher/src/block_builder.rs +++ b/crates/starknet_batcher/src/block_builder.rs @@ -3,10 +3,8 @@ use std::collections::BTreeMap; use async_trait::async_trait; use blockifier::blockifier::config::TransactionExecutorConfig; use blockifier::blockifier::transaction_executor::{ - TransactionExecutor, - TransactionExecutorError as BlockifierTransactionExecutorError, - TransactionExecutorResult, - VisitedSegmentsMapping, + TransactionExecutor, TransactionExecutorError as BlockifierTransactionExecutorError, + TransactionExecutorResult, VisitedSegmentsMapping, }; use blockifier::bouncer::{BouncerConfig, BouncerWeights}; use blockifier::context::{BlockContext, ChainInfo}; diff --git a/crates/starknet_batcher/src/block_builder_test.rs b/crates/starknet_batcher/src/block_builder_test.rs index c378f8715b..1bb5583928 100644 --- a/crates/starknet_batcher/src/block_builder_test.rs +++ b/crates/starknet_batcher/src/block_builder_test.rs @@ -16,13 +16,8 @@ use starknet_api::tx_hash; use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender}; use crate::block_builder::{ - BlockBuilder, - BlockBuilderError, - BlockBuilderExecutionParams, - BlockBuilderResult, - BlockBuilderTrait, - BlockExecutionArtifacts, - FailOnErrorCause, + BlockBuilder, BlockBuilderError, BlockBuilderExecutionParams, BlockBuilderResult, + BlockBuilderTrait, BlockExecutionArtifacts, FailOnErrorCause, }; use crate::test_utils::test_txs; use crate::transaction_executor::MockTransactionExecutorTrait; diff --git a/crates/starknet_batcher/src/fee_market.rs b/crates/starknet_batcher/src/fee_market.rs index 71cba26a49..3f55adb174 100644 --- a/crates/starknet_batcher/src/fee_market.rs +++ b/crates/starknet_batcher/src/fee_market.rs @@ -9,7 +9,7 @@ pub mod fee_market_test; // between consecutive blocks. const GAS_PRICE_MAX_CHANGE_DENOMINATOR: u128 = 48; const MIN_GAS_PRICE: u64 = 100000; // In fri. -// TODO(Mohammad): Check the exact value for maximum block size in StarkNet. + // TODO(Mohammad): Check the exact value for maximum block size in StarkNet. const MAX_BLOCK_SIZE: u64 = 4000000000; // In gas units. It's equivalent to 40M gas steps, with 100 gas units per step. /// Calculate the base gas price for the next block according to EIP-1559. diff --git a/crates/starknet_batcher/src/fee_market_test.rs b/crates/starknet_batcher/src/fee_market_test.rs index 88e4ecebe9..c478184000 100644 --- a/crates/starknet_batcher/src/fee_market_test.rs +++ b/crates/starknet_batcher/src/fee_market_test.rs @@ -1,8 +1,5 @@ use crate::fee_market::{ - calculate_next_base_gas_price, - GAS_PRICE_MAX_CHANGE_DENOMINATOR, - MAX_BLOCK_SIZE, - MIN_GAS_PRICE, + calculate_next_base_gas_price, GAS_PRICE_MAX_CHANGE_DENOMINATOR, MAX_BLOCK_SIZE, MIN_GAS_PRICE, }; #[test] @@ -58,5 +55,6 @@ fn test_gas_price_with_extreme_values() { max_u128 * GAS_PRICE_MAX_CHANGE_DENOMINATOR / (GAS_PRICE_MAX_CHANGE_DENOMINATOR + 1); let gas_target = MAX_BLOCK_SIZE / 2; let gas_used = MAX_BLOCK_SIZE; - calculate_next_base_gas_price(u64::try_from(price_u128).unwrap(), gas_used, gas_target); // Should not panic. + calculate_next_base_gas_price(u64::try_from(price_u128).unwrap(), gas_used, gas_target); + // Should not panic. } diff --git a/crates/starknet_batcher/src/proposal_manager_test.rs b/crates/starknet_batcher/src/proposal_manager_test.rs index 2f92a8492b..f91649e53c 100644 --- a/crates/starknet_batcher/src/proposal_manager_test.rs +++ b/crates/starknet_batcher/src/proposal_manager_test.rs @@ -5,11 +5,7 @@ use starknet_batcher_types::batcher_types::ProposalId; use crate::block_builder::{BlockBuilderTrait, BlockExecutionArtifacts, MockBlockBuilderTrait}; use crate::proposal_manager::{ - GenerateProposalError, - ProposalError, - ProposalManager, - ProposalManagerTrait, - ProposalOutput, + GenerateProposalError, ProposalError, ProposalManager, ProposalManagerTrait, ProposalOutput, }; const BLOCK_GENERATION_TIMEOUT: tokio::time::Duration = tokio::time::Duration::from_secs(1); diff --git a/crates/starknet_batcher/src/transaction_executor.rs b/crates/starknet_batcher/src/transaction_executor.rs index a781f81bd1..0861c7025d 100644 --- a/crates/starknet_batcher/src/transaction_executor.rs +++ b/crates/starknet_batcher/src/transaction_executor.rs @@ -1,7 +1,5 @@ use blockifier::blockifier::transaction_executor::{ - TransactionExecutor, - TransactionExecutorResult, - VisitedSegmentsMapping, + TransactionExecutor, TransactionExecutorResult, VisitedSegmentsMapping, }; use blockifier::bouncer::BouncerWeights; use blockifier::state::cached_state::CommitmentStateDiff; diff --git a/crates/starknet_batcher/src/transaction_provider_test.rs b/crates/starknet_batcher/src/transaction_provider_test.rs index fc7a5f341f..2c56376639 100644 --- a/crates/starknet_batcher/src/transaction_provider_test.rs +++ b/crates/starknet_batcher/src/transaction_provider_test.rs @@ -9,12 +9,8 @@ use starknet_api::tx_hash; use starknet_mempool_types::communication::MockMempoolClient; use crate::transaction_provider::{ - MockL1ProviderClient, - NextTxs, - ProposeTransactionProvider, - TransactionProvider, - TransactionProviderError, - ValidateTransactionProvider, + MockL1ProviderClient, NextTxs, ProposeTransactionProvider, TransactionProvider, + TransactionProviderError, ValidateTransactionProvider, }; const MAX_L1_HANDLER_TXS_PER_BLOCK: usize = 15; @@ -143,16 +139,12 @@ async fn no_more_l1_handler(mut mock_dependencies: MockDependencies) { let txs = tx_provider.get_txs(MAX_TXS_PER_FETCH).await.unwrap(); let data = assert_matches!(txs, NextTxs::Txs(txs) if txs.len() == MAX_TXS_PER_FETCH => txs); - assert!( - data[..NUM_L1_HANDLER_TXS_IN_PROVIDER] - .iter() - .all(|tx| matches!(tx, Transaction::L1Handler(_))) - ); - assert!( - data[NUM_L1_HANDLER_TXS_IN_PROVIDER..] - .iter() - .all(|tx| { matches!(tx, Transaction::Account(_)) }) - ); + assert!(data[..NUM_L1_HANDLER_TXS_IN_PROVIDER] + .iter() + .all(|tx| matches!(tx, Transaction::L1Handler(_)))); + assert!(data[NUM_L1_HANDLER_TXS_IN_PROVIDER..] + .iter() + .all(|tx| { matches!(tx, Transaction::Account(_)) })); let txs = tx_provider.get_txs(MAX_TXS_PER_FETCH).await.unwrap(); let data = assert_matches!(txs, NextTxs::Txs(txs) if txs.len() == MAX_TXS_PER_FETCH => txs); diff --git a/crates/starknet_batcher_types/src/communication.rs b/crates/starknet_batcher_types/src/communication.rs index 0dbca627b5..796fe3234a 100644 --- a/crates/starknet_batcher_types/src/communication.rs +++ b/crates/starknet_batcher_types/src/communication.rs @@ -6,28 +6,18 @@ use mockall::automock; use papyrus_proc_macros::handle_response_variants; use serde::{Deserialize, Serialize}; use starknet_sequencer_infra::component_client::{ - ClientError, - LocalComponentClient, - RemoteComponentClient, + ClientError, LocalComponentClient, RemoteComponentClient, }; use starknet_sequencer_infra::component_definitions::{ - ComponentClient, - ComponentRequestAndResponseSender, + ComponentClient, ComponentRequestAndResponseSender, }; use starknet_state_sync_types::state_sync_types::SyncBlock; use thiserror::Error; use crate::batcher_types::{ - BatcherResult, - DecisionReachedInput, - GetHeightResponse, - GetProposalContentInput, - GetProposalContentResponse, - ProposeBlockInput, - SendProposalContentInput, - SendProposalContentResponse, - StartHeightInput, - ValidateBlockInput, + BatcherResult, DecisionReachedInput, GetHeightResponse, GetProposalContentInput, + GetProposalContentResponse, ProposeBlockInput, SendProposalContentInput, + SendProposalContentResponse, StartHeightInput, ValidateBlockInput, }; use crate::errors::BatcherError; diff --git a/crates/starknet_client/src/reader/mod.rs b/crates/starknet_client/src/reader/mod.rs index 7dc4b31ff1..33eff936de 100644 --- a/crates/starknet_client/src/reader/mod.rs +++ b/crates/starknet_client/src/reader/mod.rs @@ -10,8 +10,7 @@ use std::collections::HashMap; use async_trait::async_trait; use cairo_lang_starknet_classes::casm_contract_class::{ - CasmContractClass, - CasmContractEntryPoints, + CasmContractClass, CasmContractEntryPoints, }; #[cfg(any(feature = "testing", test))] use mockall::automock; @@ -27,19 +26,11 @@ use tracing::{debug, error, instrument}; use url::Url; pub use crate::reader::objects::block::{ - Block, - BlockSignatureData, - BlockSignatureMessage, - TransactionReceiptsError, + Block, BlockSignatureData, BlockSignatureMessage, TransactionReceiptsError, }; pub use crate::reader::objects::pending_data::PendingData; pub use crate::reader::objects::state::{ - ContractClass, - DeclaredClassHashEntry, - DeployedContract, - ReplacedClass, - StateDiff, - StateUpdate, + ContractClass, DeclaredClassHashEntry, DeployedContract, ReplacedClass, StateDiff, StateUpdate, StorageEntry, }; #[cfg(doc)] diff --git a/crates/starknet_client/src/reader/objects/block.rs b/crates/starknet_client/src/reader/objects/block.rs index da6700e4e5..1c3b74246d 100644 --- a/crates/starknet_client/src/reader/objects/block.rs +++ b/crates/starknet_client/src/reader/objects/block.rs @@ -6,20 +6,11 @@ use std::ops::Index; use serde::{Deserialize, Serialize}; use starknet_api::block::{ - Block as starknet_api_block, - BlockHash, - BlockHeaderWithoutHash, - BlockNumber, - BlockTimestamp, - GasPricePerToken, - StarknetVersion, + Block as starknet_api_block, BlockHash, BlockHeaderWithoutHash, BlockNumber, BlockTimestamp, + GasPricePerToken, StarknetVersion, }; use starknet_api::core::{ - EventCommitment, - GlobalRoot, - ReceiptCommitment, - SequencerContractAddress, - StateDiffCommitment, + EventCommitment, GlobalRoot, ReceiptCommitment, SequencerContractAddress, StateDiffCommitment, TransactionCommitment, }; use starknet_api::data_availability::L1DataAvailabilityMode; @@ -29,10 +20,7 @@ use starknet_api::transaction::{TransactionHash, TransactionOffsetInBlock}; use starknet_types_core::felt::Felt; use crate::reader::objects::transaction::{ - L1ToL2Message, - Transaction, - TransactionReceipt, - TransactionType, + L1ToL2Message, Transaction, TransactionReceipt, TransactionType, }; use crate::reader::{ReaderClientError, ReaderClientResult}; diff --git a/crates/starknet_client/src/reader/objects/block_test.rs b/crates/starknet_client/src/reader/objects/block_test.rs index 8e0657252a..4015cc6d51 100644 --- a/crates/starknet_client/src/reader/objects/block_test.rs +++ b/crates/starknet_client/src/reader/objects/block_test.rs @@ -10,12 +10,7 @@ use starknet_api::{class_hash, contract_address, felt, storage_key, tx_hash}; use super::{Block, GlobalRoot, TransactionReceiptsError}; use crate::reader::objects::block::BlockPostV0_13_1; use crate::reader::objects::state::{ - DeclaredClassHashEntry, - DeployedContract, - ReplacedClass, - StateDiff, - StateUpdate, - StorageEntry, + DeclaredClassHashEntry, DeployedContract, ReplacedClass, StateDiff, StateUpdate, StorageEntry, }; use crate::reader::objects::transaction::TransactionReceipt; use crate::reader::ReaderClientError; diff --git a/crates/starknet_client/src/reader/objects/pending_data.rs b/crates/starknet_client/src/reader/objects/pending_data.rs index a24dba9e18..9975eb1b9e 100644 --- a/crates/starknet_client/src/reader/objects/pending_data.rs +++ b/crates/starknet_client/src/reader/objects/pending_data.rs @@ -1,11 +1,7 @@ use serde::{Deserialize, Serialize}; use starknet_api::block::{BlockHash, BlockNumber, BlockTimestamp, GasPrice, GasPricePerToken}; use starknet_api::core::{ - EventCommitment, - GlobalRoot, - ReceiptCommitment, - SequencerContractAddress, - StateDiffCommitment, + EventCommitment, GlobalRoot, ReceiptCommitment, SequencerContractAddress, StateDiffCommitment, TransactionCommitment, }; use starknet_api::data_availability::L1DataAvailabilityMode; diff --git a/crates/starknet_client/src/reader/objects/state.rs b/crates/starknet_client/src/reader/objects/state.rs index 8fc5329042..026d9c81ad 100644 --- a/crates/starknet_client/src/reader/objects/state.rs +++ b/crates/starknet_client/src/reader/objects/state.rs @@ -2,10 +2,7 @@ use std::collections::HashMap; use indexmap::IndexMap; pub use papyrus_common::state::{ - DeclaredClassHashEntry, - DeployedContract, - ReplacedClass, - StorageEntry, + DeclaredClassHashEntry, DeployedContract, ReplacedClass, StorageEntry, }; use serde::{Deserialize, Serialize}; use starknet_api::block::BlockHash; diff --git a/crates/starknet_client/src/reader/objects/test_utils.rs b/crates/starknet_client/src/reader/objects/test_utils.rs index ffb55966f8..d30cd9427c 100644 --- a/crates/starknet_client/src/reader/objects/test_utils.rs +++ b/crates/starknet_client/src/reader/objects/test_utils.rs @@ -3,52 +3,27 @@ use std::collections::HashMap; use papyrus_test_utils::{auto_impl_get_test_instance, get_number_of_variants, GetTestInstance}; use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ - ClassHash, - CompiledClassHash, - ContractAddress, - EntryPointSelector, - EthAddress, - Nonce, + ClassHash, CompiledClassHash, ContractAddress, EntryPointSelector, EthAddress, Nonce, }; use starknet_api::execution_resources::GasVector; use starknet_api::hash::StarkHash; use starknet_api::state::EntryPoint; use starknet_api::transaction::fields::{ - AccountDeploymentData, - Calldata, - ContractAddressSalt, - Fee, - PaymasterData, - Tip, - TransactionSignature, - ValidResourceBounds, + AccountDeploymentData, Calldata, ContractAddressSalt, Fee, PaymasterData, Tip, + TransactionSignature, ValidResourceBounds, }; use starknet_api::transaction::{ - Event, - L1ToL2Payload, - L2ToL1Payload, - TransactionHash, - TransactionOffsetInBlock, + Event, L1ToL2Payload, L2ToL1Payload, TransactionHash, TransactionOffsetInBlock, TransactionVersion, }; use starknet_types_core::felt::Felt; use crate::reader::objects::state::ContractClass; use crate::reader::objects::transaction::{ - Builtin, - DeployTransaction, - ExecutionResources, - IntermediateDeclareTransaction, - IntermediateDeployAccountTransaction, - IntermediateInvokeTransaction, - L1HandlerTransaction, - L1ToL2Message, - L1ToL2Nonce, - L2ToL1Message, - ReservedDataAvailabilityMode, - Transaction, - TransactionExecutionStatus, - TransactionReceipt, + Builtin, DeployTransaction, ExecutionResources, IntermediateDeclareTransaction, + IntermediateDeployAccountTransaction, IntermediateInvokeTransaction, L1HandlerTransaction, + L1ToL2Message, L1ToL2Nonce, L2ToL1Message, ReservedDataAvailabilityMode, Transaction, + TransactionExecutionStatus, TransactionReceipt, }; auto_impl_get_test_instance! { diff --git a/crates/starknet_client/src/reader/objects/transaction.rs b/crates/starknet_client/src/reader/objects/transaction.rs index e341c2ea20..622f2354ec 100644 --- a/crates/starknet_client/src/reader/objects/transaction.rs +++ b/crates/starknet_client/src/reader/objects/transaction.rs @@ -7,41 +7,20 @@ use std::collections::HashMap; use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; use starknet_api::core::{ - ClassHash, - CompiledClassHash, - ContractAddress, - EntryPointSelector, - EthAddress, - Nonce, + ClassHash, CompiledClassHash, ContractAddress, EntryPointSelector, EthAddress, Nonce, }; use starknet_api::execution_resources::{GasAmount, GasVector}; use starknet_api::hash::StarkHash; use starknet_api::transaction::fields::{ - AccountDeploymentData, - Calldata, - ContractAddressSalt, - Fee, - PaymasterData, - Tip, - TransactionSignature, - ValidResourceBounds, + AccountDeploymentData, Calldata, ContractAddressSalt, Fee, PaymasterData, Tip, + TransactionSignature, ValidResourceBounds, }; use starknet_api::transaction::{ - DeclareTransactionOutput, - DeployAccountTransactionOutput, - DeployTransactionOutput, - Event, - InvokeTransactionOutput, - L1HandlerTransactionOutput, - L1ToL2Payload, - L2ToL1Payload, - MessageToL1, + DeclareTransactionOutput, DeployAccountTransactionOutput, DeployTransactionOutput, Event, + InvokeTransactionOutput, L1HandlerTransactionOutput, L1ToL2Payload, L2ToL1Payload, MessageToL1, RevertedTransactionExecutionStatus as SnApiRevertedTransactionExecutionStatus, - TransactionExecutionStatus as SnApiTransactionExecutionStatus, - TransactionHash, - TransactionOffsetInBlock, - TransactionOutput, - TransactionVersion, + TransactionExecutionStatus as SnApiTransactionExecutionStatus, TransactionHash, + TransactionOffsetInBlock, TransactionOutput, TransactionVersion, }; 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 4861dc0053..09d5916702 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 @@ -12,13 +12,8 @@ use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ContractAddress, EntryPointSelector, GlobalRoot, SequencerPublicKey}; use starknet_api::crypto::utils::PublicKey; use starknet_api::deprecated_contract_class::{ - ConstructorType, - ContractClass as DeprecatedContractClass, - ContractClassAbiEntry, - EntryPointOffset, - EntryPointV0 as DeprecatedEntryPoint, - FunctionAbiEntry, - Program, + ConstructorType, ContractClass as DeprecatedContractClass, ContractClassAbiEntry, + EntryPointOffset, EntryPointV0 as DeprecatedEntryPoint, FunctionAbiEntry, Program, TypedParameter, }; use starknet_api::state::{EntryPoint, FunctionIndex}; @@ -29,17 +24,9 @@ use starknet_api::{class_hash, contract_address, felt, nonce}; use super::objects::state::StateUpdate; use super::objects::transaction::IntermediateDeclareTransaction; use super::{ - ContractClass, - GenericContractClass, - PendingData, - ReaderClientError, - ReaderClientResult, - StarknetFeederGatewayClient, - StarknetReader, - BLOCK_NUMBER_QUERY, - CLASS_HASH_QUERY, - GET_BLOCK_URL, - GET_STATE_UPDATE_URL, + ContractClass, GenericContractClass, PendingData, ReaderClientError, ReaderClientResult, + StarknetFeederGatewayClient, StarknetReader, BLOCK_NUMBER_QUERY, CLASS_HASH_QUERY, + GET_BLOCK_URL, GET_STATE_UPDATE_URL, }; use crate::reader::objects::block::{BlockSignatureData, BlockSignatureMessage}; use crate::reader::Block; diff --git a/crates/starknet_client/src/retry_test.rs b/crates/starknet_client/src/retry_test.rs index 7686bd32f6..6da469004d 100644 --- a/crates/starknet_client/src/retry_test.rs +++ b/crates/starknet_client/src/retry_test.rs @@ -28,7 +28,11 @@ impl Worker { let mut number_of_calls = self.number_of_calls.lock().unwrap(); *number_of_calls += 1; - if *number_of_calls <= *self.number_of_errors { Err("Some error.") } else { Ok(()) } + if *number_of_calls <= *self.number_of_errors { + Err("Some error.") + } else { + Ok(()) + } } } diff --git a/crates/starknet_client/src/writer/mod.rs b/crates/starknet_client/src/writer/mod.rs index 344f5b089b..789548f107 100644 --- a/crates/starknet_client/src/writer/mod.rs +++ b/crates/starknet_client/src/writer/mod.rs @@ -16,9 +16,7 @@ use url::Url; use crate::writer::objects::response::{DeclareResponse, DeployAccountResponse, InvokeResponse}; use crate::writer::objects::transaction::{ - DeclareTransaction, - DeployAccountTransaction, - InvokeTransaction, + DeclareTransaction, DeployAccountTransaction, InvokeTransaction, }; use crate::{ClientCreationError, ClientError, RetryConfig, StarknetClient}; diff --git a/crates/starknet_client/src/writer/objects/test_utils.rs b/crates/starknet_client/src/writer/objects/test_utils.rs index c929fc589b..a75a012e37 100644 --- a/crates/starknet_client/src/writer/objects/test_utils.rs +++ b/crates/starknet_client/src/writer/objects/test_utils.rs @@ -4,16 +4,12 @@ use papyrus_test_utils::{auto_impl_get_test_instance, get_number_of_variants, Ge use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ClassHash, ContractAddress}; use starknet_api::deprecated_contract_class::{ - ContractClassAbiEntry as DeprecatedContractClassAbiEntry, - EntryPointV0 as DeprecatedEntryPoint, + ContractClassAbiEntry as DeprecatedContractClassAbiEntry, EntryPointV0 as DeprecatedEntryPoint, }; use starknet_api::transaction::TransactionHash; use crate::writer::objects::response::{ - DeclareResponse, - DeployAccountResponse, - InvokeResponse, - SuccessfulStarknetErrorCode, + DeclareResponse, DeployAccountResponse, InvokeResponse, SuccessfulStarknetErrorCode, }; use crate::writer::objects::transaction::DeprecatedContractClass; diff --git a/crates/starknet_client/src/writer/objects/transaction.rs b/crates/starknet_client/src/writer/objects/transaction.rs index 3e346d7a9f..689ce41fd6 100644 --- a/crates/starknet_client/src/writer/objects/transaction.rs +++ b/crates/starknet_client/src/writer/objects/transaction.rs @@ -16,26 +16,15 @@ use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; use starknet_api::contract_class::EntryPointType; use starknet_api::core::{ - ClassHash, - CompiledClassHash, - ContractAddress, - EntryPointSelector, - Nonce, + ClassHash, CompiledClassHash, ContractAddress, EntryPointSelector, Nonce, }; use starknet_api::deprecated_contract_class::{ - ContractClassAbiEntry as DeprecatedContractClassAbiEntry, - EntryPointV0 as DeprecatedEntryPoint, + ContractClassAbiEntry as DeprecatedContractClassAbiEntry, EntryPointV0 as DeprecatedEntryPoint, }; use starknet_api::state::EntryPoint; use starknet_api::transaction::fields::{ - AccountDeploymentData, - Calldata, - ContractAddressSalt, - DeprecatedResourceBoundsMapping, - Fee, - PaymasterData, - Tip, - TransactionSignature, + AccountDeploymentData, Calldata, ContractAddressSalt, DeprecatedResourceBoundsMapping, Fee, + PaymasterData, Tip, TransactionSignature, }; use starknet_api::transaction::TransactionVersion; diff --git a/crates/starknet_client/src/writer/objects/transaction_test.rs b/crates/starknet_client/src/writer/objects/transaction_test.rs index 61054f3cd7..038194f16a 100644 --- a/crates/starknet_client/src/writer/objects/transaction_test.rs +++ b/crates/starknet_client/src/writer/objects/transaction_test.rs @@ -1,13 +1,8 @@ use papyrus_test_utils::validate_load_and_dump; use super::{ - DeclareV1Transaction, - DeclareV2Transaction, - DeclareV3Transaction, - DeployAccountV1Transaction, - DeployAccountV3Transaction, - InvokeV1Transaction, - InvokeV3Transaction, + DeclareV1Transaction, DeclareV2Transaction, DeclareV3Transaction, DeployAccountV1Transaction, + DeployAccountV3Transaction, InvokeV1Transaction, InvokeV3Transaction, }; #[test] diff --git a/crates/starknet_committer/src/forest/filled_forest.rs b/crates/starknet_committer/src/forest/filled_forest.rs index e1d0037112..404209f8e4 100644 --- a/crates/starknet_committer/src/forest/filled_forest.rs +++ b/crates/starknet_committer/src/forest/filled_forest.rs @@ -14,12 +14,7 @@ use crate::forest::updated_skeleton_forest::UpdatedSkeletonForest; use crate::hash_function::hash::ForestHashFunction; use crate::patricia_merkle_tree::leaf::leaf_impl::{ContractState, ContractStateInput}; use crate::patricia_merkle_tree::types::{ - ClassHash, - ClassesTrie, - CompiledClassHash, - ContractsTrie, - Nonce, - StorageTrieMap, + ClassHash, ClassesTrie, CompiledClassHash, ContractsTrie, Nonce, StorageTrieMap, }; pub struct FilledForest { diff --git a/crates/starknet_committer/src/forest/original_skeleton_forest.rs b/crates/starknet_committer/src/forest/original_skeleton_forest.rs index 1ecca036d2..84603550a6 100644 --- a/crates/starknet_committer/src/forest/original_skeleton_forest.rs +++ b/crates/starknet_committer/src/forest/original_skeleton_forest.rs @@ -3,8 +3,7 @@ use std::collections::HashMap; use starknet_patricia::hash::hash_trait::HashOutput; use starknet_patricia::patricia_merkle_tree::node_data::leaf::LeafModifications; use starknet_patricia::patricia_merkle_tree::original_skeleton_tree::tree::{ - OriginalSkeletonTree, - OriginalSkeletonTreeImpl, + OriginalSkeletonTree, OriginalSkeletonTreeImpl, }; use starknet_patricia::patricia_merkle_tree::types::{NodeIndex, SortedLeafIndices}; use starknet_patricia::storage::storage_trait::Storage; @@ -13,8 +12,7 @@ use crate::block_committer::input::{Config, ContractAddress, StarknetStorageValu use crate::forest::forest_errors::{ForestError, ForestResult}; use crate::patricia_merkle_tree::leaf::leaf_impl::ContractState; use crate::patricia_merkle_tree::tree::{ - OriginalSkeletonClassesTrieConfig, - OriginalSkeletonContractsTrieConfig, + OriginalSkeletonClassesTrieConfig, OriginalSkeletonContractsTrieConfig, OriginalSkeletonStorageTrieConfig, }; use crate::patricia_merkle_tree::types::CompiledClassHash; diff --git a/crates/starknet_committer/src/forest/skeleton_forest_test.rs b/crates/starknet_committer/src/forest/skeleton_forest_test.rs index e6707f41bd..111dfbbd52 100644 --- a/crates/starknet_committer/src/forest/skeleton_forest_test.rs +++ b/crates/starknet_committer/src/forest/skeleton_forest_test.rs @@ -5,13 +5,8 @@ use rstest::rstest; use starknet_patricia::felt::Felt; use starknet_patricia::hash::hash_trait::HashOutput; use starknet_patricia::patricia_merkle_tree::external_test_utils::{ - create_32_bytes_entry, - create_binary_entry, - create_binary_skeleton_node, - create_edge_entry, - create_edge_skeleton_node, - create_expected_skeleton_nodes, - create_root_edge_entry, + create_32_bytes_entry, create_binary_entry, create_binary_skeleton_node, create_edge_entry, + create_edge_skeleton_node, create_expected_skeleton_nodes, create_root_edge_entry, create_unmodified_subtree_skeleton_node, }; use starknet_patricia::patricia_merkle_tree::original_skeleton_tree::tree::OriginalSkeletonTreeImpl; @@ -23,12 +18,7 @@ use tracing::level_filters::LevelFilter; use crate::block_committer::commit::get_all_modified_indices; use crate::block_committer::input::{ - ConfigImpl, - ContractAddress, - Input, - StarknetStorageKey, - StarknetStorageValue, - StateDiff, + ConfigImpl, ContractAddress, Input, StarknetStorageKey, StarknetStorageValue, StateDiff, }; use crate::forest::original_skeleton_forest::{ForestSortedIndices, OriginalSkeletonForest}; use crate::patricia_merkle_tree::leaf::leaf_impl::ContractState; diff --git a/crates/starknet_committer/src/forest/updated_skeleton_forest.rs b/crates/starknet_committer/src/forest/updated_skeleton_forest.rs index 44bff0a86d..9a871385d6 100644 --- a/crates/starknet_committer/src/forest/updated_skeleton_forest.rs +++ b/crates/starknet_committer/src/forest/updated_skeleton_forest.rs @@ -4,8 +4,7 @@ use starknet_patricia::felt::Felt; use starknet_patricia::patricia_merkle_tree::node_data::leaf::{LeafModifications, SkeletonLeaf}; use starknet_patricia::patricia_merkle_tree::types::NodeIndex; use starknet_patricia::patricia_merkle_tree::updated_skeleton_tree::tree::{ - UpdatedSkeletonTree, - UpdatedSkeletonTreeImpl, + UpdatedSkeletonTree, UpdatedSkeletonTreeImpl, }; use crate::block_committer::input::ContractAddress; diff --git a/crates/starknet_committer/src/hash_function/hash.rs b/crates/starknet_committer/src/hash_function/hash.rs index 19223f7ce1..018b4610a7 100644 --- a/crates/starknet_committer/src/hash_function/hash.rs +++ b/crates/starknet_committer/src/hash_function/hash.rs @@ -2,8 +2,7 @@ use starknet_patricia::felt::Felt; use starknet_patricia::hash::hash_trait::HashOutput; use starknet_patricia::patricia_merkle_tree::node_data::inner_node::NodeData; use starknet_patricia::patricia_merkle_tree::updated_skeleton_tree::hash_function::{ - HashFunction, - TreeHashFunction, + HashFunction, TreeHashFunction, }; use starknet_types_core::hash::{Pedersen, Poseidon, StarkHash}; diff --git a/crates/starknet_committer/src/hash_function/hash_test.rs b/crates/starknet_committer/src/hash_function/hash_test.rs index 8e3c7c5b0a..a9eaea9834 100644 --- a/crates/starknet_committer/src/hash_function/hash_test.rs +++ b/crates/starknet_committer/src/hash_function/hash_test.rs @@ -3,11 +3,7 @@ use rstest::rstest; use starknet_patricia::felt::Felt; use starknet_patricia::hash::hash_trait::HashOutput; use starknet_patricia::patricia_merkle_tree::node_data::inner_node::{ - BinaryData, - EdgeData, - EdgePathLength, - NodeData, - PathToBottom, + BinaryData, EdgeData, EdgePathLength, NodeData, PathToBottom, }; use starknet_patricia::patricia_merkle_tree::updated_skeleton_tree::hash_function::TreeHashFunction; use starknet_types_core::hash::Pedersen; diff --git a/crates/starknet_gateway/src/compilation_test.rs b/crates/starknet_gateway/src/compilation_test.rs index 0958884ee6..41bff119e2 100644 --- a/crates/starknet_gateway/src/compilation_test.rs +++ b/crates/starknet_gateway/src/compilation_test.rs @@ -1,13 +1,10 @@ use assert_matches::assert_matches; use mempool_test_utils::starknet_api_test_utils::{ - declare_tx as rpc_declare_tx, - COMPILED_CLASS_HASH, + declare_tx as rpc_declare_tx, COMPILED_CLASS_HASH, }; use rstest::{fixture, rstest}; use starknet_api::rpc_transaction::{ - RpcDeclareTransaction, - RpcDeclareTransactionV3, - RpcTransaction, + RpcDeclareTransaction, RpcDeclareTransactionV3, RpcTransaction, }; use starknet_gateway_types::errors::GatewaySpecError; use starknet_sierra_compile::config::SierraToCasmCompilationConfig; diff --git a/crates/starknet_gateway/src/gateway_test.rs b/crates/starknet_gateway/src/gateway_test.rs index e8502f43ae..7460738e0d 100644 --- a/crates/starknet_gateway/src/gateway_test.rs +++ b/crates/starknet_gateway/src/gateway_test.rs @@ -18,9 +18,7 @@ use starknet_sierra_compile::config::SierraToCasmCompilationConfig; use crate::compilation::GatewayCompiler; use crate::config::{ - GatewayConfig, - StatefulTransactionValidatorConfig, - StatelessTransactionValidatorConfig, + GatewayConfig, StatefulTransactionValidatorConfig, StatelessTransactionValidatorConfig, }; use crate::gateway::Gateway; use crate::state_reader_test_utils::{local_test_state_reader_factory, TestStateReaderFactory}; diff --git a/crates/starknet_gateway/src/rpc_objects.rs b/crates/starknet_gateway/src/rpc_objects.rs index 78ec71f82a..c220af72d3 100644 --- a/crates/starknet_gateway/src/rpc_objects.rs +++ b/crates/starknet_gateway/src/rpc_objects.rs @@ -2,12 +2,7 @@ use blockifier::blockifier::block::validated_gas_prices; use serde::{Deserialize, Serialize}; use serde_json::Value; use starknet_api::block::{ - BlockHash, - BlockInfo, - BlockNumber, - BlockTimestamp, - GasPrice, - NonzeroGasPrice, + BlockHash, BlockInfo, BlockNumber, BlockTimestamp, GasPrice, NonzeroGasPrice, }; use starknet_api::core::{ClassHash, ContractAddress, GlobalRoot}; use starknet_api::data_availability::L1DataAvailabilityMode; diff --git a/crates/starknet_gateway/src/rpc_state_reader.rs b/crates/starknet_gateway/src/rpc_state_reader.rs index a01ccdc703..7a2c7292e6 100644 --- a/crates/starknet_gateway/src/rpc_state_reader.rs +++ b/crates/starknet_gateway/src/rpc_state_reader.rs @@ -1,7 +1,5 @@ use blockifier::execution::contract_class::{ - CompiledClassV0, - CompiledClassV1, - RunnableCompiledClass, + CompiledClassV0, CompiledClassV1, RunnableCompiledClass, }; use blockifier::state::errors::StateError; use blockifier::state::state_api::{StateReader as BlockifierStateReader, StateResult}; @@ -17,18 +15,9 @@ use starknet_types_core::felt::Felt; use crate::config::RpcStateReaderConfig; use crate::errors::{serde_err_to_state_err, RPCStateReaderError, RPCStateReaderResult}; use crate::rpc_objects::{ - BlockHeader, - BlockId, - GetBlockWithTxHashesParams, - GetClassHashAtParams, - GetCompiledClassParams, - GetNonceParams, - GetStorageAtParams, - RpcResponse, - RPC_CLASS_HASH_NOT_FOUND, - RPC_ERROR_BLOCK_NOT_FOUND, - RPC_ERROR_CONTRACT_ADDRESS_NOT_FOUND, - RPC_ERROR_INVALID_PARAMS, + BlockHeader, BlockId, GetBlockWithTxHashesParams, GetClassHashAtParams, GetCompiledClassParams, + GetNonceParams, GetStorageAtParams, RpcResponse, RPC_CLASS_HASH_NOT_FOUND, + RPC_ERROR_BLOCK_NOT_FOUND, RPC_ERROR_CONTRACT_ADDRESS_NOT_FOUND, RPC_ERROR_INVALID_PARAMS, }; use crate::state_reader::{MempoolStateReader, StateReaderFactory}; diff --git a/crates/starknet_gateway/src/rpc_state_reader_test.rs b/crates/starknet_gateway/src/rpc_state_reader_test.rs index 623c049427..2ee6bcbe94 100644 --- a/crates/starknet_gateway/src/rpc_state_reader_test.rs +++ b/crates/starknet_gateway/src/rpc_state_reader_test.rs @@ -10,16 +10,8 @@ use starknet_api::{class_hash, contract_address, felt, nonce}; use crate::config::RpcStateReaderConfig; use crate::rpc_objects::{ - BlockHeader, - BlockId, - GetBlockWithTxHashesParams, - GetClassHashAtParams, - GetCompiledClassParams, - GetNonceParams, - GetStorageAtParams, - ResourcePrice, - RpcResponse, - RpcSuccessResponse, + BlockHeader, BlockId, GetBlockWithTxHashesParams, GetClassHashAtParams, GetCompiledClassParams, + GetNonceParams, GetStorageAtParams, ResourcePrice, RpcResponse, RpcSuccessResponse, }; use crate::rpc_state_reader::RpcStateReader; use crate::state_reader::MempoolStateReader; diff --git a/crates/starknet_gateway/src/stateful_transaction_validator.rs b/crates/starknet_gateway/src/stateful_transaction_validator.rs index fd04f6d66f..e8bb1e7350 100644 --- a/crates/starknet_gateway/src/stateful_transaction_validator.rs +++ b/crates/starknet_gateway/src/stateful_transaction_validator.rs @@ -1,6 +1,5 @@ use blockifier::blockifier::stateful_validator::{ - StatefulValidator, - StatefulValidatorResult as BlockifierStatefulValidatorResult, + StatefulValidator, StatefulValidatorResult as BlockifierStatefulValidatorResult, }; use blockifier::bouncer::BouncerConfig; use blockifier::context::{BlockContext, ChainInfo}; @@ -13,8 +12,7 @@ use mockall::automock; use starknet_api::block::BlockInfo; use starknet_api::core::{ContractAddress, Nonce}; use starknet_api::executable_transaction::{ - AccountTransaction as ExecutableTransaction, - InvokeTransaction as ExecutableInvokeTransaction, + AccountTransaction as ExecutableTransaction, InvokeTransaction as ExecutableInvokeTransaction, }; use starknet_gateway_types::errors::GatewaySpecError; use starknet_types_core::felt::Felt; diff --git a/crates/starknet_gateway/src/stateful_transaction_validator_test.rs b/crates/starknet_gateway/src/stateful_transaction_validator_test.rs index de734b71cd..71594af5e7 100644 --- a/crates/starknet_gateway/src/stateful_transaction_validator_test.rs +++ b/crates/starknet_gateway/src/stateful_transaction_validator_test.rs @@ -6,8 +6,7 @@ use blockifier::context::ChainInfo; use blockifier::test_utils::{CairoVersion, RunnableCairo1}; use blockifier::transaction::errors::{TransactionFeeError, TransactionPreValidationError}; use mempool_test_utils::starknet_api_test_utils::{ - executable_invoke_tx as create_executable_invoke_tx, - VALID_L1_GAS_MAX_AMOUNT, + executable_invoke_tx as create_executable_invoke_tx, VALID_L1_GAS_MAX_AMOUNT, VALID_L1_GAS_MAX_PRICE_PER_UNIT, }; use mockall::predicate::eq; @@ -30,8 +29,7 @@ use crate::config::StatefulTransactionValidatorConfig; use crate::state_reader::{MockStateReaderFactory, StateReaderFactory}; use crate::state_reader_test_utils::local_test_state_reader_factory; use crate::stateful_transaction_validator::{ - MockStatefulTransactionValidatorTrait, - StatefulTransactionValidator, + MockStatefulTransactionValidatorTrait, StatefulTransactionValidator, }; pub const STATEFUL_VALIDATOR_FEE_ERROR: BlockifierStatefulValidatorError = diff --git a/crates/starknet_gateway/src/stateless_transaction_validator.rs b/crates/starknet_gateway/src/stateless_transaction_validator.rs index 871e2a3d3c..019cb70713 100644 --- a/crates/starknet_gateway/src/stateless_transaction_validator.rs +++ b/crates/starknet_gateway/src/stateless_transaction_validator.rs @@ -2,10 +2,7 @@ use starknet_api::block::GasPrice; use starknet_api::data_availability::DataAvailabilityMode; use starknet_api::execution_resources::GasAmount; use starknet_api::rpc_transaction::{ - RpcDeclareTransaction, - RpcDeployAccountTransaction, - RpcInvokeTransaction, - RpcTransaction, + RpcDeclareTransaction, RpcDeployAccountTransaction, RpcInvokeTransaction, RpcTransaction, }; use starknet_api::state::EntryPoint; use starknet_api::transaction::fields::{AllResourceBounds, Resource}; diff --git a/crates/starknet_gateway/src/stateless_transaction_validator_test.rs b/crates/starknet_gateway/src/stateless_transaction_validator_test.rs index 57319f1d3a..a927c17ee5 100644 --- a/crates/starknet_gateway/src/stateless_transaction_validator_test.rs +++ b/crates/starknet_gateway/src/stateless_transaction_validator_test.rs @@ -9,11 +9,7 @@ use starknet_api::rpc_transaction::EntryPointByType; use starknet_api::state::{EntryPoint, SierraContractClass}; use starknet_api::test_utils::declare::rpc_declare_tx; use starknet_api::transaction::fields::{ - AccountDeploymentData, - AllResourceBounds, - PaymasterData, - Resource, - ResourceBounds, + AccountDeploymentData, AllResourceBounds, PaymasterData, Resource, ResourceBounds, TransactionSignature, }; use starknet_api::{calldata, contract_address, declare_tx_args, felt, StarknetApiError}; @@ -23,14 +19,10 @@ use crate::compiler_version::{VersionId, VersionIdError}; use crate::config::StatelessTransactionValidatorConfig; use crate::errors::StatelessTransactionValidatorResult; use crate::stateless_transaction_validator::{ - StatelessTransactionValidator, - StatelessTransactionValidatorError, + StatelessTransactionValidator, StatelessTransactionValidatorError, }; use crate::test_utils::{ - create_sierra_program, - rpc_tx_for_testing, - RpcTransactionArgs, - TransactionType, + create_sierra_program, rpc_tx_for_testing, RpcTransactionArgs, TransactionType, NON_EMPTY_RESOURCE_BOUNDS, }; diff --git a/crates/starknet_gateway/src/test_utils.rs b/crates/starknet_gateway/src/test_utils.rs index f92bb5bce8..f15a242067 100644 --- a/crates/starknet_gateway/src/test_utils.rs +++ b/crates/starknet_gateway/src/test_utils.rs @@ -8,13 +8,8 @@ use starknet_api::test_utils::declare::{rpc_declare_tx, TEST_SENDER_ADDRESS}; use starknet_api::test_utils::deploy_account::rpc_deploy_account_tx; use starknet_api::test_utils::invoke::rpc_invoke_tx; use starknet_api::transaction::fields::{ - AccountDeploymentData, - AllResourceBounds, - Calldata, - PaymasterData, - ResourceBounds, - TransactionSignature, - ValidResourceBounds, + AccountDeploymentData, AllResourceBounds, Calldata, PaymasterData, ResourceBounds, + TransactionSignature, ValidResourceBounds, }; use starknet_api::{declare_tx_args, deploy_account_tx_args, felt, invoke_tx_args}; use starknet_types_core::felt::Felt; diff --git a/crates/starknet_gateway_types/src/communication.rs b/crates/starknet_gateway_types/src/communication.rs index 75a6b56a87..28ffd7d091 100644 --- a/crates/starknet_gateway_types/src/communication.rs +++ b/crates/starknet_gateway_types/src/communication.rs @@ -7,13 +7,10 @@ use papyrus_proc_macros::handle_response_variants; use serde::{Deserialize, Serialize}; use starknet_api::transaction::TransactionHash; use starknet_sequencer_infra::component_client::{ - ClientError, - LocalComponentClient, - RemoteComponentClient, + ClientError, LocalComponentClient, RemoteComponentClient, }; use starknet_sequencer_infra::component_definitions::{ - ComponentClient, - ComponentRequestAndResponseSender, + ComponentClient, ComponentRequestAndResponseSender, }; use thiserror::Error; diff --git a/crates/starknet_gateway_types/src/errors.rs b/crates/starknet_gateway_types/src/errors.rs index bca04f72cf..cc75a76a27 100644 --- a/crates/starknet_gateway_types/src/errors.rs +++ b/crates/starknet_gateway_types/src/errors.rs @@ -3,21 +3,11 @@ use axum::response::{IntoResponse, Response}; use enum_assoc::Assoc; use papyrus_network_types::network_types::BroadcastedMessageMetadata; use papyrus_rpc::error::{ - unexpected_error, - validation_failure, - JsonRpcError, - CLASS_ALREADY_DECLARED, - CLASS_HASH_NOT_FOUND, - COMPILATION_FAILED, - COMPILED_CLASS_HASH_MISMATCH, - CONTRACT_CLASS_SIZE_IS_TOO_LARGE, - DUPLICATE_TX, - INSUFFICIENT_ACCOUNT_BALANCE, - INSUFFICIENT_MAX_FEE, - INVALID_TRANSACTION_NONCE, - NON_ACCOUNT, - UNSUPPORTED_CONTRACT_CLASS_VERSION, - UNSUPPORTED_TX_VERSION, + unexpected_error, validation_failure, JsonRpcError, CLASS_ALREADY_DECLARED, + CLASS_HASH_NOT_FOUND, COMPILATION_FAILED, COMPILED_CLASS_HASH_MISMATCH, + CONTRACT_CLASS_SIZE_IS_TOO_LARGE, DUPLICATE_TX, INSUFFICIENT_ACCOUNT_BALANCE, + INSUFFICIENT_MAX_FEE, INVALID_TRANSACTION_NONCE, NON_ACCOUNT, + UNSUPPORTED_CONTRACT_CLASS_VERSION, UNSUPPORTED_TX_VERSION, }; use serde::{Deserialize, Serialize}; use thiserror::Error; diff --git a/crates/starknet_integration_tests/src/config_utils.rs b/crates/starknet_integration_tests/src/config_utils.rs index c684cc4f59..d9882eba8f 100644 --- a/crates/starknet_integration_tests/src/config_utils.rs +++ b/crates/starknet_integration_tests/src/config_utils.rs @@ -5,15 +5,12 @@ use std::path::PathBuf; use serde_json::{json, Value}; use starknet_sequencer_infra::component_definitions::{ - LocalServerConfig, - RemoteClientConfig, - RemoteServerConfig, + LocalServerConfig, RemoteClientConfig, RemoteServerConfig, }; use starknet_sequencer_infra::test_utils::get_available_socket; use starknet_sequencer_node::config::component_config::ComponentConfig; use starknet_sequencer_node::config::component_execution_config::{ - ActiveComponentExecutionConfig, - ReactiveComponentExecutionConfig, + ActiveComponentExecutionConfig, ReactiveComponentExecutionConfig, ReactiveComponentExecutionMode, }; use starknet_sequencer_node::config::node_config::SequencerNodeConfig; diff --git a/crates/starknet_integration_tests/src/flow_test_setup.rs b/crates/starknet_integration_tests/src/flow_test_setup.rs index f1d6ac6d0f..3515aacb05 100644 --- a/crates/starknet_integration_tests/src/flow_test_setup.rs +++ b/crates/starknet_integration_tests/src/flow_test_setup.rs @@ -21,9 +21,7 @@ use tracing::{debug, instrument}; use crate::state_reader::{spawn_test_rpc_state_reader, StorageTestSetup}; use crate::utils::{ - create_chain_info, - create_config, - create_consensus_manager_configs_and_channels, + create_chain_info, create_config, create_consensus_manager_configs_and_channels, }; const SEQUENCER_0: usize = 0; diff --git a/crates/starknet_integration_tests/src/integration_test_setup.rs b/crates/starknet_integration_tests/src/integration_test_setup.rs index c83fb2f6a9..5483a0f3f5 100644 --- a/crates/starknet_integration_tests/src/integration_test_setup.rs +++ b/crates/starknet_integration_tests/src/integration_test_setup.rs @@ -12,9 +12,7 @@ use tempfile::{tempdir, TempDir}; use crate::config_utils::dump_config_file_changes; use crate::state_reader::{spawn_test_rpc_state_reader, StorageTestSetup}; use crate::utils::{ - create_chain_info, - create_config, - create_consensus_manager_configs_and_channels, + create_chain_info, create_config, create_consensus_manager_configs_and_channels, }; const SEQUENCER_INDEX: usize = 0; diff --git a/crates/starknet_integration_tests/src/state_reader.rs b/crates/starknet_integration_tests/src/state_reader.rs index a04340f2a4..17dda98019 100644 --- a/crates/starknet_integration_tests/src/state_reader.rs +++ b/crates/starknet_integration_tests/src/state_reader.rs @@ -5,13 +5,8 @@ use assert_matches::assert_matches; use blockifier::context::ChainInfo; use blockifier::test_utils::contracts::FeatureContract; use blockifier::test_utils::{ - CairoVersion, - RunnableCairo1, - BALANCE, - CURRENT_BLOCK_TIMESTAMP, - DEFAULT_ETH_L1_GAS_PRICE, - DEFAULT_STRK_L1_GAS_PRICE, - TEST_SEQUENCER_ADDRESS, + CairoVersion, RunnableCairo1, BALANCE, CURRENT_BLOCK_TIMESTAMP, DEFAULT_ETH_L1_GAS_PRICE, + DEFAULT_STRK_L1_GAS_PRICE, TEST_SEQUENCER_ADDRESS, }; use blockifier::versioned_constants::VersionedConstants; use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass; @@ -28,12 +23,7 @@ use papyrus_storage::test_utils::TestStorageBuilder; use papyrus_storage::{StorageConfig, StorageReader, StorageScope, StorageWriter}; use starknet_api::abi::abi_utils::get_fee_token_var_address; use starknet_api::block::{ - BlockBody, - BlockHeader, - BlockHeaderWithoutHash, - BlockNumber, - BlockTimestamp, - FeeType, + BlockBody, BlockHeader, BlockHeaderWithoutHash, BlockNumber, BlockTimestamp, FeeType, GasPricePerToken, }; use starknet_api::core::{ChainId, ClassHash, ContractAddress, Nonce, SequencerContractAddress}; diff --git a/crates/starknet_integration_tests/src/utils.rs b/crates/starknet_integration_tests/src/utils.rs index 18f04d18ba..b99dacd489 100644 --- a/crates/starknet_integration_tests/src/utils.rs +++ b/crates/starknet_integration_tests/src/utils.rs @@ -20,9 +20,7 @@ use starknet_batcher::block_builder::BlockBuilderConfig; use starknet_batcher::config::BatcherConfig; use starknet_consensus_manager::config::ConsensusManagerConfig; use starknet_gateway::config::{ - GatewayConfig, - RpcStateReaderConfig, - StatefulTransactionValidatorConfig, + GatewayConfig, RpcStateReaderConfig, StatefulTransactionValidatorConfig, StatelessTransactionValidatorConfig, }; use starknet_http_server::config::HttpServerConfig; diff --git a/crates/starknet_integration_tests/tests/end_to_end_flow_test.rs b/crates/starknet_integration_tests/tests/end_to_end_flow_test.rs index 4e50a8d259..9d55bd0dec 100644 --- a/crates/starknet_integration_tests/tests/end_to_end_flow_test.rs +++ b/crates/starknet_integration_tests/tests/end_to_end_flow_test.rs @@ -5,11 +5,7 @@ use mempool_test_utils::starknet_api_test_utils::MultiAccountTransactionGenerato use papyrus_consensus::types::ValidatorId; use papyrus_network::network_manager::BroadcastTopicChannels; use papyrus_protobuf::consensus::{ - ProposalFin, - ProposalInit, - ProposalPart, - StreamMessage, - StreamMessageBody, + ProposalFin, ProposalInit, ProposalPart, StreamMessage, StreamMessageBody, }; use papyrus_storage::test_utils::CHAIN_ID_FOR_TESTS; use pretty_assertions::assert_eq; @@ -18,8 +14,7 @@ use starknet_api::block::{BlockHash, BlockNumber}; use starknet_api::transaction::TransactionHash; use starknet_integration_tests::flow_test_setup::FlowTestSetup; use starknet_integration_tests::utils::{ - create_integration_test_tx_generator, - run_integration_test_scenario, + create_integration_test_tx_generator, run_integration_test_scenario, }; use starknet_sequencer_infra::trace_util::configure_tracing; use starknet_types_core::felt::Felt; diff --git a/crates/starknet_integration_tests/tests/end_to_end_integration_test.rs b/crates/starknet_integration_tests/tests/end_to_end_integration_test.rs index fdb2d8f082..b3cb29b844 100644 --- a/crates/starknet_integration_tests/tests/end_to_end_integration_test.rs +++ b/crates/starknet_integration_tests/tests/end_to_end_integration_test.rs @@ -9,9 +9,7 @@ use starknet_api::core::{ContractAddress, Nonce}; use starknet_api::state::StateNumber; use starknet_integration_tests::integration_test_setup::IntegrationTestSetup; use starknet_integration_tests::utils::{ - create_integration_test_tx_generator, - run_integration_test, - send_account_txs, + create_integration_test_tx_generator, run_integration_test, send_account_txs, }; use starknet_sequencer_infra::trace_util::configure_tracing; use starknet_sequencer_node::test_utils::compilation::spawn_run_node; diff --git a/crates/starknet_integration_tests/tests/mempool_p2p_flow_test.rs b/crates/starknet_integration_tests/tests/mempool_p2p_flow_test.rs index fa8e3e5404..6eda11b729 100644 --- a/crates/starknet_integration_tests/tests/mempool_p2p_flow_test.rs +++ b/crates/starknet_integration_tests/tests/mempool_p2p_flow_test.rs @@ -11,29 +11,22 @@ use papyrus_protobuf::mempool::RpcTransactionWrapper; use rstest::{fixture, rstest}; use starknet_api::executable_transaction::AccountTransaction; use starknet_api::rpc_transaction::{ - RpcDeployAccountTransaction, - RpcInvokeTransaction, - RpcTransaction, + RpcDeployAccountTransaction, RpcInvokeTransaction, RpcTransaction, }; use starknet_api::transaction::TransactionHash; use starknet_http_server::config::HttpServerConfig; use starknet_http_server::test_utils::HttpTestClient; use starknet_integration_tests::state_reader::{spawn_test_rpc_state_reader, StorageTestSetup}; use starknet_integration_tests::utils::{ - create_batcher_config, - create_chain_info, - create_gateway_config, - create_http_server_config, - create_integration_test_tx_generator, - run_integration_test_scenario, + create_batcher_config, create_chain_info, create_gateway_config, create_http_server_config, + create_integration_test_tx_generator, run_integration_test_scenario, test_rpc_state_reader_config, }; use starknet_mempool_p2p::config::MempoolP2pConfig; use starknet_mempool_p2p::MEMPOOL_TOPIC; use starknet_sequencer_node::config::component_config::ComponentConfig; use starknet_sequencer_node::config::component_execution_config::{ - ActiveComponentExecutionConfig, - ReactiveComponentExecutionConfig, + ActiveComponentExecutionConfig, ReactiveComponentExecutionConfig, ReactiveComponentExecutionMode, }; use starknet_sequencer_node::config::node_config::SequencerNodeConfig; diff --git a/crates/starknet_mempool/src/communication.rs b/crates/starknet_mempool/src/communication.rs index 6a00f5bbbf..eed4e0333c 100644 --- a/crates/starknet_mempool/src/communication.rs +++ b/crates/starknet_mempool/src/communication.rs @@ -2,15 +2,11 @@ use async_trait::async_trait; use papyrus_network_types::network_types::BroadcastedMessageMetadata; use starknet_api::executable_transaction::AccountTransaction; use starknet_api::rpc_transaction::{ - RpcDeployAccountTransaction, - RpcInvokeTransaction, - RpcTransaction, + RpcDeployAccountTransaction, RpcInvokeTransaction, RpcTransaction, }; use starknet_mempool_p2p_types::communication::SharedMempoolP2pPropagatorClient; use starknet_mempool_types::communication::{ - AddTransactionArgsWrapper, - MempoolRequest, - MempoolResponse, + AddTransactionArgsWrapper, MempoolRequest, MempoolResponse, }; use starknet_mempool_types::errors::MempoolError; use starknet_mempool_types::mempool_types::{CommitBlockArgs, MempoolResult}; diff --git a/crates/starknet_mempool/src/mempool.rs b/crates/starknet_mempool/src/mempool.rs index 2962e47ba9..ab1f063cbb 100644 --- a/crates/starknet_mempool/src/mempool.rs +++ b/crates/starknet_mempool/src/mempool.rs @@ -7,10 +7,7 @@ use starknet_api::transaction::fields::Tip; use starknet_api::transaction::TransactionHash; use starknet_mempool_types::errors::MempoolError; use starknet_mempool_types::mempool_types::{ - AccountState, - AddTransactionArgs, - CommitBlockArgs, - MempoolResult, + AccountState, AddTransactionArgs, CommitBlockArgs, MempoolResult, }; use crate::transaction_pool::TransactionPool; diff --git a/crates/starknet_mempool/src/mempool_test.rs b/crates/starknet_mempool/src/mempool_test.rs index be73d6a8af..deb65c0ebd 100644 --- a/crates/starknet_mempool/src/mempool_test.rs +++ b/crates/starknet_mempool/src/mempool_test.rs @@ -8,9 +8,7 @@ use rstest::{fixture, rstest}; use starknet_api::block::GasPrice; use starknet_api::executable_transaction::AccountTransaction; use starknet_api::rpc_transaction::{ - RpcDeployAccountTransaction, - RpcInvokeTransaction, - RpcTransaction, + RpcDeployAccountTransaction, RpcInvokeTransaction, RpcTransaction, }; use starknet_api::{contract_address, nonce}; use starknet_mempool_p2p_types::communication::MockMempoolP2pPropagatorClient; @@ -23,8 +21,7 @@ use crate::mempool::{Mempool, MempoolConfig, TransactionReference}; use crate::test_utils::{add_tx, add_tx_expect_error, commit_block, get_txs_and_assert_expected}; use crate::transaction_pool::TransactionPool; use crate::transaction_queue::transaction_queue_test_utils::{ - TransactionQueueContent, - TransactionQueueContentBuilder, + TransactionQueueContent, TransactionQueueContentBuilder, }; use crate::{add_tx_input, tx}; diff --git a/crates/starknet_mempool/tests/flow_test.rs b/crates/starknet_mempool/tests/flow_test.rs index af279711a9..5c9e0d0e2a 100644 --- a/crates/starknet_mempool/tests/flow_test.rs +++ b/crates/starknet_mempool/tests/flow_test.rs @@ -4,10 +4,7 @@ use starknet_api::{contract_address, nonce}; use starknet_mempool::add_tx_input; use starknet_mempool::mempool::Mempool; use starknet_mempool::test_utils::{ - add_tx, - add_tx_expect_error, - commit_block, - get_txs_and_assert_expected, + add_tx, add_tx_expect_error, commit_block, get_txs_and_assert_expected, }; use starknet_mempool_types::errors::MempoolError; diff --git a/crates/starknet_mempool_p2p/src/propagator/mod.rs b/crates/starknet_mempool_p2p/src/propagator/mod.rs index dc896fc614..8949c5622c 100644 --- a/crates/starknet_mempool_p2p/src/propagator/mod.rs +++ b/crates/starknet_mempool_p2p/src/propagator/mod.rs @@ -5,8 +5,7 @@ use async_trait::async_trait; use papyrus_network::network_manager::{BroadcastTopicClient, BroadcastTopicClientTrait}; use papyrus_protobuf::mempool::RpcTransactionWrapper; use starknet_mempool_p2p_types::communication::{ - MempoolP2pPropagatorRequest, - MempoolP2pPropagatorResponse, + MempoolP2pPropagatorRequest, MempoolP2pPropagatorResponse, }; use starknet_mempool_p2p_types::errors::MempoolP2pPropagatorError; use starknet_sequencer_infra::component_definitions::{ComponentRequestHandler, ComponentStarter}; diff --git a/crates/starknet_mempool_p2p/src/propagator/test.rs b/crates/starknet_mempool_p2p/src/propagator/test.rs index 155e832060..0779800e0f 100644 --- a/crates/starknet_mempool_p2p/src/propagator/test.rs +++ b/crates/starknet_mempool_p2p/src/propagator/test.rs @@ -1,8 +1,6 @@ use futures::stream::StreamExt; use papyrus_network::network_manager::test_utils::{ - mock_register_broadcast_topic, - BroadcastNetworkMock, - TestSubscriberChannels, + mock_register_broadcast_topic, BroadcastNetworkMock, TestSubscriberChannels, }; use papyrus_network::network_manager::BroadcastTopicChannels; use papyrus_network_types::network_types::BroadcastedMessageMetadata; diff --git a/crates/starknet_mempool_p2p/src/runner/mod.rs b/crates/starknet_mempool_p2p/src/runner/mod.rs index 8f2e6563cb..2cb08dcc31 100644 --- a/crates/starknet_mempool_p2p/src/runner/mod.rs +++ b/crates/starknet_mempool_p2p/src/runner/mod.rs @@ -5,10 +5,7 @@ use async_trait::async_trait; use futures::stream::FuturesUnordered; use futures::{pin_mut, StreamExt, TryFutureExt}; use papyrus_network::network_manager::{ - BroadcastTopicClient, - BroadcastTopicClientTrait, - BroadcastTopicServer, - NetworkManager, + BroadcastTopicClient, BroadcastTopicClientTrait, BroadcastTopicServer, NetworkManager, }; use papyrus_protobuf::mempool::RpcTransactionWrapper; use starknet_gateway_types::communication::{GatewayClientError, SharedGatewayClient}; diff --git a/crates/starknet_mempool_p2p/src/runner/test.rs b/crates/starknet_mempool_p2p/src/runner/test.rs index e64f272c32..a9a4e820b7 100644 --- a/crates/starknet_mempool_p2p/src/runner/test.rs +++ b/crates/starknet_mempool_p2p/src/runner/test.rs @@ -6,9 +6,7 @@ use futures::channel::mpsc::Sender; use futures::stream::StreamExt; use futures::SinkExt; use papyrus_network::network_manager::test_utils::{ - mock_register_broadcast_topic, - BroadcastNetworkMock, - TestSubscriberChannels, + mock_register_broadcast_topic, BroadcastNetworkMock, TestSubscriberChannels, }; use papyrus_network::network_manager::{BroadcastTopicChannels, NetworkManager}; use papyrus_network::NetworkConfig; diff --git a/crates/starknet_mempool_p2p_types/src/communication.rs b/crates/starknet_mempool_p2p_types/src/communication.rs index 42a9a190d6..bab3188bd7 100644 --- a/crates/starknet_mempool_p2p_types/src/communication.rs +++ b/crates/starknet_mempool_p2p_types/src/communication.rs @@ -6,13 +6,10 @@ use papyrus_proc_macros::handle_response_variants; use serde::{Deserialize, Serialize}; use starknet_api::rpc_transaction::RpcTransaction; use starknet_sequencer_infra::component_client::{ - ClientError, - LocalComponentClient, - RemoteComponentClient, + ClientError, LocalComponentClient, RemoteComponentClient, }; use starknet_sequencer_infra::component_definitions::{ - ComponentClient, - ComponentRequestAndResponseSender, + ComponentClient, ComponentRequestAndResponseSender, }; use thiserror::Error; diff --git a/crates/starknet_mempool_types/src/communication.rs b/crates/starknet_mempool_types/src/communication.rs index bf6b83df78..aa4b35f74b 100644 --- a/crates/starknet_mempool_types/src/communication.rs +++ b/crates/starknet_mempool_types/src/communication.rs @@ -8,13 +8,10 @@ use papyrus_proc_macros::handle_response_variants; use serde::{Deserialize, Serialize}; use starknet_api::executable_transaction::AccountTransaction; use starknet_sequencer_infra::component_client::{ - ClientError, - LocalComponentClient, - RemoteComponentClient, + ClientError, LocalComponentClient, RemoteComponentClient, }; use starknet_sequencer_infra::component_definitions::{ - ComponentClient, - ComponentRequestAndResponseSender, + ComponentClient, ComponentRequestAndResponseSender, }; use thiserror::Error; diff --git a/crates/starknet_monitoring_endpoint/src/monitoring_endpoint_test.rs b/crates/starknet_monitoring_endpoint/src/monitoring_endpoint_test.rs index e0c222a1d9..dd9017e7ea 100644 --- a/crates/starknet_monitoring_endpoint/src/monitoring_endpoint_test.rs +++ b/crates/starknet_monitoring_endpoint/src/monitoring_endpoint_test.rs @@ -13,12 +13,7 @@ use tower::ServiceExt; use super::MonitoringEndpointConfig; use crate::monitoring_endpoint::{ - create_monitoring_endpoint, - MonitoringEndpoint, - ALIVE, - METRICS, - READY, - VERSION, + create_monitoring_endpoint, MonitoringEndpoint, ALIVE, METRICS, READY, VERSION, }; use crate::test_utils::build_request; diff --git a/crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/node_serde.rs b/crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/node_serde.rs index fc7295fd7c..de8dd9123b 100644 --- a/crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/node_serde.rs +++ b/crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/node_serde.rs @@ -5,11 +5,7 @@ use crate::felt::Felt; use crate::hash::hash_trait::HashOutput; use crate::patricia_merkle_tree::filled_tree::node::FilledNode; use crate::patricia_merkle_tree::node_data::inner_node::{ - BinaryData, - EdgeData, - EdgePathLength, - NodeData, - PathToBottom, + BinaryData, EdgeData, EdgePathLength, NodeData, PathToBottom, }; use crate::patricia_merkle_tree::node_data::leaf::Leaf; use crate::storage::db_object::DBObject; diff --git a/crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/tree_test.rs b/crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/tree_test.rs index bf820c651e..1299d00d3c 100644 --- a/crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/tree_test.rs +++ b/crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/tree_test.rs @@ -6,26 +6,18 @@ use crate::patricia_merkle_tree::filled_tree::errors::FilledTreeError; use crate::patricia_merkle_tree::filled_tree::node::FilledNode; use crate::patricia_merkle_tree::filled_tree::tree::{FilledTree, FilledTreeImpl}; use crate::patricia_merkle_tree::internal_test_utils::{ - MockLeaf, - OriginalSkeletonMockTrieConfig, - TestTreeHashFunction, + MockLeaf, OriginalSkeletonMockTrieConfig, TestTreeHashFunction, }; use crate::patricia_merkle_tree::node_data::errors::LeafError; use crate::patricia_merkle_tree::node_data::inner_node::{ - BinaryData, - EdgeData, - EdgePathLength, - NodeData, - PathToBottom, + BinaryData, EdgeData, EdgePathLength, NodeData, PathToBottom, }; use crate::patricia_merkle_tree::node_data::leaf::{LeafModifications, SkeletonLeaf}; use crate::patricia_merkle_tree::original_skeleton_tree::tree::OriginalSkeletonTreeImpl; use crate::patricia_merkle_tree::types::{NodeIndex, SortedLeafIndices}; use crate::patricia_merkle_tree::updated_skeleton_tree::node::UpdatedSkeletonNode; use crate::patricia_merkle_tree::updated_skeleton_tree::tree::{ - UpdatedSkeletonNodeMap, - UpdatedSkeletonTree, - UpdatedSkeletonTreeImpl, + UpdatedSkeletonNodeMap, UpdatedSkeletonTree, UpdatedSkeletonTreeImpl, }; use crate::storage::map_storage::MapStorage; @@ -296,8 +288,8 @@ async fn test_delete_leaf_from_empty_tree() { assert!(root_hash == HashOutput::ROOT_OF_EMPTY_TREE); } -fn get_small_tree_updated_skeleton_and_leaf_modifications() --> (UpdatedSkeletonTreeImpl, LeafModifications) { +fn get_small_tree_updated_skeleton_and_leaf_modifications( +) -> (UpdatedSkeletonTreeImpl, LeafModifications) { // Set up the updated skeleton tree. let new_leaves = [(35, "0x1"), (36, "0x2"), (63, "0x3")]; let nodes_in_skeleton_tree: Vec<(NodeIndex, UpdatedSkeletonNode)> = [ @@ -323,8 +315,8 @@ fn get_small_tree_updated_skeleton_and_leaf_modifications() (updated_skeleton_tree, modifications) } -fn get_small_tree_expected_filled_tree_map_and_root_hash() --> (HashMap>, HashOutput) { +fn get_small_tree_expected_filled_tree_map_and_root_hash( +) -> (HashMap>, HashOutput) { let expected_root_hash = HashOutput(Felt::from_hex("0x21").unwrap()); let expected_filled_tree_map = HashMap::from([ create_mock_binary_entry_for_testing(1, "0x21", "0xb", "0x16"), diff --git a/crates/starknet_patricia/src/patricia_merkle_tree/internal_test_utils.rs b/crates/starknet_patricia/src/patricia_merkle_tree/internal_test_utils.rs index 4ed6f391a6..c63a53c9c3 100644 --- a/crates/starknet_patricia/src/patricia_merkle_tree/internal_test_utils.rs +++ b/crates/starknet_patricia/src/patricia_merkle_tree/internal_test_utils.rs @@ -14,8 +14,7 @@ use crate::patricia_merkle_tree::original_skeleton_tree::config::OriginalSkeleto use crate::patricia_merkle_tree::original_skeleton_tree::node::OriginalSkeletonNode; use crate::patricia_merkle_tree::types::{NodeIndex, SubTreeHeight}; use crate::patricia_merkle_tree::updated_skeleton_tree::hash_function::{ - HashFunction, - TreeHashFunction, + HashFunction, TreeHashFunction, }; use crate::patricia_merkle_tree::updated_skeleton_tree::node::UpdatedSkeletonNode; use crate::patricia_merkle_tree::updated_skeleton_tree::tree::UpdatedSkeletonTreeImpl; diff --git a/crates/starknet_patricia/src/patricia_merkle_tree/node_data/leaf.rs b/crates/starknet_patricia/src/patricia_merkle_tree/node_data/leaf.rs index e779a10d82..0a711e5eca 100644 --- a/crates/starknet_patricia/src/patricia_merkle_tree/node_data/leaf.rs +++ b/crates/starknet_patricia/src/patricia_merkle_tree/node_data/leaf.rs @@ -65,7 +65,11 @@ impl SkeletonLeaf { impl From for SkeletonLeaf { fn from(value: Felt) -> Self { - if value == Felt::ZERO { Self::Zero } else { Self::NonZero } + if value == Felt::ZERO { + Self::Zero + } else { + Self::NonZero + } } } diff --git a/crates/starknet_patricia/src/patricia_merkle_tree/original_skeleton_tree/create_tree.rs b/crates/starknet_patricia/src/patricia_merkle_tree/original_skeleton_tree/create_tree.rs index 1cbec49f82..7e535fc29d 100644 --- a/crates/starknet_patricia/src/patricia_merkle_tree/original_skeleton_tree/create_tree.rs +++ b/crates/starknet_patricia/src/patricia_merkle_tree/original_skeleton_tree/create_tree.rs @@ -7,17 +7,13 @@ use tracing::warn; use crate::hash::hash_trait::HashOutput; use crate::patricia_merkle_tree::filled_tree::node::FilledNode; use crate::patricia_merkle_tree::node_data::inner_node::{ - BinaryData, - EdgeData, - NodeData, - PathToBottom, + BinaryData, EdgeData, NodeData, PathToBottom, }; use crate::patricia_merkle_tree::node_data::leaf::{Leaf, LeafModifications}; use crate::patricia_merkle_tree::original_skeleton_tree::config::OriginalSkeletonTreeConfig; use crate::patricia_merkle_tree::original_skeleton_tree::node::OriginalSkeletonNode; use crate::patricia_merkle_tree::original_skeleton_tree::tree::{ - OriginalSkeletonTreeImpl, - OriginalSkeletonTreeResult, + OriginalSkeletonTreeImpl, OriginalSkeletonTreeResult, }; use crate::patricia_merkle_tree::original_skeleton_tree::utils::split_leaves; use crate::patricia_merkle_tree::types::{NodeIndex, SortedLeafIndices, SubTreeHeight}; diff --git a/crates/starknet_patricia/src/patricia_merkle_tree/original_skeleton_tree/create_tree_test.rs b/crates/starknet_patricia/src/patricia_merkle_tree/original_skeleton_tree/create_tree_test.rs index 145f2fa5ee..64a8389e3b 100644 --- a/crates/starknet_patricia/src/patricia_merkle_tree/original_skeleton_tree/create_tree_test.rs +++ b/crates/starknet_patricia/src/patricia_merkle_tree/original_skeleton_tree/create_tree_test.rs @@ -8,18 +8,12 @@ use super::OriginalSkeletonTreeImpl; use crate::felt::Felt; use crate::hash::hash_trait::HashOutput; use crate::patricia_merkle_tree::external_test_utils::{ - create_binary_entry, - create_binary_skeleton_node, - create_edge_entry, - create_edge_skeleton_node, - create_expected_skeleton_nodes, - create_root_edge_entry, + create_binary_entry, create_binary_skeleton_node, create_edge_entry, create_edge_skeleton_node, + create_expected_skeleton_nodes, create_root_edge_entry, create_unmodified_subtree_skeleton_node, }; use crate::patricia_merkle_tree::internal_test_utils::{ - small_tree_index_to_full, - MockLeaf, - OriginalSkeletonMockTrieConfig, + small_tree_index_to_full, MockLeaf, OriginalSkeletonMockTrieConfig, }; use crate::patricia_merkle_tree::node_data::inner_node::{EdgePath, EdgePathLength, PathToBottom}; use crate::patricia_merkle_tree::node_data::leaf::LeafModifications; diff --git a/crates/starknet_patricia/src/patricia_merkle_tree/original_skeleton_tree/utils_test.rs b/crates/starknet_patricia/src/patricia_merkle_tree/original_skeleton_tree/utils_test.rs index da55e02e75..8d9b4416cd 100644 --- a/crates/starknet_patricia/src/patricia_merkle_tree/original_skeleton_tree/utils_test.rs +++ b/crates/starknet_patricia/src/patricia_merkle_tree/original_skeleton_tree/utils_test.rs @@ -6,9 +6,7 @@ use rstest::rstest; use super::split_leaves; use crate::patricia_merkle_tree::external_test_utils::get_random_u256; use crate::patricia_merkle_tree::internal_test_utils::{ - as_fully_indexed, - random, - small_tree_index_to_full, + as_fully_indexed, random, small_tree_index_to_full, }; use crate::patricia_merkle_tree::types::{NodeIndex, SortedLeafIndices, SubTreeHeight}; diff --git a/crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/create_tree_helper.rs b/crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/create_tree_helper.rs index 4bf82a4ce0..0facc7f438 100644 --- a/crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/create_tree_helper.rs +++ b/crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/create_tree_helper.rs @@ -4,17 +4,14 @@ use crate::patricia_merkle_tree::node_data::inner_node::{EdgePathLength, PathToB use crate::patricia_merkle_tree::node_data::leaf::{LeafModifications, SkeletonLeaf}; use crate::patricia_merkle_tree::original_skeleton_tree::node::OriginalSkeletonNode; use crate::patricia_merkle_tree::original_skeleton_tree::tree::{ - OriginalSkeletonNodeMap, - OriginalSkeletonTree, + OriginalSkeletonNodeMap, OriginalSkeletonTree, }; use crate::patricia_merkle_tree::original_skeleton_tree::utils::split_leaves; use crate::patricia_merkle_tree::types::{NodeIndex, SortedLeafIndices}; use crate::patricia_merkle_tree::updated_skeleton_tree::errors::UpdatedSkeletonTreeError; use crate::patricia_merkle_tree::updated_skeleton_tree::node::UpdatedSkeletonNode; use crate::patricia_merkle_tree::updated_skeleton_tree::tree::{ - UpdatedSkeletonNodeMap, - UpdatedSkeletonTreeImpl, - UpdatedSkeletonTreeResult, + UpdatedSkeletonNodeMap, UpdatedSkeletonTreeImpl, UpdatedSkeletonTreeResult, }; #[cfg(test)] diff --git a/crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/create_tree_helper_test.rs b/crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/create_tree_helper_test.rs index f4988e578b..17c933492e 100644 --- a/crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/create_tree_helper_test.rs +++ b/crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/create_tree_helper_test.rs @@ -8,30 +8,21 @@ use crate::felt::Felt; use crate::hash::hash_trait::HashOutput; use crate::patricia_merkle_tree::filled_tree::tree::FilledTree; use crate::patricia_merkle_tree::internal_test_utils::{ - as_fully_indexed, - get_initial_updated_skeleton, - small_tree_index_to_full, - MockLeaf, - MockTrie, - OriginalSkeletonMockTrieConfig, - TestTreeHashFunction, + as_fully_indexed, get_initial_updated_skeleton, small_tree_index_to_full, MockLeaf, MockTrie, + OriginalSkeletonMockTrieConfig, TestTreeHashFunction, }; use crate::patricia_merkle_tree::node_data::inner_node::{EdgePathLength, PathToBottom}; use crate::patricia_merkle_tree::original_skeleton_tree::node::OriginalSkeletonNode; use crate::patricia_merkle_tree::original_skeleton_tree::tree::{ - OriginalSkeletonNodeMap, - OriginalSkeletonTreeImpl, + OriginalSkeletonNodeMap, OriginalSkeletonTreeImpl, }; use crate::patricia_merkle_tree::types::{NodeIndex, SortedLeafIndices, SubTreeHeight}; use crate::patricia_merkle_tree::updated_skeleton_tree::create_tree_helper::{ - get_path_to_lca, - has_leaves_on_both_sides, - TempSkeletonNode, + get_path_to_lca, has_leaves_on_both_sides, TempSkeletonNode, }; use crate::patricia_merkle_tree::updated_skeleton_tree::node::UpdatedSkeletonNode; use crate::patricia_merkle_tree::updated_skeleton_tree::tree::{ - UpdatedSkeletonTree, - UpdatedSkeletonTreeImpl, + UpdatedSkeletonTree, UpdatedSkeletonTreeImpl, }; use crate::storage::map_storage::MapStorage; diff --git a/crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/hash_function.rs b/crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/hash_function.rs index c35224ca10..cd091732ac 100644 --- a/crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/hash_function.rs +++ b/crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/hash_function.rs @@ -1,10 +1,7 @@ use crate::felt::Felt; use crate::hash::hash_trait::HashOutput; use crate::patricia_merkle_tree::node_data::inner_node::{ - BinaryData, - EdgeData, - NodeData, - PathToBottom, + BinaryData, EdgeData, NodeData, PathToBottom, }; use crate::patricia_merkle_tree::node_data::leaf::Leaf; diff --git a/crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/tree_test.rs b/crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/tree_test.rs index 57cca5e8f2..327d9377fd 100644 --- a/crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/tree_test.rs +++ b/crates/starknet_patricia/src/patricia_merkle_tree/updated_skeleton_tree/tree_test.rs @@ -5,22 +5,18 @@ use rstest::{fixture, rstest}; use crate::felt::Felt; use crate::hash::hash_trait::HashOutput; use crate::patricia_merkle_tree::internal_test_utils::{ - get_initial_updated_skeleton, - MockLeaf, - OriginalSkeletonMockTrieConfig, + get_initial_updated_skeleton, MockLeaf, OriginalSkeletonMockTrieConfig, }; use crate::patricia_merkle_tree::node_data::inner_node::PathToBottom; use crate::patricia_merkle_tree::node_data::leaf::{LeafModifications, SkeletonLeaf}; use crate::patricia_merkle_tree::original_skeleton_tree::node::OriginalSkeletonNode; use crate::patricia_merkle_tree::original_skeleton_tree::tree::{ - OriginalSkeletonTree, - OriginalSkeletonTreeImpl, + OriginalSkeletonTree, OriginalSkeletonTreeImpl, }; use crate::patricia_merkle_tree::types::{NodeIndex, SortedLeafIndices, SubTreeHeight}; use crate::patricia_merkle_tree::updated_skeleton_tree::node::UpdatedSkeletonNode; use crate::patricia_merkle_tree::updated_skeleton_tree::tree::{ - UpdatedSkeletonTree, - UpdatedSkeletonTreeImpl, + UpdatedSkeletonTree, UpdatedSkeletonTreeImpl, }; use crate::storage::map_storage::MapStorage; diff --git a/crates/starknet_sequencer_infra/src/component_client/remote_component_client.rs b/crates/starknet_sequencer_infra/src/component_client/remote_component_client.rs index 532da1dc63..bc08d14ae4 100644 --- a/crates/starknet_sequencer_infra/src/component_client/remote_component_client.rs +++ b/crates/starknet_sequencer_infra/src/component_client/remote_component_client.rs @@ -13,10 +13,7 @@ use serde::Serialize; use super::definitions::{ClientError, ClientResult}; use crate::component_definitions::{ - ComponentClient, - RemoteClientConfig, - ServerError, - APPLICATION_OCTET_STREAM, + ComponentClient, RemoteClientConfig, ServerError, APPLICATION_OCTET_STREAM, }; use crate::serde_utils::SerdeWrapper; diff --git a/crates/starknet_sequencer_infra/src/component_server/local_component_server.rs b/crates/starknet_sequencer_infra/src/component_server/local_component_server.rs index eeb4f02597..55c2d98133 100644 --- a/crates/starknet_sequencer_infra/src/component_server/local_component_server.rs +++ b/crates/starknet_sequencer_infra/src/component_server/local_component_server.rs @@ -7,9 +7,7 @@ use tokio::sync::mpsc::Receiver; use tracing::{debug, error, info}; use crate::component_definitions::{ - ComponentRequestAndResponseSender, - ComponentRequestHandler, - ComponentStarter, + ComponentRequestAndResponseSender, ComponentRequestHandler, ComponentStarter, }; use crate::component_server::{ComponentReplacer, ComponentServerStarter}; use crate::errors::{ComponentServerError, ReplaceComponentError}; diff --git a/crates/starknet_sequencer_infra/src/component_server/remote_component_server.rs b/crates/starknet_sequencer_infra/src/component_server/remote_component_server.rs index 7c16b9a05a..a50f226cd7 100644 --- a/crates/starknet_sequencer_infra/src/component_server/remote_component_server.rs +++ b/crates/starknet_sequencer_infra/src/component_server/remote_component_server.rs @@ -12,10 +12,7 @@ use serde::Serialize; use crate::component_client::{ClientError, LocalComponentClient}; use crate::component_definitions::{ - ComponentClient, - RemoteServerConfig, - ServerError, - APPLICATION_OCTET_STREAM, + ComponentClient, RemoteServerConfig, ServerError, APPLICATION_OCTET_STREAM, }; use crate::component_server::ComponentServerStarter; use crate::errors::ComponentServerError; diff --git a/crates/starknet_sequencer_infra/src/serde_utils_test.rs b/crates/starknet_sequencer_infra/src/serde_utils_test.rs index 6b6bc2cf54..ae56583fff 100644 --- a/crates/starknet_sequencer_infra/src/serde_utils_test.rs +++ b/crates/starknet_sequencer_infra/src/serde_utils_test.rs @@ -3,13 +3,8 @@ use std::fmt::Debug; use serde::{Deserialize, Serialize}; use starknet_api::data_availability::DataAvailabilityMode; use starknet_api::rpc_transaction::{ - RpcDeclareTransaction, - RpcDeclareTransactionV3, - RpcDeployAccountTransaction, - RpcDeployAccountTransactionV3, - RpcInvokeTransaction, - RpcInvokeTransactionV3, - RpcTransaction, + RpcDeclareTransaction, RpcDeclareTransactionV3, RpcDeployAccountTransaction, + RpcDeployAccountTransactionV3, RpcInvokeTransaction, RpcInvokeTransactionV3, RpcTransaction, }; use starknet_types_core::felt::Felt; diff --git a/crates/starknet_sequencer_infra/src/tests/local_component_client_server_test.rs b/crates/starknet_sequencer_infra/src/tests/local_component_client_server_test.rs index f369867796..08660d7ebc 100644 --- a/crates/starknet_sequencer_infra/src/tests/local_component_client_server_test.rs +++ b/crates/starknet_sequencer_infra/src/tests/local_component_client_server_test.rs @@ -7,19 +7,9 @@ use crate::component_client::{ClientError, ClientResult, LocalComponentClient}; use crate::component_definitions::{ComponentClient, ComponentRequestAndResponseSender}; use crate::component_server::{ComponentServerStarter, LocalComponentServer}; use crate::tests::{ - test_a_b_functionality, - ComponentA, - ComponentAClientTrait, - ComponentARequest, - ComponentAResponse, - ComponentB, - ComponentBClientTrait, - ComponentBRequest, - ComponentBResponse, - ResultA, - ResultB, - ValueA, - ValueB, + test_a_b_functionality, ComponentA, ComponentAClientTrait, ComponentARequest, + ComponentAResponse, ComponentB, ComponentBClientTrait, ComponentBRequest, ComponentBResponse, + ResultA, ResultB, ValueA, ValueB, }; type ComponentAClient = LocalComponentClient; diff --git a/crates/starknet_sequencer_infra/src/tests/remote_component_client_server_test.rs b/crates/starknet_sequencer_infra/src/tests/remote_component_client_server_test.rs index 44ce834a1d..7ac784d5c8 100644 --- a/crates/starknet_sequencer_infra/src/tests/remote_component_client_server_test.rs +++ b/crates/starknet_sequencer_infra/src/tests/remote_component_client_server_test.rs @@ -16,40 +16,21 @@ use tokio::sync::Mutex; use tokio::task; use crate::component_client::{ - ClientError, - ClientResult, - LocalComponentClient, - RemoteComponentClient, + ClientError, ClientResult, LocalComponentClient, RemoteComponentClient, }; use crate::component_definitions::{ - ComponentClient, - ComponentRequestAndResponseSender, - RemoteClientConfig, - RemoteServerConfig, - ServerError, - APPLICATION_OCTET_STREAM, + ComponentClient, ComponentRequestAndResponseSender, RemoteClientConfig, RemoteServerConfig, + ServerError, APPLICATION_OCTET_STREAM, }; use crate::component_server::{ - ComponentServerStarter, - LocalComponentServer, - RemoteComponentServer, + ComponentServerStarter, LocalComponentServer, RemoteComponentServer, }; use crate::serde_utils::SerdeWrapper; use crate::test_utils::get_available_socket; use crate::tests::{ - test_a_b_functionality, - ComponentA, - ComponentAClientTrait, - ComponentARequest, - ComponentAResponse, - ComponentB, - ComponentBClientTrait, - ComponentBRequest, - ComponentBResponse, - ResultA, - ResultB, - ValueA, - ValueB, + test_a_b_functionality, ComponentA, ComponentAClientTrait, ComponentARequest, + ComponentAResponse, ComponentB, ComponentBClientTrait, ComponentBRequest, ComponentBResponse, + ResultA, ResultB, ValueA, ValueB, }; type ComponentAClient = RemoteComponentClient; diff --git a/crates/starknet_sequencer_node/src/bin/sequencer_dump_config.rs b/crates/starknet_sequencer_node/src/bin/sequencer_dump_config.rs index 6a2e976987..3b38df5c60 100644 --- a/crates/starknet_sequencer_node/src/bin/sequencer_dump_config.rs +++ b/crates/starknet_sequencer_node/src/bin/sequencer_dump_config.rs @@ -1,9 +1,6 @@ use papyrus_config::dumping::SerializeConfig; use starknet_sequencer_node::config::node_config::{ - SequencerNodeConfig, - CONFIG_NON_POINTERS_WHITELIST, - CONFIG_POINTERS, - DEFAULT_CONFIG_PATH, + SequencerNodeConfig, CONFIG_NON_POINTERS_WHITELIST, CONFIG_POINTERS, DEFAULT_CONFIG_PATH, }; /// Updates the default config file by: diff --git a/crates/starknet_sequencer_node/src/clients.rs b/crates/starknet_sequencer_node/src/clients.rs index 336bc32aec..fd39c9b273 100644 --- a/crates/starknet_sequencer_node/src/clients.rs +++ b/crates/starknet_sequencer_node/src/clients.rs @@ -1,39 +1,21 @@ use std::sync::Arc; use starknet_batcher_types::communication::{ - BatcherRequest, - BatcherResponse, - LocalBatcherClient, - RemoteBatcherClient, - SharedBatcherClient, + BatcherRequest, BatcherResponse, LocalBatcherClient, RemoteBatcherClient, SharedBatcherClient, }; use starknet_gateway_types::communication::{ - GatewayRequest, - GatewayResponse, - LocalGatewayClient, - RemoteGatewayClient, - SharedGatewayClient, + GatewayRequest, GatewayResponse, LocalGatewayClient, RemoteGatewayClient, SharedGatewayClient, }; use starknet_mempool_p2p_types::communication::{ - LocalMempoolP2pPropagatorClient, - MempoolP2pPropagatorRequest, - MempoolP2pPropagatorResponse, - RemoteMempoolP2pPropagatorClient, - SharedMempoolP2pPropagatorClient, + LocalMempoolP2pPropagatorClient, MempoolP2pPropagatorRequest, MempoolP2pPropagatorResponse, + RemoteMempoolP2pPropagatorClient, SharedMempoolP2pPropagatorClient, }; use starknet_mempool_types::communication::{ - LocalMempoolClient, - MempoolRequest, - MempoolResponse, - RemoteMempoolClient, - SharedMempoolClient, + LocalMempoolClient, MempoolRequest, MempoolResponse, RemoteMempoolClient, SharedMempoolClient, }; use starknet_sequencer_infra::component_client::{Client, LocalComponentClient}; use starknet_state_sync_types::communication::{ - LocalStateSyncClient, - RemoteStateSyncClient, - SharedStateSyncClient, - StateSyncRequest, + LocalStateSyncClient, RemoteStateSyncClient, SharedStateSyncClient, StateSyncRequest, StateSyncResponse, }; diff --git a/crates/starknet_sequencer_node/src/components.rs b/crates/starknet_sequencer_node/src/components.rs index 8c06adff56..342945a0bc 100644 --- a/crates/starknet_sequencer_node/src/components.rs +++ b/crates/starknet_sequencer_node/src/components.rs @@ -9,15 +9,13 @@ use starknet_mempool_p2p::create_p2p_propagator_and_runner; use starknet_mempool_p2p::propagator::MempoolP2pPropagator; use starknet_mempool_p2p::runner::MempoolP2pRunner; use starknet_monitoring_endpoint::monitoring_endpoint::{ - create_monitoring_endpoint, - MonitoringEndpoint, + create_monitoring_endpoint, MonitoringEndpoint, }; use starknet_state_sync_types::communication::EmptyStateSyncClient; use crate::clients::SequencerNodeClients; use crate::config::component_execution_config::{ - ActiveComponentExecutionMode, - ReactiveComponentExecutionMode, + ActiveComponentExecutionMode, ReactiveComponentExecutionMode, }; use crate::config::node_config::SequencerNodeConfig; use crate::version::VERSION_FULL; diff --git a/crates/starknet_sequencer_node/src/config/component_config.rs b/crates/starknet_sequencer_node/src/config/component_config.rs index 1cde477042..15e62ae209 100644 --- a/crates/starknet_sequencer_node/src/config/component_config.rs +++ b/crates/starknet_sequencer_node/src/config/component_config.rs @@ -6,8 +6,7 @@ use serde::{Deserialize, Serialize}; use validator::Validate; use crate::config::component_execution_config::{ - ActiveComponentExecutionConfig, - ReactiveComponentExecutionConfig, + ActiveComponentExecutionConfig, ReactiveComponentExecutionConfig, }; /// The components configuration. diff --git a/crates/starknet_sequencer_node/src/config/component_execution_config.rs b/crates/starknet_sequencer_node/src/config/component_execution_config.rs index 03af9e5e78..fc8829fd31 100644 --- a/crates/starknet_sequencer_node/src/config/component_execution_config.rs +++ b/crates/starknet_sequencer_node/src/config/component_execution_config.rs @@ -4,9 +4,7 @@ use papyrus_config::dumping::{ser_optional_sub_config, ser_param, SerializeConfi use papyrus_config::{ParamPath, ParamPrivacyInput, SerializedParam}; use serde::{Deserialize, Serialize}; use starknet_sequencer_infra::component_definitions::{ - LocalServerConfig, - RemoteClientConfig, - RemoteServerConfig, + LocalServerConfig, RemoteClientConfig, RemoteServerConfig, }; use tracing::error; use validator::{Validate, ValidationError}; diff --git a/crates/starknet_sequencer_node/src/config/config_test.rs b/crates/starknet_sequencer_node/src/config/config_test.rs index 3d636e950a..8043e9119a 100644 --- a/crates/starknet_sequencer_node/src/config/config_test.rs +++ b/crates/starknet_sequencer_node/src/config/config_test.rs @@ -13,21 +13,15 @@ use rstest::rstest; use starknet_batcher::block_builder::BlockBuilderConfig; use starknet_batcher::config::BatcherConfig; use starknet_sequencer_infra::component_definitions::{ - LocalServerConfig, - RemoteClientConfig, - RemoteServerConfig, + LocalServerConfig, RemoteClientConfig, RemoteServerConfig, }; use validator::Validate; use crate::config::component_execution_config::{ - ReactiveComponentExecutionConfig, - ReactiveComponentExecutionMode, + ReactiveComponentExecutionConfig, ReactiveComponentExecutionMode, }; use crate::config::node_config::{ - SequencerNodeConfig, - CONFIG_NON_POINTERS_WHITELIST, - CONFIG_POINTERS, - DEFAULT_CONFIG_PATH, + SequencerNodeConfig, CONFIG_NON_POINTERS_WHITELIST, CONFIG_POINTERS, DEFAULT_CONFIG_PATH, }; use crate::config::test_utils::{create_test_config_load_args, RequiredParams}; @@ -159,9 +153,7 @@ fn test_validate_batcher_config_failure() { }; let error = config.validate().unwrap_err(); - assert!( - error - .to_string() - .contains("input_stream_content_buffer_size must be at least tx_chunk_size") - ); + assert!(error + .to_string() + .contains("input_stream_content_buffer_size must be at least tx_chunk_size")); } diff --git a/crates/starknet_sequencer_node/src/config/node_config.rs b/crates/starknet_sequencer_node/src/config/node_config.rs index 412b5d9c7d..8e5367a332 100644 --- a/crates/starknet_sequencer_node/src/config/node_config.rs +++ b/crates/starknet_sequencer_node/src/config/node_config.rs @@ -7,13 +7,8 @@ use std::vec::Vec; use clap::Command; use infra_utils::path::resolve_project_relative_path; use papyrus_config::dumping::{ - append_sub_config_name, - generate_struct_pointer, - ser_pointer_target_required_param, - set_pointing_param_paths, - ConfigPointers, - Pointers, - SerializeConfig, + append_sub_config_name, generate_struct_pointer, ser_pointer_target_required_param, + set_pointing_param_paths, ConfigPointers, Pointers, SerializeConfig, }; use papyrus_config::loading::load_and_process_config; use papyrus_config::{ConfigError, ParamPath, SerializationType, SerializedParam}; diff --git a/crates/starknet_sequencer_node/src/servers.rs b/crates/starknet_sequencer_node/src/servers.rs index 690edc2fc8..5c05411dda 100644 --- a/crates/starknet_sequencer_node/src/servers.rs +++ b/crates/starknet_sequencer_node/src/servers.rs @@ -8,16 +8,12 @@ use starknet_gateway::communication::{LocalGatewayServer, RemoteGatewayServer}; use starknet_http_server::communication::HttpServer; use starknet_mempool::communication::{LocalMempoolServer, RemoteMempoolServer}; use starknet_mempool_p2p::propagator::{ - LocalMempoolP2pPropagatorServer, - RemoteMempoolP2pPropagatorServer, + LocalMempoolP2pPropagatorServer, RemoteMempoolP2pPropagatorServer, }; use starknet_mempool_p2p::runner::MempoolP2pRunnerServer; use starknet_monitoring_endpoint::communication::MonitoringEndpointServer; use starknet_sequencer_infra::component_server::{ - ComponentServerStarter, - LocalComponentServer, - RemoteComponentServer, - WrapperServer, + ComponentServerStarter, LocalComponentServer, RemoteComponentServer, WrapperServer, }; use starknet_sequencer_infra::errors::ComponentServerError; use tracing::error; @@ -26,8 +22,7 @@ use crate::clients::SequencerNodeClients; use crate::communication::SequencerNodeCommunication; use crate::components::SequencerNodeComponents; use crate::config::component_execution_config::{ - ActiveComponentExecutionMode, - ReactiveComponentExecutionMode, + ActiveComponentExecutionMode, ReactiveComponentExecutionMode, }; use crate::config::node_config::SequencerNodeConfig; diff --git a/crates/starknet_sierra_compile/src/utils.rs b/crates/starknet_sierra_compile/src/utils.rs index bc73f000bd..0aef812755 100644 --- a/crates/starknet_sierra_compile/src/utils.rs +++ b/crates/starknet_sierra_compile/src/utils.rs @@ -1,15 +1,13 @@ use std::clone::Clone; use cairo_lang_starknet_classes::contract_class::{ - ContractClass as CairoLangContractClass, - ContractEntryPoint as CairoLangContractEntryPoint, + ContractClass as CairoLangContractClass, ContractEntryPoint as CairoLangContractEntryPoint, ContractEntryPoints as CairoLangContractEntryPoints, }; use cairo_lang_utils::bigint::BigUintAsHex; use starknet_api::rpc_transaction::EntryPointByType as StarknetApiEntryPointByType; use starknet_api::state::{ - EntryPoint as StarknetApiEntryPoint, - SierraContractClass as StarknetApiContractClass, + EntryPoint as StarknetApiEntryPoint, SierraContractClass as StarknetApiContractClass, }; use starknet_types_core::felt::Felt; diff --git a/crates/starknet_state_sync/src/lib.rs b/crates/starknet_state_sync/src/lib.rs index 1f86107806..92be38b563 100644 --- a/crates/starknet_state_sync/src/lib.rs +++ b/crates/starknet_state_sync/src/lib.rs @@ -8,9 +8,7 @@ use papyrus_storage::StorageReader; use starknet_api::block::BlockNumber; use starknet_sequencer_infra::component_definitions::ComponentRequestHandler; use starknet_state_sync_types::communication::{ - StateSyncRequest, - StateSyncResponse, - StateSyncResult, + StateSyncRequest, StateSyncResponse, StateSyncResult, }; use starknet_state_sync_types::state_sync_types::SyncBlock; diff --git a/crates/starknet_state_sync_types/src/communication.rs b/crates/starknet_state_sync_types/src/communication.rs index d940e6d065..8f05593aa5 100644 --- a/crates/starknet_state_sync_types/src/communication.rs +++ b/crates/starknet_state_sync_types/src/communication.rs @@ -5,13 +5,10 @@ use papyrus_proc_macros::handle_response_variants; use serde::{Deserialize, Serialize}; use starknet_api::block::BlockNumber; use starknet_sequencer_infra::component_client::{ - ClientError, - LocalComponentClient, - RemoteComponentClient, + ClientError, LocalComponentClient, RemoteComponentClient, }; use starknet_sequencer_infra::component_definitions::{ - ComponentClient, - ComponentRequestAndResponseSender, + ComponentClient, ComponentRequestAndResponseSender, }; use thiserror::Error;