diff --git a/.github/workflows/cargo-audit.yml b/.github/workflows/cargo-audit.yml index 9bd9795f17..04046c11d4 100644 --- a/.github/workflows/cargo-audit.yml +++ b/.github/workflows/cargo-audit.yml @@ -46,4 +46,6 @@ jobs: cargo audit --ignore RUSTSEC-2023-0091 \ --ignore RUSTSEC-2024-0438 \ --ignore RUSTSEC-2025-0009 \ - --ignore RUSTSEC-2025-0055 + --ignore RUSTSEC-2025-0055 \ + --ignore RUSTSEC-2025-0073 \ + --ignore RUSTSEC-2025-0118 diff --git a/.github/workflows/check-rust.yml b/.github/workflows/check-rust.yml index 6cdc56f26a..4b975959d0 100644 --- a/.github/workflows/check-rust.yml +++ b/.github/workflows/check-rust.yml @@ -38,7 +38,7 @@ jobs: - name: Install Rust Nightly uses: actions-rs/toolchain@v1 with: - toolchain: nightly + toolchain: stable components: rustfmt - name: Utilize Shared Rust Cache @@ -48,7 +48,22 @@ jobs: cache-on-failure: true - name: cargo fmt - run: cargo +nightly fmt --check --all + run: | + set -euo pipefail + # Run cargo fmt and capture both stdout and stderr + output=$(cargo fmt --check --all 2>&1) || { + echo "❌ cargo fmt failed with non-zero exit code" + echo "$output" + exit 1 + } + # Check for panic/ICE messages even if exit code was 0 + if echo "$output" | grep -qiE "(the compiler unexpectedly panicked|panicked at|Internal Compiler Error|ICE|error: the compiler unexpectedly panicked)"; then + echo "❌ rustfmt panicked (ICE detected) - this should fail the build" + echo "$output" + exit 1 + fi + echo "$output" + echo "✅ cargo fmt completed successfully" cargo-clippy-default-features: name: cargo clippy diff --git a/chain-extensions/src/tests.rs b/chain-extensions/src/tests.rs index 094b0987e2..bd6f46c8ab 100644 --- a/chain-extensions/src/tests.rs +++ b/chain-extensions/src/tests.rs @@ -757,12 +757,12 @@ impl SubtensorExtensionEnv for MockEnv { } fn charge_weight(&mut self, weight: Weight) -> Result<(), DispatchError> { - if let Some(expected) = self.expected_weight { - if weight != expected { - return Err(DispatchError::Other( - "unexpected weight charged by mock env", - )); - } + if let Some(expected) = self.expected_weight + && weight != expected + { + return Err(DispatchError::Other( + "unexpected weight charged by mock env", + )); } self.charged_weight = Some(weight); Ok(()) diff --git a/node/src/command.rs b/node/src/command.rs index 67cb200e43..3350c1443e 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -272,7 +272,7 @@ fn start_babe_service(arg_matches: &ArgMatches) -> Result<(), sc_cli::Error> { { log::info!("Failed to aquire DB lock, trying again in 1s..."); std::thread::sleep(std::time::Duration::from_secs(1)); - return start_babe_service(arg_matches); + start_babe_service(arg_matches) // Unknown error, return it. } else { log::error!("Failed to start Babe service: {e:?}"); diff --git a/node/src/consensus/aura_consensus.rs b/node/src/consensus/aura_consensus.rs index 57012733f6..57b5559fd3 100644 --- a/node/src/consensus/aura_consensus.rs +++ b/node/src/consensus/aura_consensus.rs @@ -120,7 +120,7 @@ impl ConsensusMechanism for AuraConsensus { Self {} } - fn build_biq(&mut self) -> Result + fn build_biq(&mut self) -> Result, sc_service::Error> where NumberFor: BlockNumberOps, { diff --git a/node/src/consensus/babe_consensus.rs b/node/src/consensus/babe_consensus.rs index 8c9a974d20..42d3022512 100644 --- a/node/src/consensus/babe_consensus.rs +++ b/node/src/consensus/babe_consensus.rs @@ -128,7 +128,7 @@ impl ConsensusMechanism for BabeConsensus { } } - fn build_biq(&mut self) -> Result + fn build_biq(&mut self) -> Result, sc_service::Error> where NumberFor: BlockNumberOps, { diff --git a/node/src/consensus/consensus_mechanism.rs b/node/src/consensus/consensus_mechanism.rs index 359b89f6ef..a500f5efe0 100644 --- a/node/src/consensus/consensus_mechanism.rs +++ b/node/src/consensus/consensus_mechanism.rs @@ -77,7 +77,7 @@ pub trait ConsensusMechanism { fn new() -> Self; /// Builds a `BIQ` that uses the ConsensusMechanism. - fn build_biq(&mut self) -> Result; + fn build_biq(&mut self) -> Result, sc_service::Error>; /// Returns the slot duration. fn slot_duration(&self, client: &FullClient) -> Result; diff --git a/pallets/subtensor/src/coinbase/block_step.rs b/pallets/subtensor/src/coinbase/block_step.rs index b8004f6e5c..6081edad19 100644 --- a/pallets/subtensor/src/coinbase/block_step.rs +++ b/pallets/subtensor/src/coinbase/block_step.rs @@ -229,9 +229,9 @@ impl Pallet { if next_value >= U110F18::saturating_from_num(Self::get_max_difficulty(netuid)) { Self::get_max_difficulty(netuid) } else if next_value <= U110F18::saturating_from_num(Self::get_min_difficulty(netuid)) { - return Self::get_min_difficulty(netuid); + Self::get_min_difficulty(netuid) } else { - return next_value.saturating_to_num::(); + next_value.saturating_to_num::() } } @@ -263,9 +263,9 @@ impl Pallet { if next_value >= U110F18::saturating_from_num(Self::get_max_burn(netuid)) { Self::get_max_burn(netuid) } else if next_value <= U110F18::saturating_from_num(Self::get_min_burn(netuid)) { - return Self::get_min_burn(netuid); + Self::get_min_burn(netuid) } else { - return next_value.saturating_to_num::().into(); + next_value.saturating_to_num::().into() } } diff --git a/pallets/subtensor/src/coinbase/run_coinbase.rs b/pallets/subtensor/src/coinbase/run_coinbase.rs index 4a91e0e4cd..2091946598 100644 --- a/pallets/subtensor/src/coinbase/run_coinbase.rs +++ b/pallets/subtensor/src/coinbase/run_coinbase.rs @@ -491,10 +491,11 @@ impl Pallet { // Insert subnet owner hotkey in the beginning of the list if valid and not // already present - if let Ok(owner_hk) = SubnetOwnerHotkey::::try_get(netuid) { - if Uids::::get(netuid, &owner_hk).is_some() && !owner_hotkeys.contains(&owner_hk) { - owner_hotkeys.insert(0, owner_hk); - } + if let Ok(owner_hk) = SubnetOwnerHotkey::::try_get(netuid) + && Uids::::get(netuid, &owner_hk).is_some() + && !owner_hotkeys.contains(&owner_hk) + { + owner_hotkeys.insert(0, owner_hk); } owner_hotkeys @@ -508,22 +509,22 @@ impl Pallet { root_alpha_dividends: BTreeMap, ) { // Distribute the owner cut. - if let Ok(owner_coldkey) = SubnetOwner::::try_get(netuid) { - if let Ok(owner_hotkey) = SubnetOwnerHotkey::::try_get(netuid) { - // Increase stake for owner hotkey and coldkey. - log::debug!( - "owner_hotkey: {owner_hotkey:?} owner_coldkey: {owner_coldkey:?}, owner_cut: {owner_cut:?}" - ); - let real_owner_cut = Self::increase_stake_for_hotkey_and_coldkey_on_subnet( - &owner_hotkey, - &owner_coldkey, - netuid, - owner_cut, - ); - // If the subnet is leased, notify the lease logic that owner cut has been distributed. - if let Some(lease_id) = SubnetUidToLeaseId::::get(netuid) { - Self::distribute_leased_network_dividends(lease_id, real_owner_cut); - } + if let Ok(owner_coldkey) = SubnetOwner::::try_get(netuid) + && let Ok(owner_hotkey) = SubnetOwnerHotkey::::try_get(netuid) + { + // Increase stake for owner hotkey and coldkey. + log::debug!( + "owner_hotkey: {owner_hotkey:?} owner_coldkey: {owner_coldkey:?}, owner_cut: {owner_cut:?}" + ); + let real_owner_cut = Self::increase_stake_for_hotkey_and_coldkey_on_subnet( + &owner_hotkey, + &owner_coldkey, + netuid, + owner_cut, + ); + // If the subnet is leased, notify the lease logic that owner cut has been distributed. + if let Some(lease_id) = SubnetUidToLeaseId::::get(netuid) { + Self::distribute_leased_network_dividends(lease_id, real_owner_cut); } } diff --git a/pallets/subtensor/src/epoch/math.rs b/pallets/subtensor/src/epoch/math.rs index 2cbbfae77d..ee165e7670 100644 --- a/pallets/subtensor/src/epoch/math.rs +++ b/pallets/subtensor/src/epoch/math.rs @@ -335,10 +335,10 @@ pub fn inplace_row_normalize_sparse(sparse_matrix: &mut [Vec<(u16, I32F32)>]) { // Sum across each row (dim=0) of a matrix. pub fn row_sum(x: &[Vec]) -> Vec { - if let Some(first_row) = x.first() { - if first_row.is_empty() { - return vec![]; - } + if let Some(first_row) = x.first() + && first_row.is_empty() + { + return vec![]; } x.iter().map(|row| row.iter().sum()).collect() } @@ -424,10 +424,10 @@ pub fn inplace_col_max_upscale_sparse(sparse_matrix: &mut [Vec<(u16, I32F32)>], // Pass 1: compute per-column max for sparse_row in sparse_matrix.iter() { for (j, value) in sparse_row.iter() { - if let Some(m) = col_max.get_mut(*j as usize) { - if *m < *value { - *m = *value; - } + if let Some(m) = col_max.get_mut(*j as usize) + && *m < *value + { + *m = *value; } } } @@ -1147,10 +1147,10 @@ pub fn weighted_median_col_sparse( while let (Some(&s), Some(sparse_row)) = (stake_it.next(), score_it.next()) { if s > zero { for &(c, val) in sparse_row.iter() { - if let Some(col_vec) = use_score.get_mut(c as usize) { - if let Some(cell) = col_vec.get_mut(k) { - *cell = val; - } + if let Some(col_vec) = use_score.get_mut(c as usize) + && let Some(cell) = col_vec.get_mut(k) + { + *cell = val; } } k = k.saturating_add(1); @@ -1289,10 +1289,10 @@ pub fn interpolate_sparse( let v1 = row1.get(j).unwrap_or(&zero); let v2 = row2.get(j).unwrap_or(&zero); let interp = v1.saturating_add(ratio.saturating_mul(v2.saturating_sub(*v1))); - if zero < interp { - if let Some(res) = result.get_mut(i) { - res.push((j as u16, interp)); - } + if zero < interp + && let Some(res) = result.get_mut(i) + { + res.push((j as u16, interp)); } } } @@ -1338,10 +1338,10 @@ pub fn mat_vec_mul_sparse( for (j, value) in matrix_row.iter() { if let Some(vector_value) = vector.get(*j as usize) { let new_value = value.saturating_mul(*vector_value); - if new_value != I32F32::saturating_from_num(0.0) { - if let Some(result_row) = result.get_mut(i) { - result_row.push((*j, new_value)); - } + if new_value != I32F32::saturating_from_num(0.0) + && let Some(result_row) = result.get_mut(i) + { + result_row.push((*j, new_value)); } } } diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index 763df09c4f..6c0c435f8e 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -730,10 +730,10 @@ impl Pallet { // ---------- v3 ------------------------------------------------------ for (_epoch, q) in TimelockedWeightCommits::::iter_prefix(netuid_index) { for (who, cb, ..) in q.iter() { - if !Self::is_commit_expired(netuid, *cb) { - if let Some(cell) = uid_of(who).and_then(|i| commit_blocks.get_mut(i)) { - *cell = (*cell).min(*cb); - } + if !Self::is_commit_expired(netuid, *cb) + && let Some(cell) = uid_of(who).and_then(|i| commit_blocks.get_mut(i)) + { + *cell = (*cell).min(*cb); } } } diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 61d5523285..6d927f33a3 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -49,7 +49,7 @@ mod dispatches { /// /// * 'weights' (Vec): /// - The u16 integer encoded weights. Interpreted as rational - /// values in the range [0,1]. They must sum to in32::MAX. + /// values in the range [0,1]. They must sum to in32::MAX. /// /// * 'version_key' ( u64 ): /// - The network version key to check if the validator is up to date. @@ -128,7 +128,7 @@ mod dispatches { /// /// * 'weights' (Vec): /// - The u16 integer encoded weights. Interpreted as rational - /// values in the range [0,1]. They must sum to in32::MAX. + /// values in the range [0,1]. They must sum to in32::MAX. /// /// * 'version_key' ( u64 ): /// - The network version key to check if the validator is up to date. diff --git a/pallets/subtensor/src/staking/stake_utils.rs b/pallets/subtensor/src/staking/stake_utils.rs index d0f78551c1..f61a8a6ce2 100644 --- a/pallets/subtensor/src/staking/stake_utils.rs +++ b/pallets/subtensor/src/staking/stake_utils.rs @@ -564,11 +564,10 @@ impl Pallet { // We expect a negative value here let mut actual_alpha = 0; - if let Ok(value) = alpha_share_pool.try_get_value(coldkey) { - if value >= amount { - actual_alpha = - alpha_share_pool.update_value_for_one(coldkey, (amount as i64).neg()); - } + if let Ok(value) = alpha_share_pool.try_get_value(coldkey) + && value >= amount + { + actual_alpha = alpha_share_pool.update_value_for_one(coldkey, (amount as i64).neg()); } // Get the negation of the removed alpha, and clamp at 0. @@ -1181,10 +1180,10 @@ impl Pallet { // Ensure that if partial execution is not allowed, the amount will not cause // slippage over desired - if let Some(allow_partial) = maybe_allow_partial { - if !allow_partial { - ensure!(alpha_amount <= max_amount, Error::::SlippageTooHigh); - } + if let Some(allow_partial) = maybe_allow_partial + && !allow_partial + { + ensure!(alpha_amount <= max_amount, Error::::SlippageTooHigh); } } diff --git a/pallets/subtensor/src/subnets/registration.rs b/pallets/subtensor/src/subnets/registration.rs index 0157b844ba..a7771857bb 100644 --- a/pallets/subtensor/src/subnets/registration.rs +++ b/pallets/subtensor/src/subnets/registration.rs @@ -436,14 +436,13 @@ impl Pallet { // Insert subnet owner hotkey in the beginning of the list if valid and not // already present - if let Ok(owner_hk) = SubnetOwnerHotkey::::try_get(netuid) { - if let Some(owner_uid) = Uids::::get(netuid, &owner_hk) { - if !immune_tuples.contains(&(owner_uid, owner_hk.clone())) { - immune_tuples.insert(0, (owner_uid, owner_hk.clone())); - if immune_tuples.len() > limit { - immune_tuples.truncate(limit); - } - } + if let Ok(owner_hk) = SubnetOwnerHotkey::::try_get(netuid) + && let Some(owner_uid) = Uids::::get(netuid, &owner_hk) + && !immune_tuples.contains(&(owner_uid, owner_hk.clone())) + { + immune_tuples.insert(0, (owner_uid, owner_hk.clone())); + if immune_tuples.len() > limit { + immune_tuples.truncate(limit); } } @@ -523,10 +522,8 @@ impl Pallet { let can_prune_non_immune = free_count > min_free; // Prefer non‑immune if allowed; otherwise fall back to immune. - if can_prune_non_immune { - if let Some((_, _, uid)) = best_non_immune { - return Some(uid); - } + if can_prune_non_immune && let Some((_, _, uid)) = best_non_immune { + return Some(uid); } best_immune.map(|(_, _, uid)| uid) } diff --git a/pallets/subtensor/src/subnets/serving.rs b/pallets/subtensor/src/subnets/serving.rs index cdaf39e51b..d11eb479d3 100644 --- a/pallets/subtensor/src/subnets/serving.rs +++ b/pallets/subtensor/src/subnets/serving.rs @@ -84,10 +84,10 @@ impl Pallet { )?; // Check+insert certificate - if let Some(certificate) = certificate { - if let Ok(certificate) = NeuronCertificateOf::try_from(certificate) { - NeuronCertificates::::insert(netuid, hotkey_id.clone(), certificate) - } + if let Some(certificate) = certificate + && let Ok(certificate) = NeuronCertificateOf::try_from(certificate) + { + NeuronCertificates::::insert(netuid, hotkey_id.clone(), certificate) } // We insert the axon meta. diff --git a/pallets/subtensor/src/subnets/uids.rs b/pallets/subtensor/src/subnets/uids.rs index 0690ca8e8a..0a09017e64 100644 --- a/pallets/subtensor/src/subnets/uids.rs +++ b/pallets/subtensor/src/subnets/uids.rs @@ -63,14 +63,14 @@ impl Pallet { let old_hotkey: T::AccountId = Keys::::get(netuid, uid_to_replace); // Do not replace owner hotkey from `SubnetOwnerHotkey` - if let Ok(sn_owner_hotkey) = SubnetOwnerHotkey::::try_get(netuid) { - if sn_owner_hotkey == old_hotkey.clone() { - log::warn!( - "replace_neuron: Skipped replacement because neuron is the subnet owner hotkey. \ + if let Ok(sn_owner_hotkey) = SubnetOwnerHotkey::::try_get(netuid) + && sn_owner_hotkey == old_hotkey.clone() + { + log::warn!( + "replace_neuron: Skipped replacement because neuron is the subnet owner hotkey. \ netuid: {netuid:?}, uid_to_replace: {uid_to_replace:?}, new_hotkey: {new_hotkey:?}, owner_hotkey: {sn_owner_hotkey:?}" - ); - return; - } + ); + return; } // 2. Remove previous set memberships. diff --git a/pallets/subtensor/src/subnets/weights.rs b/pallets/subtensor/src/subnets/weights.rs index f1a2df56e2..56acbef9c7 100644 --- a/pallets/subtensor/src/subnets/weights.rs +++ b/pallets/subtensor/src/subnets/weights.rs @@ -1109,16 +1109,16 @@ impl Pallet { current_block: u64, ) -> bool { let maybe_netuid_and_subid = Self::get_netuid_and_subid(netuid_index); - if let Ok((netuid, _)) = maybe_netuid_and_subid { - if Self::is_uid_exist_on_network(netuid, neuron_uid) { - // --- 1. Ensure that the diff between current and last_set weights is greater than limit. - let last_set_weights: u64 = Self::get_last_update_for_uid(netuid_index, neuron_uid); - if last_set_weights == 0 { - return true; - } // (Storage default) Never set weights. - return current_block.saturating_sub(last_set_weights) - >= Self::get_weights_set_rate_limit(netuid); - } + if let Ok((netuid, _)) = maybe_netuid_and_subid + && Self::is_uid_exist_on_network(netuid, neuron_uid) + { + // --- 1. Ensure that the diff between current and last_set weights is greater than limit. + let last_set_weights: u64 = Self::get_last_update_for_uid(netuid_index, neuron_uid); + if last_set_weights == 0 { + return true; + } // (Storage default) Never set weights. + return current_block.saturating_sub(last_set_weights) + >= Self::get_weights_set_rate_limit(netuid); } // --- 3. Non registered peers cant pass. Neither can non-existing mecid diff --git a/pallets/subtensor/src/swap/swap_hotkey.rs b/pallets/subtensor/src/swap/swap_hotkey.rs index 38f1f85df8..4fdf87fb7b 100644 --- a/pallets/subtensor/src/swap/swap_hotkey.rs +++ b/pallets/subtensor/src/swap/swap_hotkey.rs @@ -369,22 +369,20 @@ impl Pallet { // 3.3 Swap Prometheus. // Prometheus( netuid, hotkey ) -> prometheus -- the prometheus data that a hotkey has in the network. - if is_network_member { - if let Ok(old_prometheus_info) = Prometheus::::try_get(netuid, old_hotkey) { - Prometheus::::remove(netuid, old_hotkey); - Prometheus::::insert(netuid, new_hotkey, old_prometheus_info); - weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 2)); - } + if is_network_member + && let Ok(old_prometheus_info) = Prometheus::::try_get(netuid, old_hotkey) + { + Prometheus::::remove(netuid, old_hotkey); + Prometheus::::insert(netuid, new_hotkey, old_prometheus_info); + weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 2)); } // 3.4. Swap axons. // Axons( netuid, hotkey ) -> axon -- the axon that the hotkey has. - if is_network_member { - if let Ok(old_axon_info) = Axons::::try_get(netuid, old_hotkey) { - Axons::::remove(netuid, old_hotkey); - Axons::::insert(netuid, new_hotkey, old_axon_info); - weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 2)); - } + if is_network_member && let Ok(old_axon_info) = Axons::::try_get(netuid, old_hotkey) { + Axons::::remove(netuid, old_hotkey); + Axons::::insert(netuid, new_hotkey, old_axon_info); + weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 2)); } // 3.5 Swap WeightCommits @@ -404,29 +402,27 @@ impl Pallet { // 3.6. Swap the subnet loaded emission. // LoadedEmission( netuid ) --> Vec<(hotkey, u64)> -- the loaded emission for the subnet. - if is_network_member { - if let Some(mut old_loaded_emission) = LoadedEmission::::get(netuid) { - for emission in old_loaded_emission.iter_mut() { - if emission.0 == *old_hotkey { - emission.0 = new_hotkey.clone(); - } + if is_network_member && let Some(mut old_loaded_emission) = LoadedEmission::::get(netuid) + { + for emission in old_loaded_emission.iter_mut() { + if emission.0 == *old_hotkey { + emission.0 = new_hotkey.clone(); } - LoadedEmission::::remove(netuid); - LoadedEmission::::insert(netuid, old_loaded_emission); - weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 2)); } + LoadedEmission::::remove(netuid); + LoadedEmission::::insert(netuid, old_loaded_emission); + weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 2)); } // 3.7. Swap neuron TLS certificates. // NeuronCertificates( netuid, hotkey ) -> Vec -- the neuron certificate for the hotkey. - if is_network_member { - if let Ok(old_neuron_certificates) = + if is_network_member + && let Ok(old_neuron_certificates) = NeuronCertificates::::try_get(netuid, old_hotkey) - { - NeuronCertificates::::remove(netuid, old_hotkey); - NeuronCertificates::::insert(netuid, new_hotkey, old_neuron_certificates); - weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 2)); - } + { + NeuronCertificates::::remove(netuid, old_hotkey); + NeuronCertificates::::insert(netuid, new_hotkey, old_neuron_certificates); + weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 2)); } // 4. Swap ChildKeys. // 5. Swap ParentKeys. diff --git a/pallets/subtensor/src/tests/networks.rs b/pallets/subtensor/src/tests/networks.rs index 60637e0b1f..00b894ac5a 100644 --- a/pallets/subtensor/src/tests/networks.rs +++ b/pallets/subtensor/src/tests/networks.rs @@ -1930,8 +1930,8 @@ fn massive_dissolve_refund_and_reregistration_flow_is_lossless_and_cleans_state( // Capture **pair‑level** α snapshot per net (pre‑LP). for ((hot, cold, net), amt) in Alpha::::iter() { - if let Some(&ni) = net_index.get(&net) { - if lp_sets_per_net[ni].contains(&cold) { + if let Some(&ni) = net_index.get(&net) + && lp_sets_per_net[ni].contains(&cold) { let a: u128 = amt.saturating_to_num(); if a > 0 { alpha_pairs_per_net @@ -1940,7 +1940,6 @@ fn massive_dissolve_refund_and_reregistration_flow_is_lossless_and_cleans_state( .push(((hot, cold), a)); } } - } } // ──────────────────────────────────────────────────────────────────── diff --git a/pallets/subtensor/src/tests/weights.rs b/pallets/subtensor/src/tests/weights.rs index 21d37984e4..20ace5ee0d 100644 --- a/pallets/subtensor/src/tests/weights.rs +++ b/pallets/subtensor/src/tests/weights.rs @@ -4383,8 +4383,8 @@ fn test_highly_concurrent_commits_and_reveals_with_multiple_hotkeys() { // Attempt unauthorized reveal let unauthorized_hotkey = hotkeys[0]; let target_hotkey = hotkeys[1]; - if let Some(commits) = commit_info_map.get(&target_hotkey) { - if let Some((_commit_hash, salt, uids, values, version_key)) = commits.first() { + if let Some(commits) = commit_info_map.get(&target_hotkey) + && let Some((_commit_hash, salt, uids, values, version_key)) = commits.first() { assert_err!( SubtensorModule::reveal_weights( RuntimeOrigin::signed(unauthorized_hotkey), @@ -4397,7 +4397,6 @@ fn test_highly_concurrent_commits_and_reveals_with_multiple_hotkeys() { Error::::InvalidRevealCommitHashNotMatch ); } - } let non_committing_hotkey: ::AccountId = U256::from(9999); assert_err!( diff --git a/pallets/swap/src/pallet/impls.rs b/pallets/swap/src/pallet/impls.rs index 9c27b82a02..6ec02879bf 100644 --- a/pallets/swap/src/pallet/impls.rs +++ b/pallets/swap/src/pallet/impls.rs @@ -261,12 +261,12 @@ impl Pallet { // Should persist changes // Check if reserves are overused - if let Ok(ref swap_result) = result { - if reserve < swap_result.amount_paid_out { - return TransactionOutcome::Commit(Err( - Error::::InsufficientLiquidity.into() - )); - } + if let Ok(ref swap_result) = result + && reserve < swap_result.amount_paid_out + { + return TransactionOutcome::Commit(Err( + Error::::InsufficientLiquidity.into() + )); } TransactionOutcome::Commit(result) diff --git a/pallets/utility/src/lib.rs b/pallets/utility/src/lib.rs index c54413c2ea..d9f9bca281 100644 --- a/pallets/utility/src/lib.rs +++ b/pallets/utility/src/lib.rs @@ -145,8 +145,7 @@ pub mod pallet { let allocator_limit = sp_core::MAX_POSSIBLE_ALLOCATION; let call_size = (core::mem::size_of::<::RuntimeCall>() as u32) .div_ceil(CALL_ALIGN) - .checked_mul(CALL_ALIGN) - .unwrap_or(u32::MAX); + .saturating_mul(CALL_ALIGN); // The margin to take into account vec doubling capacity. let margin_factor = 3; @@ -636,7 +635,8 @@ pub mod pallet { } /// A pallet identifier. These are per pallet and should be stored in a registry somewhere. -#[freeze_struct("7e600c53ace0630a")] +#[allow(unused)] +#[freeze_struct("8b0fb6b91f673972")] #[derive(Clone, Copy, Eq, PartialEq, Encode, Decode)] struct IndexedUtilityPalletId(u16); diff --git a/pallets/utility/src/tests.rs b/pallets/utility/src/tests.rs index 8b0a9274c2..03b4acbbf2 100644 --- a/pallets/utility/src/tests.rs +++ b/pallets/utility/src/tests.rs @@ -133,12 +133,11 @@ impl pallet_timestamp::Config for Test { type WeightInfo = (); } -const MOTION_DURATION_IN_BLOCKS: BlockNumber = 3; parameter_types! { pub const MultisigDepositBase: u64 = 1; pub const MultisigDepositFactor: u64 = 1; pub const MaxSignatories: u32 = 3; - pub const MotionDuration: BlockNumber = MOTION_DURATION_IN_BLOCKS; + pub const MotionDuration: BlockNumber = 3; pub const MaxProposals: u32 = 100; pub const MaxMembers: u32 = 100; pub MaxProposalWeight: Weight = BlockWeights::get().max_block.saturating_div(2); diff --git a/rust-toolchain.toml b/rust-toolchain.toml index bfb378c468..55003ecad6 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,5 @@ [toolchain] -channel = "1.88" # rustc 1.88.0 (6b00bc388 2025-06-23) +channel = "1.89" # rustc 1.89.0 (29483883e 2025-08-04) components = [ "cargo", "clippy", diff --git a/scripts/fix_rust.sh b/scripts/fix_rust.sh index 9d2af2904b..08e983a432 100755 --- a/scripts/fix_rust.sh +++ b/scripts/fix_rust.sh @@ -11,12 +11,12 @@ commit_if_changes() { fi } -# Step 1: Run cargo check and commit changes to Cargo.lock if any. +# Step 1: Run cargo check and commit changes to Cargo.lock if any cargo check --workspace commit_if_changes "commit Cargo.lock" # Step 2: Run cargo clippy with fixes and commit changes if any. -cargo clippy --fix --workspace --all-features +cargo clippy --fix --workspace --all-features --all-targets commit_if_changes "cargo clippy" # Step 3: Run cargo fix and commit changes if any. @@ -24,5 +24,10 @@ cargo fix --workspace --all-features --all-targets commit_if_changes "cargo fix" # Step 4: Run cargo fmt and commit changes if any. -cargo fmt +cargo fmt --all commit_if_changes "cargo fmt" + +if command -v zepter >/dev/null 2>&1; then + echo "zepter detected, running 'zepter run check'..." + zepter run check +fi \ No newline at end of file diff --git a/support/linting/src/require_freeze_struct.rs b/support/linting/src/require_freeze_struct.rs index b697c5b824..288f2a2b1a 100644 --- a/support/linting/src/require_freeze_struct.rs +++ b/support/linting/src/require_freeze_struct.rs @@ -54,14 +54,14 @@ fn is_freeze_struct(attr: &Attribute) -> bool { } fn is_derive_encode_or_decode(attr: &Attribute) -> bool { - if let Meta::List(MetaList { path, tokens, .. }) = &attr.meta { - if path.is_ident("derive") { - let nested: Punctuated = parse_quote!(#tokens); - return nested.iter().any(|nested| { - nested.segments.iter().any(|seg| seg.ident == "Encode") - || nested.segments.iter().any(|seg| seg.ident == "Decode") - }); - } + if let Meta::List(MetaList { path, tokens, .. }) = &attr.meta + && path.is_ident("derive") + { + let nested: Punctuated = parse_quote!(#tokens); + return nested.iter().any(|nested| { + nested.segments.iter().any(|seg| seg.ident == "Encode") + || nested.segments.iter().any(|seg| seg.ident == "Decode") + }); } false }