From f4ad7258de02cf1a13e656478f2a1ef0dcd3c4fa Mon Sep 17 00:00:00 2001 From: Dori Medini Date: Tue, 1 Jul 2025 15:59:26 +0300 Subject: [PATCH] ci: rust 1.88 --- crates/apollo_batcher/src/batcher_test.rs | 16 +++------- .../sources/central/state_update_stream.rs | 6 ++-- .../src/sources/central_test.rs | 2 +- crates/apollo_class_manager/src/metrics.rs | 7 ++--- .../src/build_utils.rs | 4 +-- .../src/compiler_utils.rs | 2 +- .../resource_limits/resource_limits_test.rs | 6 ++-- crates/apollo_compile_to_casm/build.rs | 2 +- .../build_with_cairo_native.rs | 2 +- crates/apollo_config/src/converters.rs | 5 ++-- crates/apollo_config/src/dumping.rs | 12 ++++---- crates/apollo_config/src/test_utils.rs | 2 +- crates/apollo_config/src/validators.rs | 14 ++++----- .../src/bin/run_simulation.rs | 17 +++++------ .../src/single_height_consensus.rs | 7 ++--- crates/apollo_consensus/src/state_machine.rs | 2 +- crates/apollo_consensus/src/stream_handler.rs | 2 +- .../src/consensus_manager.rs | 6 ++-- .../src/metric_definitions_test.rs | 2 +- crates/apollo_deployments/src/addresses.rs | 4 +-- crates/apollo_deployments/src/deployment.rs | 4 +-- .../src/deployments/hybrid.rs | 4 +-- crates/apollo_deployments/src/service.rs | 4 +-- crates/apollo_deployments/src/utils.rs | 2 +- crates/apollo_gateway/src/errors.rs | 4 +-- .../stateful_transaction_validator_test.rs | 2 +- crates/apollo_http_server/src/http_server.rs | 2 +- .../src/http_server_test.rs | 4 +-- crates/apollo_http_server/src/test_utils.rs | 2 +- .../remote_component_client.rs | 2 +- .../remote_component_server.rs | 5 ++-- .../src/tests/server_metrics_test.rs | 28 +++++++---------- crates/apollo_infra_utils/src/dumping.rs | 8 ++--- crates/apollo_infra_utils/src/path_test.rs | 2 +- crates/apollo_infra_utils/src/run_until.rs | 8 ++--- crates/apollo_infra_utils/src/test_utils.rs | 10 ++----- crates/apollo_infra_utils/src/tracing.rs | 2 +- crates/apollo_infra_utils/src/tracing_test.rs | 2 +- .../integration_test_restart_flow.rs | 3 +- .../src/bin/sequencer_node_setup.rs | 2 +- .../src/bin/sequencer_simulator.rs | 4 +-- .../src/flow_test_setup.rs | 7 ++--- .../src/integration_test_manager.rs | 21 +++++-------- .../src/sequencer_simulator_utils.rs | 6 ++-- crates/apollo_integration_tests/src/utils.rs | 6 ++-- .../src/l1_endpoint_monitor_tests.rs | 3 +- .../apollo_l1_endpoint_monitor/src/monitor.rs | 2 +- .../src/eth_to_strk_oracle_test.rs | 2 +- .../src/l1_gas_price_scraper.rs | 2 +- crates/apollo_l1_provider/src/l1_scraper.rs | 2 +- .../src/l1_scraper_tests.rs | 4 +-- crates/apollo_l1_provider_types/src/lib.rs | 9 +++--- crates/apollo_mempool/src/mempool_test.rs | 5 ++-- crates/apollo_metrics/src/metrics.rs | 12 ++++---- .../src/monitoring_endpoint.rs | 2 +- .../bin/get_peer_id_from_secret_key/main.rs | 4 +-- .../src/bin/network_stress_test/utils.rs | 2 +- .../bootstrapping/bootstrap_test.rs | 2 +- .../discovery/behaviours/bootstrapping/mod.rs | 3 +- crates/apollo_network/src/lib.rs | 4 +-- crates/apollo_network/src/mixed_behaviour.rs | 2 +- .../apollo_network/src/network_manager/mod.rs | 18 +++++------ .../apollo_network/src/sqmr/behaviour_test.rs | 5 ++-- crates/apollo_network/src/sqmr/flow_test.rs | 6 ++-- .../src/config/component_execution_config.rs | 4 +-- crates/apollo_node/src/config/config_utils.rs | 4 +-- crates/apollo_node/src/servers.rs | 2 +- .../apollo_node/src/test_utils/node_runner.rs | 2 +- crates/apollo_protobuf/src/consensus.rs | 2 +- .../src/converters/consensus_test.rs | 7 ++--- .../src/protoc_regression_test.rs | 4 +-- .../src/rpc_metrics/rpc_metrics_test.rs | 8 ++--- crates/apollo_rpc/src/test_utils.rs | 2 +- crates/apollo_rpc/src/v0_8/api/api_impl.rs | 2 +- crates/apollo_rpc/src/v0_8/api/test.rs | 5 ++-- crates/apollo_rpc/src/v0_8/transaction.rs | 4 +-- .../tests/gateway_integration_test.rs | 6 ++-- .../src/state_reader_test.rs | 2 +- .../src/reader/objects/transaction_test.rs | 10 +++---- .../starknet_feeder_gateway_client_test.rs | 4 +-- crates/apollo_state_sync/src/test.rs | 24 +++++++-------- crates/apollo_storage/src/body/body_test.rs | 2 +- crates/apollo_storage/src/db/db_test.rs | 2 +- crates/apollo_storage/src/db/mod.rs | 2 +- crates/apollo_storage/src/lib.rs | 12 ++++---- .../src/serialization/serializers_test.rs | 6 ++-- crates/blockifier/src/blockifier/block.rs | 8 ++--- .../src/blockifier/transaction_executor.rs | 6 ++-- .../src/blockifier/transfers_flow_test.rs | 6 ++-- .../src/blockifier_versioned_constants.rs | 2 +- crates/blockifier/src/bouncer.rs | 17 +++++------ crates/blockifier/src/bouncer_test.rs | 2 +- .../src/concurrency/worker_logic_test.rs | 2 +- .../deprecated_syscalls_test.rs | 11 ++++--- .../blockifier/src/execution/stack_trace.rs | 12 ++++---- .../syscalls/syscall_tests/builtins_test.rs | 2 +- .../syscall_tests/get_execution_info.rs | 2 +- crates/blockifier/src/fee/fee_utils.rs | 4 +-- .../src/state/native_class_manager.rs | 2 +- .../src/test_utils/test_templates.rs | 6 ++-- .../src/transaction/account_transaction.rs | 5 +--- crates/blockifier/src/transaction/errors.rs | 2 +- .../src/transaction/transactions_test.rs | 10 +++---- crates/blockifier/src/utils.rs | 4 +-- .../src/state_reader/offline_state_reader.rs | 3 +- .../src/state_reader/rpc_https_test.rs | 8 ++--- .../src/cairo_compile.rs | 2 +- .../src/cairo_versions.rs | 2 +- crates/blockifier_test_utils/src/contracts.rs | 2 +- .../feature_contracts_compatibility_test.rs | 5 ++-- .../src/py_block_executor.rs | 2 +- .../src/monitored_base_layer.rs | 4 +-- crates/papyrus_base_layer/src/test_utils.rs | 2 +- crates/papyrus_common/src/python_json.rs | 2 +- .../src/compare_endpoints.rs | 6 ++-- .../examples/get_transaction_hash.rs | 5 ++-- crates/starknet_api/src/contract_class.rs | 5 ++-- crates/starknet_api/src/core.rs | 16 +++++----- .../src/deprecated_contract_class.rs | 2 +- .../starknet_api/src/execution_resources.rs | 30 ++++++++----------- .../src/patricia_merkle_tree/types.rs | 2 +- .../src/block_hash_cli/run_block_hash_cli.rs | 2 +- .../src/committer_cli/tests/python_tests.rs | 13 ++++---- .../src/os_cli/commands.rs | 6 ++-- .../src/os_cli/tests/bls_field.rs | 2 +- .../src/shared_utils/types.rs | 4 +-- .../src/hint_processor/os_logger.rs | 2 +- .../compiled_class/implementation.rs | 2 +- .../execution/implementation.rs | 4 +-- crates/starknet_os/src/hints/vars.rs | 2 +- .../src/test_utils/cairo_runner.rs | 27 +++++++---------- .../patricia_merkle_tree/filled_tree/tree.rs | 8 ++--- .../src/patricia_merkle_tree/types_test.rs | 2 +- rust-toolchain.toml | 2 +- toml_test_utils/src/lib.rs | 2 +- 135 files changed, 335 insertions(+), 413 deletions(-) diff --git a/crates/apollo_batcher/src/batcher_test.rs b/crates/apollo_batcher/src/batcher_test.rs index 8644d06175a..cdba63505d8 100644 --- a/crates/apollo_batcher/src/batcher_test.rs +++ b/crates/apollo_batcher/src/batcher_test.rs @@ -323,30 +323,22 @@ fn assert_proposal_metrics( assert_eq!( started, Some(expected_started), - "unexpected value proposal_started, expected {} got {:?}", - expected_started, - started, + "unexpected value proposal_started, expected {expected_started} got {started:?}", ); assert_eq!( succeeded, Some(expected_succeeded), - "unexpected value proposal_succeeded, expected {} got {:?}", - expected_succeeded, - succeeded, + "unexpected value proposal_succeeded, expected {expected_succeeded} got {succeeded:?}", ); assert_eq!( failed, Some(expected_failed), - "unexpected value proposal_failed, expected {} got {:?}", - expected_failed, - failed, + "unexpected value proposal_failed, expected {expected_failed} got {failed:?}", ); assert_eq!( aborted, Some(expected_aborted), - "unexpected value proposal_aborted, expected {} got {:?}", - expected_aborted, - aborted, + "unexpected value proposal_aborted, expected {expected_aborted} got {aborted:?}", ); } diff --git a/crates/apollo_central_sync/src/sources/central/state_update_stream.rs b/crates/apollo_central_sync/src/sources/central/state_update_stream.rs index 254e46b9948..dd2f0c882c1 100644 --- a/crates/apollo_central_sync/src/sources/central/state_update_stream.rs +++ b/crates/apollo_central_sync/src/sources/central/state_update_stream.rs @@ -358,7 +358,7 @@ async fn download_class_if_necessary( // Check declared classes. if let Ok(Some(class)) = state_reader.get_class_definition_at(state_number, &class_hash) { - trace!("Class {:?} retrieved from storage.", class_hash); + trace!("Class {class_hash:?} retrieved from storage."); { let mut cache = cache.lock().expect("Failed to lock class cache."); cache.put(class_hash, ApiContractClass::ContractClass(class.clone())); @@ -370,7 +370,7 @@ async fn download_class_if_necessary( if let Ok(Some(class)) = state_reader.get_deprecated_class_definition_at(state_number, &class_hash) { - trace!("Deprecated class {:?} retrieved from storage.", class_hash); + trace!("Deprecated class {class_hash:?} retrieved from storage."); { let mut cache = cache.lock().expect("Failed to lock class cache."); cache.put(class_hash, ApiContractClass::DeprecatedContractClass(class.clone())); @@ -379,7 +379,7 @@ async fn download_class_if_necessary( } // Class not found in storage - download. - trace!("Downloading class {:?}.", class_hash); + trace!("Downloading class {class_hash:?}."); let client_class = apollo_starknet_client.class_by_hash(class_hash).await.map_err(Arc::new)?; match client_class { None => Ok(None), diff --git a/crates/apollo_central_sync/src/sources/central_test.rs b/crates/apollo_central_sync/src/sources/central_test.rs index c6512a25321..49c4bd01c9b 100644 --- a/crates/apollo_central_sync/src/sources/central_test.rs +++ b/crates/apollo_central_sync/src/sources/central_test.rs @@ -124,7 +124,7 @@ async fn stream_block_headers_some_are_missing() { (false, true, "signature missing"), ]; for (block_missing, signature_missing, test_case_description) in test_cases { - println!("Test case: {}", test_case_description); + println!("Test case: {test_case_description}"); const START_BLOCK_NUMBER: u64 = 5; const END_BLOCK_NUMBER: u64 = 13; const MISSING_BLOCK_NUMBER: u64 = 9; diff --git a/crates/apollo_class_manager/src/metrics.rs b/crates/apollo_class_manager/src/metrics.rs index bbc9eb1e2fb..132e25d2133 100644 --- a/crates/apollo_class_manager/src/metrics.rs +++ b/crates/apollo_class_manager/src/metrics.rs @@ -56,13 +56,12 @@ pub(crate) fn increment_n_classes(cls_type: CairoClassType) { pub(crate) fn record_class_size(class_type: ClassObjectType, class: &SerializedClass) { let class_size = class.size().unwrap_or_else(|_| { - panic!("Illegally formatted {} class, should not have gotten into the system.", class_type) + panic!("Illegally formatted {class_type} class, should not have gotten into the system.") }); let class_size = u32::try_from(class_size).unwrap_or_else(|_| { panic!( - "{} class size {} is bigger than what is allowed, - should not have gotten into the system.", - class_type, class_size + "{class_type} class size {class_size} is bigger than what is allowed, + should not have gotten into the system." ) }); diff --git a/crates/apollo_compilation_utils/src/build_utils.rs b/crates/apollo_compilation_utils/src/build_utils.rs index b420de3b773..b96e9619081 100644 --- a/crates/apollo_compilation_utils/src/build_utils.rs +++ b/crates/apollo_compilation_utils/src/build_utils.rs @@ -47,7 +47,7 @@ pub fn install_compiler_binary( .unwrap_or_else(|_| panic!("Failed to install {binary_name}")); if !install_command_status.success() { - panic!("Failed to install {}", binary_name); + panic!("Failed to install {binary_name}"); } // Move the '{binary_name}' executable to a shared location. @@ -59,7 +59,7 @@ pub fn install_compiler_binary( .expect("Failed to perform mv command."); if !move_command_status.success() { - panic!("Failed to move the {} binary to the shared folder.", binary_name); + panic!("Failed to move the {binary_name} binary to the shared folder."); } std::fs::remove_dir_all(temp_cargo_path).expect("Failed to remove the cargo directory."); diff --git a/crates/apollo_compilation_utils/src/compiler_utils.rs b/crates/apollo_compilation_utils/src/compiler_utils.rs index 44b08db8ae7..356bd11933a 100644 --- a/crates/apollo_compilation_utils/src/compiler_utils.rs +++ b/crates/apollo_compilation_utils/src/compiler_utils.rs @@ -46,7 +46,7 @@ pub fn compile_with_args( "Process exited with non-zero status but no signal (likely a handled error, e.g., \ memory allocation failure)." } - Some(sig) => &format!("Process terminated by unexpected signal: {}", sig), + Some(sig) => &format!("Process terminated by unexpected signal: {sig}"), }; let stderr_output = String::from_utf8(compile_output.stderr) diff --git a/crates/apollo_compilation_utils/src/resource_limits/resource_limits_test.rs b/crates/apollo_compilation_utils/src/resource_limits/resource_limits_test.rs index 39636212b07..980eecbc30d 100644 --- a/crates/apollo_compilation_utils/src/resource_limits/resource_limits_test.rs +++ b/crates/apollo_compilation_utils/src/resource_limits/resource_limits_test.rs @@ -19,7 +19,7 @@ fn test_cpu_time_limit() { let status = command.spawn().expect("Failed to start CPU consuming process").wait().unwrap(); assert!(start.elapsed().as_secs() <= cpu_limit); let signal = status.signal(); - assert_eq!(signal, Some(9), "Process should terminate with SIGKILL (9) got {:?}", signal); + assert_eq!(signal, Some(9), "Process should terminate with SIGKILL (9) got {signal:?}"); } #[rstest] @@ -34,7 +34,7 @@ fn test_memory_size_limit() { let output = command.output().expect("Failed to start memory consuming process"); let signal = output.status.signal(); - assert!(signal.is_none(), "Exceeding memory usage should not cause a signal, got {:?}", signal); + assert!(signal.is_none(), "Exceeding memory usage should not cause a signal, got {signal:?}"); let stderr = String::from_utf8_lossy(&output.stderr); @@ -66,7 +66,7 @@ fn test_file_size_limit() { let status = command.spawn().expect("Failed to start disk consuming process").wait().unwrap(); assert_eq!(std::fs::metadata(temp_file_path).unwrap().len(), file_limit); let signal = status.signal(); - assert!(signal == Some(25), "Process should terminate with SIGXFSZ (25), got {:?}", signal); + assert!(signal == Some(25), "Process should terminate with SIGXFSZ (25), got {signal:?}"); } #[rstest] diff --git a/crates/apollo_compile_to_casm/build.rs b/crates/apollo_compile_to_casm/build.rs index 0c41892886a..f2a4b703c49 100644 --- a/crates/apollo_compile_to_casm/build.rs +++ b/crates/apollo_compile_to_casm/build.rs @@ -26,7 +26,7 @@ fn install_starknet_sierra_compile() { // available only after the build is completed. Most importantly, it is available during runtime. fn set_run_time_out_dir_env_var() { let out_dir = std::env::var("OUT_DIR").expect("OUT_DIR is not set"); - println!("cargo:rustc-env=RUNTIME_ACCESSIBLE_OUT_DIR={}", out_dir); + println!("cargo:rustc-env=RUNTIME_ACCESSIBLE_OUT_DIR={out_dir}"); } // Returns the OUT_DIR. This function is only operable at build time. diff --git a/crates/apollo_compile_to_native/build_with_cairo_native.rs b/crates/apollo_compile_to_native/build_with_cairo_native.rs index 36e65ec9eda..c10a1a5219e 100644 --- a/crates/apollo_compile_to_native/build_with_cairo_native.rs +++ b/crates/apollo_compile_to_native/build_with_cairo_native.rs @@ -25,7 +25,7 @@ fn install_starknet_native_compile() { // available only after the build is completed. Most importantly, it is available during runtime. fn set_run_time_out_dir_env_var() { let out_dir = std::env::var("OUT_DIR").expect("OUT_DIR is not set"); - println!("cargo:rustc-env=RUNTIME_ACCESSIBLE_OUT_DIR={}", out_dir); + println!("cargo:rustc-env=RUNTIME_ACCESSIBLE_OUT_DIR={out_dir}"); } // Returns the OUT_DIR. This function is only operable at build time. diff --git a/crates/apollo_config/src/converters.rs b/crates/apollo_config/src/converters.rs index 3e5f1604191..14f3e8424ff 100644 --- a/crates/apollo_config/src/converters.rs +++ b/crates/apollo_config/src/converters.rs @@ -95,7 +95,7 @@ pub fn serialize_optional_vec_u8(optional_vector: &Option>) -> String { Some(vector) => { format!( "0x{}", - vector.iter().map(|num| format!("{:02x}", num)).collect::>().join("") + vector.iter().map(|num| format!("{num:02x}")).collect::>().join("") ) } } @@ -125,8 +125,7 @@ where let byte_str = &hex_str[i..i + 2]; let byte = u8::from_str_radix(byte_str, 16).map_err(|e| { D::Error::custom(format!( - "Couldn't deserialize vector. Failed to parse byte: {} {}", - byte_str, e + "Couldn't deserialize vector. Failed to parse byte: {byte_str} {e}" )) })?; vector.push(byte); diff --git a/crates/apollo_config/src/dumping.rs b/crates/apollo_config/src/dumping.rs index 856f91a858e..648870ff664 100644 --- a/crates/apollo_config/src/dumping.rs +++ b/crates/apollo_config/src/dumping.rs @@ -259,7 +259,7 @@ pub fn ser_generated_param( common_ser_param( name, SerializedContent::ParamType(serialization_type), - format!("{} If no value is provided, the system will generate one.", description).as_str(), + format!("{description} If no value is provided, the system will generate one.").as_str(), privacy.into(), ) } @@ -401,8 +401,7 @@ pub fn set_pointing_param_paths(param_path_list: &[&str]) -> Pointers { for ¶m_path in param_path_list { assert!( param_paths.insert(param_path.to_string()), - "Duplicate parameter path found: {}", - param_path + "Duplicate parameter path found: {param_path}" ); } param_paths @@ -412,7 +411,7 @@ pub fn set_pointing_param_paths(param_path_list: &[&str]) -> Pointers { pub(crate) const REQUIRED_PARAM_DESCRIPTION_PREFIX: &str = "A required param!"; pub(crate) fn required_param_description(description: &str) -> String { - format!("{} {}", REQUIRED_PARAM_DESCRIPTION_PREFIX, description) + format!("{REQUIRED_PARAM_DESCRIPTION_PREFIX} {description}") } /// Verifies that params whose name matches a pointer target either point at it, or are whitelisted. @@ -434,9 +433,8 @@ fn verify_pointing_params_by_name( assert!( serialized_param.content == SerializedContent::PointerTarget(target_param.to_owned()), - "The target param {} should point to {}, or to be whitelisted.", - param_path, - target_param + "The target param {param_path} should point to {target_param}, or to be \ + whitelisted." ); }; } diff --git a/crates/apollo_config/src/test_utils.rs b/crates/apollo_config/src/test_utils.rs index 771d0a593d8..07aefa96fe8 100644 --- a/crates/apollo_config/src/test_utils.rs +++ b/crates/apollo_config/src/test_utils.rs @@ -45,6 +45,6 @@ pub fn assert_default_config_file_is_up_to_date( "Diffs shown below (default config file <<>> dump of {}::default()).", std::any::type_name::() ); - let error_message = format!("{}\n{}", update_instructions, file_names_on_diff); + let error_message = format!("{update_instructions}\n{file_names_on_diff}"); assert_json_eq(&from_default_config_file, &from_code, error_message); } diff --git a/crates/apollo_config/src/validators.rs b/crates/apollo_config/src/validators.rs index 93b2fcab6b3..4ff5a10cb2c 100644 --- a/crates/apollo_config/src/validators.rs +++ b/crates/apollo_config/src/validators.rs @@ -72,7 +72,7 @@ impl std::fmt::Display for ParsedValidationErrors { )); } error_string = error_string.replace('\"', ""); - write!(f, "{}", error_string) + write!(f, "{error_string}") } } @@ -106,7 +106,7 @@ fn parse_validation_error( let new_path = if current_path.is_empty() { field.to_string() } else { - format!("{}.{}", current_path, field) + format!("{current_path}.{field}") }; match error { @@ -115,11 +115,7 @@ fn parse_validation_error( } ValidationErrorsKind::List(errors) => { for (index, error) in errors.iter().enumerate() { - parse_validation_error( - error.1, - format!("{}[{}]", new_path, index), - parsed_errors, - ); + parse_validation_error(error.1, format!("{new_path}[{index}]"), parsed_errors); } } ValidationErrorsKind::Field(errors) => { @@ -131,8 +127,8 @@ fn parse_validation_error( params: { let params = &error.params; params - .iter() - .map(|(_k, v)| v.to_string().replace('\"', "")) + .values() + .map(|v| v.to_string().replace('\"', "")) .collect::>() .join(", ") } diff --git a/crates/apollo_consensus/src/bin/run_simulation.rs b/crates/apollo_consensus/src/bin/run_simulation.rs index a1eccc33a33..fcad5da8458 100644 --- a/crates/apollo_consensus/src/bin/run_simulation.rs +++ b/crates/apollo_consensus/src/bin/run_simulation.rs @@ -254,7 +254,7 @@ async fn run_simulation( should_break = async { tokio::time::sleep(Duration::from_secs(MONITORING_PERIOD_SECONDS)).await; let elapsed = start_time.elapsed().as_secs(); - println!("\nTime elapsed: {}s", elapsed); + println!("\nTime elapsed: {elapsed}s"); monitor_simulation(&mut nodes, start_time, max_test_duration, stagnation_timeout).await } => { @@ -278,7 +278,7 @@ async fn build_node(data_dir: &str, logs_dir: &str, i: usize, papyrus_args: &Pap let is_bootstrap = i == 1; let port = if is_bootstrap { *BOOTNODE_TCP_PORT } else { find_free_port() }; let monitoring_gateway_server_port = find_free_port(); - let data_dir = format!("{}/data{}", data_dir, i); + let data_dir = format!("{data_dir}/data{i}"); let validator_id = i + usize::try_from(DEFAULT_VALIDATOR_ID).expect("Conversion failed"); let mut cmd = format!( @@ -303,7 +303,7 @@ async fn build_node(data_dir: &str, logs_dir: &str, i: usize, papyrus_args: &Pap ]; for (key, value) in conditional_params { if let Some(v) = value { - cmd.push_str(&format!("--consensus.{} {} ", key, v)); + cmd.push_str(&format!("--consensus.{key} {v} ")); } } @@ -319,15 +319,14 @@ async fn build_node(data_dir: &str, logs_dir: &str, i: usize, papyrus_args: &Pap ]; for (key, value) in conditional_test_params { if let Some(v) = value { - cmd.push_str(&format!("--test.{} {} ", key, v)); + cmd.push_str(&format!("--test.{key} {v} ")); } } if is_bootstrap { cmd.push_str(&format!( - "--network.secret_key {} 2>&1 | sed -r 's/\\x1B\\[[0-9;]*[mK]//g' > \ - {}/validator0x{:x}.txt", - SECRET_KEY, logs_dir, validator_id + "--network.secret_key {SECRET_KEY} 2>&1 | sed -r 's/\\x1B\\[[0-9;]*[mK]//g' > \ + {logs_dir}/validator0x{validator_id:x}.txt" )); } else { cmd.push_str(&format!( @@ -385,11 +384,11 @@ fn setup_artifact_dirs(papyrus_args: &PapyrusArgs) -> (String, LockDir) { .map(|d| d.file_name().into_string().unwrap()) .collect(); let expected_dirs: HashSet<_> = - (0..papyrus_args.num_validators).map(|i| format!("data{}", i)).collect(); + (0..papyrus_args.num_validators).map(|i| format!("data{i}")).collect(); assert!(expected_dirs.is_subset(&actual_dirs), "{db_dir} must contain: {expected_dirs:?}"); } else { for i in 0..papyrus_args.num_validators { - fs::create_dir_all(format!("{}/data{}", db_dir, i)).unwrap(); + fs::create_dir_all(format!("{db_dir}/data{i}")).unwrap(); } } let db_lock = LockDir::new(db_dir).unwrap(); diff --git a/crates/apollo_consensus/src/single_height_consensus.rs b/crates/apollo_consensus/src/single_height_consensus.rs index d014cef7064..6c98d2c35a5 100644 --- a/crates/apollo_consensus/src/single_height_consensus.rs +++ b/crates/apollo_consensus/src/single_height_consensus.rs @@ -563,8 +563,7 @@ impl SingleHeightConsensus { }; if let Some(old) = votes.insert((round, self.id), vote.clone()) { return Err(ConsensusError::InternalInconsistency(format!( - "State machine should not send repeat votes: old={:?}, new={:?}", - old, vote + "State machine should not send repeat votes: old={old:?}, new={vote:?}" ))); } *last_vote = match last_vote { @@ -575,8 +574,8 @@ impl SingleHeightConsensus { // current round. It should monotonicly increase its round. It should only vote once // per step. return Err(ConsensusError::InternalInconsistency(format!( - "State machine must progress in time: last_vote: {:?} new_vote: {:?}", - last_vote, vote, + "State machine must progress in time: last_vote: {last_vote:?} new_vote: \ + {vote:?}", ))); } }; diff --git a/crates/apollo_consensus/src/state_machine.rs b/crates/apollo_consensus/src/state_machine.rs index f6e7c450ae1..afb226d0c19 100644 --- a/crates/apollo_consensus/src/state_machine.rs +++ b/crates/apollo_consensus/src/state_machine.rs @@ -228,7 +228,7 @@ impl StateMachine { { trace!("Processing event: {:?}", event); if self.awaiting_get_proposal { - assert!(matches!(event, StateMachineEvent::GetProposal(_, _)), "{:?}", event); + assert!(matches!(event, StateMachineEvent::GetProposal(_, _)), "{event:?}"); } match event { diff --git a/crates/apollo_consensus/src/stream_handler.rs b/crates/apollo_consensus/src/stream_handler.rs index e1f9daaf0ff..e5552c46902 100644 --- a/crates/apollo_consensus/src/stream_handler.rs +++ b/crates/apollo_consensus/src/stream_handler.rs @@ -271,7 +271,7 @@ where ); } else { // TODO(guyn): replace panic with more graceful error handling - panic!("Unexpected error: {:?}", e); + panic!("Unexpected error: {e:?}"); } } }; diff --git a/crates/apollo_consensus_manager/src/consensus_manager.rs b/crates/apollo_consensus_manager/src/consensus_manager.rs index cc668cd7781..e48dd176770 100644 --- a/crates/apollo_consensus_manager/src/consensus_manager.rs +++ b/crates/apollo_consensus_manager/src/consensus_manager.rs @@ -204,10 +204,10 @@ impl ConsensusManager { } }, network_result = network_task => { - panic!("Consensus' network task finished unexpectedly: {:?}", network_result); + panic!("Consensus' network task finished unexpectedly: {network_result:?}"); } stream_handler_result = stream_handler_task => { - panic!("Consensus' stream handler task finished unexpectedly: {:?}", stream_handler_result); + panic!("Consensus' stream handler task finished unexpectedly: {stream_handler_result:?}"); } } } @@ -264,6 +264,6 @@ impl ComponentStarter for ConsensusManager { info!("Starting component {}.", short_type_name::()); self.run() .await - .unwrap_or_else(|e| panic!("Failed to start ConsensusManager component: {:?}", e)) + .unwrap_or_else(|e| panic!("Failed to start ConsensusManager component: {e:?}")) } } diff --git a/crates/apollo_dashboard/src/metric_definitions_test.rs b/crates/apollo_dashboard/src/metric_definitions_test.rs index 3a760714d82..94ceeb20450 100644 --- a/crates/apollo_dashboard/src/metric_definitions_test.rs +++ b/crates/apollo_dashboard/src/metric_definitions_test.rs @@ -38,6 +38,6 @@ fn metric_names_no_duplications() { let mut unique_metric_names: HashSet<&&'static str> = HashSet::new(); for metric_name in all_metric_names { - assert!(unique_metric_names.insert(metric_name), "Duplicated metric name: {}", metric_name); + assert!(unique_metric_names.insert(metric_name), "Duplicated metric name: {metric_name}"); } } diff --git a/crates/apollo_deployments/src/addresses.rs b/crates/apollo_deployments/src/addresses.rs index 60ac9e08977..d963a5c43c7 100644 --- a/crates/apollo_deployments/src/addresses.rs +++ b/crates/apollo_deployments/src/addresses.rs @@ -11,7 +11,7 @@ impl TryFrom<&str> for SecretKey { fn try_from(hex_str: &str) -> Result { let bytes = hex::decode(hex_str.strip_prefix("0x").unwrap_or(hex_str)) - .map_err(|e| format!("Invalid hex: {}", e))?; + .map_err(|e| format!("Invalid hex: {e}"))?; if bytes.len() != 32 { return Err(format!("Expected 32 bytes, got {}", bytes.len())); } @@ -52,5 +52,5 @@ pub(crate) fn get_peer_id(secret_key: SecretKey) -> String { } pub(crate) fn get_p2p_address(dns: &str, port: u16, peer_id: &str) -> String { - format!("/dns/{}/tcp/{}/p2p/{}", dns, port, peer_id) + format!("/dns/{dns}/tcp/{port}/p2p/{peer_id}") } diff --git a/crates/apollo_deployments/src/deployment.rs b/crates/apollo_deployments/src/deployment.rs index 3e5799b1761..5f5b90c39a3 100644 --- a/crates/apollo_deployments/src/deployment.rs +++ b/crates/apollo_deployments/src/deployment.rs @@ -164,7 +164,7 @@ impl Display for PragmaDomain { PragmaDomain::Dev => "devnet", PragmaDomain::Prod => "production", }; - write!(f, "{}", s) + write!(f, "{s}") } } @@ -174,7 +174,7 @@ pub(crate) fn build_service_namespace_domain_address( namespace: &str, domain: &str, ) -> String { - format!("{}.{}.{}", service_name, namespace, domain) + format!("{service_name}.{namespace}.{domain}") } // TODO(Tsabary): when transitioning runnings nodes in different clusters, this enum should be diff --git a/crates/apollo_deployments/src/deployments/hybrid.rs b/crates/apollo_deployments/src/deployments/hybrid.rs index 5f64b40b8cb..2410d23478c 100644 --- a/crates/apollo_deployments/src/deployments/hybrid.rs +++ b/crates/apollo_deployments/src/deployments/hybrid.rs @@ -414,9 +414,7 @@ pub(crate) fn create_hybrid_instance_config_override( ) -> InstanceConfigOverride { assert!( node_id < MAX_NODE_ID, - "Node node_id {} exceeds the number of nodes {}", - node_id, - MAX_NODE_ID + "Node node_id {node_id} exceeds the number of nodes {MAX_NODE_ID}" ); // TODO(Tsabary): these ports should be derived from the hybrid deployment module, and used diff --git a/crates/apollo_deployments/src/service.rs b/crates/apollo_deployments/src/service.rs index 80c2a857932..e52c17de386 100644 --- a/crates/apollo_deployments/src/service.rs +++ b/crates/apollo_deployments/src/service.rs @@ -273,7 +273,7 @@ pub(crate) trait ServiceNameInner: Display { // Kubernetes service name as defined by CDK8s. fn k8s_service_name(&self) -> String { let formatted_service_name = self.to_string().replace('_', ""); - format!("sequencer-{}-service", formatted_service_name) + format!("sequencer-{formatted_service_name}-service") } } @@ -291,7 +291,7 @@ impl DeploymentName { let deployment_with_instance = deployment_name_dir.join(instance_name); let s = deployment_with_instance.to_string_lossy(); - let modified = if s.ends_with('/') { s.into_owned() } else { format!("{}/", s) }; + let modified = if s.ends_with('/') { s.into_owned() } else { format!("{s}/") }; modified.into() } diff --git a/crates/apollo_deployments/src/utils.rs b/crates/apollo_deployments/src/utils.rs index bee93004538..edfa536f9cd 100644 --- a/crates/apollo_deployments/src/utils.rs +++ b/crates/apollo_deployments/src/utils.rs @@ -36,7 +36,7 @@ pub(crate) fn determine_port_numbers( ); let unique: HashSet<_> = v.iter().cloned().collect(); - assert!(unique.len() == v.len(), "Vector contains duplicate values: {:?}", v); + assert!(unique.len() == v.len(), "Vector contains duplicate values: {v:?}"); v } diff --git a/crates/apollo_gateway/src/errors.rs b/crates/apollo_gateway/src/errors.rs index c6858c8e2aa..92416bbb9d6 100644 --- a/crates/apollo_gateway/src/errors.rs +++ b/crates/apollo_gateway/src/errors.rs @@ -102,7 +102,7 @@ impl From for GatewaySpecError { impl From for StarknetError { fn from(e: StatelessTransactionValidatorError) -> Self { - let message = format!("{}", e); + let message = format!("{e}"); let code = match e { StatelessTransactionValidatorError::ContractBytecodeSizeTooLarge { .. } => { StarknetErrorCode::KnownErrorCode( @@ -217,7 +217,7 @@ pub fn mempool_client_result_to_gw_spec_result( } pub fn mempool_client_err_to_deprecated_gw_err(err: MempoolClientError) -> StarknetError { - let message = format!("{}", err); + let message = format!("{err}"); let code = match err { MempoolClientError::ClientError(client_error) => { error!("Mempool client error: {}", client_error); diff --git a/crates/apollo_gateway/src/stateful_transaction_validator_test.rs b/crates/apollo_gateway/src/stateful_transaction_validator_test.rs index 2fdda4ff918..799e445e3c5 100644 --- a/crates/apollo_gateway/src/stateful_transaction_validator_test.rs +++ b/crates/apollo_gateway/src/stateful_transaction_validator_test.rs @@ -74,7 +74,7 @@ async fn test_stateful_tx_validator( .map(|validate_result| *validate_result) .map_err(|blockifier_error| StarknetError { code: StarknetErrorCode::KnownErrorCode(KnownStarknetErrorCode::ValidateFailure), - message: format!("{}", blockifier_error), + message: format!("{blockifier_error}"), }); let mut mock_validator = MockStatefulTransactionValidatorTrait::new(); diff --git a/crates/apollo_http_server/src/http_server.rs b/crates/apollo_http_server/src/http_server.rs index f144619f89d..019da06b4f6 100644 --- a/crates/apollo_http_server/src/http_server.rs +++ b/crates/apollo_http_server/src/http_server.rs @@ -205,7 +205,7 @@ pub fn create_http_server( impl ComponentStarter for HttpServer { async fn start(&mut self) { info!("Starting component {}.", short_type_name::()); - self.run().await.unwrap_or_else(|e| panic!("Failed to start HttpServer component: {:?}", e)) + self.run().await.unwrap_or_else(|e| panic!("Failed to start HttpServer component: {e:?}")) } } diff --git a/crates/apollo_http_server/src/http_server_test.rs b/crates/apollo_http_server/src/http_server_test.rs index 2726c6a29ad..c23011c2a1d 100644 --- a/crates/apollo_http_server/src/http_server_test.rs +++ b/crates/apollo_http_server/src/http_server_test.rs @@ -99,7 +99,7 @@ async fn error_into_response() { let body = to_bytes(response).await; let json: Value = serde_json::from_slice(&body).unwrap(); - assert!(!status.is_success(), "{:?}", status); + assert!(!status.is_success(), "{status:?}"); assert_eq!( json.get("code").unwrap(), &serde_json::to_value(&KnownStarknetErrorCode::MalformedRequest).unwrap() @@ -140,7 +140,7 @@ async fn record_region_test(#[case] index: u16, #[case] tx: impl GatewayTransact let region = "test"; http_client.add_tx_with_headers(tx, [(CLIENT_REGION_HEADER, region)]).await; assert!(logs_contain( - format!("Recorded transaction transaction_hash={} region={}", tx_hash_2, region).as_str() + format!("Recorded transaction transaction_hash={tx_hash_2} region={region}").as_str() )); } diff --git a/crates/apollo_http_server/src/test_utils.rs b/crates/apollo_http_server/src/test_utils.rs index 9c5c981ddff..31b9a8a7449 100644 --- a/crates/apollo_http_server/src/test_utils.rs +++ b/crates/apollo_http_server/src/test_utils.rs @@ -35,7 +35,7 @@ impl HttpTestClient { assert!(response.status().is_success(), "{:?}", response.status()); let text = response.text().await.unwrap(); let response: GatewayOutput = serde_json::from_str(&text) - .unwrap_or_else(|_| panic!("Gateway responded with: {}", text)); + .unwrap_or_else(|_| panic!("Gateway responded with: {text}")); response.transaction_hash() } diff --git a/crates/apollo_infra/src/component_client/remote_component_client.rs b/crates/apollo_infra/src/component_client/remote_component_client.rs index 4406030edfb..9b4e4e72fc3 100644 --- a/crates/apollo_infra/src/component_client/remote_component_client.rs +++ b/crates/apollo_infra/src/component_client/remote_component_client.rs @@ -181,7 +181,7 @@ where port: u16, metrics: RemoteClientMetrics, ) -> Self { - let uri = format!("http://{}:{}/", url, port).parse().unwrap(); + let uri = format!("http://{url}:{port}/").parse().unwrap(); let client = Client::builder() .http2_only(true) .pool_max_idle_per_host(config.idle_connections) diff --git a/crates/apollo_infra/src/component_server/remote_component_server.rs b/crates/apollo_infra/src/component_server/remote_component_server.rs index 52ad2956a24..8d6728560e4 100644 --- a/crates/apollo_infra/src/component_server/remote_component_server.rs +++ b/crates/apollo_infra/src/component_server/remote_component_server.rs @@ -201,8 +201,7 @@ where } Err(error) => { panic!( - "Remote server failed sending with its local client. Error: {:?}", - error + "Remote server failed sending with its local client. Error: {error:?}" ); } } @@ -262,7 +261,7 @@ where Server::bind(&self.socket) .serve(make_svc) .await - .unwrap_or_else(|e| panic!("HttpServerStartError: {}", e)); + .unwrap_or_else(|e| panic!("HttpServerStartError: {e}")); } } diff --git a/crates/apollo_infra/src/tests/server_metrics_test.rs b/crates/apollo_infra/src/tests/server_metrics_test.rs index 70982e82d80..8ca78607507 100644 --- a/crates/apollo_infra/src/tests/server_metrics_test.rs +++ b/crates/apollo_infra/src/tests/server_metrics_test.rs @@ -195,21 +195,18 @@ fn assert_server_metrics( assert_eq!( received_msgs, usize_to_u64(expected_received_msgs), - "unexpected value for receives_msgs_started counter, expected {} got {:?}", - expected_received_msgs, - received_msgs, + "unexpected value for receives_msgs_started counter, expected {expected_received_msgs} \ + got {received_msgs:?}" ); assert_eq!( processed_msgs, usize_to_u64(expected_processed_msgs), - "unexpected value for processed_msgs counter, expected {} got {:?}", - expected_processed_msgs, - processed_msgs, + "unexpected value for processed_msgs counter, expected {expected_processed_msgs} got \ + {processed_msgs:?}" ); assert_eq!( queue_depth, expected_queue_depth, - "unexpected value for queue_depth, expected {} got {:?}", - expected_queue_depth, queue_depth, + "unexpected value for queue_depth, expected {expected_queue_depth} got {queue_depth:?}" ); } @@ -228,23 +225,20 @@ fn assert_remote_server_metrics( assert_eq!( total_received_msgs, usize_to_u64(expected_total_received_msgs), - "unexpected value for total_receives_msgs_started counter, expected {} got {:?}", - expected_total_received_msgs, - total_received_msgs, + "unexpected value for total_receives_msgs_started counter, expected \ + {expected_total_received_msgs} got {total_received_msgs:?}" ); assert_eq!( valid_received_msgs, usize_to_u64(expected_valid_received_msgs), - "unexpected value for valid_receives_msgs_started counter, expected {} got {:?}", - expected_total_received_msgs, - valid_received_msgs, + "unexpected value for valid_receives_msgs_started counter, expected \ + {expected_total_received_msgs} got {valid_received_msgs:?}" ); assert_eq!( processed_msgs, usize_to_u64(expected_processed_msgs), - "unexpected value for processed_msgs counter, expected {} got {:?}", - expected_processed_msgs, - processed_msgs, + "unexpected value for processed_msgs counter, expected {expected_processed_msgs} got \ + {processed_msgs:?}" ); } diff --git a/crates/apollo_infra_utils/src/dumping.rs b/crates/apollo_infra_utils/src/dumping.rs index 7444ab82258..517721c886c 100644 --- a/crates/apollo_infra_utils/src/dumping.rs +++ b/crates/apollo_infra_utils/src/dumping.rs @@ -40,13 +40,13 @@ pub fn serialize_to_file(data: T, file_path: &str) { // Ensure the parent directory exists if let Some(parent) = PathBuf::from(file_path).parent() { create_dir_all(parent).unwrap_or_else(|err| { - panic!("Failed to create directory for {}: {}", file_path, err); + panic!("Failed to create directory for {file_path}: {err}"); }); } // Create file writer. let file = File::create(file_path) - .unwrap_or_else(|err| panic!("Failed generating data file: {:?}: {}", file_path, err)); + .unwrap_or_else(|err| panic!("Failed generating data file: {file_path:?}: {err}")); let mut writer = BufWriter::new(file); @@ -60,7 +60,7 @@ pub fn serialize_to_file(data: T, file_path: &str) { // Write to file. writer.flush().expect("Should have been able to flush the writer."); - assert!(PathBuf::from(&file_path).exists(), "Failed generating data file: {:?}", file_path); + assert!(PathBuf::from(&file_path).exists(), "Failed generating data file: {file_path:?}"); - println!("Generated data file: {:?}", file_path); + println!("Generated data file: {file_path:?}"); } diff --git a/crates/apollo_infra_utils/src/path_test.rs b/crates/apollo_infra_utils/src/path_test.rs index 81330072628..fdff4d078dc 100644 --- a/crates/apollo_infra_utils/src/path_test.rs +++ b/crates/apollo_infra_utils/src/path_test.rs @@ -7,7 +7,7 @@ fn resolve_project_relative_path_on_non_existent_path() { assert!(!expected_path.exists()); let result = resolve_project_relative_path(relative_path); - assert!(result.is_err(), "Expected an non-existent path error, got {:?}", result); + assert!(result.is_err(), "Expected an non-existent path error, got {result:?}"); } #[test] diff --git a/crates/apollo_infra_utils/src/run_until.rs b/crates/apollo_infra_utils/src/run_until.rs index a4fb3ee951d..8a0e70d6060 100644 --- a/crates/apollo_infra_utils/src/run_until.rs +++ b/crates/apollo_infra_utils/src/run_until.rs @@ -39,16 +39,14 @@ where // Log attempt message. if let Some(config) = &logger { - let attempt_message = - format!("Attempt {}/{}, Value {:?}", attempt, max_attempts, result); + let attempt_message = format!("Attempt {attempt}/{max_attempts}, Value {result:?}"); config.log_message(&attempt_message); } // Check if the condition is met. if condition(&result) { if let Some(config) = &logger { - let success_message = - format!("Condition met on attempt {}/{}", attempt, max_attempts); + let success_message = format!("Condition met on attempt {attempt}/{max_attempts}"); config.log_message(&success_message); } return Some(result); @@ -60,7 +58,7 @@ where if let Some(config) = &logger { let failure_message = - format!("Condition not met after the maximum number of {} attempts.", max_attempts); + format!("Condition not met after the maximum number of {max_attempts} attempts."); config.log_message(&failure_message); } diff --git a/crates/apollo_infra_utils/src/test_utils.rs b/crates/apollo_infra_utils/src/test_utils.rs index 192ee518fb5..8ca0ca74163 100644 --- a/crates/apollo_infra_utils/src/test_utils.rs +++ b/crates/apollo_infra_utils/src/test_utils.rs @@ -47,15 +47,11 @@ impl AvailablePorts { pub fn new(test_unique_index: u16, instance_index: u16) -> Self { assert!( test_unique_index < MAX_NUMBER_OF_TESTS, - "Test unique index {:?} exceeded bound {:?}", - test_unique_index, - MAX_NUMBER_OF_TESTS + "Test unique index {test_unique_index:?} exceeded bound {MAX_NUMBER_OF_TESTS:?}" ); assert!( instance_index < MAX_NUMBER_OF_INSTANCES_PER_TEST, - "Instance index {:?} exceeded bound {:?}", - instance_index, - MAX_NUMBER_OF_INSTANCES_PER_TEST + "Instance index {instance_index:?} exceeded bound {MAX_NUMBER_OF_INSTANCES_PER_TEST:?}", ); let test_offset: u16 = @@ -140,7 +136,7 @@ where Rhs: Serialize, { if let Err(error) = assert_json_matches_no_panic(lhs, rhs, Config::new(CompareMode::Strict)) { - let printed_error = format!("\n\n{}\n{}\n\n", message, error); + let printed_error = format!("\n\n{message}\n{error}\n\n"); panic!("{}", printed_error); } } diff --git a/crates/apollo_infra_utils/src/tracing.rs b/crates/apollo_infra_utils/src/tracing.rs index 82906349422..f91c0d72448 100644 --- a/crates/apollo_infra_utils/src/tracing.rs +++ b/crates/apollo_infra_utils/src/tracing.rs @@ -20,7 +20,7 @@ impl CustomLogger { /// it exists. pub fn log_message(&self, message: &str) { let message = match &self.base_message { - Some(base_message) => format!("{}: {}", base_message, message), + Some(base_message) => format!("{base_message}: {message}"), None => message.to_string(), }; diff --git a/crates/apollo_infra_utils/src/tracing_test.rs b/crates/apollo_infra_utils/src/tracing_test.rs index 422a2da5c0e..50060452387 100644 --- a/crates/apollo_infra_utils/src/tracing_test.rs +++ b/crates/apollo_infra_utils/src/tracing_test.rs @@ -102,7 +102,7 @@ struct MessageVisitor<'a> { impl Visit for MessageVisitor<'_> { fn record_debug(&mut self, field: &Field, value: &dyn Debug) { if field.name() == "message" { - self.message.push_str(&format!("{:?}", value)); + self.message.push_str(&format!("{value:?}")); } } } diff --git a/crates/apollo_integration_tests/src/bin/sequencer_node_end_to_end_integration_tests/integration_test_restart_flow.rs b/crates/apollo_integration_tests/src/bin/sequencer_node_end_to_end_integration_tests/integration_test_restart_flow.rs index 7c191cce3dd..e44ae8ec263 100644 --- a/crates/apollo_integration_tests/src/bin/sequencer_node_end_to_end_integration_tests/integration_test_restart_flow.rs +++ b/crates/apollo_integration_tests/src/bin/sequencer_node_end_to_end_integration_tests/integration_test_restart_flow.rs @@ -171,8 +171,7 @@ async fn verify_running_nodes_received_more_txs( info!("Node {} processed {} transactions", node_idx, curr_n_processed); assert!( curr_n_processed > prev_n_processed, - "Node {} did not process more transactions", - node_idx + "Node {node_idx} did not process more transactions" ); } } diff --git a/crates/apollo_integration_tests/src/bin/sequencer_node_setup.rs b/crates/apollo_integration_tests/src/bin/sequencer_node_setup.rs index 3f31ab0de66..f9f7e9fcbac 100644 --- a/crates/apollo_integration_tests/src/bin/sequencer_node_setup.rs +++ b/crates/apollo_integration_tests/src/bin/sequencer_node_setup.rs @@ -41,7 +41,7 @@ async fn main() { info!("Generate simulator ports json files under {:?}", simulator_config_file); create_dir_all(&simulator_config_file).await.unwrap(); for (node_index, node_setup) in test_manager.get_idle_nodes().iter() { - let path = format!("{}/node_{}", simulator_config_file, node_index); + let path = format!("{simulator_config_file}/node_{node_index}"); node_setup.generate_simulator_ports_json(&path); } diff --git a/crates/apollo_integration_tests/src/bin/sequencer_simulator.rs b/crates/apollo_integration_tests/src/bin/sequencer_simulator.rs index 6fa40825e33..4e5e4bc8d0e 100644 --- a/crates/apollo_integration_tests/src/bin/sequencer_simulator.rs +++ b/crates/apollo_integration_tests/src/bin/sequencer_simulator.rs @@ -25,13 +25,13 @@ fn read_ports_from_file(path: &str) -> (u16, u16) { let http_port: u16 = json[HTTP_PORT_ARG] .as_u64() - .unwrap_or_else(|| panic!("http port should be available in {}", path)) + .unwrap_or_else(|| panic!("http port should be available in {path}")) .try_into() .expect("http port should be within the valid range for u16"); let monitoring_port: u16 = json[MONITORING_PORT_ARG] .as_u64() - .unwrap_or_else(|| panic!("monitoring port should be available in {}", path)) + .unwrap_or_else(|| panic!("monitoring port should be available in {path}")) .try_into() .expect("monitoring port should be within the valid range for u16"); diff --git a/crates/apollo_integration_tests/src/flow_test_setup.rs b/crates/apollo_integration_tests/src/flow_test_setup.rs index d4929a154ae..9bdbad0d129 100644 --- a/crates/apollo_integration_tests/src/flow_test_setup.rs +++ b/crates/apollo_integration_tests/src/flow_test_setup.rs @@ -382,12 +382,11 @@ impl TxCollector { assert_eq!( incoming_message_id, 0, - "Expected the first message in the stream to have id 0, got {}", - incoming_message_id + "Expected the first message in the stream to have id 0, got {incoming_message_id}" ); let StreamMessageBody::Content(ProposalPart::Init(incoming_proposal_init)) = init_message else { - panic!("Expected an init message. Got: {:?}", init_message) + panic!("Expected an init message. Got: {init_message:?}") }; self.accumulated_txs @@ -403,7 +402,7 @@ impl TxCollector { assert_eq!(stream_id, first_stream_id, "Expected the same stream id for all messages"); match message { StreamMessageBody::Content(ProposalPart::Init(init)) => { - panic!("Unexpected init: {:?}", init) + panic!("Unexpected init: {init:?}") } StreamMessageBody::Content(ProposalPart::Fin(..)) => { got_proposal_fin = true; diff --git a/crates/apollo_integration_tests/src/integration_test_manager.rs b/crates/apollo_integration_tests/src/integration_test_manager.rs index 66b933c891d..01d90656afc 100644 --- a/crates/apollo_integration_tests/src/integration_test_manager.rs +++ b/crates/apollo_integration_tests/src/integration_test_manager.rs @@ -121,10 +121,7 @@ impl NodeSetup { fn validate_index(index: usize, len: usize, label: &str) { assert!( index < len, - "{} index {} is out of range. There are {} executables.", - label, - index, - len + "{label} index {index} is out of range. There are {len} executables." ); } @@ -327,13 +324,12 @@ impl IntegrationTestManager { let node_setup = self .idle_nodes .remove(&index) - .unwrap_or_else(|| panic!("Node {} does not exist in idle_nodes.", index)); + .unwrap_or_else(|| panic!("Node {index} does not exist in idle_nodes.")); info!("Running node {}.", index); let running_node = node_setup.run(); assert!( self.running_nodes.insert(index, running_node).is_none(), - "Node {} is already in the running map.", - index + "Node {index} is already in the running map." ); }); @@ -354,7 +350,7 @@ impl IntegrationTestManager { let node_setup = self .idle_nodes .get_mut(&node_index) - .unwrap_or_else(|| panic!("Node {} does not exist in idle_nodes.", node_index)); + .unwrap_or_else(|| panic!("Node {node_index} does not exist in idle_nodes.")); node_setup.executables.iter_mut().for_each(|executable| { info!("Modifying {} config.", executable.node_execution_id); executable.modify_config(modify_config_fn); @@ -375,7 +371,7 @@ impl IntegrationTestManager { let node_setup = self .idle_nodes .get_mut(&node_index) - .unwrap_or_else(|| panic!("Node {} does not exist in idle_nodes.", node_index)); + .unwrap_or_else(|| panic!("Node {node_index} does not exist in idle_nodes.")); node_setup.executables.iter_mut().for_each(|executable| { info!("Modifying {} config pointers.", executable.node_execution_id); executable.modify_config_pointers(modify_config_pointers_fn); @@ -455,15 +451,14 @@ impl IntegrationTestManager { let running_node = self .running_nodes .remove(&index) - .unwrap_or_else(|| panic!("Node {} is not in the running map.", index)); + .unwrap_or_else(|| panic!("Node {index} is not in the running map.")); running_node.executable_handles.iter().for_each(|handle| { - assert!(!handle.is_finished(), "Node {} should still be running.", index); + assert!(!handle.is_finished(), "Node {index} should still be running."); handle.abort(); }); assert!( self.idle_nodes.insert(index, running_node.node_setup).is_none(), - "Node {} is already in the idle map.", - index + "Node {index} is already in the idle map." ); info!("Node {} has been shut down.", index); }); diff --git a/crates/apollo_integration_tests/src/sequencer_simulator_utils.rs b/crates/apollo_integration_tests/src/sequencer_simulator_utils.rs index 4e0708ab0ee..33666fdc05e 100644 --- a/crates/apollo_integration_tests/src/sequencer_simulator_utils.rs +++ b/crates/apollo_integration_tests/src/sequencer_simulator_utils.rs @@ -96,10 +96,8 @@ fn get_socket_addr(url_str: &str, port: u16) -> Result (Url, JoinHandle<()>) { // [127, 0, 0, 1] is the localhost IP address. let socket_address = SocketAddr::from(([127, 0, 0, 1], port)); // TODO(Tsabary): create a socket-to-url function. - let url = Url::parse(&format!("http://{}", socket_address)).unwrap(); + let url = Url::parse(&format!("http://{socket_address}")).unwrap(); let join_handle = spawn_success_recorder(socket_address); (url, join_handle) } @@ -350,7 +350,7 @@ async fn get_price(Query(query): Query) -> Json JoinHandle /// Starts the fake eth to fri oracle server and returns its URL and handle. pub fn spawn_local_eth_to_strk_oracle(port: u16) -> (Url, JoinHandle<()>) { let socket_address = SocketAddr::from(([127, 0, 0, 1], port)); - let url = Url::parse(&format!("http://{}{}", socket_address, ETH_TO_STRK_ORACLE_PATH)).unwrap(); + let url = Url::parse(&format!("http://{socket_address}{ETH_TO_STRK_ORACLE_PATH}")).unwrap(); let join_handle = spawn_eth_to_strk_oracle_server(socket_address); (url, join_handle) } diff --git a/crates/apollo_l1_endpoint_monitor/src/l1_endpoint_monitor_tests.rs b/crates/apollo_l1_endpoint_monitor/src/l1_endpoint_monitor_tests.rs index c4cbf149b25..07c5eb766a4 100644 --- a/crates/apollo_l1_endpoint_monitor/src/l1_endpoint_monitor_tests.rs +++ b/crates/apollo_l1_endpoint_monitor/src/l1_endpoint_monitor_tests.rs @@ -47,8 +47,7 @@ async fn mock_working_l1_endpoint() -> MockL1Endpoint { .mock("POST", "/") // Catch this specific RPC method. .match_body(Matcher::PartialJsonString(format!( - r#"{{ "method": "{}"}}"#, - HEALTH_CHECK_RPC_METHOD + r#"{{ "method": "{HEALTH_CHECK_RPC_METHOD}"}}"# ))) .with_status(200) // Return 2_u64 as a valid response for the method. diff --git a/crates/apollo_l1_endpoint_monitor/src/monitor.rs b/crates/apollo_l1_endpoint_monitor/src/monitor.rs index e5b5928da20..4a6be1a8d7f 100644 --- a/crates/apollo_l1_endpoint_monitor/src/monitor.rs +++ b/crates/apollo_l1_endpoint_monitor/src/monitor.rs @@ -138,6 +138,6 @@ where } raw.split_whitespace() - .map(|s| Url::parse(s).map_err(|e| D::Error::custom(format!("Invalid URL '{}': {}", s, e)))) + .map(|s| Url::parse(s).map_err(|e| D::Error::custom(format!("Invalid URL '{s}': {e}")))) .collect() } diff --git a/crates/apollo_l1_gas_price/src/eth_to_strk_oracle_test.rs b/crates/apollo_l1_gas_price/src/eth_to_strk_oracle_test.rs index 67e0250068a..fa520e5cccf 100644 --- a/crates/apollo_l1_gas_price/src/eth_to_strk_oracle_test.rs +++ b/crates/apollo_l1_gas_price/src/eth_to_strk_oracle_test.rs @@ -8,7 +8,7 @@ use crate::eth_to_strk_oracle::{EthToStrkOracleClient, EthToStrkOracleConfig}; #[tokio::test] async fn eth_to_fri_rate_uses_cache_on_quantized_hit() { let expected_rate = 123456; - let expected_rate_hex = format!("0x{:x}", expected_rate); + let expected_rate_hex = format!("0x{expected_rate:x}"); let timestamp1 = 1234567890; let timestamp2 = timestamp1 + 10; // Still in the same quantized bucket let lag_interval_seconds = 60; diff --git a/crates/apollo_l1_gas_price/src/l1_gas_price_scraper.rs b/crates/apollo_l1_gas_price/src/l1_gas_price_scraper.rs index 653b6be4604..8be4297715d 100644 --- a/crates/apollo_l1_gas_price/src/l1_gas_price_scraper.rs +++ b/crates/apollo_l1_gas_price/src/l1_gas_price_scraper.rs @@ -256,6 +256,6 @@ where ) } }; - self.run(start_from).await.unwrap_or_else(|e| panic!("L1 gas price scraper failed: {}", e)) + self.run(start_from).await.unwrap_or_else(|e| panic!("L1 gas price scraper failed: {e}")) } } diff --git a/crates/apollo_l1_provider/src/l1_scraper.rs b/crates/apollo_l1_provider/src/l1_scraper.rs index 10a9948cafe..6665663b4ef 100644 --- a/crates/apollo_l1_provider/src/l1_scraper.rs +++ b/crates/apollo_l1_provider/src/l1_scraper.rs @@ -136,7 +136,7 @@ impl L1Scraper { }); let formatted_pairs = zip_eq(l1_hashes, l2_hashes) - .map(|(l1_hash, l2_hash)| format!("L1 hash: {:?}, L2 hash: {}", l1_hash, l2_hash)) + .map(|(l1_hash, l2_hash)| format!("L1 hash: {l1_hash:?}, L2 hash: {l2_hash}")) .collect::>(); debug!("Got Messages to L2: {:?}", formatted_pairs); diff --git a/crates/apollo_l1_provider/src/l1_scraper_tests.rs b/crates/apollo_l1_provider/src/l1_scraper_tests.rs index 5c298fb1250..2091208a613 100644 --- a/crates/apollo_l1_provider/src/l1_scraper_tests.rs +++ b/crates/apollo_l1_provider/src/l1_scraper_tests.rs @@ -289,8 +289,8 @@ async fn bootstrap_e2e() { vec![BlockNumber(2), BlockNumber(5), BlockNumber(6), BlockNumber(3), BlockNumber(4)]; assert_eq!( received_order, expected_order, - "Sanity check failed: commit block order mismatch. Expected {:?}, got {:?}", - expected_order, received_order + "Sanity check failed: commit block order mismatch. Expected {expected_order:?}, got \ + {received_order:?}" ); // Apply commit blocks and assert that correct height commit_blocks are applied, but commit diff --git a/crates/apollo_l1_provider_types/src/lib.rs b/crates/apollo_l1_provider_types/src/lib.rs index bf5c7a1baf6..e0cb1025cb4 100644 --- a/crates/apollo_l1_provider_types/src/lib.rs +++ b/crates/apollo_l1_provider_types/src/lib.rs @@ -272,16 +272,15 @@ impl Display for Event { tx.tx_hash, timestamp ) } - Event::TransactionCanceled(data) => write!(f, "TransactionCanceled({})", data), + Event::TransactionCanceled(data) => write!(f, "TransactionCanceled({data})"), Event::TransactionCancellationStarted { tx_hash, cancellation_request_timestamp } => { write!( f, - "TransactionCancellationStarted(tx_hash={}, \ - cancellation_request_block_timestamp={})", - tx_hash, cancellation_request_timestamp + "TransactionCancellationStarted(tx_hash={tx_hash}, \ + cancellation_request_block_timestamp={cancellation_request_timestamp})" ) } - Event::TransactionConsumed(data) => write!(f, "TransactionConsumed({})", data), + Event::TransactionConsumed(data) => write!(f, "TransactionConsumed({data})"), } } } diff --git a/crates/apollo_mempool/src/mempool_test.rs b/crates/apollo_mempool/src/mempool_test.rs index 54919d7ca3d..b46c47359aa 100644 --- a/crates/apollo_mempool/src/mempool_test.rs +++ b/crates/apollo_mempool/src/mempool_test.rs @@ -1383,7 +1383,7 @@ fn test_get_mempool_snapshot() { fake_clock.advance(Duration::from_secs(1)); add_tx( &mut mempool, - &add_tx_input!(tx_hash: i, address: format!("0x{}", i).as_str(), tip: 10), + &add_tx_input!(tx_hash: i, address: format!("0x{i}").as_str(), tip: 10), ); } @@ -1416,8 +1416,7 @@ async fn add_tx_tolerates_p2p_propagation_error(mempool: Mempool) { assert!( result.is_ok(), - "Expected add_tx to succeed even if P2P propagation fails, but got error: {:?}", - result + "Expected add_tx to succeed even if P2P propagation fails, but got error: {result:?}" ); } diff --git a/crates/apollo_metrics/src/metrics.rs b/crates/apollo_metrics/src/metrics.rs index 4c3c3c14cc8..4e5699778c8 100644 --- a/crates/apollo_metrics/src/metrics.rs +++ b/crates/apollo_metrics/src/metrics.rs @@ -550,7 +550,7 @@ pub fn parse_numeric_metric( .map(|(k, v)| format!(r#"{}="{}""#, escape(k), escape(v))) .collect::>() .join(r","); - labels_pattern = format!(r#"\{{{}\}}"#, inner_pattern) + labels_pattern = format!(r#"\{{{inner_pattern}\}}"#) }; let pattern = format!(r#"{}{}\s+(\d+)"#, escape(metric_name), labels_pattern); let re = Regex::new(&pattern).expect("Invalid regex"); @@ -594,8 +594,8 @@ pub fn parse_histogram_metric( .map(|(k, v)| format!(r#"{}="{}""#, escape(k), escape(v))) .collect::>() .join(r","); - quantile_labels_pattern = format!(r#"\{{{},"#, inner_pattern); - labels_pattern = format!(r#"\{{{}\}}"#, inner_pattern); + quantile_labels_pattern = format!(r#"\{{{inner_pattern},"#); + labels_pattern = format!(r#"\{{{inner_pattern}\}}"#); } // Define regex patterns for quantiles, sum, and count. let quantile_pattern = format!( @@ -648,10 +648,10 @@ fn assert_equality( metric_name: &str, label: Option<&[(&str, &str)]>, ) { - let label_msg = label.map(|l| format!(" {:?}", l)).unwrap_or_default(); + let label_msg = label.map(|l| format!(" {l:?}")).unwrap_or_default(); assert_eq!( value, expected_value, - "Metric {}{} did not match the expected value. Expected value: {:?}, metric value: {:?}", - metric_name, label_msg, expected_value, value + "Metric {metric_name}{label_msg} did not match the expected value. Expected value: \ + {expected_value:?}, metric value: {value:?}" ); } diff --git a/crates/apollo_monitoring_endpoint/src/monitoring_endpoint.rs b/crates/apollo_monitoring_endpoint/src/monitoring_endpoint.rs index ebffb5a737f..7bf1cfef23e 100644 --- a/crates/apollo_monitoring_endpoint/src/monitoring_endpoint.rs +++ b/crates/apollo_monitoring_endpoint/src/monitoring_endpoint.rs @@ -137,7 +137,7 @@ pub fn create_monitoring_endpoint( impl ComponentStarter for MonitoringEndpoint { async fn start(&mut self) { info!("Starting component {}.", short_type_name::()); - self.run().await.unwrap_or_else(|e| panic!("Failed to start MointoringEndpoint: {:?}", e)); + self.run().await.unwrap_or_else(|e| panic!("Failed to start MointoringEndpoint: {e:?}")); } } diff --git a/crates/apollo_network/src/bin/get_peer_id_from_secret_key/main.rs b/crates/apollo_network/src/bin/get_peer_id_from_secret_key/main.rs index bb912783e7f..8cae5d40a84 100644 --- a/crates/apollo_network/src/bin/get_peer_id_from_secret_key/main.rs +++ b/crates/apollo_network/src/bin/get_peer_id_from_secret_key/main.rs @@ -27,7 +27,7 @@ fn main() { for i in (0..hex_str.len()).step_by(2) { let byte_str = &hex_str[i..i + 2]; let byte = u8::from_str_radix(byte_str, 16).map_err(|e| { - eprintln!("Couldn't deserialize vector. Failed to parse byte: {} {}", byte_str, e); + eprintln!("Couldn't deserialize vector. Failed to parse byte: {byte_str} {e}"); }); match byte { Ok(b) => vector.push(b), @@ -37,5 +37,5 @@ fn main() { let keypair = Keypair::ed25519_from_bytes(vector).expect("Invalid private key"); let peer_id = keypair.public().to_peer_id(); - println!("Peer ID: {}", peer_id); + println!("Peer ID: {peer_id}"); } diff --git a/crates/apollo_network/src/bin/network_stress_test/utils.rs b/crates/apollo_network/src/bin/network_stress_test/utils.rs index 89d9c336b15..e9052221ba8 100644 --- a/crates/apollo_network/src/bin/network_stress_test/utils.rs +++ b/crates/apollo_network/src/bin/network_stress_test/utils.rs @@ -93,7 +93,7 @@ impl TestConfig { network_config: NetworkConfig { port: 10002, bootstrap_peer_multiaddr: Some(vec![ - Multiaddr::from_str(&format!("/ip4/127.0.0.1/tcp/10000/p2p/{}", peer_id)) + Multiaddr::from_str(&format!("/ip4/127.0.0.1/tcp/10000/p2p/{peer_id}")) .unwrap(), ]), ..Default::default() diff --git a/crates/apollo_network/src/discovery/behaviours/bootstrapping/bootstrap_test.rs b/crates/apollo_network/src/discovery/behaviours/bootstrapping/bootstrap_test.rs index a70836b49fb..04f741e783e 100644 --- a/crates/apollo_network/src/discovery/behaviours/bootstrapping/bootstrap_test.rs +++ b/crates/apollo_network/src/discovery/behaviours/bootstrapping/bootstrap_test.rs @@ -61,7 +61,7 @@ const TIMES_TO_CHECK_FOR_PENDING_EVENT: usize = 5; fn assert_no_event(behaviour: &mut BootstrappingBehaviour) { for _ in 0..TIMES_TO_CHECK_FOR_PENDING_EVENT { let next_event = behaviour.next().now_or_never(); - assert!(next_event.is_none(), "Expected None, received {:?}", next_event); + assert!(next_event.is_none(), "Expected None, received {next_event:?}"); } } diff --git a/crates/apollo_network/src/discovery/behaviours/bootstrapping/mod.rs b/crates/apollo_network/src/discovery/behaviours/bootstrapping/mod.rs index 1a9c6d66a9d..990423b394b 100644 --- a/crates/apollo_network/src/discovery/behaviours/bootstrapping/mod.rs +++ b/crates/apollo_network/src/discovery/behaviours/bootstrapping/mod.rs @@ -89,8 +89,7 @@ impl BootstrappingBehaviour { bootstrap_peers.iter().map(|(id, _)| id).collect(); assert!( unique_peer_ids.len() == bootstrap_peers.len(), - "Bootstrap peer IDs must be unique, PeerIds: {:?}", - bootstrap_peers + "Bootstrap peer IDs must be unique, PeerIds: {bootstrap_peers:?}" ); let mut peers = SelectAll::new(); diff --git a/crates/apollo_network/src/lib.rs b/crates/apollo_network/src/lib.rs index 7938bfc697c..0739ffb1552 100644 --- a/crates/apollo_network/src/lib.rs +++ b/crates/apollo_network/src/lib.rs @@ -60,7 +60,7 @@ where let mut vector = Vec::new(); for i in raw_str.split(',').filter(|s| !s.is_empty()) { let value = Multiaddr::from_str(i).map_err(|_| { - D::Error::custom(format!("Couldn't deserialize vector. Failed to parse value: {}", i)) + D::Error::custom(format!("Couldn't deserialize vector. Failed to parse value: {i}")) })?; vector.push(value); } @@ -217,7 +217,7 @@ fn validate_bootstrap_peer_multiaddr_list( if !peers.insert(peer_id) { let mut error = ValidationError::new("Bootstrap peer PeerIds are not unique."); - error.message = Some(std::borrow::Cow::from(format!("Repeated PeerId: {}", peer_id))); + error.message = Some(std::borrow::Cow::from(format!("Repeated PeerId: {peer_id}"))); return Err(error); } } diff --git a/crates/apollo_network/src/mixed_behaviour.rs b/crates/apollo_network/src/mixed_behaviour.rs index a92141b10ee..98f7003f471 100644 --- a/crates/apollo_network/src/mixed_behaviour.rs +++ b/crates/apollo_network/src/mixed_behaviour.rs @@ -72,7 +72,7 @@ impl MixedBehaviour { 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)) + StreamProtocol::try_from_owned(format!("/starknet/kad/{chain_id}/1.0.0")) .expect("Failed to create StreamProtocol from a string that starts with /"), ]); Self { diff --git a/crates/apollo_network/src/network_manager/mod.rs b/crates/apollo_network/src/network_manager/mod.rs index 31234d4febe..5b91ebcd942 100644 --- a/crates/apollo_network/src/network_manager/mod.rs +++ b/crates/apollo_network/src/network_manager/mod.rs @@ -151,7 +151,7 @@ impl GenericNetworkManager { if let Some(_old_buffer_size) = self.inbound_protocol_to_buffer_size.insert(protocol.clone(), buffer_size) { - panic!("Protocol '{}' has already been registered as a server.", protocol); + panic!("Protocol '{protocol}' has already been registered as a server."); } let (inbound_payload_sender, inbound_payload_receiver) = futures::channel::mpsc::channel(buffer_size); @@ -159,7 +159,7 @@ impl GenericNetworkManager { .sqmr_inbound_payload_senders .insert(protocol.clone(), Box::new(inbound_payload_sender)); if insert_result.is_some() { - panic!("Protocol '{}' has already been registered as a server.", protocol); + panic!("Protocol '{protocol}' has already been registered as a server."); } let inbound_payload_receiver = inbound_payload_receiver @@ -192,7 +192,7 @@ impl GenericNetworkManager { .sqmr_outbound_payload_receivers .insert(protocol.clone().as_ref().to_string(), Box::new(payload_receiver)); if insert_result.is_some() { - panic!("Protocol '{}' has already been registered as a client.", protocol); + panic!("Protocol '{protocol}' has already been registered as a client."); }; SqmrClientSender::new(Box::new(payload_sender), buffer_size) @@ -224,14 +224,14 @@ impl GenericNetworkManager { .messages_to_broadcast_receivers .insert(topic_hash.clone(), messages_to_broadcast_receiver); if insert_result.is_some() { - panic!("Topic '{}' has already been registered.", topic); + panic!("Topic '{topic}' has already been registered."); } let insert_result = self .broadcasted_messages_senders .insert(topic_hash.clone(), broadcasted_messages_sender.clone()); if insert_result.is_some() { - panic!("Topic '{}' has already been registered.", topic); + panic!("Topic '{topic}' has already been registered."); } let broadcasted_messages_fn: BroadcastReceivedMessagesConverterFn = @@ -671,7 +671,7 @@ fn send_now( Some(Ok(())) => {} Some(Err(error)) => { if should_panic_upon_disconnect || !error.is_disconnected() { - panic!("Received error while sending message: {:?}", error); + panic!("Received error while sending message: {error:?}"); } } None => { @@ -705,8 +705,8 @@ impl NetworkManager { // TODO(shahak): Add quic transport. let listen_address_str = format!("/ip4/0.0.0.0/tcp/{port}"); let listen_address = Multiaddr::from_str(&listen_address_str) - .unwrap_or_else(|_| panic!("Unable to parse address {}", listen_address_str)); - debug!("Creating swarm with listen address: {:?}", listen_address); + .unwrap_or_else(|_| panic!("Unable to parse address {listen_address_str}")); + debug!("Creating swarm with listen address: {listen_address:?}"); let key_pair = match secret_key { Some(secret_key) => { @@ -737,7 +737,7 @@ impl NetworkManager { swarm .listen_on(listen_address.clone()) - .unwrap_or_else(|_| panic!("Error while binding to {}", listen_address)); + .unwrap_or_else(|_| panic!("Error while binding to {listen_address}")); let advertised_multiaddr = advertised_multiaddr.map(|address| { address diff --git a/crates/apollo_network/src/sqmr/behaviour_test.rs b/crates/apollo_network/src/sqmr/behaviour_test.rs index b9f5f5e9d02..f1d8a684443 100644 --- a/crates/apollo_network/src/sqmr/behaviour_test.rs +++ b/crates/apollo_network/src/sqmr/behaviour_test.rs @@ -376,10 +376,9 @@ async fn connection_closed() { })) = event else { panic!( - "Event {:?} doesn't match expected event \ + "Event {event:?} doesn't match expected event \ ToSwarm::GenerateEvent(Event::External(ExternalEvent::SessionFailed {{ \ - error: SessionError::ConnectionClosed }}))", - event + error: SessionError::ConnectionClosed }}))" ); }; *session_id diff --git a/crates/apollo_network/src/sqmr/flow_test.rs b/crates/apollo_network/src/sqmr/flow_test.rs index a34900aad38..c82ccd1a530 100644 --- a/crates/apollo_network/src/sqmr/flow_test.rs +++ b/crates/apollo_network/src/sqmr/flow_test.rs @@ -132,7 +132,7 @@ fn check_request_peer_assignment_event_and_return_session_id( outbound_session_id, }) = event else { - panic!("Got unexpected event {:?} when expecting RequestPeerAssignment", event); + panic!("Got unexpected event {event:?} when expecting RequestPeerAssignment"); }; let assigned_peer_id = *outbound_session_id_to_peer_id.get(&(outbound_peer_id, outbound_session_id)).unwrap(); @@ -153,7 +153,7 @@ fn check_new_inbound_session_event_and_return_id( protocol_name, }) = event else { - panic!("Got unexpected event {:?} when expecting NewInboundSession", event); + panic!("Got unexpected event {event:?} when expecting NewInboundSession"); }; assert_eq!(query, get_bytes_from_query_indices(outbound_peer_id, inbound_peer_id)); assert_eq!(protocol_name, PROTOCOL_NAME); @@ -175,7 +175,7 @@ fn check_received_response_event( peer_id: inbound_peer_id, }) = event else { - panic!("Got unexpected event {:?} when expecting ReceivedResponse", event); + panic!("Got unexpected event {event:?} when expecting ReceivedResponse"); }; assert_eq!( outbound_session_id_to_peer_id[&(outbound_peer_id, _outbound_session_id)], diff --git a/crates/apollo_node/src/config/component_execution_config.rs b/crates/apollo_node/src/config/component_execution_config.rs index 02e8922f57b..9cbcf13ba1c 100644 --- a/crates/apollo_node/src/config/component_execution_config.rs +++ b/crates/apollo_node/src/config/component_execution_config.rs @@ -193,7 +193,7 @@ fn validate_url(url: &str) -> Result<(), ValidationError> { let arbitrary_port: u16 = 0; let socket_addrs = (url, arbitrary_port) .to_socket_addrs() - .map_err(|e| create_url_validation_error(format!("Failed to resolve url IP: {}", e)))?; + .map_err(|e| create_url_validation_error(format!("Failed to resolve url IP: {e}")))?; if socket_addrs.count() > 0 { Ok(()) @@ -212,7 +212,7 @@ fn validate_max_concurrency(max_concurrency: usize) -> Result<(), ValidationErro Ok(()) } else { Err(create_validation_error( - format!("Invalid max_concurrency: {}", max_concurrency), + format!("Invalid max_concurrency: {max_concurrency}"), "Invalid max concurrency", "Ensure the max concurrency is greater than 0.", )) diff --git a/crates/apollo_node/src/config/config_utils.rs b/crates/apollo_node/src/config/config_utils.rs index 151ba87a080..04f96029bcc 100644 --- a/crates/apollo_node/src/config/config_utils.rs +++ b/crates/apollo_node/src/config/config_utils.rs @@ -61,7 +61,7 @@ pub fn config_to_preset(config_map: &Value) -> Value { // Return the transformed result as a JSON object. Value::Object(result) } else { - panic!("Config map is not a JSON object: {:?}", config_map); + panic!("Config map is not a JSON object: {config_map:?}"); } } @@ -71,7 +71,7 @@ fn validate_all_pointer_targets_set(preset: Value) -> Result<(), ValidationError for (key, value) in preset_map { if value == POINTER_TARGET_VALUE { return Err(create_validation_error( - format!("Pointer target not set for key: '{}'", key), + format!("Pointer target not set for key: '{key}'"), "pointer_target_not_set", "Pointer target not set", )); diff --git a/crates/apollo_node/src/servers.rs b/crates/apollo_node/src/servers.rs index 2648601ef60..94f10adea22 100644 --- a/crates/apollo_node/src/servers.rs +++ b/crates/apollo_node/src/servers.rs @@ -818,7 +818,7 @@ pub async fn run_component_servers(servers: SequencerNodeServers) { if let Some(servers_type) = all_servers.next().await { // TODO(alonl): check all tasks are exited properly in case of a server failure before // panicing. - panic!("{} Servers ended unexpectedly.", servers_type); + panic!("{servers_type} Servers ended unexpectedly."); } else { unreachable!("all_servers is never empty"); } diff --git a/crates/apollo_node/src/test_utils/node_runner.rs b/crates/apollo_node/src/test_utils/node_runner.rs index 5ab93d37dba..1455e963285 100644 --- a/crates/apollo_node/src/test_utils/node_runner.rs +++ b/crates/apollo_node/src/test_utils/node_runner.rs @@ -49,7 +49,7 @@ pub fn spawn_run_node( let _node_run_result = node_handle. wait(). // Runs the node until completion, should be running indefinitely. await; // Awaits the completion of the node. - panic!("Node {:?} stopped unexpectedly.", node_runner); + panic!("Node {node_runner:?} stopped unexpectedly."); })) } diff --git a/crates/apollo_protobuf/src/consensus.rs b/crates/apollo_protobuf/src/consensus.rs index ca8c6d36ed8..a1281556896 100644 --- a/crates/apollo_protobuf/src/consensus.rs +++ b/crates/apollo_protobuf/src/consensus.rs @@ -133,7 +133,7 @@ impl TryInto for ProposalPart { _ => Err(ProtobufConversionError::WrongEnumVariant { type_description: "ProposalPart", expected: "Init", - value_as_str: format!("{:?}", self), + value_as_str: format!("{self:?}"), }), } } diff --git a/crates/apollo_protobuf/src/converters/consensus_test.rs b/crates/apollo_protobuf/src/converters/consensus_test.rs index 98a32144997..fd441502c53 100644 --- a/crates/apollo_protobuf/src/converters/consensus_test.rs +++ b/crates/apollo_protobuf/src/converters/consensus_test.rs @@ -153,8 +153,8 @@ fn stream_message_display() { assert_eq!( txt, format!( - "StreamMessage {{ stream_id: {}, message_id: {}, message_length: {}}}", - stream_id, message_id, proposal_length + "StreamMessage {{ stream_id: {stream_id}, message_id: {message_id}, message_length: \ + {proposal_length}}}" ) ); @@ -164,8 +164,7 @@ fn stream_message_display() { assert_eq!( txt, format!( - "StreamMessage {{ stream_id: {}, message_id: {}, message is fin }}", - stream_id, message_id + "StreamMessage {{ stream_id: {stream_id}, message_id: {message_id}, message is fin }}" ) ); } diff --git a/crates/apollo_protobuf/src/protoc_regression_test.rs b/crates/apollo_protobuf/src/protoc_regression_test.rs index 29df2b3510b..3f2e086dcef 100644 --- a/crates/apollo_protobuf/src/protoc_regression_test.rs +++ b/crates/apollo_protobuf/src/protoc_regression_test.rs @@ -15,9 +15,9 @@ fn protoc_output_matches_result_of_running_protoc() { let expected_name = PathBuf::from(PROTO_DIR).join(PROTOC_OUTPUT); let expected_file = fs::read_to_string(&expected_name) - .unwrap_or_else(|_| panic!("Failed to read expected file at {:?}", expected_name)); + .unwrap_or_else(|_| panic!("Failed to read expected file at {expected_name:?}")); let generated_file = fs::read_to_string(&generated_name) - .unwrap_or_else(|_| panic!("Failed to read generated file at {:?}", generated_name)); + .unwrap_or_else(|_| panic!("Failed to read generated file at {generated_name:?}")); // Using assert instead of assert_eq to avoid showing the entire content of the files on // assertion fail diff --git a/crates/apollo_rpc/src/rpc_metrics/rpc_metrics_test.rs b/crates/apollo_rpc/src/rpc_metrics/rpc_metrics_test.rs index 0cb3ee0d4a2..f5d63049035 100644 --- a/crates/apollo_rpc/src/rpc_metrics/rpc_metrics_test.rs +++ b/crates/apollo_rpc/src/rpc_metrics/rpc_metrics_test.rs @@ -181,19 +181,19 @@ async fn server_metrics() { let metrics = prometheus_handle.render(); for line in metrics.split('\n').filter(|line| line.contains("V0_8")) { if line.contains("rpc_incoming_requests{method=\"blockNumber\"") { - println!("{}", line); + println!("{line}"); line.split(' ').next_back().unwrap().clone_into(&mut incoming_block_number); } if line.contains("rpc_failed_requests{method=\"blockNumber\"") { - println!("{}", line); + println!("{line}"); line.split(' ').next_back().unwrap().clone_into(&mut failing_block_number); } if line.contains("rpc_incoming_requests{method=\"getStateUpdate\"") { - println!("{}", line); + println!("{line}"); line.split(' ').next_back().unwrap().clone_into(&mut incoming_get_state_update); } if line.contains("rpc_failed_requests{method=\"getStateUpdate\"") { - println!("{}", line); + println!("{line}"); line.split(' ').next_back().unwrap().clone_into(&mut failing_get_state_update); } } diff --git a/crates/apollo_rpc/src/test_utils.rs b/crates/apollo_rpc/src/test_utils.rs index e1c95357518..7aa69129d0b 100644 --- a/crates/apollo_rpc/src/test_utils.rs +++ b/crates/apollo_rpc/src/test_utils.rs @@ -111,7 +111,7 @@ pub(crate) async fn raw_call Des let params_str = match params { Value::Array(vec) if vec.is_empty() => "".to_string(), Value::Object(map) if map.is_empty() => "".to_string(), - _ => format!(r#", "params":{}"#, params), + _ => format!(r#", "params":{params}"#), }; let req = format!(r#"{{"jsonrpc":"2.0","id":"1","method":"{method}"{params_str}}}"#); let (resp_wrapper, _) = module diff --git a/crates/apollo_rpc/src/v0_8/api/api_impl.rs b/crates/apollo_rpc/src/v0_8/api/api_impl.rs index c40bc007f1e..0b080648d55 100644 --- a/crates/apollo_rpc/src/v0_8/api/api_impl.rs +++ b/crates/apollo_rpc/src/v0_8/api/api_impl.rs @@ -551,7 +551,7 @@ impl JsonRpcServer for JsonRpcServerImpl { let tx = txn .get_transaction(transaction_index) .map_err(internal_server_error)? - .unwrap_or_else(|| panic!("Should have tx {}", transaction_hash)); + .unwrap_or_else(|| panic!("Should have tx {transaction_hash}")); // TODO(Shahak): Add version function to transaction in SN_API. let tx_version = match &tx { diff --git a/crates/apollo_rpc/src/v0_8/api/test.rs b/crates/apollo_rpc/src/v0_8/api/test.rs index d930b5ab8a3..4ffc1634d82 100644 --- a/crates/apollo_rpc/src/v0_8/api/test.rs +++ b/crates/apollo_rpc/src/v0_8/api/test.rs @@ -4171,9 +4171,8 @@ fn spec_api_methods_coverage() { // Methods in the spec are a subset of the implemented methods. assert!( method_names_in_spec.iter().all(|method| implemented_method_names.contains(method)), - "Implemented methods: {:#?}, methods in spec: {:#?}", - implemented_method_names, - method_names_in_spec + "Implemented methods: {implemented_method_names:#?}, methods in spec: \ + {method_names_in_spec:#?}" ); } diff --git a/crates/apollo_rpc/src/v0_8/transaction.rs b/crates/apollo_rpc/src/v0_8/transaction.rs index 049c29070b3..e91f2803525 100644 --- a/crates/apollo_rpc/src/v0_8/transaction.rs +++ b/crates/apollo_rpc/src/v0_8/transaction.rs @@ -1210,7 +1210,7 @@ impl Serialize for L1L2MsgHash { where S: Serializer, { - serializer.serialize_str(format!("{}", self).as_str()) + serializer.serialize_str(format!("{self}").as_str()) } } @@ -1297,7 +1297,7 @@ where S: serde::Serializer, { let hex_string = hex::encode(eth_address.0.as_bytes()); - let fixed_size_hex_string = format!("0x{:0<40}", hex_string); + let fixed_size_hex_string = format!("0x{hex_string:0<40}"); serializer.serialize_str(fixed_size_hex_string.as_str()) } diff --git a/crates/apollo_rpc/tests/gateway_integration_test.rs b/crates/apollo_rpc/tests/gateway_integration_test.rs index fb853e36aa4..417df84cd51 100644 --- a/crates/apollo_rpc/tests/gateway_integration_test.rs +++ b/crates/apollo_rpc/tests/gateway_integration_test.rs @@ -58,12 +58,12 @@ async fn test_gw_integration_testnet() { let node_url = env::var("INTEGRATION_TESTNET_NODE_URL") .expect("Node url must be given in INTEGRATION_TESTNET_NODE_URL environment variable."); let client = - HttpClientBuilder::default().build(format!("https://{}:443/rpc/v0_8", node_url)).unwrap(); + HttpClientBuilder::default().build(format!("https://{node_url}:443/rpc/v0_8")).unwrap(); let sender_address = contract_address!(USER_A_ADDRESS); // Sender balance sufficient balance should be maintained outside of this test. let sender_balance = get_eth_balance(&client, sender_address).await; if sender_balance <= MAX_FEE.into() { - println!("Sender balance is too low. Please fund account {}.", USER_A_ADDRESS); + println!("Sender balance is too low. Please fund account {USER_A_ADDRESS}."); std::process::exit(INSUFFICIENT_FUNDS_STATUS_CODE); } @@ -130,5 +130,5 @@ async fn test_gw_integration_testnet() { .await .unwrap_or_else(|err| panic!("Failed to add tx '{hash}' with nonce '{nonce:?}'.: {err}")); - println!("Invoke Tx result: {:?}", invoke_res); + println!("Invoke Tx result: {invoke_res:?}"); } diff --git a/crates/apollo_rpc_execution/src/state_reader_test.rs b/crates/apollo_rpc_execution/src/state_reader_test.rs index 87e4e843025..1a14f28886c 100644 --- a/crates/apollo_rpc_execution/src/state_reader_test.rs +++ b/crates/apollo_rpc_execution/src/state_reader_test.rs @@ -416,6 +416,6 @@ fn get_compiled_class_with_error() { let (exec_state_reader, _) = set_execution_state_reader(Arc::new(mock_class_manager_client), 0); let result = exec_state_reader.get_compiled_class(class_hash!("0x2")); - let expected_err_msg = format!("Internal client error: {}", internal_err_msg); + let expected_err_msg = format!("Internal client error: {internal_err_msg}"); assert_matches!(result, Err(StateError::StateReadError(err_str)) if err_str == expected_err_msg); } diff --git a/crates/apollo_starknet_client/src/reader/objects/transaction_test.rs b/crates/apollo_starknet_client/src/reader/objects/transaction_test.rs index 074aa10d5b3..79c6bff2148 100644 --- a/crates/apollo_starknet_client/src/reader/objects/transaction_test.rs +++ b/crates/apollo_starknet_client/src/reader/objects/transaction_test.rs @@ -56,7 +56,7 @@ fn load_transaction_succeeds() { "reader/deploy_account_v3.json", ] { let res = serde_json::from_str::(&read_resource_file(file_name)); - assert!(res.is_ok(), "filename: {}, error: {:?}", file_name, res); + assert!(res.is_ok(), "filename: {file_name}, error: {res:?}"); } } @@ -75,7 +75,7 @@ fn load_transaction_unknown_field_fails() { .unwrap() .insert("unknown_field".to_string(), serde_json::Value::Null); let json_str = serde_json::to_string(&json_value).unwrap(); - assert!(serde_json::from_str::(&json_str).is_err(), "filename: {}", file_name); + assert!(serde_json::from_str::(&json_str).is_err(), "filename: {file_name}"); } } @@ -95,7 +95,7 @@ fn load_transaction_wrong_type_fails() { .unwrap() .insert("type".to_string(), serde_json::Value::String(new_wrong_type.to_string())); let json_str = serde_json::to_string(&json_value).unwrap(); - assert!(serde_json::from_str::(&json_str).is_err(), "filename: {}", file_name); + assert!(serde_json::from_str::(&json_str).is_err(), "filename: {file_name}"); } } @@ -109,8 +109,8 @@ fn load_transaction_receipt_succeeds() { serde_json::from_str::(&read_resource_file(file_name)).unwrap_or_else( |err| { panic!( - "Failed to deserialize transaction receipt. Filename: {}. Error: {}", - file_name, err + "Failed to deserialize transaction receipt. Filename: {file_name}. Error: \ + {err}" ) }, ); diff --git a/crates/apollo_starknet_client/src/reader/starknet_feeder_gateway_client_test.rs b/crates/apollo_starknet_client/src/reader/starknet_feeder_gateway_client_test.rs index cfccf2ed995..e4463724bec 100644 --- a/crates/apollo_starknet_client/src/reader/starknet_feeder_gateway_client_test.rs +++ b/crates/apollo_starknet_client/src/reader/starknet_feeder_gateway_client_test.rs @@ -56,7 +56,7 @@ fn get_block_url( use_deprecated_feeder_gateway: bool, ) -> String { let mut url = match block_number_or_latest { - Some(block_number) => format!("/feeder_gateway/get_block?blockNumber={}", block_number), + Some(block_number) => format!("/feeder_gateway/get_block?blockNumber={block_number}"), _ => "/feeder_gateway/get_block?blockNumber=latest".to_string(), }; @@ -104,7 +104,7 @@ fn mock_current_feeder_gateway_invalid_get_latest_block_response() -> mockito::M fn block_not_found_error(block_number: i64) -> String { let error = StarknetError { code: StarknetErrorCode::KnownErrorCode(KnownStarknetErrorCode::BlockNotFound), - message: format!("Block {} was not found.", block_number), + message: format!("Block {block_number} was not found."), }; serde_json::to_string(&error).unwrap() } diff --git a/crates/apollo_state_sync/src/test.rs b/crates/apollo_state_sync/src/test.rs index b36e41e8407..b6a7544a5bb 100644 --- a/crates/apollo_state_sync/src/test.rs +++ b/crates/apollo_state_sync/src/test.rs @@ -54,10 +54,10 @@ async fn test_get_block() { )) .await; let StateSyncResponse::GetBlock(Ok(boxed_sync_block)) = response else { - panic!("Expected StateSyncResponse::GetBlock::Ok(Box(Some(_))), but got {:?}", response); + panic!("Expected StateSyncResponse::GetBlock::Ok(Box(Some(_))), but got {response:?}"); }; let Some(block) = *boxed_sync_block else { - panic!("Expected Box(Some(_)), but got {:?}", boxed_sync_block); + panic!("Expected Box(Some(_)), but got {boxed_sync_block:?}"); }; assert_eq!(block.block_header_without_hash, expected_header.block_header_without_hash); @@ -105,7 +105,7 @@ async fn test_get_storage_at() { .await; let StateSyncResponse::GetStorageAt(Ok(value)) = response else { - panic!("Expected StateSyncResponse::GetStorageAt::Ok(_), but got {:?}", response); + panic!("Expected StateSyncResponse::GetStorageAt::Ok(_), but got {response:?}"); }; assert_eq!(value, expected_value); @@ -144,7 +144,7 @@ async fn test_get_nonce_at() { .await; let StateSyncResponse::GetNonceAt(Ok(nonce)) = response else { - panic!("Expected StateSyncResponse::GetNonceAt::Ok(_), but got {:?}", response); + panic!("Expected StateSyncResponse::GetNonceAt::Ok(_), but got {response:?}"); }; assert_eq!(nonce, expected_nonce); @@ -182,7 +182,7 @@ async fn get_class_hash_at() { .await; let StateSyncResponse::GetClassHashAt(Ok(class_hash)) = response else { - panic!("Expected StateSyncResponse::GetClassHashAt::Ok(_), but got {:?}", response); + panic!("Expected StateSyncResponse::GetClassHashAt::Ok(_), but got {response:?}"); }; assert_eq!(class_hash, expected_class_hash); @@ -198,7 +198,7 @@ async fn test_block_not_found() { let response = state_sync.handle_request(StateSyncRequest::GetBlock(non_existing_block_number)).await; let StateSyncResponse::GetBlock(Ok(maybe_block)) = response else { - panic!("Expected StateSyncResponse::GetBlock::Ok(_), but got {:?}", response); + panic!("Expected StateSyncResponse::GetBlock::Ok(_), but got {response:?}"); }; assert!(maybe_block.is_none()); @@ -211,7 +211,7 @@ async fn test_block_not_found() { )) .await; let StateSyncResponse::GetStorageAt(get_storage_at_result) = response else { - panic!("Expected StateSyncResponse::GetStorageAt(_), but got {:?}", response); + panic!("Expected StateSyncResponse::GetStorageAt(_), but got {response:?}"); }; assert_eq!( @@ -223,7 +223,7 @@ async fn test_block_not_found() { .handle_request(StateSyncRequest::GetNonceAt(non_existing_block_number, Default::default())) .await; let StateSyncResponse::GetNonceAt(get_nonce_at_result) = response else { - panic!("Expected StateSyncResponse::GetNonceAt(_), but got {:?}", response); + panic!("Expected StateSyncResponse::GetNonceAt(_), but got {response:?}"); }; assert_eq!(get_nonce_at_result, Err(StateSyncError::BlockNotFound(non_existing_block_number))); @@ -235,7 +235,7 @@ async fn test_block_not_found() { )) .await; let StateSyncResponse::GetClassHashAt(get_class_hash_at_result) = response else { - panic!("Expected StateSyncResponse::GetClassHashAt(_), but got {:?}", response); + panic!("Expected StateSyncResponse::GetClassHashAt(_), but got {response:?}"); }; assert_eq!( @@ -277,7 +277,7 @@ async fn test_contract_not_found() { )) .await; let StateSyncResponse::GetStorageAt(get_storage_at_result) = response else { - panic!("Expected StateSyncResponse::GetStorageAt(_), but got {:?}", response); + panic!("Expected StateSyncResponse::GetStorageAt(_), but got {response:?}"); }; assert_eq!(get_storage_at_result, Err(StateSyncError::ContractNotFound(address))); @@ -289,7 +289,7 @@ async fn test_contract_not_found() { )) .await; let StateSyncResponse::GetNonceAt(get_nonce_at_result) = response else { - panic!("Expected StateSyncResponse::GetNonceAt(_), but got {:?}", response); + panic!("Expected StateSyncResponse::GetNonceAt(_), but got {response:?}"); }; assert_eq!(get_nonce_at_result, Err(StateSyncError::ContractNotFound(address))); @@ -301,7 +301,7 @@ async fn test_contract_not_found() { )) .await; let StateSyncResponse::GetClassHashAt(get_class_hash_at_result) = response else { - panic!("Expected StateSyncResponse::GetClassHashAt(_), but got {:?}", response); + panic!("Expected StateSyncResponse::GetClassHashAt(_), but got {response:?}"); }; assert_eq!(get_class_hash_at_result, Err(StateSyncError::ContractNotFound(address))); diff --git a/crates/apollo_storage/src/body/body_test.rs b/crates/apollo_storage/src/body/body_test.rs index 1d6dd9e4307..cc25ea01f64 100644 --- a/crates/apollo_storage/src/body/body_test.rs +++ b/crates/apollo_storage/src/body/body_test.rs @@ -68,7 +68,7 @@ async fn append_body() { table_name: _, key, value - })) if key == format!("{:?}", tx_hashes[0]) && value == format!("{:?}", expected_tx_index) + })) if key == format!("{:?}", tx_hashes[0]) && value == format!("{expected_tx_index:?}") ); let txn = reader.begin_ro_txn().unwrap(); diff --git a/crates/apollo_storage/src/db/db_test.rs b/crates/apollo_storage/src/db/db_test.rs index 879e91ae61a..51f23f6e272 100644 --- a/crates/apollo_storage/src/db/db_test.rs +++ b/crates/apollo_storage/src/db/db_test.rs @@ -307,7 +307,7 @@ impl Migratable for V1 { older_version: u8, ) -> Result { if older_version != 0 { - println!("Unexpected older version: {}", older_version); + println!("Unexpected older version: {older_version}"); return Err(StorageSerdeError::Migration); } V0::deserialize_from(bytes) diff --git a/crates/apollo_storage/src/db/mod.rs b/crates/apollo_storage/src/db/mod.rs index 6ee8af845fd..3df03bd6abe 100644 --- a/crates/apollo_storage/src/db/mod.rs +++ b/crates/apollo_storage/src/db/mod.rs @@ -183,7 +183,7 @@ pub struct KeyAlreadyExistsError { impl KeyAlreadyExistsError { /// Creates a new KeyAlreadyExistsError. pub fn new(table_name: &'static str, key: &impl Debug, value: &impl Debug) -> Self { - Self { table_name, key: format!("{:?}", key), value: format!("{:?}", value) } + Self { table_name, key: format!("{key:?}"), value: format!("{value:?}") } } } diff --git a/crates/apollo_storage/src/lib.rs b/crates/apollo_storage/src/lib.rs index aa4b5edbc52..f72d837f5b5 100644 --- a/crates/apollo_storage/src/lib.rs +++ b/crates/apollo_storage/src/lib.rs @@ -769,7 +769,7 @@ impl FileHandlers { location: LocationInFile, ) -> StorageResult { self.thin_state_diff.get(location)?.ok_or(StorageError::DBInconsistency { - msg: format!("ThinStateDiff at location {:?} not found.", location), + msg: format!("ThinStateDiff at location {location:?} not found."), }) } @@ -779,14 +779,14 @@ impl FileHandlers { location: LocationInFile, ) -> StorageResult { self.contract_class.get(location)?.ok_or(StorageError::DBInconsistency { - msg: format!("ContractClass at location {:?} not found.", location), + msg: format!("ContractClass at location {location:?} not found."), }) } // Returns the CASM at the given location or an error in case it doesn't exist. fn get_casm_unchecked(&self, location: LocationInFile) -> StorageResult { self.casm.get(location)?.ok_or(StorageError::DBInconsistency { - msg: format!("CasmContractClass at location {:?} not found.", location), + msg: format!("CasmContractClass at location {location:?} not found."), }) } @@ -797,7 +797,7 @@ impl FileHandlers { location: LocationInFile, ) -> StorageResult { self.deprecated_contract_class.get(location)?.ok_or(StorageError::DBInconsistency { - msg: format!("DeprecatedContractClass at location {:?} not found.", location), + msg: format!("DeprecatedContractClass at location {location:?} not found."), }) } @@ -808,14 +808,14 @@ impl FileHandlers { location: LocationInFile, ) -> StorageResult { self.transaction_output.get(location)?.ok_or(StorageError::DBInconsistency { - msg: format!("TransactionOutput at location {:?} not found.", location), + msg: format!("TransactionOutput at location {location:?} not found."), }) } // Returns the transaction at the given location or an error in case it doesn't exist. fn get_transaction_unchecked(&self, location: LocationInFile) -> StorageResult { self.transaction.get(location)?.ok_or(StorageError::DBInconsistency { - msg: format!("Transaction at location {:?} not found.", location), + msg: format!("Transaction at location {location:?} not found."), }) } } diff --git a/crates/apollo_storage/src/serialization/serializers_test.rs b/crates/apollo_storage/src/serialization/serializers_test.rs index e5fc1b35e7f..f569fbe8f21 100644 --- a/crates/apollo_storage/src/serialization/serializers_test.rs +++ b/crates/apollo_storage/src/serialization/serializers_test.rs @@ -152,7 +152,7 @@ fn casm_serialization_regression() { } for (json_file_name, bin_file_name) in CASM_SERIALIZATION_REGRESSION_FILES { - let json_path = format!("casm/{}", json_file_name); + let json_path = format!("casm/{json_file_name}"); let json_casm: CasmContractClass = read_json_file(&json_path); let mut serialized: Vec = Vec::new(); json_casm @@ -191,7 +191,7 @@ fn casm_deserialization_regression() { let regression_casm = CasmContractClass::deserialize_from(&mut regression_casm_bytes.as_slice()) .expect("Failed to deserialize casm file: {casm_file}."); - let json_path = format!("casm/{}", json_file_name); + let json_path = format!("casm/{json_file_name}"); let json_casm: CasmContractClass = read_json_file(&json_path); assert_eq!( regression_casm, json_casm, @@ -203,7 +203,7 @@ result.\n{FIX_SUGGESTION}" fn fix_casm_regression_files() { for (json_file_name, bin_file_name) in CASM_SERIALIZATION_REGRESSION_FILES { - let json_path = format!("casm/{}", json_file_name); + let json_path = format!("casm/{json_file_name}"); let json_casm: CasmContractClass = read_json_file(&json_path); let mut serialized: Vec = Vec::new(); json_casm.serialize_into(&mut serialized).unwrap(); diff --git a/crates/blockifier/src/blockifier/block.rs b/crates/blockifier/src/blockifier/block.rs index 9e98b63ee91..b3ed8b9e028 100644 --- a/crates/blockifier/src/blockifier/block.rs +++ b/crates/blockifier/src/blockifier/block.rs @@ -27,8 +27,8 @@ fn validate_l2_gas_price(gas_prices: &GasPrices) { if GasPrice::from(eth_l2_gas_price) != expected_eth_l2_gas_price { // TODO(Aner): change to panic! Requires fixing several tests. warn!( - "eth_l2_gas_price {} does not match expected eth_l2_gas_price {}.", - eth_l2_gas_price, expected_eth_l2_gas_price + "eth_l2_gas_price {eth_l2_gas_price} does not match expected eth_l2_gas_price \ + {expected_eth_l2_gas_price}." ) } let strk_l2_gas_price = gas_prices.strk_gas_prices.l2_gas_price; @@ -37,8 +37,8 @@ fn validate_l2_gas_price(gas_prices: &GasPrices) { if GasPrice::from(strk_l2_gas_price) != expected_strk_l2_gas_price { // TODO(Aner): change to panic! Requires fixing test_discounted_gas_overdraft warn!( - "strk_l2_gas_price {} does not match expected strk_l2_gas_price {}.", - strk_l2_gas_price, expected_strk_l2_gas_price + "strk_l2_gas_price {strk_l2_gas_price} does not match expected strk_l2_gas_price \ + {expected_strk_l2_gas_price}." ) } } diff --git a/crates/blockifier/src/blockifier/transaction_executor.rs b/crates/blockifier/src/blockifier/transaction_executor.rs index b92cbb3a5c4..b5b64cccf15 100644 --- a/crates/blockifier/src/blockifier/transaction_executor.rs +++ b/crates/blockifier/src/blockifier/transaction_executor.rs @@ -287,14 +287,12 @@ impl TransactionExecutor { assert!( chunk_size > 0, "When running transactions concurrently the chunk size must be greater than 0. It \ - equals {:?} ", - chunk_size + equals {chunk_size:?} " ); assert!( n_workers > 0, "When running transactions concurrently the number of workers must be greater \ - than 0. It equals {:?} ", - n_workers + than 0. It equals {n_workers:?} " ); txs.chunks(chunk_size) .fold_while(Vec::new(), |mut results, chunk| { diff --git a/crates/blockifier/src/blockifier/transfers_flow_test.rs b/crates/blockifier/src/blockifier/transfers_flow_test.rs index ba1969c9471..e6f1ce1980e 100644 --- a/crates/blockifier/src/blockifier/transfers_flow_test.rs +++ b/crates/blockifier/src/blockifier/transfers_flow_test.rs @@ -52,8 +52,8 @@ pub fn transfers_flow_test( assert_eq!( &block_summary, expected_block_summary, - "Block Results differ for concurrency_enabled: {}; cairo1_version: {:?}", - concurrency_enabled, cairo1_version + "Block Results differ for concurrency_enabled: {concurrency_enabled}; \ + cairo1_version: {cairo1_version:?}" ); } } @@ -94,7 +94,7 @@ pub fn transfers_flow_test_body( assert_eq!(n_results, N_TXS); } _ => { - panic!("Unexpected timeout value: {:?}", timeout); + panic!("Unexpected timeout value: {timeout:?}"); } } diff --git a/crates/blockifier/src/blockifier_versioned_constants.rs b/crates/blockifier/src/blockifier_versioned_constants.rs index 1c8ae1bc796..f5af65ff426 100644 --- a/crates/blockifier/src/blockifier_versioned_constants.rs +++ b/crates/blockifier/src/blockifier_versioned_constants.rs @@ -1020,7 +1020,7 @@ impl GasCosts { builtin_costs: &BuiltinGasCosts, ) -> SyscallGasCost { let raw_cost = syscall_gas_costs.get(&selector).unwrap_or_else(|| { - panic!("{selector:?} missing from syscall_gas_costs map. Map: {:?}", syscall_gas_costs) + panic!("{selector:?} missing from syscall_gas_costs map. Map: {syscall_gas_costs:?}") }); SyscallGasCost::new_from_base_cost(match raw_cost { RawSyscallGasCost::Flat(flat_cost) => *flat_cost, diff --git a/crates/blockifier/src/bouncer.rs b/crates/blockifier/src/bouncer.rs index 8aaeab003d0..bba2add363c 100644 --- a/crates/blockifier/src/bouncer.rs +++ b/crates/blockifier/src/bouncer.rs @@ -576,8 +576,8 @@ fn vm_resource_to_gas_amount(amount: usize, gas_per_unit: u64, name: &str) -> Ga let amount_u64 = u64_from_usize(amount); let gas = amount_u64.checked_mul(gas_per_unit).unwrap_or_else(|| { panic!( - "Multiplication overflow converting {name} to gas. units: {}, gas per unit: {}.", - amount_u64, gas_per_unit + "Multiplication overflow converting {name} to gas. units: {amount_u64}, gas per unit: \ + {gas_per_unit}." ) }); @@ -655,11 +655,8 @@ pub fn sierra_gas_to_steps_gas( sierra_gas.checked_sub(builtins_gas_cost).unwrap_or_else(|| { log::debug!( - "Sierra gas underflow: builtins gas exceeds total. Sierra gas: {:?}, Builtins gas: \ - {:?}, Builtins: {:?}", - sierra_gas, - builtins_gas_cost, - builtin_counters + "Sierra gas underflow: builtins gas exceeds total. Sierra gas: {sierra_gas:?}, \ + Builtins gas: {builtins_gas_cost:?}, Builtins: {builtin_counters:?}" ); GasAmount::ZERO }) @@ -676,15 +673,15 @@ pub fn builtins_to_sierra_gas( .try_fold(0u64, |accumulated_gas, (&builtin, &count)| { let builtin_gas_cost = gas_costs .get_builtin_gas_cost(&builtin) - .unwrap_or_else(|err| panic!("Failed to get gas cost: {}", err)); + .unwrap_or_else(|err| panic!("Failed to get gas cost: {err}")); let builtin_counters_u64 = u64_from_usize(count); let builtin_total_cost = builtin_counters_u64.checked_mul(builtin_gas_cost)?; accumulated_gas.checked_add(builtin_total_cost) }) .unwrap_or_else(|| { panic!( - "Overflow occurred while converting built-in resources to gas. Builtins: {:?}", - builtin_counters + "Overflow occurred while converting built-in resources to gas. Builtins: \ + {builtin_counters:?}" ) }); diff --git a/crates/blockifier/src/bouncer_test.rs b/crates/blockifier/src/bouncer_test.rs index b2b952b51d3..4e287c8106f 100644 --- a/crates/blockifier/src/bouncer_test.rs +++ b/crates/blockifier/src/bouncer_test.rs @@ -259,7 +259,7 @@ fn test_bouncer_try_update_sierra_gas( TransactionExecutionError::TransactionTooLarge { max_capacity, tx_size } ) ) if *max_capacity == block_max_capacity && *tx_size == expected_weights), - _ => panic!("Unexpected scenario: {}", scenario), + _ => panic!("Unexpected scenario: {scenario}"), } } diff --git a/crates/blockifier/src/concurrency/worker_logic_test.rs b/crates/blockifier/src/concurrency/worker_logic_test.rs index 5f25b02c52f..42353c4159e 100644 --- a/crates/blockifier/src/concurrency/worker_logic_test.rs +++ b/crates/blockifier/src/concurrency/worker_logic_test.rs @@ -150,7 +150,7 @@ pub fn test_commit_tx() { if should_pass_validation { assert_eq!(commit_result, CommitResult::Success); } else { - assert_eq!(commit_result, CommitResult::ValidationFailed, "commit_idx: {}", commit_idx); + assert_eq!(commit_result, CommitResult::ValidationFailed, "commit_idx: {commit_idx}"); // Re-execute the transaction. executor.execute_tx(commit_idx); // Commit again. This time it should succeed. 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 61e1c692f28..58d4a36df8e 100644 --- a/crates/blockifier/src/execution/deprecated_syscalls/deprecated_syscalls_test.rs +++ b/crates/blockifier/src/execution/deprecated_syscalls/deprecated_syscalls_test.rs @@ -483,7 +483,7 @@ fn test_block_info_syscalls( ) { let test_contract = FeatureContract::TestContract(CairoVersion::Cairo0); let mut state = test_state(&ChainInfo::create_for_testing(), Fee(0), &[(test_contract, 1)]); - let entry_point_selector = selector_from_name(&format!("test_get_{}", block_info_member_name)); + let entry_point_selector = selector_from_name(&format!("test_get_{block_info_member_name}")); let entry_point_call = CallEntryPoint { entry_point_selector, calldata, @@ -496,8 +496,7 @@ fn test_block_info_syscalls( check_entry_point_execution_error_for_custom_hint!( &error, &format!( - "Unauthorized syscall get_{} in execution mode Validate.", - block_info_member_name + "Unauthorized syscall get_{block_info_member_name} in execution mode Validate." ), ); } else { @@ -617,7 +616,7 @@ fn test_emit_event() { data_length: max_event_data_length + 1, max_data_length: max_event_data_length, }; - assert!(error.to_string().contains(format!("{}", expected_error).as_str())); + assert!(error.to_string().contains(format!("{expected_error}").as_str())); // Negative flow, the keys length exceeds the limit. let max_event_keys_length = versioned_constants.tx_event_limits.max_keys_length; @@ -627,7 +626,7 @@ fn test_emit_event() { keys_length: max_event_keys_length + 1, max_keys_length: max_event_keys_length, }; - assert!(error.to_string().contains(format!("{}", expected_error).as_str())); + assert!(error.to_string().contains(format!("{expected_error}").as_str())); // Negative flow, the number of events exceeds the limit. let max_n_emitted_events = versioned_constants.tx_event_limits.max_n_emitted_events; @@ -639,7 +638,7 @@ fn test_emit_event() { n_emitted_events: max_n_emitted_events + 1, max_n_emitted_events, }; - assert!(error.to_string().contains(format!("{}", expected_error).as_str())); + assert!(error.to_string().contains(format!("{expected_error}").as_str())); } fn emit_events( diff --git a/crates/blockifier/src/execution/stack_trace.rs b/crates/blockifier/src/execution/stack_trace.rs index f05a023b167..0fffa275b40 100644 --- a/crates/blockifier/src/execution/stack_trace.rs +++ b/crates/blockifier/src/execution/stack_trace.rs @@ -92,7 +92,7 @@ impl From<&VmExceptionFrame> for String { }; let vm_exception_preamble = format!("Error at pc={}:", value.pc); let vm_exception_traceback = if let Some(traceback) = &value.traceback { - format!("\n{}", traceback) + format!("\n{traceback}") } else { "".to_string() }; @@ -194,7 +194,7 @@ pub static MIN_CAIRO1_FRAME_LENGTH: LazyLock = LazyLock::new(|| { selector: EntryPointSelector::default(), }; // +1 for newline. - format!("{}", frame).len() + 1 + format!("{frame}").len() + 1 }); impl From<&&CallInfo> for Cairo1RevertFrame { @@ -282,7 +282,7 @@ impl Display for Cairo1RevertSummary { .collect::() + Self::TRUNCATION_SEPARATOR }; - return write!(f, "{}", output); + return write!(f, "{output}"); } let untruncated_string = [header.clone()] @@ -292,7 +292,7 @@ impl Display for Cairo1RevertSummary { .join("\n") + tail; if untruncated_string.len() <= TRACE_LENGTH_CAP { - return write!(f, "{}", untruncated_string); + return write!(f, "{untruncated_string}"); } // If the number of frames is too large, drop frames above the last frame (two frames are @@ -539,7 +539,7 @@ fn extract_virtual_machine_error_into_stack_trace( } } _ => { - error_stack.push(format!("{}\n", vm_error).into()); + error_stack.push(format!("{vm_error}\n").into()); } } } @@ -716,6 +716,6 @@ fn extract_entry_point_execution_error_into_stack_trace( EntryPointExecutionError::ExecutionFailed { error_trace } => { error_stack.push(error_trace.clone().into()) } - _ => error_stack.push(format!("{}\n", entry_point_error).into()), + _ => error_stack.push(format!("{entry_point_error}\n").into()), } } diff --git a/crates/blockifier/src/execution/syscalls/syscall_tests/builtins_test.rs b/crates/blockifier/src/execution/syscalls/syscall_tests/builtins_test.rs index 31332afdc5e..a24dbb5d7f2 100644 --- a/crates/blockifier/src/execution/syscalls/syscall_tests/builtins_test.rs +++ b/crates/blockifier/src/execution/syscalls/syscall_tests/builtins_test.rs @@ -73,6 +73,6 @@ fn change_builtins_gas_cost(block_context: &mut BlockContext, selector_name: &st os_constants.gas_costs.builtins.add_mod = TESTED_BUILTIN_GAS_COST; os_constants.gas_costs.builtins.mul_mod = TESTED_BUILTIN_GAS_COST; } - _ => panic!("Unknown selector name: {}", selector_name), + _ => panic!("Unknown selector name: {selector_name}"), } } 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 83146a94d4c..ba00ae8711c 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 @@ -512,6 +512,6 @@ fn str_to_32_bytes_in_hex(s: &str) -> String { let prefix = "0x"; let padding_zeros = "0".repeat(64 - s.len() * 2); // Each string char is 2 chars in hex. let word_in_hex: String = - s.as_bytes().iter().fold(String::new(), |s, byte| s + (&format!("{:02x}", byte))); + s.as_bytes().iter().fold(String::new(), |s, byte| s + (&format!("{byte:02x}"))); [prefix, &padding_zeros, &word_in_hex].into_iter().collect() } diff --git a/crates/blockifier/src/fee/fee_utils.rs b/crates/blockifier/src/fee/fee_utils.rs index f6c324a6a14..927a8feafe9 100644 --- a/crates/blockifier/src/fee/fee_utils.rs +++ b/crates/blockifier/src/fee/fee_utils.rs @@ -79,9 +79,7 @@ pub fn get_vm_resources_cost( let known_builtins = HashSet::<&BuiltinName>::from_iter(vm_resource_fee_costs.builtins.keys()); assert!( used_builtins.is_subset(&known_builtins), - "{:#?} should contain {:#?}", - known_builtins, - used_builtins, + "{known_builtins:#?} should contain {used_builtins:#?}", ); // Convert Cairo resource usage to L1 gas usage. diff --git a/crates/blockifier/src/state/native_class_manager.rs b/crates/blockifier/src/state/native_class_manager.rs index 5f63b945299..6f4b26fbe43 100644 --- a/crates/blockifier/src/state/native_class_manager.rs +++ b/crates/blockifier/src/state/native_class_manager.rs @@ -288,7 +288,7 @@ fn process_compilation_request( class_hash, CompiledClasses::V1Native(CachedCairoNative::CompilationFailed(casm)), ); - log::debug!("Error compiling contract class: {}", err); + log::debug!("Error compiling contract class: {err}"); NATIVE_COMPILATION_ERROR.increment(1); if panic_on_compilation_failure { panic!("Compilation failed"); diff --git a/crates/blockifier/src/test_utils/test_templates.rs b/crates/blockifier/src/test_utils/test_templates.rs index 310e069a773..0b3dc84e725 100644 --- a/crates/blockifier/src/test_utils/test_templates.rs +++ b/crates/blockifier/src/test_utils/test_templates.rs @@ -75,15 +75,15 @@ fn two_cairo_versions( #[apply(cairo_version)] fn test_cairo_version(cairo_version: CairoVersion) { - println!("test {:?}", cairo_version); + println!("test {cairo_version:?}"); } #[apply(two_cairo_versions)] fn test_two_cairo_version(cairo_version1: CairoVersion, cairo_version2: CairoVersion) { - println!("test {:?} {:?}", cairo_version1, cairo_version2); + println!("test {cairo_version1:?} {cairo_version2:?}"); } #[apply(runnable_version)] fn test_runnable_version(runnable_version: RunnableCairo1) { - println!("test {:?}", runnable_version); + println!("test {runnable_version:?}"); } diff --git a/crates/blockifier/src/transaction/account_transaction.rs b/crates/blockifier/src/transaction/account_transaction.rs index e728441a85f..491dd66f271 100644 --- a/crates/blockifier/src/transaction/account_transaction.rs +++ b/crates/blockifier/src/transaction/account_transaction.rs @@ -410,10 +410,7 @@ impl AccountTransaction { ); } TransactionInfo::Deprecated(_) => { - panic!( - "Actual fee {:#?} exceeded bounds; max fee is {:#?}.", - actual_fee, max_fee - ); + panic!("Actual fee {actual_fee:#?} exceeded bounds; max fee is {max_fee:#?}."); } } } diff --git a/crates/blockifier/src/transaction/errors.rs b/crates/blockifier/src/transaction/errors.rs index f0e6b90dc8d..fd19961c8ee 100644 --- a/crates/blockifier/src/transaction/errors.rs +++ b/crates/blockifier/src/transaction/errors.rs @@ -61,7 +61,7 @@ pub enum TransactionFeeError { MaxFeeExceedsBalance { max_fee: Fee, balance: BigUint }, #[error("Max fee ({}) is too low. Minimum fee: {}.", max_fee.0, min_fee.0)] MaxFeeTooLow { min_fee: Fee, max_fee: Fee }, - #[error("Resource bounds were not satisfied: {}", errors.iter().map(|e| format!("{}", e)).collect::>().join("\n"))] + #[error("Resource bounds were not satisfied: {}", errors.iter().map(|e| format!("{e}")).collect::>().join("\n"))] InsufficientResourceBounds { errors: Vec }, #[error("Missing L1 gas bounds in resource bounds.")] MissingL1GasBounds, diff --git a/crates/blockifier/src/transaction/transactions_test.rs b/crates/blockifier/src/transaction/transactions_test.rs index 176616dd1d9..7e0bc28685d 100644 --- a/crates/blockifier/src/transaction/transactions_test.rs +++ b/crates/blockifier/src/transaction/transactions_test.rs @@ -2277,7 +2277,7 @@ fn check_native_validate_error( assert!(!validate_constructor); boxed_syscall_error } - _ => panic!("Unexpected error: {:?}", boxed_error), + _ => panic!("Unexpected error: {boxed_error:?}"), } } TransactionExecutionError::ContractConstructorExecutionFailed( @@ -2287,7 +2287,7 @@ fn check_native_validate_error( assert!(validate_constructor); boxed_syscall_error } - _ => panic!("Unexpected error: {:?}", boxed_error), + _ => panic!("Unexpected error: {boxed_error:?}"), }, _ => panic!("Unexpected error: {:?}", &error), }; @@ -2943,7 +2943,7 @@ fn test_execute_tx_with_invalid_tx_version( .revert_error .unwrap() .to_string() - .contains(format!("ASSERT_EQ instruction failed: {} != 3.", invalid_version).as_str()) + .contains(format!("ASSERT_EQ instruction failed: {invalid_version} != 3.").as_str()) ); } @@ -3031,7 +3031,7 @@ fn test_emit_event_exceeds_limit( match &expected_error { Some(expected_error) => { let error_string = execution_info.revert_error.unwrap().to_string(); - assert!(error_string.contains(&format!("{}", expected_error))); + assert!(error_string.contains(&format!("{expected_error}"))); } None => { assert!(!execution_info.is_reverted()); @@ -3042,7 +3042,7 @@ fn test_emit_event_exceeds_limit( #[test] fn test_balance_print() { let int = balance_to_big_uint(&Felt::from(16_u64), &Felt::from(1_u64)); - assert!(format!("{}", int) == (BigUint::from(u128::MAX) + BigUint::from(17_u128)).to_string()); + assert!(format!("{int}") == (BigUint::from(u128::MAX) + BigUint::from(17_u128)).to_string()); } #[apply(two_cairo_versions)] diff --git a/crates/blockifier/src/utils.rs b/crates/blockifier/src/utils.rs index 5991eea7ff4..ab8120ae6b9 100644 --- a/crates/blockifier/src/utils.rs +++ b/crates/blockifier/src/utils.rs @@ -77,7 +77,7 @@ pub fn get_gas_cost_from_vm_resources( .map(|(builtin, amount)| { let builtin_cost = builtin_costs .get_builtin_gas_cost(builtin) - .unwrap_or_else(|err| panic!("Failed to get gas cost: {}", err)); + .unwrap_or_else(|err| panic!("Failed to get gas cost: {err}")); builtin_cost * u64_from_usize(*amount) }) .sum(); @@ -99,7 +99,7 @@ where dest.entry(key.clone()) .and_modify(|existing| { *existing = existing.checked_add(value).unwrap_or_else(|| { - panic!("add counters: overflow when adding {:?} to {:?}", value, existing) + panic!("add counters: overflow when adding {value:?} to {existing:?}") }); }) .or_insert_with(|| value.clone()); 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 5ec14aabfa8..64cbefad41b 100644 --- a/crates/blockifier_reexecution/src/state_reader/offline_state_reader.rs +++ b/crates/blockifier_reexecution/src/state_reader/offline_state_reader.rs @@ -137,8 +137,7 @@ impl StateReader for OfflineStateReader { ) -> StateResult { Ok(*self.state_maps.storage.get(&(contract_address, key)).ok_or( StateError::StateReadError(format!( - "Missing Storage Value at contract_address: {}, key:{:?}", - contract_address, key + "Missing Storage Value at contract_address: {contract_address}, key:{key:?}" )), )?) } 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 75e6b4f17b1..e03044bb6ac 100644 --- a/crates/blockifier_reexecution/src/state_reader/rpc_https_test.rs +++ b/crates/blockifier_reexecution/src/state_reader/rpc_https_test.rs @@ -142,9 +142,9 @@ pub fn test_get_contract_class(test_state_reader: TestStateReader, test_block_nu let deprecated_contract_class = test_state_reader.get_contract_class(&class_hash).unwrap_or_else(|err| { panic!( - "Error retrieving deprecated contract class for class hash {}: {} - This class hash exist in Mainnet Block Number: {}", - class_hash, test_block_number, err + "Error retrieving deprecated contract class for class hash {class_hash}: \ + {test_block_number} + This class hash exist in Mainnet Block Number: {err}" ); }); @@ -162,7 +162,7 @@ pub fn test_get_contract_class(test_state_reader: TestStateReader, test_block_nu #[rstest] pub fn test_get_tx_hashes(test_state_reader: TestStateReader) { test_state_reader.get_tx_hashes().unwrap_or_else(|err| { - panic!("Error retrieving txs hash: {}", err); + panic!("Error retrieving txs hash: {err}"); }); } diff --git a/crates/blockifier_test_utils/src/cairo_compile.rs b/crates/blockifier_test_utils/src/cairo_compile.rs index 4da261d35f2..84634de05fa 100644 --- a/crates/blockifier_test_utils/src/cairo_compile.rs +++ b/crates/blockifier_test_utils/src/cairo_compile.rs @@ -14,7 +14,7 @@ pub enum CompilationArtifacts { } pub fn cairo1_compiler_tag() -> String { - format!("v{}", CAIRO1_COMPILER_VERSION) + format!("v{CAIRO1_COMPILER_VERSION}") } /// Path to local compiler package directory, of the specified version. diff --git a/crates/blockifier_test_utils/src/cairo_versions.rs b/crates/blockifier_test_utils/src/cairo_versions.rs index 82ed2eaf5dc..46b11e97793 100644 --- a/crates/blockifier_test_utils/src/cairo_versions.rs +++ b/crates/blockifier_test_utils/src/cairo_versions.rs @@ -49,7 +49,7 @@ impl CairoVersion { } else if tx_version == TransactionVersion::TWO || tx_version == TransactionVersion::THREE { CairoVersion::Cairo1(RunnableCairo1::Casm) } else { - panic!("Transaction version {:?} is not supported.", tx_version) + panic!("Transaction version {tx_version:?} is not supported.") } } diff --git a/crates/blockifier_test_utils/src/contracts.rs b/crates/blockifier_test_utils/src/contracts.rs index e316aada2be..941d3b6968c 100644 --- a/crates/blockifier_test_utils/src/contracts.rs +++ b/crates/blockifier_test_utils/src/contracts.rs @@ -430,5 +430,5 @@ impl FeatureContract { pub fn get_raw_contract_class(contract_path: &str) -> String { let path: PathBuf = [compile_time_cargo_manifest_dir!(), contract_path].iter().collect(); fs::read_to_string(&path) - .unwrap_or_else(|e| panic!("Failed to read contract from {:?}: {}", path, e)) + .unwrap_or_else(|e| panic!("Failed to read contract from {path:?}: {e}")) } diff --git a/crates/blockifier_test_utils/tests/feature_contracts_compatibility_test.rs b/crates/blockifier_test_utils/tests/feature_contracts_compatibility_test.rs index 28963979eb1..033e67790d2 100644 --- a/crates/blockifier_test_utils/tests/feature_contracts_compatibility_test.rs +++ b/crates/blockifier_test_utils/tests/feature_contracts_compatibility_test.rs @@ -117,9 +117,8 @@ fn check_compilation( ) { if String::from_utf8(actual_content).unwrap() != existing_contents { panic!( - "{} does not compile to {}.\nRun `{FIX_COMMAND}` to fix the existing file according \ - to locally installed `starknet-compile-deprecated`.\n", - source_path, path + "{source_path} does not compile to {path}.\nRun `{FIX_COMMAND}` to fix the existing \ + file according to locally installed `starknet-compile-deprecated`.\n" ); } } diff --git a/crates/native_blockifier/src/py_block_executor.rs b/crates/native_blockifier/src/py_block_executor.rs index ad7037c229b..2695ad2bc2f 100644 --- a/crates/native_blockifier/src/py_block_executor.rs +++ b/crates/native_blockifier/src/py_block_executor.rs @@ -470,5 +470,5 @@ impl Default for PyOsConfig { fn serialize_failure_reason(error: TransactionExecutorError) -> RawTransactionExecutionResult { // TODO(Yoni, 1/7/2024): re-consider this serialization. - serde_json::to_vec(&format!("{}", error)).expect(RESULT_SERIALIZE_ERR) + serde_json::to_vec(&format!("{error}")).expect(RESULT_SERIALIZE_ERR) } diff --git a/crates/papyrus_base_layer/src/monitored_base_layer.rs b/crates/papyrus_base_layer/src/monitored_base_layer.rs index f3ccdcc33cf..73911af6908 100644 --- a/crates/papyrus_base_layer/src/monitored_base_layer.rs +++ b/crates/papyrus_base_layer/src/monitored_base_layer.rs @@ -222,8 +222,8 @@ impl PartialEq for MonitoredBaseLayerError std::fmt::Debug for MonitoredBaseLayerError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - MonitoredBaseLayerError::L1EndpointMonitorError(err) => write!(f, "{:?}", err), - MonitoredBaseLayerError::BaseLayerContractError(err) => write!(f, "{:?}", err), + MonitoredBaseLayerError::L1EndpointMonitorError(err) => write!(f, "{err:?}"), + MonitoredBaseLayerError::BaseLayerContractError(err) => write!(f, "{err:?}"), } } } diff --git a/crates/papyrus_base_layer/src/test_utils.rs b/crates/papyrus_base_layer/src/test_utils.rs index 06fd2765801..a735b0a6861 100644 --- a/crates/papyrus_base_layer/src/test_utils.rs +++ b/crates/papyrus_base_layer/src/test_utils.rs @@ -125,7 +125,7 @@ pub fn anvil(port: Option) -> AnvilInstance { pub fn ethereum_base_layer_config_for_anvil(port: Option) -> EthereumBaseLayerConfig { // Use the specified port if provided; otherwise, default to Anvil's default port. let non_optional_port = port.unwrap_or(DEFAULT_ANVIL_PORT); - let endpoint = format!("http://localhost:{}", non_optional_port); + let endpoint = format!("http://localhost:{non_optional_port}"); EthereumBaseLayerConfig { node_url: Url::parse(&endpoint).unwrap(), starknet_contract_address: DEFAULT_ANVIL_L1_DEPLOYED_ADDRESS.parse().unwrap(), diff --git a/crates/papyrus_common/src/python_json.rs b/crates/papyrus_common/src/python_json.rs index 220a874bb08..1aaadaa6e90 100644 --- a/crates/papyrus_common/src/python_json.rs +++ b/crates/papyrus_common/src/python_json.rs @@ -41,7 +41,7 @@ impl Formatter for PythonJsonFormatter { } else { let slice = ch.encode_utf16(&mut buf); for num in slice { - write!(writer, r"\u{:4x}", num)?; + write!(writer, r"\u{num:4x}")?; } } } diff --git a/crates/papyrus_load_test/src/compare_endpoints.rs b/crates/papyrus_load_test/src/compare_endpoints.rs index e3968e2f8a5..5f1eb66b68a 100644 --- a/crates/papyrus_load_test/src/compare_endpoints.rs +++ b/crates/papyrus_load_test/src/compare_endpoints.rs @@ -125,13 +125,13 @@ async fn compare(requests: Vec, endpoint: &str, fixes: &[fn(&mut jsonVa create_dir(¶m_path).unwrap(); let mut file = File::create(param_path.join(&*REQUEST_FILE_NAME)).unwrap(); - file.write_all(format!("{:#?}", request).as_bytes()).unwrap(); + file.write_all(format!("{request:#?}").as_bytes()).unwrap(); let mut file = File::create(param_path.join(&*ALPHA_RESPONSE_FILE_NAME)).unwrap(); - file.write_all(format!("{:#?}", alpha_response).as_bytes()).unwrap(); + file.write_all(format!("{alpha_response:#?}").as_bytes()).unwrap(); let mut file = File::create(param_path.join(&*BETA_RESPONSE_FILE_NAME)).unwrap(); - file.write_all(format!("{:#?}", beta_response).as_bytes()).unwrap(); + file.write_all(format!("{beta_response:#?}").as_bytes()).unwrap(); } } diff --git a/crates/papyrus_node/examples/get_transaction_hash.rs b/crates/papyrus_node/examples/get_transaction_hash.rs index 73517ef97cf..18342e49835 100644 --- a/crates/papyrus_node/examples/get_transaction_hash.rs +++ b/crates/papyrus_node/examples/get_transaction_hash.rs @@ -162,14 +162,13 @@ async fn main() -> Result<(), Box> { let node_url_ref = node_url.clone(); let handle = async move { - println!("Processing block number: {}", block_number); + println!("Processing block number: {block_number}"); let block_transactions = get_block_transactions_via_rpc(&client_ref, node_url_ref.clone(), block_number) .await .unwrap_or_else(|_| { println!( - "Failed to get block transactions for block number: {}", - block_number + "Failed to get block transactions for block number: {block_number}" ); vec![] }); diff --git a/crates/starknet_api/src/contract_class.rs b/crates/starknet_api/src/contract_class.rs index 8f756d80fef..6d1d739e4eb 100644 --- a/crates/starknet_api/src/contract_class.rs +++ b/crates/starknet_api/src/contract_class.rs @@ -106,9 +106,8 @@ impl SierraVersion { .map(|(index, felt)| { felt.clone().try_into().map_err(|err| { StarknetApiError::ParseSierraVersionError(format!( - "Failed to parse Sierra program to Sierra version. Index: {}, Felt: {}, \ - Error: {}", - index, felt, err + "Failed to parse Sierra program to Sierra version. Index: {index}, Felt: \ + {felt}, Error: {err}" )) }) }) diff --git a/crates/starknet_api/src/core.rs b/crates/starknet_api/src/core.rs index 79a71eb5809..75b87f35fa7 100644 --- a/crates/starknet_api/src/core.rs +++ b/crates/starknet_api/src/core.rs @@ -22,7 +22,7 @@ use crate::{impl_from_through_intermediate, StarknetApiError}; /// Felt. pub fn ascii_as_felt(ascii_str: &str) -> Result { Felt::from_hex(hex::encode(ascii_str).as_str()).map_err(|_| StarknetApiError::OutOfRange { - string: format!("The str {}, does not fit into a single felt", ascii_str), + string: format!("The str {ascii_str}, does not fit into a single felt"), }) } @@ -75,7 +75,7 @@ impl std::fmt::Display for ChainId { ChainId::Mainnet => write!(f, "SN_MAIN"), ChainId::Sepolia => write!(f, "SN_SEPOLIA"), ChainId::IntegrationSepolia => write!(f, "SN_INTEGRATION_SEPOLIA"), - ChainId::Other(ref s) => write!(f, "{}", s), + ChainId::Other(ref s) => write!(f, "{s}"), } } } @@ -93,11 +93,9 @@ where let hex_str = String::deserialize(deserializer)?; let chain_id_str = std::str::from_utf8(&hex::decode(hex_str.trim_start_matches("0x")).map_err(|e| { - D::Error::custom(format!("Failed to decode the hex string {hex_str}. Error: {:?}", e)) + D::Error::custom(format!("Failed to decode the hex string {hex_str}. Error: {e:?}")) })?) - .map_err(|e| { - D::Error::custom(format!("Failed to convert to UTF-8 string. Error: {:?}", e)) - })? + .map_err(|e| D::Error::custom(format!("Failed to convert to UTF-8 string. Error: {e:?}")))? .to_string(); Ok(ChainId::from(chain_id_str)) } @@ -138,7 +136,7 @@ impl ContractAddress { return Ok(()); } - Err(StarknetApiError::OutOfRange { string: format!("[0x2, {})", l2_address_upper_bound) }) + Err(StarknetApiError::OutOfRange { string: format!("[0x2, {l2_address_upper_bound})") }) } } @@ -258,7 +256,7 @@ impl Nonce { // Check if an overflow occurred during increment. let incremented = self.0 + Felt::ONE; if incremented == Felt::ZERO { - return Err(StarknetApiError::OutOfRange { string: format!("{:?}", self) }); + return Err(StarknetApiError::OutOfRange { string: format!("{self:?}") }); } Ok(Self(incremented)) } @@ -266,7 +264,7 @@ impl Nonce { pub fn try_decrement(&self) -> Result { // Check if an underflow occurred during decrement. if self.0 == Felt::ZERO { - return Err(StarknetApiError::OutOfRange { string: format!("{:?}", self) }); + return Err(StarknetApiError::OutOfRange { string: format!("{self:?}") }); } Ok(Self(self.0 - Felt::ONE)) } diff --git a/crates/starknet_api/src/deprecated_contract_class.rs b/crates/starknet_api/src/deprecated_contract_class.rs index df03fc4fcf6..2fa7bdd5304 100644 --- a/crates/starknet_api/src/deprecated_contract_class.rs +++ b/crates/starknet_api/src/deprecated_contract_class.rs @@ -230,5 +230,5 @@ fn usize_to_hex(value: &usize, s: S) -> Result where S: Serializer, { - s.serialize_str(format!("{:#x}", value).as_str()) + s.serialize_str(format!("{value:#x}").as_str()) } diff --git a/crates/starknet_api/src/execution_resources.rs b/crates/starknet_api/src/execution_resources.rs index e215a84d4cb..5309aa12f93 100644 --- a/crates/starknet_api/src/execution_resources.rs +++ b/crates/starknet_api/src/execution_resources.rs @@ -67,9 +67,8 @@ impl GasAmount { pub fn checked_add_panic_on_overflow(self, added_gas: GasAmount) -> GasAmount { self.checked_add(added_gas).unwrap_or_else(|| { panic!( - "Addition overflow while adding gas. current gas: {}, try to add - gas: {}.", - self, added_gas + "Addition overflow while adding gas. current gas: {self}, try to add + gas: {added_gas}.", ) }) } @@ -172,16 +171,14 @@ impl GasVector { ] { let cost = gas.checked_mul(price.get()).unwrap_or_else(|| { panic!( - "{} cost overflowed: multiplication of gas amount ({}) by price per unit ({}) \ - resulted in overflow.", - resource, gas, price + "{resource} cost overflowed: multiplication of gas amount ({gas}) by price \ + per unit ({price}) resulted in overflow." ) }); sum = sum.checked_add(cost).unwrap_or_else(|| { panic!( - "Total cost overflowed: addition of current sum ({}) and cost of {} ({}) \ - resulted in overflow.", - sum, resource, cost + "Total cost overflowed: addition of current sum ({sum}) and cost of \ + {resource} ({cost}) resulted in overflow." ) }); } @@ -210,24 +207,21 @@ pub fn to_discounted_l1_gas( ) -> GasAmount { let l1_data_gas_fee = l1_data_gas.checked_mul(l1_data_gas_price).unwrap_or_else(|| { panic!( - "Discounted L1 gas cost overflowed: multiplication of L1 data gas ({}) by L1 data gas \ - price ({}) resulted in overflow.", - l1_data_gas, l1_data_gas_price + "Discounted L1 gas cost overflowed: multiplication of L1 data gas ({l1_data_gas}) by \ + L1 data gas price ({l1_data_gas_price}) resulted in overflow." ); }); let l1_data_gas_in_l1_gas_units = l1_data_gas_fee.checked_div_ceil(l1_gas_price).unwrap_or_else(|| { panic!( - "Discounted L1 gas cost overflowed: division of L1 data fee ({}) by regular L1 \ - gas price ({}) resulted in overflow.", - l1_data_gas_fee, l1_gas_price + "Discounted L1 gas cost overflowed: division of L1 data fee ({l1_data_gas_fee}) \ + by regular L1 gas price ({l1_gas_price}) resulted in overflow." ); }); l1_gas.checked_add(l1_data_gas_in_l1_gas_units).unwrap_or_else(|| { panic!( - "Overflow while computing discounted L1 gas: L1 gas ({}) + L1 data gas in L1 gas \ - units ({}) resulted in overflow.", - l1_gas, l1_data_gas_in_l1_gas_units + "Overflow while computing discounted L1 gas: L1 gas ({l1_gas}) + L1 data gas in L1 \ + gas units ({l1_data_gas_in_l1_gas_units}) resulted in overflow." ) }) } diff --git a/crates/starknet_committer/src/patricia_merkle_tree/types.rs b/crates/starknet_committer/src/patricia_merkle_tree/types.rs index 60ef41e7342..2c1bcf8660d 100644 --- a/crates/starknet_committer/src/patricia_merkle_tree/types.rs +++ b/crates/starknet_committer/src/patricia_merkle_tree/types.rs @@ -10,7 +10,7 @@ use crate::block_committer::input::StarknetStorageValue; use crate::patricia_merkle_tree::leaf::leaf_impl::ContractState; pub fn fixed_hex_string_no_prefix(felt: &Felt) -> String { - format!("{:064x}", felt) + format!("{felt:064x}") } pub fn class_hash_into_node_index(class_hash: &ClassHash) -> NodeIndex { diff --git a/crates/starknet_committer_and_os_cli/src/block_hash_cli/run_block_hash_cli.rs b/crates/starknet_committer_and_os_cli/src/block_hash_cli/run_block_hash_cli.rs index a742c11136c..ceefe71b2e2 100644 --- a/crates/starknet_committer_and_os_cli/src/block_hash_cli/run_block_hash_cli.rs +++ b/crates/starknet_committer_and_os_cli/src/block_hash_cli/run_block_hash_cli.rs @@ -39,7 +39,7 @@ pub async fn run_block_hash_cli(block_hash_cli_command: BlockHashCliCommand) { info!("Successfully loaded block hash input."); let block_hash = calculate_block_hash(block_hash_input.header, block_hash_input.block_commitments) - .unwrap_or_else(|error| panic!("Failed to calculate block hash: {}", error)); + .unwrap_or_else(|error| panic!("Failed to calculate block hash: {error}")); write_to_file(&output_path, &block_hash); info!("Successfully computed block hash {:?}.", block_hash); } diff --git a/crates/starknet_committer_and_os_cli/src/committer_cli/tests/python_tests.rs b/crates/starknet_committer_and_os_cli/src/committer_cli/tests/python_tests.rs index 1826addad2f..382515893cc 100644 --- a/crates/starknet_committer_and_os_cli/src/committer_cli/tests/python_tests.rs +++ b/crates/starknet_committer_and_os_cli/src/committer_cli/tests/python_tests.rs @@ -204,8 +204,7 @@ fn get_or_key_not_found<'a, T: Debug>( ) -> Result<&'a T, CommitterPythonTestError> { map.get(key).ok_or_else(|| { PythonTestError::SpecificError(CommitterSpecificTestError::KeyNotFound(format!( - "Failed to get value for key '{}' from {:?}.", - key, map + "Failed to get value for key '{key}' from {map:?}." ))) }) } @@ -217,14 +216,14 @@ fn get_actual_tree_height() -> String { pub(crate) fn example_test(test_args: HashMap) -> String { let x = test_args.get("x").expect("Failed to get value for key 'x'"); let y = test_args.get("y").expect("Failed to get value for key 'y'"); - format!("Calling example test with args: x: {}, y: {}", x, y) + format!("Calling example test with args: x: {x}, y: {y}") } /// Serializes a Felt into a string. pub(crate) fn felt_serialize_test(felt: u128) -> String { let bytes = Felt::from(felt).to_bytes_be().to_vec(); serde_json::to_string(&bytes) - .unwrap_or_else(|error| panic!("Failed to serialize felt: {}", error)) + .unwrap_or_else(|error| panic!("Failed to serialize felt: {error}")) } pub(crate) fn test_hash_function(hash_input: HashMap) -> String { @@ -241,7 +240,7 @@ pub(crate) fn test_hash_function(hash_input: HashMap) -> String { // Serialize the hash result. serde_json::to_string(&hash_result) - .unwrap_or_else(|error| panic!("Failed to serialize hash result: {}", error)) + .unwrap_or_else(|error| panic!("Failed to serialize hash result: {error}")) } /// Serializes binary data into a JSON string. @@ -277,7 +276,7 @@ pub(crate) fn test_binary_serialize_test(binary_input: HashMap) -> // Serialize the map to a JSON string and handle serialization errors. serde_json::to_string(&map) - .unwrap_or_else(|error| panic!("Failed to serialize binary fact: {}", error)) + .unwrap_or_else(|error| panic!("Failed to serialize binary fact: {error}")) } pub(crate) fn parse_input_test(committer_input: String) -> CommitterPythonTestResult { @@ -454,7 +453,7 @@ pub(crate) fn test_node_db_key() -> String { // Serialize the map to a JSON string and handle serialization errors. serde_json::to_string(&map) - .unwrap_or_else(|error| panic!("Failed to serialize storage prefix: {}", error)) + .unwrap_or_else(|error| panic!("Failed to serialize storage prefix: {error}")) } /// This function storage_serialize_test generates a MapStorage containing DbKey and diff --git a/crates/starknet_committer_and_os_cli/src/os_cli/commands.rs b/crates/starknet_committer_and_os_cli/src/os_cli/commands.rs index 345cbf4c85b..05d1b252d18 100644 --- a/crates/starknet_committer_and_os_cli/src/os_cli/commands.rs +++ b/crates/starknet_committer_and_os_cli/src/os_cli/commands.rs @@ -87,7 +87,7 @@ pub(crate) fn parse_and_run_os(input_path: String, output_path: String) { let StarknetOsRunnerOutput { os_output, cairo_pie, unused_hints } = run_os_stateless(layout, os_hints) - .unwrap_or_else(|err| panic!("OS run failed. Error: {}", err)); + .unwrap_or_else(|err| panic!("OS run failed. Error: {err}")); serialize_runner_output( &OsCliOutput { os_output, unused_hints }, output_path, @@ -104,7 +104,7 @@ pub(crate) fn parse_and_run_aggregator(input_path: String, output_path: String) let StarknetAggregatorRunnerOutput { aggregator_output, cairo_pie, unused_hints } = run_aggregator(layout, aggregator_input) - .unwrap_or_else(|err| panic!("Aggregator run failed. Error: {}", err)); + .unwrap_or_else(|err| panic!("Aggregator run failed. Error: {err}")); serialize_runner_output( &AggregatorCliOutput { aggregator_output, unused_hints }, output_path, @@ -124,7 +124,7 @@ fn serialize_runner_output( let merge_extra_segments = true; cairo_pie .write_zip_file(Path::new(&cairo_pie_zip_path), merge_extra_segments) - .unwrap_or_else(|err| panic!("Failed to write cairo pie. Error: {}", err)); + .unwrap_or_else(|err| panic!("Failed to write cairo pie. Error: {err}")); } pub(crate) fn dump_source_files(output_path: String) { diff --git a/crates/starknet_committer_and_os_cli/src/os_cli/tests/bls_field.rs b/crates/starknet_committer_and_os_cli/src/os_cli/tests/bls_field.rs index 3372ee3e92e..8a1ba5b45cf 100644 --- a/crates/starknet_committer_and_os_cli/src/os_cli/tests/bls_field.rs +++ b/crates/starknet_committer_and_os_cli/src/os_cli/tests/bls_field.rs @@ -268,7 +268,7 @@ fn test_bls_prime_value(input: &str) -> OsPythonTestResult { let actual_split_bls_prime: [Felt; 3] = array::from_fn(|i| { *program .constants - .get(&format!("starkware.starknet.core.os.data_availability.bls_field.P{}", i)) + .get(&format!("starkware.starknet.core.os.data_availability.bls_field.P{i}")) .unwrap() }); let expected_split_bls_prime = split_bigint3(BLS_PRIME.to_bigint().unwrap()).unwrap(); diff --git a/crates/starknet_committer_and_os_cli/src/shared_utils/types.rs b/crates/starknet_committer_and_os_cli/src/shared_utils/types.rs index d59af9938bf..bcb392e0fdd 100644 --- a/crates/starknet_committer_and_os_cli/src/shared_utils/types.rs +++ b/crates/starknet_committer_and_os_cli/src/shared_utils/types.rs @@ -63,14 +63,14 @@ where { // Create PythonTest from test_name. let test = PT::try_from(python_test_arg.test_name) - .unwrap_or_else(|error| panic!("Failed to create PythonTest: {:?}", error)); + .unwrap_or_else(|error| panic!("Failed to create PythonTest: {error:?}")); let input = read_input(python_test_arg.io_args.input_path); // Run relevant test. let output = test .run(Some(&input)) .await - .unwrap_or_else(|error| panic!("Failed to run test: {:?}", error)); + .unwrap_or_else(|error| panic!("Failed to run test: {error:?}")); // Write test's output. write_to_file(&python_test_arg.io_args.output_path, &output); diff --git a/crates/starknet_os/src/hint_processor/os_logger.rs b/crates/starknet_os/src/hint_processor/os_logger.rs index 78243b7a640..d0e8d1180a3 100644 --- a/crates/starknet_os/src/hint_processor/os_logger.rs +++ b/crates/starknet_os/src/hint_processor/os_logger.rs @@ -400,7 +400,7 @@ impl OsLogger { if selector.is_calling_syscall() { let deprecated_str = if is_deprecated { "deprecated " } else { "" }; - self.log(&format!("Entering {deprecated_str}{:?}.", selector), true); + self.log(&format!("Entering {deprecated_str}{selector:?}."), true); } Ok(()) diff --git a/crates/starknet_os/src/hints/hint_implementation/compiled_class/implementation.rs b/crates/starknet_os/src/hints/hint_implementation/compiled_class/implementation.rs index d85dfaedade..f5090bf42b5 100644 --- a/crates/starknet_os/src/hints/hint_implementation/compiled_class/implementation.rs +++ b/crates/starknet_os/src/hints/hint_implementation/compiled_class/implementation.rs @@ -97,7 +97,7 @@ pub(crate) fn delete_memory_data( let data_ptr = get_ptr_from_var_name(Ids::DataPtr.into(), vm, ids_data, ap_tracking)?; if vm.is_accessed(&data_ptr)? { return Err(OsHintError::AssertionFailed { - message: format!("The segment {} is skipped but was accessed.", data_ptr), + message: format!("The segment {data_ptr} is skipped but was accessed."), }); } vm.delete_unaccessed(data_ptr)?; diff --git a/crates/starknet_os/src/hints/hint_implementation/execution/implementation.rs b/crates/starknet_os/src/hints/hint_implementation/execution/implementation.rs index 7612d38cc94..a0f0249c096 100644 --- a/crates/starknet_os/src/hints/hint_implementation/execution/implementation.rs +++ b/crates/starknet_os/src/hints/hint_implementation/execution/implementation.rs @@ -893,7 +893,7 @@ pub(crate) fn write_old_block_to_storage( let old_block_hash = get_integer_from_var_name(Ids::OldBlockHash.into(), vm, ids_data, ap_tracking)?; - log::debug!("writing block number: {} -> block hash: {}", old_block_number, old_block_hash); + log::debug!("writing block number: {old_block_number} -> block hash: {old_block_hash}"); execution_helper.cached_state.set_storage_at( ContractAddress(PatriciaKey::try_from(*block_hash_contract_address)?), @@ -1017,7 +1017,7 @@ pub(crate) fn fetch_result( if retdata_size != 1 || result[0] != Some(Cow::Borrowed(&validated)) { log::info!("Invalid return value from __validate__:"); log::info!(" Size: {retdata_size}"); - log::info!(" Result (at most 100 elements): {:?}", result); + log::info!(" Result (at most 100 elements): {result:?}"); } Ok(()) } diff --git a/crates/starknet_os/src/hints/vars.rs b/crates/starknet_os/src/hints/vars.rs index 8071ead2bd9..2d8a16b57d4 100644 --- a/crates/starknet_os/src/hints/vars.rs +++ b/crates/starknet_os/src/hints/vars.rs @@ -105,7 +105,7 @@ define_string_enum! { impl std::fmt::Display for Scope { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let scope_string: &'static str = (*self).into(); - write!(f, "{}", scope_string) + write!(f, "{scope_string}") } } diff --git a/crates/starknet_os/src/test_utils/cairo_runner.rs b/crates/starknet_os/src/test_utils/cairo_runner.rs index 808ef468b48..ae54ad145a8 100644 --- a/crates/starknet_os/src/test_utils/cairo_runner.rs +++ b/crates/starknet_os/src/test_utils/cairo_runner.rs @@ -192,10 +192,8 @@ fn perform_basic_validations_on_explicit_args( entrypoint: &str, ) -> Cairo0EntryPointRunnerResult<()> { let mut expected_explicit_args: Vec = program - .get_identifier(&format!("{}.Args", entrypoint)) - .unwrap_or_else(|| { - panic!("Found no explicit args identifier for entrypoint {}.", entrypoint) - }) + .get_identifier(&format!("{entrypoint}.Args")) + .unwrap_or_else(|| panic!("Found no explicit args identifier for entrypoint {entrypoint}.")) .members .as_ref() .unwrap() @@ -230,10 +228,8 @@ fn perform_basic_validations_on_implicit_args( entrypoint: &str, ) -> Cairo0EntryPointRunnerResult<()> { let mut expected_implicit_args: Vec<(String, Member)> = program - .get_identifier(&format!("{}.ImplicitArgs", entrypoint)) - .unwrap_or_else(|| { - panic!("Found no implicit args identifier for entrypoint {}.", entrypoint) - }) + .get_identifier(&format!("{entrypoint}.ImplicitArgs")) + .unwrap_or_else(|| panic!("Found no implicit args identifier for entrypoint {entrypoint}.")) .members .as_ref() .unwrap() @@ -497,7 +493,7 @@ fn get_return_values( let mut implicit_return_values: Vec = vec![]; let mut builtin_runner_iterator = vm.get_builtin_runners().iter(); for (i, implicit_arg) in implicit_return_values_structures.iter().enumerate() { - debug!("Loading implicit return value {}. Value: {:?}", i, implicit_arg); + debug!("Loading implicit return value {i}. Value: {implicit_arg:?}"); match implicit_arg { ImplicitArg::Builtin(builtin) => { let curr_builtin_runner = builtin_runner_iterator @@ -509,9 +505,8 @@ fn get_return_values( let return_value_segment_index = vm.get_relocatable(current_address)?.segment_index; assert_eq!( builtin_runner_segment_index, return_value_segment_index, - "Builtin runner segment index {} doesn't match return value's segment index \ - {}.", - builtin_runner_segment_index, return_value_segment_index + "Builtin runner segment index {builtin_runner_segment_index} doesn't match \ + return value's segment index {return_value_segment_index}." ); match builtin { @@ -536,7 +531,7 @@ fn get_return_values( let mut explicit_return_values: Vec = vec![]; for (i, expected_return_value) in explicit_return_values_structures.iter().enumerate() { - debug!("Loading explicit return value {}. Value: {:?}", i, expected_return_value); + debug!("Loading explicit return value {i}. Value: {expected_return_value:?}"); let (value, next_arg_address) = load_endpoint_arg_from_address(expected_return_value, current_address, vm)?; explicit_return_values.push(value); @@ -579,7 +574,7 @@ pub fn run_cairo_0_entry_point( &os_block_input, os_state_input, ) - .unwrap_or_else(|err| panic!("Failed to create SnosHintProcessor: {:?}", err)); + .unwrap_or_else(|err| panic!("Failed to create SnosHintProcessor: {err:?}")); info!("Program and Hint processor created successfully."); // TODO(Amos): Perform complete validations. @@ -619,7 +614,7 @@ pub fn run_cairo_0_entry_point( .run_from_entrypoint( program .get_identifier(&entrypoint) - .unwrap_or_else(|| panic!("entrypoint {} not found.", entrypoint)) + .unwrap_or_else(|| panic!("entrypoint {entrypoint} not found.")) .pc .unwrap(), &entrypoint_args, @@ -628,7 +623,7 @@ pub fn run_cairo_0_entry_point( &mut hint_processor, ) .map_err(Box::new)?; - info!("Successfully finished running entrypoint {}", entrypoint); + info!("Successfully finished running entrypoint {entrypoint}"); let (implicit_return_values, explicit_return_values) = get_return_values(implicit_args, expected_explicit_return_values, &cairo_runner.vm)?; Ok((implicit_return_values, explicit_return_values, cairo_runner)) diff --git a/crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/tree.rs b/crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/tree.rs index 584d426c6bf..ab708297da5 100644 --- a/crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/tree.rs +++ b/crates/starknet_patricia/src/patricia_merkle_tree/filled_tree/tree.rs @@ -91,7 +91,7 @@ impl FilledTreeImpl { match node.take() { Some(existing_node) => Err(FilledTreeError::DoubleUpdate { index, - existing_value_as_string: format!("{:?}", existing_node), + existing_value_as_string: format!("{existing_node:?}"), }), None => { *node = Some(output); @@ -122,7 +122,7 @@ impl FilledTreeImpl { } None => { if panic_if_empty_placeholder { - panic!("Empty placeholder in an output map for index {0:?}.", key); + panic!("Empty placeholder in an output map for index {key:?}."); } } } @@ -161,7 +161,7 @@ impl FilledTreeImpl { .lock() .map_err(|_| FilledTreeError::PoisonedLock("Cannot lock node.".to_owned()))? .take() - .unwrap_or_else(|| panic!("Leaf input is None for index {0:?}.", index)); + .unwrap_or_else(|| panic!("Leaf input is None for index {index:?}.")); let (leaf_data, leaf_output) = L::create(leaf_input).await.map_err(|leaf_err| { FilledTreeError::Leaf { leaf_error: leaf_err, leaf_index: index } })?; @@ -366,7 +366,7 @@ impl FilledTree for FilledTreeImpl { fn serialize(&self) -> HashMap { // This function iterates over each node in the tree, using the node's `db_key` as the // hashmap key and the result of the node's `serialize` method as the value. - self.get_all_nodes().iter().map(|(_, node)| (node.db_key(), node.serialize())).collect() + self.get_all_nodes().values().map(|node| (node.db_key(), node.serialize())).collect() } fn get_root_hash(&self) -> HashOutput { diff --git a/crates/starknet_patricia/src/patricia_merkle_tree/types_test.rs b/crates/starknet_patricia/src/patricia_merkle_tree/types_test.rs index ab1b92c4cc1..ffacc3773e9 100644 --- a/crates/starknet_patricia/src/patricia_merkle_tree/types_test.rs +++ b/crates/starknet_patricia/src/patricia_merkle_tree/types_test.rs @@ -121,5 +121,5 @@ fn test_nodeindex_to_felt_conversion() { #[rstest] fn test_felt_printing() { let felt = Felt::from(17_u8); - assert_eq!(format!("{:?}", felt), "0x11"); + assert_eq!(format!("{felt:?}"), "0x11"); } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 01570ed3cfb..41bf0fb6d03 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "1.87" +channel = "1.88" components = ["rustc-dev"] profile = "default" targets = ["x86_64-unknown-linux-gnu"] diff --git a/toml_test_utils/src/lib.rs b/toml_test_utils/src/lib.rs index fe55597edc4..9ead8aa65e8 100644 --- a/toml_test_utils/src/lib.rs +++ b/toml_test_utils/src/lib.rs @@ -183,7 +183,7 @@ impl CargoToml { let cargo_toml_path = crates_dir.join(member).join("Cargo.toml"); let cargo_toml_content = fs::read_to_string(&cargo_toml_path) - .unwrap_or_else(|_| panic!("Failed to read {:?}", cargo_toml_path)); + .unwrap_or_else(|_| panic!("Failed to read {cargo_toml_path:?}")); let cargo_toml: CrateCargoToml = toml::from_str(&cargo_toml_content).unwrap(); (cargo_toml.package_name().clone(), cargo_toml)