From 4be2d2bf6f5b4e3bbae3aaaae1509b59a602f59a Mon Sep 17 00:00:00 2001 From: Honza <115138297+Supremesource@users.noreply.github.com> Date: Thu, 28 Nov 2024 16:45:58 -0300 Subject: [PATCH] fix: clippy --- pallets/offworker/src/lib.rs | 5 +++-- pallets/subnet_emission/src/decryption.rs | 6 ++---- pallets/subnet_emission/src/distribute_emission.rs | 2 +- pallets/subnet_emission/src/set_weights.rs | 2 +- pallets/subspace/src/lib.rs | 2 +- pallets/subspace/src/network/module.rs | 2 +- pallets/subspace/src/network/staking.rs | 2 +- 7 files changed, 10 insertions(+), 11 deletions(-) diff --git a/pallets/offworker/src/lib.rs b/pallets/offworker/src/lib.rs index 7a2801789..a777264c3 100644 --- a/pallets/offworker/src/lib.rs +++ b/pallets/offworker/src/lib.rs @@ -355,8 +355,9 @@ impl Pallet { .map(|(block_number, consensus_params)| { let uid_weights: Vec<_> = consensus_params .modules - .iter() - .map(|(_, module_params)| { + .values() + .map(|module_params| { + // Removed the (_, module_params) pattern if !module_params.weight_encrypted.is_empty() { ow_extensions::offworker::decrypt_weight( module_params.weight_encrypted.clone(), diff --git a/pallets/subnet_emission/src/decryption.rs b/pallets/subnet_emission/src/decryption.rs index 1bcc63788..aa56228dc 100644 --- a/pallets/subnet_emission/src/decryption.rs +++ b/pallets/subnet_emission/src/decryption.rs @@ -1,5 +1,3 @@ -use core::u32; - use crate::{ distribute_emission::update_pending_emission, subnet_consensus::{util::params::ConsensusParams, yuma::YumaEpoch}, @@ -105,7 +103,7 @@ impl Pallet { } /// 1. TODO: step 4. verify the zk proofs, if only one zk proof is invalid, you will ban the - /// offchain worker + /// offchain worker /// /// 2. TODO: add a test where some of the decrypted weights will be empty, and expect everything /// to be handeled correctly @@ -329,7 +327,7 @@ impl Pallet { ) -> Option> { // Collect baseline weights from storage let baseline_weights: Vec<(u16, Vec<(u16, u16)>)> = - Weights::::iter_prefix(netuid).map(|(dst, weights)| (dst, weights)).collect(); + Weights::::iter_prefix(netuid).collect(); // Process each block's weights let result: Vec = valid_weights diff --git a/pallets/subnet_emission/src/distribute_emission.rs b/pallets/subnet_emission/src/distribute_emission.rs index 59bea178e..58f88b1f3 100644 --- a/pallets/subnet_emission/src/distribute_emission.rs +++ b/pallets/subnet_emission/src/distribute_emission.rs @@ -7,7 +7,7 @@ use pallet_subnet_emission_api::SubnetConsensus; use pallet_subspace::{Pallet as PalletSubspace, N}; use subnet_consensus::yuma::YumaEpoch; -const NO_WEIGHTS: &'static str = "no weights"; +const NO_WEIGHTS: &str = "no weights"; /// Processes subnets by updating pending emissions and running epochs when due. /// diff --git a/pallets/subnet_emission/src/set_weights.rs b/pallets/subnet_emission/src/set_weights.rs index afb257f15..8767ba04e 100644 --- a/pallets/subnet_emission/src/set_weights.rs +++ b/pallets/subnet_emission/src/set_weights.rs @@ -98,7 +98,7 @@ impl Pallet { pallet_subspace::Pallet::::is_rootnet(netuid) || !uids.contains(&uid), Error::::NoSelfWeight ); - Self::check_whitelisted(netuid, &uids)?; + Self::check_whitelisted(netuid, uids)?; Ok(()) } diff --git a/pallets/subspace/src/lib.rs b/pallets/subspace/src/lib.rs index 0a39eb7c1..526043710 100644 --- a/pallets/subspace/src/lib.rs +++ b/pallets/subspace/src/lib.rs @@ -152,7 +152,7 @@ pub mod pallet { define_module_includes!( // Put here every module-related storage map that has netuid as a key and holds a vector of values. The vector has to be indexed by the module uid. vectors: { - Active: bool = |_: PhantomData| true, + Active: bool = |_: PhantomData| false, Consensus: u64 = |_: PhantomData| 0, Emission: u64 = |_: PhantomData| 0, Incentive: u64 = |_: PhantomData| 0, diff --git a/pallets/subspace/src/network/module.rs b/pallets/subspace/src/network/module.rs index fe8723a02..c991c530f 100644 --- a/pallets/subspace/src/network/module.rs +++ b/pallets/subspace/src/network/module.rs @@ -76,7 +76,7 @@ impl Pallet { )?; // --- Delete Rate Limit --- - RootNetWeightCalls::::remove(&uid); + RootNetWeightCalls::::remove(uid); // --- Delete Global-Module Storage --- // This will remove storages if the module is only registered on this network. diff --git a/pallets/subspace/src/network/staking.rs b/pallets/subspace/src/network/staking.rs index 5bf949240..834287310 100644 --- a/pallets/subspace/src/network/staking.rs +++ b/pallets/subspace/src/network/staking.rs @@ -382,7 +382,7 @@ impl Pallet { TotalStake::::mutate(|total_stake| *total_stake = total_stake.saturating_sub(amount)); } - // Decreases the stake by the amount while decreasing other counters. + /// Decreases the stake by the amount while decreasing other counters. pub fn remove_stake_from_storage(staked: &T::AccountId) { // Get all stakers for this staked account let stakers: Vec =