From d9cdc06ab544822bb219525239f2d528642d868a Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Mon, 17 Aug 2026 13:53:38 +0200 Subject: [PATCH] chore: fix new clippy lints Fix needless_late_init, useless_format, and manual slice chunking lints across several crates. Co-Authored-By: Claude Fable 5 --- crates/iota-core/src/overload_monitor.rs | 34 +++++++++---------- .../src/iota_transaction.rs | 16 ++++----- crates/iota-json-rpc/src/coin_api.rs | 4 +-- crates/iota-replay/src/lib.rs | 4 ++- crates/typed-store/tests/macro_tests.rs | 8 ++--- .../iota-move-natives/src/crypto/groth16.rs | 22 ++++++------ 6 files changed, 44 insertions(+), 44 deletions(-) diff --git a/crates/iota-core/src/overload_monitor.rs b/crates/iota-core/src/overload_monitor.rs index c12adb6bbcf4..257d1d9d2381 100644 --- a/crates/iota-core/src/overload_monitor.rs +++ b/crates/iota-core/src/overload_monitor.rs @@ -276,27 +276,27 @@ fn compute_latency_load_shedding_percentage( // First, we calculate based on the current `txn_ready_rate` and // `execution_rate`, what's the percentage of traffic to shed from // `txn_ready_rate`. - let additional_load_shedding_percentage; - if queueing_latency > config.execution_queue_latency_hard_limit { - let calculated_load_shedding_percentage = - calculate_load_shedding_percentage(txn_ready_rate, execution_rate); - additional_load_shedding_percentage = if calculated_load_shedding_percentage > 0 - || txn_ready_rate >= config.safe_transaction_ready_rate as f64 - { - max( - calculated_load_shedding_percentage, - config.min_load_shedding_percentage_above_hard_limit, - ) + let additional_load_shedding_percentage = + if queueing_latency > config.execution_queue_latency_hard_limit { + let calculated_load_shedding_percentage = + calculate_load_shedding_percentage(txn_ready_rate, execution_rate); + + if calculated_load_shedding_percentage > 0 + || txn_ready_rate >= config.safe_transaction_ready_rate as f64 + { + max( + calculated_load_shedding_percentage, + config.min_load_shedding_percentage_above_hard_limit, + ) + } else { + 0 + } + } else if queueing_latency > config.execution_queue_latency_soft_limit { + calculate_load_shedding_percentage(txn_ready_rate, execution_rate) } else { 0 }; - } else if queueing_latency > config.execution_queue_latency_soft_limit { - additional_load_shedding_percentage = - calculate_load_shedding_percentage(txn_ready_rate, execution_rate); - } else { - additional_load_shedding_percentage = 0; - } // Next, we calculate the new load shedding percentage. let load_shedding_percentage = if additional_load_shedding_percentage > 0 { diff --git a/crates/iota-json-rpc-types/src/iota_transaction.rs b/crates/iota-json-rpc-types/src/iota_transaction.rs index edd2cd7a3d46..ae081f460b76 100644 --- a/crates/iota-json-rpc-types/src/iota_transaction.rs +++ b/crates/iota-json-rpc-types/src/iota_transaction.rs @@ -1087,7 +1087,7 @@ impl Display for IotaTransactionBlockEffects { builder.push_record(vec![format!("Executed Epoch: {}", self.executed_epoch())]); if !self.created().is_empty() { - builder.push_record(vec![format!("\nCreated Objects: ")]); + builder.push_record(vec!["\nCreated Objects: ".to_string()]); for oref in self.created() { builder.push_record(vec![owned_objref_string(oref)]); @@ -1095,21 +1095,21 @@ impl Display for IotaTransactionBlockEffects { } if !self.mutated().is_empty() { - builder.push_record(vec![format!("Mutated Objects: ")]); + builder.push_record(vec!["Mutated Objects: ".to_string()]); for oref in self.mutated() { builder.push_record(vec![owned_objref_string(oref)]); } } if !self.shared_objects().is_empty() { - builder.push_record(vec![format!("Shared Objects: ")]); + builder.push_record(vec!["Shared Objects: ".to_string()]); for oref in self.shared_objects() { builder.push_record(vec![objref_string(oref)]); } } if !self.deleted().is_empty() { - builder.push_record(vec![format!("Deleted Objects: ")]); + builder.push_record(vec!["Deleted Objects: ".to_string()]); for oref in self.deleted() { builder.push_record(vec![objref_string(oref)]); @@ -1117,7 +1117,7 @@ impl Display for IotaTransactionBlockEffects { } if !self.wrapped().is_empty() { - builder.push_record(vec![format!("Wrapped Objects: ")]); + builder.push_record(vec!["Wrapped Objects: ".to_string()]); for oref in self.wrapped() { builder.push_record(vec![objref_string(oref)]); @@ -1125,7 +1125,7 @@ impl Display for IotaTransactionBlockEffects { } if !self.unwrapped().is_empty() { - builder.push_record(vec![format!("Unwrapped Objects: ")]); + builder.push_record(vec!["Unwrapped Objects: ".to_string()]); for oref in self.unwrapped() { builder.push_record(vec![owned_objref_string(oref)]); } @@ -1153,7 +1153,7 @@ impl Display for IotaTransactionBlockEffects { let dependencies = self.dependencies(); if !dependencies.is_empty() { - builder.push_record(vec![format!("\nTransaction Dependencies:")]); + builder.push_record(vec!["\nTransaction Dependencies:".to_string()]); for dependency in dependencies { builder.push_record(vec![format!(" {dependency}")]); } @@ -1812,7 +1812,7 @@ impl Display for IotaTransactionBlock { let mut builder = TableBuilder::default(); builder.push_record(vec![format!("{}", self.data)]); - builder.push_record(vec![format!("Signatures:")]); + builder.push_record(vec!["Signatures:".to_string()]); for tx_sig in &self.tx_signatures { builder.push_record(vec![format!( " {}\n", diff --git a/crates/iota-json-rpc/src/coin_api.rs b/crates/iota-json-rpc/src/coin_api.rs index 77641309e4c2..2ef333324edd 100644 --- a/crates/iota-json-rpc/src/coin_api.rs +++ b/crates/iota-json-rpc/src/coin_api.rs @@ -1096,7 +1096,7 @@ mod tests { mod get_balance_tests { - use super::{super::*, *}; + use super::*; // Success scenarios #[tokio::test] async fn test_gas_coin() { @@ -1241,7 +1241,7 @@ mod tests { } mod get_all_balances_tests { - use super::{super::*, *}; + use super::*; // Success scenarios #[tokio::test] diff --git a/crates/iota-replay/src/lib.rs b/crates/iota-replay/src/lib.rs index 0f14e4b5ca25..e907ce9ef7b9 100644 --- a/crates/iota-replay/src/lib.rs +++ b/crates/iota-replay/src/lib.rs @@ -596,7 +596,9 @@ fn parse_configs_versions( ); Some( configs_and_versions - .chunks_exact(2) + .as_chunks::<2>() + .0 + .iter() .map(|chunk| { let object_id = ObjectId::from_str(&chunk[0]).expect("Invalid object id for config"); diff --git a/crates/typed-store/tests/macro_tests.rs b/crates/typed-store/tests/macro_tests.rs index 24591f150a7e..46f7b5983395 100644 --- a/crates/typed-store/tests/macro_tests.rs +++ b/crates/typed-store/tests/macro_tests.rs @@ -145,13 +145,13 @@ async fn macro_test() { // Test pagination let m = tbls_secondary.dump("table1", 2, 0).unwrap(); assert_eq!(2, m.len()); - assert_eq!(format!("\"1\""), *m.get("\"1\"").unwrap()); - assert_eq!(format!("\"2\""), *m.get("\"2\"").unwrap()); + assert_eq!("\"1\"".to_string(), *m.get("\"1\"").unwrap()); + assert_eq!("\"2\"".to_string(), *m.get("\"2\"").unwrap()); let m = tbls_secondary.dump("table1", 3, 2).unwrap(); assert_eq!(3, m.len()); - assert_eq!(format!("\"7\""), *m.get("\"7\"").unwrap()); - assert_eq!(format!("\"8\""), *m.get("\"8\"").unwrap()); + assert_eq!("\"7\"".to_string(), *m.get("\"7\"").unwrap()); + assert_eq!("\"8\"".to_string(), *m.get("\"8\"").unwrap()); } #[tokio::test] diff --git a/iota-execution/latest/iota-move-natives/src/crypto/groth16.rs b/iota-execution/latest/iota-move-natives/src/crypto/groth16.rs index 57b27f893ee6..1729760ed37f 100644 --- a/iota-execution/latest/iota-move-natives/src/crypto/groth16.rs +++ b/iota-execution/latest/iota-move-natives/src/crypto/groth16.rs @@ -87,14 +87,13 @@ pub fn prepare_verifying_key_internal( native_charge_gas_early_exit!(context, base_cost); let cost = context.gas_used(); - let result; - if curve == BLS12381 { - result = fastcrypto_zkp::bls12381::api::prepare_pvk_bytes(&verifying_key); + let result = if curve == BLS12381 { + fastcrypto_zkp::bls12381::api::prepare_pvk_bytes(&verifying_key) } else if curve == BN254 { - result = fastcrypto_zkp::bn254::api::prepare_pvk_bytes(&verifying_key); + fastcrypto_zkp::bn254::api::prepare_pvk_bytes(&verifying_key) } else { return Ok(NativeResult::err(cost, INVALID_CURVE)); - } + }; match result { Ok(pvk) => Ok(NativeResult::ok( @@ -231,36 +230,35 @@ pub fn verify_groth16_proof_internal( let cost = context.gas_used(); - let result; - if curve == BLS12381 { + let result = if curve == BLS12381 { if public_proof_inputs.len() > fastcrypto::groups::bls12381::SCALAR_LENGTH * MAX_PUBLIC_INPUTS { return Ok(NativeResult::err(cost, TOO_MANY_PUBLIC_INPUTS)); } - result = fastcrypto_zkp::bls12381::api::verify_groth16_in_bytes( + fastcrypto_zkp::bls12381::api::verify_groth16_in_bytes( &vk_gamma_abc_g1, &alpha_g1_beta_g2, &gamma_g2_neg_pc, &delta_g2_neg_pc, &public_proof_inputs, &proof_points, - ); + ) } else if curve == BN254 { if public_proof_inputs.len() > fastcrypto_zkp::bn254::api::SCALAR_SIZE * MAX_PUBLIC_INPUTS { return Ok(NativeResult::err(cost, TOO_MANY_PUBLIC_INPUTS)); } - result = fastcrypto_zkp::bn254::api::verify_groth16_in_bytes( + fastcrypto_zkp::bn254::api::verify_groth16_in_bytes( &vk_gamma_abc_g1, &alpha_g1_beta_g2, &gamma_g2_neg_pc, &delta_g2_neg_pc, &public_proof_inputs, &proof_points, - ); + ) } else { return Ok(NativeResult::err(cost, INVALID_CURVE)); - } + }; Ok(NativeResult::ok( cost,