From 6e642136e4e8c08388e7d27fbd68587222aa816f Mon Sep 17 00:00:00 2001 From: camfairchild Date: Tue, 16 Dec 2025 12:41:07 -0500 Subject: [PATCH] remove block em storage value --- .../subtensor/src/coinbase/block_emission.rs | 3 -- pallets/subtensor/src/lib.rs | 4 --- .../migrate_remove_block_emission_storage.rs | 36 +++++++++++++++++++ 3 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 pallets/subtensor/src/migrations/migrate_remove_block_emission_storage.rs diff --git a/pallets/subtensor/src/coinbase/block_emission.rs b/pallets/subtensor/src/coinbase/block_emission.rs index 064bab4d2a..c47a89d638 100644 --- a/pallets/subtensor/src/coinbase/block_emission.rs +++ b/pallets/subtensor/src/coinbase/block_emission.rs @@ -144,9 +144,6 @@ impl Pallet { .saturating_mul(I96F32::saturating_from_num(DefaultBlockEmission::::get())); // Convert to u64 let block_emission_u64: u64 = block_emission.saturating_to_num::(); - if BlockEmission::::get() != block_emission_u64 { - BlockEmission::::put(block_emission_u64); - } Ok(block_emission_u64) } } diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index ce0781b536..1836fe565a 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -1241,10 +1241,6 @@ pub mod pallet { /// ================== /// ==== Coinbase ==== /// ================== - /// --- ITEM ( global_block_emission ) - #[pallet::storage] - pub type BlockEmission = StorageValue<_, u64, ValueQuery, DefaultBlockEmission>; - /// --- DMap ( hot, netuid ) --> emission | last hotkey emission on network. #[pallet::storage] pub type LastHotkeyEmissionOnNetuid = StorageDoubleMap< diff --git a/pallets/subtensor/src/migrations/migrate_remove_block_emission_storage.rs b/pallets/subtensor/src/migrations/migrate_remove_block_emission_storage.rs new file mode 100644 index 0000000000..ede4d39ab0 --- /dev/null +++ b/pallets/subtensor/src/migrations/migrate_remove_block_emission_storage.rs @@ -0,0 +1,36 @@ +use super::*; +use crate::HasMigrationRun; +use frame_support::{traits::Get, weights::Weight}; +use scale_info::prelude::string::String; +use sp_io::storage::clear; + +pub fn migrate_remove_block_emission_storage() -> Weight { + let migration_name = b"migrate_remove_block_emission_storage".to_vec(); + let mut weight = T::DbWeight::get().reads(1); + + if HasMigrationRun::::get(&migration_name) { + log::info!( + "Migration '{:?}' has already run. Skipping.", + String::from_utf8_lossy(&migration_name) + ); + return weight; + } + + log::info!( + "Running migration '{}'", + String::from_utf8_lossy(&migration_name) + ); + + clear(b"SubtensorModule::BlockEmission"); + + // Mark Migration as Completed + HasMigrationRun::::insert(&migration_name, true); + weight = weight.saturating_add(T::DbWeight::get().writes(2)); + + log::info!( + "Migration '{:?}' completed successfully.", + String::from_utf8_lossy(&migration_name) + ); + + weight +}