From b216c12e3973769ca4c2f9825a3e8f75cc4a40f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=B5?= Date: Tue, 26 Aug 2025 20:59:13 +0200 Subject: [PATCH 1/5] rename coinbase() to increase_issuance() to better reflect what the function does --- pallets/subtensor/src/subnets/registration.rs | 2 +- pallets/subtensor/src/utils/misc.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/subtensor/src/subnets/registration.rs b/pallets/subtensor/src/subnets/registration.rs index bfde68601d..c8f6b04cb6 100644 --- a/pallets/subtensor/src/subnets/registration.rs +++ b/pallets/subtensor/src/subnets/registration.rs @@ -369,7 +369,7 @@ impl Pallet { // --- 5. Add Balance via faucet. let balance_to_add: u64 = 1_000_000_000_000; - Self::coinbase(100_000_000_000.into()); // We are creating tokens here from the coinbase. + Self::increase_issuance(100_000_000_000.into()); // We are creating tokens here from the coinbase. Self::add_balance_to_coldkey_account(&coldkey, balance_to_add); diff --git a/pallets/subtensor/src/utils/misc.rs b/pallets/subtensor/src/utils/misc.rs index 9fd6d27de7..f64962f094 100644 --- a/pallets/subtensor/src/utils/misc.rs +++ b/pallets/subtensor/src/utils/misc.rs @@ -273,7 +273,7 @@ impl Pallet { pub fn burn_tokens(amount: TaoCurrency) { TotalIssuance::::put(TotalIssuance::::get().saturating_sub(amount)); } - pub fn coinbase(amount: TaoCurrency) { + pub fn increase_issuance(amount: TaoCurrency) { TotalIssuance::::put(TotalIssuance::::get().saturating_add(amount)); } From a49de77addb0e609da3e6ebef6514c8ca14363d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=B5?= Date: Tue, 26 Aug 2025 21:01:23 +0200 Subject: [PATCH 2/5] run_coinbase(): fix comments --- pallets/subtensor/src/coinbase/run_coinbase.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/subtensor/src/coinbase/run_coinbase.rs b/pallets/subtensor/src/coinbase/run_coinbase.rs index dcdab8072e..5d83bb7e2e 100644 --- a/pallets/subtensor/src/coinbase/run_coinbase.rs +++ b/pallets/subtensor/src/coinbase/run_coinbase.rs @@ -239,14 +239,14 @@ impl Pallet { }); } - // --- 7 Update moving prices after using them in the emission calculation. + // --- 7. Update moving prices after using them in the emission calculation. // Only update price EMA for subnets that we emit to. for netuid_i in subnets_to_emit_to.iter() { // Update moving prices after using them above. Self::update_moving_price(*netuid_i); } - // --- 7. Drain pending emission through the subnet based on tempo. + // --- 8. Drain pending emission through the subnet based on tempo. // Run the epoch for *all* subnets, even if we don't emit anything. for &netuid in subnets.iter() { // Reveal matured weights. From 03dbf4f72823d3f312e66875e6045b1fad31ea2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=B5?= Date: Tue, 26 Aug 2025 21:07:38 +0200 Subject: [PATCH 3/5] run_coinbase(): move fetching constants out of for loop --- pallets/subtensor/src/coinbase/run_coinbase.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pallets/subtensor/src/coinbase/run_coinbase.rs b/pallets/subtensor/src/coinbase/run_coinbase.rs index 5d83bb7e2e..20432ba060 100644 --- a/pallets/subtensor/src/coinbase/run_coinbase.rs +++ b/pallets/subtensor/src/coinbase/run_coinbase.rs @@ -183,21 +183,22 @@ impl Pallet { }); } + // Get total TAO on root. + let root_tao: U96F32 = asfloat!(SubnetTAO::::get(NetUid::ROOT)); + log::debug!("root_tao: {root_tao:?}"); + // Get tao_weight + let tao_weight: U96F32 = root_tao.saturating_mul(Self::get_tao_weight()); + log::debug!("tao_weight: {tao_weight:?}"); + // --- 6. Seperate out root dividends in alpha and sell them into tao. // Then accumulate those dividends for later. for netuid_i in subnets_to_emit_to.iter() { // Get remaining alpha out. let alpha_out_i: U96F32 = *alpha_out.get(netuid_i).unwrap_or(&asfloat!(0.0)); log::debug!("alpha_out_i: {alpha_out_i:?}"); - // Get total TAO on root. - let root_tao: U96F32 = asfloat!(SubnetTAO::::get(NetUid::ROOT)); - log::debug!("root_tao: {root_tao:?}"); // Get total ALPHA on subnet. let alpha_issuance: U96F32 = asfloat!(Self::get_alpha_issuance(*netuid_i)); log::debug!("alpha_issuance: {alpha_issuance:?}"); - // Get tao_weight - let tao_weight: U96F32 = root_tao.saturating_mul(Self::get_tao_weight()); - log::debug!("tao_weight: {tao_weight:?}"); // Get root proportional dividends. let root_proportion: U96F32 = tao_weight .checked_div(tao_weight.saturating_add(alpha_issuance)) From 24a1334da2a78a732be5d9b16a007fa77dd56248 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=B5?= Date: Tue, 26 Aug 2025 21:09:32 +0200 Subject: [PATCH 4/5] run_coinbase(): make total_moving_prices immutable --- pallets/subtensor/src/coinbase/run_coinbase.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pallets/subtensor/src/coinbase/run_coinbase.rs b/pallets/subtensor/src/coinbase/run_coinbase.rs index 20432ba060..73fc928e90 100644 --- a/pallets/subtensor/src/coinbase/run_coinbase.rs +++ b/pallets/subtensor/src/coinbase/run_coinbase.rs @@ -39,13 +39,14 @@ impl Pallet { log::debug!("Subnets to emit to: {subnets_to_emit_to:?}"); // --- 2. Get sum of tao reserves ( in a later version we will switch to prices. ) - let mut total_moving_prices = U96F32::saturating_from_num(0.0); + let mut acc_total_moving_prices = U96F32::saturating_from_num(0.0); // Only get price EMA for subnets that we emit to. for netuid_i in subnets_to_emit_to.iter() { // Get and update the moving price of each subnet adding the total together. - total_moving_prices = - total_moving_prices.saturating_add(Self::get_moving_alpha_price(*netuid_i)); + acc_total_moving_prices = + acc_total_moving_prices.saturating_add(Self::get_moving_alpha_price(*netuid_i)); } + let total_moving_prices = acc_total_moving_prices; log::debug!("total_moving_prices: {total_moving_prices:?}"); // --- 3. Get subnet terms (tao_in, alpha_in, and alpha_out) From 2c6e9cc6bc51bf02238d30bd35e6863b4a8792ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=B5?= Date: Thu, 28 Aug 2025 15:56:09 +0200 Subject: [PATCH 5/5] bump spec version to 307 to make CI happy --- runtime/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 60687d3a30..00cc24b411 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -220,7 +220,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // `spec_version`, and `authoring_version` are the same between Wasm and native. // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use // the compatible custom types. - spec_version: 306, + spec_version: 307, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1,