From dd5880423cee6b62137209b5e000f93469bc6522 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Fri, 29 Nov 2024 14:15:32 -0500 Subject: [PATCH 1/3] fix remaining escapes in hotfix pr bot message --- .github/workflows/hotfixes.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/hotfixes.yml b/.github/workflows/hotfixes.yml index 1a8df37a0..529274769 100644 --- a/.github/workflows/hotfixes.yml +++ b/.github/workflows/hotfixes.yml @@ -38,7 +38,7 @@ jobs: COMMENT_BODY=$(cat < Date: Mon, 2 Dec 2024 11:13:05 -0500 Subject: [PATCH 2/3] fix clippy --- .../subtensor/src/coinbase/run_coinbase.rs | 44 +++++++++---------- pallets/subtensor/src/epoch/math.rs | 10 ++--- pallets/subtensor/src/tests/epoch.rs | 2 +- runtime/src/lib.rs | 3 ++ 4 files changed, 31 insertions(+), 28 deletions(-) diff --git a/pallets/subtensor/src/coinbase/run_coinbase.rs b/pallets/subtensor/src/coinbase/run_coinbase.rs index 5529fd129..d424e5ccb 100644 --- a/pallets/subtensor/src/coinbase/run_coinbase.rs +++ b/pallets/subtensor/src/coinbase/run_coinbase.rs @@ -5,28 +5,28 @@ use substrate_fixed::types::I96F32; impl Pallet { /// The `coinbase` function performs a four-part emission distribution process involving /// subnets, epochs, hotkeys, and nominators. - // It is divided into several steps, each handling a specific part of the distribution: - - // Step 1: Compute the block-wise emission for each subnet. - // This involves calculating how much (TAO) should be emitted into each subnet using the - // root epoch function. - - // Step 2: Accumulate the subnet block emission. - // After calculating the block-wise emission, these values are accumulated to keep track - // of how much each subnet should emit before the next distribution phase. This accumulation - // is a running total that gets updated each block. - - // Step 3: Distribute the accumulated emissions through epochs. - // Subnets periodically distribute their accumulated emissions to hotkeys (active validators/miners) - // in the network on a `tempo` --- the time between epochs. This step runs Yuma consensus to - // determine how emissions are split among hotkeys based on their contributions and roles. - // The accumulation of hotkey emissions is done through the `accumulate_hotkey_emission` function. - // The function splits the rewards for a hotkey amongst itself and its `parents`. The parents are - // the hotkeys that are delegating their stake to the hotkey. - - // Step 4: Further distribute emissions from hotkeys to nominators. - // Finally, the emissions received by hotkeys are further distributed to their nominators, - // who are stakeholders that support the hotkeys. + /// It is divided into several steps, each handling a specific part of the distribution: + /// + /// Step 1: Compute the block-wise emission for each subnet. + /// This involves calculating how much (TAO) should be emitted into each subnet using the + /// root epoch function. + /// + /// Step 2: Accumulate the subnet block emission. + /// After calculating the block-wise emission, these values are accumulated to keep track + /// of how much each subnet should emit before the next distribution phase. This accumulation + /// is a running total that gets updated each block. + /// + /// Step 3: Distribute the accumulated emissions through epochs. + /// Subnets periodically distribute their accumulated emissions to hotkeys (active validators/miners) + /// in the network on a `tempo` --- the time between epochs. This step runs Yuma consensus to + /// determine how emissions are split among hotkeys based on their contributions and roles. + /// The accumulation of hotkey emissions is done through the `accumulate_hotkey_emission` function. + /// The function splits the rewards for a hotkey amongst itself and its `parents`. The parents are + /// the hotkeys that are delegating their stake to the hotkey. + /// + /// Step 4: Further distribute emissions from hotkeys to nominators. + /// Finally, the emissions received by hotkeys are further distributed to their nominators, + /// who are stakeholders that support the hotkeys. pub fn run_coinbase() { // --- 0. Get current block. let current_block: u64 = Self::get_current_block_as_u64(); diff --git a/pallets/subtensor/src/epoch/math.rs b/pallets/subtensor/src/epoch/math.rs index 1abc9ed9b..c8a3040ff 100644 --- a/pallets/subtensor/src/epoch/math.rs +++ b/pallets/subtensor/src/epoch/math.rs @@ -113,7 +113,7 @@ pub fn vec_max_upscale_to_u16(vec: &[I32F32]) -> Vec { }) .collect(); } - return vec + vec .iter() .map(|e: &I32F32| { e.saturating_mul(u16_max) @@ -121,18 +121,18 @@ pub fn vec_max_upscale_to_u16(vec: &[I32F32]) -> Vec { .round() .to_num::() }) - .collect(); + .collect() } None => { let sum: I32F32 = vec.iter().sum(); - return vec + vec .iter() .map(|e: &I32F32| { e.saturating_mul(u16_max) .saturating_div(sum) .to_num::() }) - .collect(); + .collect() } } } @@ -246,7 +246,7 @@ pub fn is_topk(vector: &[I32F32], k: usize) -> Vec { pub fn normalize(x: &[I32F32]) -> Vec { let x_sum: I32F32 = sum(x); if x_sum != I32F32::from_num(0.0_f32) { - return x.iter().map(|xi| xi.saturating_div(x_sum)).collect(); + x.iter().map(|xi| xi.saturating_div(x_sum)).collect() } else { x.to_vec() } diff --git a/pallets/subtensor/src/tests/epoch.rs b/pallets/subtensor/src/tests/epoch.rs index 8a2f21537..5edd3f940 100644 --- a/pallets/subtensor/src/tests/epoch.rs +++ b/pallets/subtensor/src/tests/epoch.rs @@ -2835,7 +2835,7 @@ fn test_blocks_since_last_step() { // println!("]"); // } -/// Helpers +// Helpers /// Asserts that two I32F32 values are approximately equal within a given epsilon. /// diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index fcaeb56d1..c2ae2ee62 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -1867,7 +1867,10 @@ impl_runtime_apis! { use frame_system_benchmarking::Pallet as SystemBench; use baseline::Pallet as BaselineBench; + #[allow(non_local_definitions)] impl frame_system_benchmarking::Config for Runtime {} + + #[allow(non_local_definitions)] impl baseline::Config for Runtime {} use frame_support::traits::WhitelistedStorageKeys; From f21a5ea0680e6c3bdb1097a2cf74f4f7aa747830 Mon Sep 17 00:00:00 2001 From: Sam Johnson Date: Mon, 2 Dec 2024 11:15:12 -0500 Subject: [PATCH 3/3] cargo fmt --- pallets/subtensor/src/epoch/math.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pallets/subtensor/src/epoch/math.rs b/pallets/subtensor/src/epoch/math.rs index c8a3040ff..027966f92 100644 --- a/pallets/subtensor/src/epoch/math.rs +++ b/pallets/subtensor/src/epoch/math.rs @@ -113,8 +113,7 @@ pub fn vec_max_upscale_to_u16(vec: &[I32F32]) -> Vec { }) .collect(); } - vec - .iter() + vec.iter() .map(|e: &I32F32| { e.saturating_mul(u16_max) .saturating_div(*val) @@ -125,8 +124,7 @@ pub fn vec_max_upscale_to_u16(vec: &[I32F32]) -> Vec { } None => { let sum: I32F32 = vec.iter().sum(); - vec - .iter() + vec.iter() .map(|e: &I32F32| { e.saturating_mul(u16_max) .saturating_div(sum)