From 86b4b1988444b094589ec149041fc338a9591b99 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Wed, 4 Jun 2025 14:01:00 +0400 Subject: [PATCH 1/7] Migrate NetworkLastRegistered storage --- pallets/subtensor/src/coinbase/root.rs | 4 +- pallets/subtensor/src/lib.rs | 11 +-- pallets/subtensor/src/macros/hooks.rs | 4 +- .../migrate_rate_limiting_last_blocks.rs | 75 +++++++++++++++++++ pallets/subtensor/src/migrations/mod.rs | 1 + pallets/subtensor/src/subnets/subnet.rs | 2 +- pallets/subtensor/src/tests/migration.rs | 59 +++++++++++++++ pallets/subtensor/src/utils/rate_limiting.rs | 8 -- 8 files changed, 143 insertions(+), 21 deletions(-) create mode 100644 pallets/subtensor/src/migrations/migrate_rate_limiting_last_blocks.rs diff --git a/pallets/subtensor/src/coinbase/root.rs b/pallets/subtensor/src/coinbase/root.rs index 1f3a91b339..b033fc873f 100644 --- a/pallets/subtensor/src/coinbase/root.rs +++ b/pallets/subtensor/src/coinbase/root.rs @@ -645,10 +645,10 @@ impl Pallet { NetworkLastLockCost::::get() } pub fn get_network_last_lock_block() -> u64 { - NetworkLastRegistered::::get() + Self::get_rate_limited_last_block(&RateLimitKey::NetworkLastRegistered) } pub fn set_network_last_lock_block(block: u64) { - NetworkLastRegistered::::set(block); + Self::set_rate_limited_last_block(&RateLimitKey::NetworkLastRegistered, block); } pub fn set_lock_reduction_interval(interval: u64) { NetworkLockReductionInterval::::set(interval); diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index f4f511e74a..5259033891 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -556,11 +556,6 @@ pub mod pallet { T::InitialNetworkImmunityPeriod::get() } #[pallet::type_value] - /// Default value for network last registered. - pub fn DefaultNetworkLastRegistered() -> u64 { - 0 - } - #[pallet::type_value] /// Default value for network min allowed UIDs. pub fn DefaultNetworkMinAllowedUids() -> u16 { T::InitialNetworkMinAllowedUids::get() @@ -1194,10 +1189,6 @@ pub mod pallet { pub type NetworkImmunityPeriod = StorageValue<_, u64, ValueQuery, DefaultNetworkImmunityPeriod>; #[pallet::storage] - /// ITEM( network_last_registered_block ) - pub type NetworkLastRegistered = - StorageValue<_, u64, ValueQuery, DefaultNetworkLastRegistered>; - #[pallet::storage] /// ITEM( min_network_lock_cost ) pub type NetworkMinLockCost = StorageValue<_, u64, ValueQuery, DefaultNetworkMinLockCost>; #[pallet::storage] @@ -2713,4 +2704,6 @@ impl CollectiveInterface for () { pub enum RateLimitKey { // The setting sn owner hotkey operation is rate limited per netuid SetSNOwnerHotkey(u16), + // Last registered network limit + NetworkLastRegistered, } diff --git a/pallets/subtensor/src/macros/hooks.rs b/pallets/subtensor/src/macros/hooks.rs index 8dff0ed106..e5e52a41ea 100644 --- a/pallets/subtensor/src/macros/hooks.rs +++ b/pallets/subtensor/src/macros/hooks.rs @@ -113,7 +113,9 @@ mod hooks { // Reset max burn .saturating_add(migrations::migrate_reset_max_burn::migrate_reset_max_burn::()) // Migrate ColdkeySwapScheduled structure to new format - .saturating_add(migrations::migrate_coldkey_swap_scheduled::migrate_coldkey_swap_scheduled::()); + .saturating_add(migrations::migrate_coldkey_swap_scheduled::migrate_coldkey_swap_scheduled::()) + // Migrate last block rate limiting storage items + .saturating_add(migrations::migrate_rate_limiting_last_blocks::migrate_obsolete_rate_limiting_last_blocks_storage::()); weight } diff --git a/pallets/subtensor/src/migrations/migrate_rate_limiting_last_blocks.rs b/pallets/subtensor/src/migrations/migrate_rate_limiting_last_blocks.rs new file mode 100644 index 0000000000..25eeb489ef --- /dev/null +++ b/pallets/subtensor/src/migrations/migrate_rate_limiting_last_blocks.rs @@ -0,0 +1,75 @@ +use crate::Vec; +use crate::{Config, HasMigrationRun, Pallet}; +use alloc::string::String; +use codec::Decode; +use frame_support::traits::Get; +use frame_support::weights::Weight; +use sp_io::hashing::twox_128; +use sp_io::storage::{clear, get}; + +pub fn migrate_obsolete_rate_limiting_last_blocks_storage() -> Weight { + migrate_network_last_registered::() +} + +pub fn migrate_network_last_registered() -> Weight { + let migration_name = b"migrate_network_last_registered".to_vec(); + let pallet_name = "SubtensorModule"; + let storage_name = "NetworkLastRegistered"; + + migrate_value::(migration_name, pallet_name, storage_name, |limit| { + Pallet::::set_network_last_lock_block(limit); + }) +} +fn migrate_value( + migration_name: Vec, + pallet_name: &str, + storage_name: &str, + set_value: SetValueFunction, +) -> Weight +where + T: Config, + SetValueFunction: Fn(u64 /*limit in blocks*/), +{ + // Initialize the weight with one read operation. + let mut weight = T::DbWeight::get().reads(1); + + // Check if the migration has already run + if HasMigrationRun::::get(&migration_name) { + log::info!( + "Migration '{:?}' has already run. Skipping.", + migration_name + ); + return weight; + } + log::info!( + "Running migration '{}'", + String::from_utf8_lossy(&migration_name) + ); + + let pallet_name_hash = twox_128(pallet_name.as_bytes()); + let storage_name_hash = twox_128(storage_name.as_bytes()); + let full_key = [pallet_name_hash, storage_name_hash].concat(); + + if let Some(value_bytes) = get(&full_key) { + if let Ok(rate_limit) = Decode::decode(&mut &value_bytes[..]) { + set_value(rate_limit); + } + + clear(&full_key); + } + + weight = weight.saturating_add(T::DbWeight::get().writes(2)); + weight = weight.saturating_add(T::DbWeight::get().reads(1)); + + // Mark the migration as completed + HasMigrationRun::::insert(&migration_name, true); + weight = weight.saturating_add(T::DbWeight::get().writes(1)); + + log::info!( + "Migration '{:?}' completed.", + String::from_utf8_lossy(&migration_name) + ); + + // Return the migration weight. + weight +} diff --git a/pallets/subtensor/src/migrations/mod.rs b/pallets/subtensor/src/migrations/mod.rs index 5c6347034f..1a5dc81919 100644 --- a/pallets/subtensor/src/migrations/mod.rs +++ b/pallets/subtensor/src/migrations/mod.rs @@ -15,6 +15,7 @@ pub mod migrate_init_total_issuance; pub mod migrate_orphaned_storage_items; pub mod migrate_populate_owned_hotkeys; pub mod migrate_rao; +pub mod migrate_rate_limiting_last_blocks; pub mod migrate_remove_commitments_rate_limit; pub mod migrate_remove_stake_map; pub mod migrate_remove_total_hotkey_coldkey_stakes_this_interval; diff --git a/pallets/subtensor/src/subnets/subnet.rs b/pallets/subtensor/src/subnets/subnet.rs index b122bfa049..b89546cf69 100644 --- a/pallets/subtensor/src/subnets/subnet.rs +++ b/pallets/subtensor/src/subnets/subnet.rs @@ -193,7 +193,7 @@ impl Pallet { ); // --- 11. Set the creation terms. - NetworkLastRegistered::::set(current_block); + Self::set_network_last_lock_block(current_block); NetworkRegisteredAt::::insert(netuid_to_register, current_block); // --- 14. Init the pool by putting the lock as the initial alpha. diff --git a/pallets/subtensor/src/tests/migration.rs b/pallets/subtensor/src/tests/migration.rs index 1dfac06ad5..55fd845ef1 100644 --- a/pallets/subtensor/src/tests/migration.rs +++ b/pallets/subtensor/src/tests/migration.rs @@ -820,3 +820,62 @@ fn test_migrate_remove_commitments_rate_limit() { assert!(!weight.is_zero(), "Migration weight should be non-zero"); }); } + +#[test] +fn test_migrate_network_last_registered() { + new_test_ext(1).execute_with(|| { + // ------------------------------ + // Step 1: Simulate Old Storage Entry + // ------------------------------ + const MIGRATION_NAME: &str = "migrate_network_last_registered"; + + let pallet_name = "SubtensorModule"; + let storage_name = "NetworkLastRegistered"; + let pallet_name_hash = twox_128(pallet_name.as_bytes()); + let storage_name_hash = twox_128(storage_name.as_bytes()); + let prefix = [pallet_name_hash, storage_name_hash].concat(); + + let mut full_key = prefix.clone(); + + let original_value: u64 = 123; + put_raw(&full_key, &original_value.encode()); + + let stored_before = get_raw(&full_key).expect("Expected RateLimit to exist"); + assert_eq!( + u64::decode(&mut &stored_before[..]).expect("Failed to decode RateLimit"), + original_value + ); + + assert!( + !HasMigrationRun::::get(MIGRATION_NAME.as_bytes().to_vec()), + "Migration should not have run yet" + ); + + // ------------------------------ + // Step 2: Run the Migration + // ------------------------------ + let weight = crate::migrations::migrate_rate_limiting_last_blocks:: + migrate_obsolete_rate_limiting_last_blocks_storage::(); + + assert!( + HasMigrationRun::::get(MIGRATION_NAME.as_bytes().to_vec()), + "Migration should be marked as completed" + ); + + // ------------------------------ + // Step 3: Verify Migration Effects + // ------------------------------ + + assert_eq!( + SubtensorModule::get_network_last_lock_block(), + original_value + ); + assert_eq!( + get_raw(&full_key), + None, + "RateLimit storage should have been cleared" + ); + + assert!(!weight.is_zero(), "Migration weight should be non-zero"); + }); +} diff --git a/pallets/subtensor/src/utils/rate_limiting.rs b/pallets/subtensor/src/utils/rate_limiting.rs index 7edaebc98a..e33f1569e5 100644 --- a/pallets/subtensor/src/utils/rate_limiting.rs +++ b/pallets/subtensor/src/utils/rate_limiting.rs @@ -117,14 +117,6 @@ impl Pallet { } } - /// Set the block number of the last transaction for a specific key, and transaction type - pub fn set_last_transaction_block(key: &T::AccountId, tx_type: &TransactionType, block: u64) { - match tx_type { - TransactionType::RegisterNetwork => Self::set_network_last_lock_block(block), - _ => Self::set_last_transaction_block_on_subnet(key, 0, tx_type, block), - } - } - /// Set the block number of the last transaction for a specific hotkey, network, and transaction type pub fn set_last_transaction_block_on_subnet( key: &T::AccountId, From 9fb0b949c5cd11e41d511953c74e6dc1c0cba4f5 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Wed, 4 Jun 2025 16:24:45 +0400 Subject: [PATCH 2/7] Migrate LastTxBlock --- pallets/subtensor/src/coinbase/root.rs | 7 ++- pallets/subtensor/src/lib.rs | 8 ++- .../migrate_rate_limiting_last_blocks.rs | 63 +++++++++++++++++++ pallets/subtensor/src/swap/swap_hotkey.rs | 7 +-- pallets/subtensor/src/tests/swap_hotkey.rs | 9 ++- pallets/subtensor/src/utils/rate_limiting.rs | 7 ++- 6 files changed, 88 insertions(+), 13 deletions(-) diff --git a/pallets/subtensor/src/coinbase/root.rs b/pallets/subtensor/src/coinbase/root.rs index b033fc873f..32bf73762f 100644 --- a/pallets/subtensor/src/coinbase/root.rs +++ b/pallets/subtensor/src/coinbase/root.rs @@ -665,10 +665,13 @@ impl Pallet { let halved_interval: I64F64 = interval.saturating_mul(halving); halved_interval.saturating_to_num::() } - pub fn get_rate_limited_last_block(rate_limit_key: &RateLimitKey) -> u64 { + pub fn get_rate_limited_last_block(rate_limit_key: &RateLimitKey) -> u64 { LastRateLimitedBlock::::get(rate_limit_key) } - pub fn set_rate_limited_last_block(rate_limit_key: &RateLimitKey, block: u64) { + pub fn set_rate_limited_last_block(rate_limit_key: &RateLimitKey, block: u64) { LastRateLimitedBlock::::set(rate_limit_key, block); } + pub fn remove_rate_limited_last_block(rate_limit_key: &RateLimitKey) { + LastRateLimitedBlock::::remove(rate_limit_key); + } } diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index 5259033891..19c8281bcb 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -57,6 +57,7 @@ extern crate alloc; pub const MAX_CRV3_COMMIT_SIZE_BYTES: u32 = 5000; +#[allow(deprecated)] #[deny(missing_docs)] #[import_section(errors::errors)] #[import_section(events::events)] @@ -1219,7 +1220,7 @@ pub mod pallet { #[pallet::storage] /// --- MAP ( RateLimitKey ) --> Block number in which the last rate limited operation occured pub type LastRateLimitedBlock = - StorageMap<_, Identity, RateLimitKey, u64, ValueQuery, DefaultZeroU64>; + StorageMap<_, Identity, RateLimitKey, u64, ValueQuery, DefaultZeroU64>; /// ============================ /// ==== Subnet Locks ===== @@ -1621,6 +1622,7 @@ pub mod pallet { u64, ValueQuery, >; + #[deprecated] #[pallet::storage] /// --- MAP ( key ) --> last_block pub type LastTxBlock = @@ -2701,9 +2703,11 @@ impl CollectiveInterface for () { /// Enum that defines types of rate limited operations for /// storing last block when this operation occured #[derive(Encode, Decode, Clone, PartialEq, Eq, Debug, TypeInfo)] -pub enum RateLimitKey { +pub enum RateLimitKey { // The setting sn owner hotkey operation is rate limited per netuid SetSNOwnerHotkey(u16), // Last registered network limit NetworkLastRegistered, + // Last tx block limit + LastTxBlock(AccountId), } diff --git a/pallets/subtensor/src/migrations/migrate_rate_limiting_last_blocks.rs b/pallets/subtensor/src/migrations/migrate_rate_limiting_last_blocks.rs index 25eeb489ef..307e9f5242 100644 --- a/pallets/subtensor/src/migrations/migrate_rate_limiting_last_blocks.rs +++ b/pallets/subtensor/src/migrations/migrate_rate_limiting_last_blocks.rs @@ -20,6 +20,20 @@ pub fn migrate_network_last_registered() -> Weight { Pallet::::set_network_last_lock_block(limit); }) } + +#[allow(deprecated)] +pub fn migrate_last_tx_block() -> Weight { + let migration_name = b"migrate_last_tx_block".to_vec(); + + migrate_last_block_map::( + migration_name, + || crate::LastTxBlock::::iter().collect::>(), + |account, block| { + Pallet::::set_last_tx_block(&account, block); + }, + ) +} + fn migrate_value( migration_name: Vec, pallet_name: &str, @@ -73,3 +87,52 @@ where // Return the migration weight. weight } + +fn migrate_last_block_map( + migration_name: Vec, + get_values: GetValuesFunction, + set_value: SetValueFunction, +) -> Weight +where + T: Config, + GetValuesFunction: Fn() -> Vec<(T::AccountId, u64)>, // (account, limit in blocks) + SetValueFunction: Fn(T::AccountId, u64), +{ + // Initialize the weight with one read operation. + let mut weight = T::DbWeight::get().reads(1); + + // Check if the migration has already run + if HasMigrationRun::::get(&migration_name) { + log::info!( + "Migration '{:?}' has already run. Skipping.", + migration_name + ); + return weight; + } + log::info!( + "Running migration '{}'", + String::from_utf8_lossy(&migration_name) + ); + + let key_values = get_values(); + weight = weight.saturating_add(T::DbWeight::get().reads(key_values.len() as u64)); + + for (account, block) in key_values.into_iter() { + set_value(account, block); + + weight = weight.saturating_add(T::DbWeight::get().writes(2)); + weight = weight.saturating_add(T::DbWeight::get().reads(1)); + } + + // Mark the migration as completed + HasMigrationRun::::insert(&migration_name, true); + weight = weight.saturating_add(T::DbWeight::get().writes(1)); + + log::info!( + "Migration '{:?}' completed.", + String::from_utf8_lossy(&migration_name) + ); + + // Return the migration weight. + weight +} diff --git a/pallets/subtensor/src/swap/swap_hotkey.rs b/pallets/subtensor/src/swap/swap_hotkey.rs index 54c7c01d8e..4c93b066b1 100644 --- a/pallets/subtensor/src/swap/swap_hotkey.rs +++ b/pallets/subtensor/src/swap/swap_hotkey.rs @@ -187,10 +187,9 @@ impl Pallet { }); // 5. Swap LastTxBlock - // LastTxBlock( hotkey ) --> u64 -- the last transaction block for the hotkey. - let last_tx_block: u64 = LastTxBlock::::get(old_hotkey); - LastTxBlock::::remove(old_hotkey); - LastTxBlock::::insert(new_hotkey, last_tx_block); + let last_tx_block: u64 = Self::get_last_tx_block(old_hotkey); + Self::remove_last_tx_block(old_hotkey); + Self::set_last_tx_block(new_hotkey, last_tx_block); weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 2)); // 6. Swap LastTxBlockDelegateTake diff --git a/pallets/subtensor/src/tests/swap_hotkey.rs b/pallets/subtensor/src/tests/swap_hotkey.rs index a82972c2f7..17b8d61abb 100644 --- a/pallets/subtensor/src/tests/swap_hotkey.rs +++ b/pallets/subtensor/src/tests/swap_hotkey.rs @@ -1011,7 +1011,7 @@ fn test_swap_hotkey_error_cases() { // Set up initial state Owner::::insert(old_hotkey, coldkey); TotalNetworks::::put(1); - LastTxBlock::::insert(coldkey, 0); + SubtensorModule::set_last_tx_block(&coldkey, 0); // Test not enough balance let swap_cost = SubtensorModule::get_key_swap_cost(); @@ -1373,7 +1373,7 @@ fn test_swap_hotkey_swap_rate_limits() { let child_key_take_block = 8910; // Set the last tx block for the old hotkey - LastTxBlock::::insert(old_hotkey, last_tx_block); + SubtensorModule::set_last_tx_block(&old_hotkey, last_tx_block); // Set the last delegate take block for the old hotkey LastTxBlockDelegateTake::::insert(old_hotkey, delegate_take_block); // Set last childkey take block for the old hotkey @@ -1383,7 +1383,10 @@ fn test_swap_hotkey_swap_rate_limits() { SubtensorModule::perform_hotkey_swap(&old_hotkey, &new_hotkey, &coldkey, &mut weight); // Check for new hotkey - assert_eq!(LastTxBlock::::get(new_hotkey), last_tx_block); + assert_eq!( + SubtensorModule::get_last_tx_block(&new_hotkey), + last_tx_block + ); assert_eq!( LastTxBlockDelegateTake::::get(new_hotkey), delegate_take_block diff --git a/pallets/subtensor/src/utils/rate_limiting.rs b/pallets/subtensor/src/utils/rate_limiting.rs index e33f1569e5..6be1467d37 100644 --- a/pallets/subtensor/src/utils/rate_limiting.rs +++ b/pallets/subtensor/src/utils/rate_limiting.rs @@ -136,11 +136,14 @@ impl Pallet { } } + pub fn remove_last_tx_block(key: &T::AccountId) { + Self::remove_rate_limited_last_block(&RateLimitKey::LastTxBlock(key.clone())) + } pub fn set_last_tx_block(key: &T::AccountId, block: u64) { - LastTxBlock::::insert(key, block) + Self::set_rate_limited_last_block(&RateLimitKey::LastTxBlock(key.clone()), block); } pub fn get_last_tx_block(key: &T::AccountId) -> u64 { - LastTxBlock::::get(key) + Self::get_rate_limited_last_block(&RateLimitKey::LastTxBlock(key.clone())) } pub fn set_last_tx_block_delegate_take(key: &T::AccountId, block: u64) { LastTxBlockDelegateTake::::insert(key, block) From 8a345d2af85337c62bde1d7b6ed95d366ad418ce Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Thu, 5 Jun 2025 15:07:48 +0400 Subject: [PATCH 3/7] Add TxLastBlock migration test --- pallets/subtensor/src/coinbase/root.rs | 2 +- pallets/subtensor/src/lib.rs | 2 +- .../migrate_rate_limiting_last_blocks.rs | 4 +- pallets/subtensor/src/tests/migration.rs | 47 +++++++++++++++++++ 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/pallets/subtensor/src/coinbase/root.rs b/pallets/subtensor/src/coinbase/root.rs index 32bf73762f..a3e5d7a8c4 100644 --- a/pallets/subtensor/src/coinbase/root.rs +++ b/pallets/subtensor/src/coinbase/root.rs @@ -669,7 +669,7 @@ impl Pallet { LastRateLimitedBlock::::get(rate_limit_key) } pub fn set_rate_limited_last_block(rate_limit_key: &RateLimitKey, block: u64) { - LastRateLimitedBlock::::set(rate_limit_key, block); + LastRateLimitedBlock::::insert(rate_limit_key, block); } pub fn remove_rate_limited_last_block(rate_limit_key: &RateLimitKey) { LastRateLimitedBlock::::remove(rate_limit_key); diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index 19c8281bcb..e14f3a2a95 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -2706,7 +2706,7 @@ impl CollectiveInterface for () { pub enum RateLimitKey { // The setting sn owner hotkey operation is rate limited per netuid SetSNOwnerHotkey(u16), - // Last registered network limit + // Subnet registration rate limit NetworkLastRegistered, // Last tx block limit LastTxBlock(AccountId), diff --git a/pallets/subtensor/src/migrations/migrate_rate_limiting_last_blocks.rs b/pallets/subtensor/src/migrations/migrate_rate_limiting_last_blocks.rs index 307e9f5242..fa7d212cdd 100644 --- a/pallets/subtensor/src/migrations/migrate_rate_limiting_last_blocks.rs +++ b/pallets/subtensor/src/migrations/migrate_rate_limiting_last_blocks.rs @@ -8,7 +8,7 @@ use sp_io::hashing::twox_128; use sp_io::storage::{clear, get}; pub fn migrate_obsolete_rate_limiting_last_blocks_storage() -> Weight { - migrate_network_last_registered::() + migrate_network_last_registered::().saturating_add(migrate_last_tx_block::()) } pub fn migrate_network_last_registered() -> Weight { @@ -27,7 +27,7 @@ pub fn migrate_last_tx_block() -> Weight { migrate_last_block_map::( migration_name, - || crate::LastTxBlock::::iter().collect::>(), + || crate::LastTxBlock::::drain().collect::>(), |account, block| { Pallet::::set_last_tx_block(&account, block); }, diff --git a/pallets/subtensor/src/tests/migration.rs b/pallets/subtensor/src/tests/migration.rs index 55fd845ef1..dd3471d755 100644 --- a/pallets/subtensor/src/tests/migration.rs +++ b/pallets/subtensor/src/tests/migration.rs @@ -879,3 +879,50 @@ fn test_migrate_network_last_registered() { assert!(!weight.is_zero(), "Migration weight should be non-zero"); }); } + +#[allow(deprecated)] +#[test] +fn test_migrate_last_block_tx() { + new_test_ext(1).execute_with(|| { + // ------------------------------ + // Step 1: Simulate Old Storage Entry + // ------------------------------ + const MIGRATION_NAME: &str = "migrate_last_tx_block"; + + let test_account: U256 = U256::from(1); + let original_value: u64 = 123; + + LastTxBlock::::insert(test_account.clone(), original_value); + + assert!( + !HasMigrationRun::::get(MIGRATION_NAME.as_bytes().to_vec()), + "Migration should not have run yet" + ); + + // ------------------------------ + // Step 2: Run the Migration + // ------------------------------ + let weight = crate::migrations::migrate_rate_limiting_last_blocks:: + migrate_obsolete_rate_limiting_last_blocks_storage::(); + + assert!( + HasMigrationRun::::get(MIGRATION_NAME.as_bytes().to_vec()), + "Migration should be marked as completed" + ); + + // ------------------------------ + // Step 3: Verify Migration Effects + // ------------------------------ + + assert_eq!( + SubtensorModule::get_last_tx_block(&test_account), + original_value + ); + assert!( + !LastTxBlock::::contains_key(&test_account), + "RateLimit storage should have been cleared" + ); + + assert!(!weight.is_zero(), "Migration weight should be non-zero"); + }); +} From 6cac416b3a08bc9cac9053b758bb13b7ebf4aa8b Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Thu, 5 Jun 2025 17:10:29 +0400 Subject: [PATCH 4/7] Migrate LastTxBlockChildKeyTake --- pallets/subtensor/src/lib.rs | 3 ++ .../migrate_rate_limiting_last_blocks.rs | 17 ++++++- pallets/subtensor/src/swap/swap_hotkey.rs | 7 ++- pallets/subtensor/src/tests/migration.rs | 51 ++++++++++++++++++- pallets/subtensor/src/tests/swap_hotkey.rs | 4 +- pallets/subtensor/src/utils/rate_limiting.rs | 11 +++- 6 files changed, 83 insertions(+), 10 deletions(-) diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index e14f3a2a95..d7f1ef47c4 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -1627,6 +1627,7 @@ pub mod pallet { /// --- MAP ( key ) --> last_block pub type LastTxBlock = StorageMap<_, Identity, T::AccountId, u64, ValueQuery, DefaultLastTxBlock>; + #[deprecated] #[pallet::storage] /// --- MAP ( key ) --> last_tx_block_childkey_take pub type LastTxBlockChildKeyTake = @@ -2710,4 +2711,6 @@ pub enum RateLimitKey { NetworkLastRegistered, // Last tx block limit LastTxBlock(AccountId), + // Last tx block child key limit + LastTxBlockChildKeyTake(AccountId), } diff --git a/pallets/subtensor/src/migrations/migrate_rate_limiting_last_blocks.rs b/pallets/subtensor/src/migrations/migrate_rate_limiting_last_blocks.rs index fa7d212cdd..05f8bbf5d4 100644 --- a/pallets/subtensor/src/migrations/migrate_rate_limiting_last_blocks.rs +++ b/pallets/subtensor/src/migrations/migrate_rate_limiting_last_blocks.rs @@ -8,7 +8,9 @@ use sp_io::hashing::twox_128; use sp_io::storage::{clear, get}; pub fn migrate_obsolete_rate_limiting_last_blocks_storage() -> Weight { - migrate_network_last_registered::().saturating_add(migrate_last_tx_block::()) + migrate_network_last_registered::() + .saturating_add(migrate_last_tx_block::()) + .saturating_add(migrate_last_tx_block_childkey_take::()) } pub fn migrate_network_last_registered() -> Weight { @@ -34,6 +36,19 @@ pub fn migrate_last_tx_block() -> Weight { ) } +#[allow(deprecated)] +pub fn migrate_last_tx_block_childkey_take() -> Weight { + let migration_name = b"migrate_last_tx_block_childkey_take".to_vec(); + + migrate_last_block_map::( + migration_name, + || crate::LastTxBlockChildKeyTake::::drain().collect::>(), + |account, block| { + Pallet::::set_last_tx_block_childkey(&account, block); + }, + ) +} + fn migrate_value( migration_name: Vec, pallet_name: &str, diff --git a/pallets/subtensor/src/swap/swap_hotkey.rs b/pallets/subtensor/src/swap/swap_hotkey.rs index 4c93b066b1..c2572fd020 100644 --- a/pallets/subtensor/src/swap/swap_hotkey.rs +++ b/pallets/subtensor/src/swap/swap_hotkey.rs @@ -200,10 +200,9 @@ impl Pallet { weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 2)); // 7. Swap LastTxBlockChildKeyTake - // LastTxBlockChildKeyTake( hotkey ) --> u64 -- the last transaction block for the hotkey child key take. - let last_tx_block_child_key_take: u64 = LastTxBlockChildKeyTake::::get(old_hotkey); - LastTxBlockChildKeyTake::::remove(old_hotkey); - LastTxBlockChildKeyTake::::insert(new_hotkey, last_tx_block_child_key_take); + let last_tx_block_child_key_take: u64 = Self::get_last_tx_block_childkey_take(old_hotkey); + Self::remove_last_tx_block_childkey(old_hotkey); + Self::set_last_tx_block_childkey(new_hotkey, last_tx_block_child_key_take); weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 2)); // 8. Swap Senate members. diff --git a/pallets/subtensor/src/tests/migration.rs b/pallets/subtensor/src/tests/migration.rs index dd3471d755..edc30aaac5 100644 --- a/pallets/subtensor/src/tests/migration.rs +++ b/pallets/subtensor/src/tests/migration.rs @@ -892,7 +892,7 @@ fn test_migrate_last_block_tx() { let test_account: U256 = U256::from(1); let original_value: u64 = 123; - LastTxBlock::::insert(test_account.clone(), original_value); + LastTxBlock::::insert(test_account, original_value); assert!( !HasMigrationRun::::get(MIGRATION_NAME.as_bytes().to_vec()), @@ -919,7 +919,54 @@ fn test_migrate_last_block_tx() { original_value ); assert!( - !LastTxBlock::::contains_key(&test_account), + !LastTxBlock::::contains_key(test_account), + "RateLimit storage should have been cleared" + ); + + assert!(!weight.is_zero(), "Migration weight should be non-zero"); + }); +} + +#[allow(deprecated)] +#[test] +fn test_migrate_last_tx_block_childkey_take() { + new_test_ext(1).execute_with(|| { + // ------------------------------ + // Step 1: Simulate Old Storage Entry + // ------------------------------ + const MIGRATION_NAME: &str = "migrate_last_tx_block_childkey_take"; + + let test_account: U256 = U256::from(1); + let original_value: u64 = 123; + + LastTxBlockChildKeyTake::::insert(test_account, original_value); + + assert!( + !HasMigrationRun::::get(MIGRATION_NAME.as_bytes().to_vec()), + "Migration should not have run yet" + ); + + // ------------------------------ + // Step 2: Run the Migration + // ------------------------------ + let weight = crate::migrations::migrate_rate_limiting_last_blocks:: + migrate_obsolete_rate_limiting_last_blocks_storage::(); + + assert!( + HasMigrationRun::::get(MIGRATION_NAME.as_bytes().to_vec()), + "Migration should be marked as completed" + ); + + // ------------------------------ + // Step 3: Verify Migration Effects + // ------------------------------ + + assert_eq!( + SubtensorModule::get_last_tx_block_childkey_take(&test_account), + original_value + ); + assert!( + !LastTxBlockChildKeyTake::::contains_key(test_account), "RateLimit storage should have been cleared" ); diff --git a/pallets/subtensor/src/tests/swap_hotkey.rs b/pallets/subtensor/src/tests/swap_hotkey.rs index 17b8d61abb..666dcb9f3a 100644 --- a/pallets/subtensor/src/tests/swap_hotkey.rs +++ b/pallets/subtensor/src/tests/swap_hotkey.rs @@ -1377,7 +1377,7 @@ fn test_swap_hotkey_swap_rate_limits() { // Set the last delegate take block for the old hotkey LastTxBlockDelegateTake::::insert(old_hotkey, delegate_take_block); // Set last childkey take block for the old hotkey - LastTxBlockChildKeyTake::::insert(old_hotkey, child_key_take_block); + SubtensorModule::set_last_tx_block_childkey(&old_hotkey, child_key_take_block); // Perform the swap SubtensorModule::perform_hotkey_swap(&old_hotkey, &new_hotkey, &coldkey, &mut weight); @@ -1392,7 +1392,7 @@ fn test_swap_hotkey_swap_rate_limits() { delegate_take_block ); assert_eq!( - LastTxBlockChildKeyTake::::get(new_hotkey), + SubtensorModule::get_last_tx_block_childkey_take(&new_hotkey), child_key_take_block ); }); diff --git a/pallets/subtensor/src/utils/rate_limiting.rs b/pallets/subtensor/src/utils/rate_limiting.rs index 6be1467d37..45a9224696 100644 --- a/pallets/subtensor/src/utils/rate_limiting.rs +++ b/pallets/subtensor/src/utils/rate_limiting.rs @@ -152,7 +152,16 @@ impl Pallet { LastTxBlockDelegateTake::::get(key) } pub fn get_last_tx_block_childkey_take(key: &T::AccountId) -> u64 { - LastTxBlockChildKeyTake::::get(key) + Self::get_rate_limited_last_block(&RateLimitKey::LastTxBlockChildKeyTake(key.clone())) + } + pub fn remove_last_tx_block_childkey(key: &T::AccountId) { + Self::remove_rate_limited_last_block(&RateLimitKey::LastTxBlockChildKeyTake(key.clone())) + } + pub fn set_last_tx_block_childkey(key: &T::AccountId, block: u64) { + Self::set_rate_limited_last_block( + &RateLimitKey::LastTxBlockChildKeyTake(key.clone()), + block, + ); } pub fn exceeds_tx_rate_limit(prev_tx_block: u64, current_block: u64) -> bool { let rate_limit: u64 = Self::get_tx_rate_limit(); From 94fca576323767a2bd1210a9a19067ee40b9b9bf Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Thu, 5 Jun 2025 17:22:31 +0400 Subject: [PATCH 5/7] MIgrate LastTxBlockDelegateTake --- pallets/subtensor/src/lib.rs | 7 ++- .../migrate_rate_limiting_last_blocks.rs | 14 ++++++ pallets/subtensor/src/swap/swap_hotkey.rs | 6 +-- pallets/subtensor/src/tests/migration.rs | 47 +++++++++++++++++++ pallets/subtensor/src/tests/swap_hotkey.rs | 4 +- pallets/subtensor/src/utils/rate_limiting.rs | 11 ++++- 6 files changed, 80 insertions(+), 9 deletions(-) diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index d7f1ef47c4..e38c963e7c 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -1632,6 +1632,7 @@ pub mod pallet { /// --- MAP ( key ) --> last_tx_block_childkey_take pub type LastTxBlockChildKeyTake = StorageMap<_, Identity, T::AccountId, u64, ValueQuery, DefaultLastTxBlock>; + #[deprecated] #[pallet::storage] /// --- MAP ( key ) --> last_tx_block_delegate_take pub type LastTxBlockDelegateTake = @@ -2709,8 +2710,10 @@ pub enum RateLimitKey { SetSNOwnerHotkey(u16), // Subnet registration rate limit NetworkLastRegistered, - // Last tx block limit + // Last tx block limit per account ID LastTxBlock(AccountId), - // Last tx block child key limit + // Last tx block child key limit per account ID LastTxBlockChildKeyTake(AccountId), + // Last tx block delegate key limit per account ID + LastTxBlockDelegateTake(AccountId), } diff --git a/pallets/subtensor/src/migrations/migrate_rate_limiting_last_blocks.rs b/pallets/subtensor/src/migrations/migrate_rate_limiting_last_blocks.rs index 05f8bbf5d4..dbfdaeb3e7 100644 --- a/pallets/subtensor/src/migrations/migrate_rate_limiting_last_blocks.rs +++ b/pallets/subtensor/src/migrations/migrate_rate_limiting_last_blocks.rs @@ -11,6 +11,7 @@ pub fn migrate_obsolete_rate_limiting_last_blocks_storage() -> Weight migrate_network_last_registered::() .saturating_add(migrate_last_tx_block::()) .saturating_add(migrate_last_tx_block_childkey_take::()) + .saturating_add(migrate_last_tx_block_delegate_take::()) } pub fn migrate_network_last_registered() -> Weight { @@ -49,6 +50,19 @@ pub fn migrate_last_tx_block_childkey_take() -> Weight { ) } +#[allow(deprecated)] +pub fn migrate_last_tx_block_delegate_take() -> Weight { + let migration_name = b"migrate_last_tx_block_delegate_take".to_vec(); + + migrate_last_block_map::( + migration_name, + || crate::LastTxBlockDelegateTake::::drain().collect::>(), + |account, block| { + Pallet::::set_last_tx_block_delegate_take(&account, block); + }, + ) +} + fn migrate_value( migration_name: Vec, pallet_name: &str, diff --git a/pallets/subtensor/src/swap/swap_hotkey.rs b/pallets/subtensor/src/swap/swap_hotkey.rs index c2572fd020..b6db5926f6 100644 --- a/pallets/subtensor/src/swap/swap_hotkey.rs +++ b/pallets/subtensor/src/swap/swap_hotkey.rs @@ -194,9 +194,9 @@ impl Pallet { // 6. Swap LastTxBlockDelegateTake // LastTxBlockDelegateTake( hotkey ) --> u64 -- the last transaction block for the hotkey delegate take. - let last_tx_block_delegate_take: u64 = LastTxBlockDelegateTake::::get(old_hotkey); - LastTxBlockDelegateTake::::remove(old_hotkey); - LastTxBlockDelegateTake::::insert(new_hotkey, last_tx_block_delegate_take); + let last_tx_block_delegate_take: u64 = Self::get_last_tx_block_delegate_take(old_hotkey); + Self::remove_last_tx_block_delegate_take(old_hotkey); + Self::set_last_tx_block_delegate_take(new_hotkey, last_tx_block_delegate_take); weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 2)); // 7. Swap LastTxBlockChildKeyTake diff --git a/pallets/subtensor/src/tests/migration.rs b/pallets/subtensor/src/tests/migration.rs index edc30aaac5..dc059b185c 100644 --- a/pallets/subtensor/src/tests/migration.rs +++ b/pallets/subtensor/src/tests/migration.rs @@ -973,3 +973,50 @@ fn test_migrate_last_tx_block_childkey_take() { assert!(!weight.is_zero(), "Migration weight should be non-zero"); }); } + +#[allow(deprecated)] +#[test] +fn test_migrate_last_tx_block_delegate_take() { + new_test_ext(1).execute_with(|| { + // ------------------------------ + // Step 1: Simulate Old Storage Entry + // ------------------------------ + const MIGRATION_NAME: &str = "migrate_last_tx_block_delegate_take"; + + let test_account: U256 = U256::from(1); + let original_value: u64 = 123; + + LastTxBlockDelegateTake::::insert(test_account, original_value); + + assert!( + !HasMigrationRun::::get(MIGRATION_NAME.as_bytes().to_vec()), + "Migration should not have run yet" + ); + + // ------------------------------ + // Step 2: Run the Migration + // ------------------------------ + let weight = crate::migrations::migrate_rate_limiting_last_blocks:: + migrate_last_tx_block_delegate_take::(); + + assert!( + HasMigrationRun::::get(MIGRATION_NAME.as_bytes().to_vec()), + "Migration should be marked as completed" + ); + + // ------------------------------ + // Step 3: Verify Migration Effects + // ------------------------------ + + assert_eq!( + SubtensorModule::get_last_tx_block_delegate_take(&test_account), + original_value + ); + assert!( + !LastTxBlockDelegateTake::::contains_key(test_account), + "RateLimit storage should have been cleared" + ); + + assert!(!weight.is_zero(), "Migration weight should be non-zero"); + }); +} diff --git a/pallets/subtensor/src/tests/swap_hotkey.rs b/pallets/subtensor/src/tests/swap_hotkey.rs index 666dcb9f3a..41177c0e12 100644 --- a/pallets/subtensor/src/tests/swap_hotkey.rs +++ b/pallets/subtensor/src/tests/swap_hotkey.rs @@ -1375,7 +1375,7 @@ fn test_swap_hotkey_swap_rate_limits() { // Set the last tx block for the old hotkey SubtensorModule::set_last_tx_block(&old_hotkey, last_tx_block); // Set the last delegate take block for the old hotkey - LastTxBlockDelegateTake::::insert(old_hotkey, delegate_take_block); + SubtensorModule::set_last_tx_block_delegate_take(&old_hotkey, delegate_take_block); // Set last childkey take block for the old hotkey SubtensorModule::set_last_tx_block_childkey(&old_hotkey, child_key_take_block); @@ -1388,7 +1388,7 @@ fn test_swap_hotkey_swap_rate_limits() { last_tx_block ); assert_eq!( - LastTxBlockDelegateTake::::get(new_hotkey), + SubtensorModule::get_last_tx_block_delegate_take(&new_hotkey), delegate_take_block ); assert_eq!( diff --git a/pallets/subtensor/src/utils/rate_limiting.rs b/pallets/subtensor/src/utils/rate_limiting.rs index 45a9224696..02b50bc799 100644 --- a/pallets/subtensor/src/utils/rate_limiting.rs +++ b/pallets/subtensor/src/utils/rate_limiting.rs @@ -145,11 +145,18 @@ impl Pallet { pub fn get_last_tx_block(key: &T::AccountId) -> u64 { Self::get_rate_limited_last_block(&RateLimitKey::LastTxBlock(key.clone())) } + + pub fn remove_last_tx_block_delegate_take(key: &T::AccountId) { + Self::remove_rate_limited_last_block(&RateLimitKey::LastTxBlockDelegateTake(key.clone())) + } pub fn set_last_tx_block_delegate_take(key: &T::AccountId, block: u64) { - LastTxBlockDelegateTake::::insert(key, block) + Self::set_rate_limited_last_block( + &RateLimitKey::LastTxBlockDelegateTake(key.clone()), + block, + ); } pub fn get_last_tx_block_delegate_take(key: &T::AccountId) -> u64 { - LastTxBlockDelegateTake::::get(key) + Self::get_rate_limited_last_block(&RateLimitKey::LastTxBlockDelegateTake(key.clone())) } pub fn get_last_tx_block_childkey_take(key: &T::AccountId) -> u64 { Self::get_rate_limited_last_block(&RateLimitKey::LastTxBlockChildKeyTake(key.clone())) From 31a900189135ffa6d8f81ff806d7bdd90f8f07ef Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Thu, 5 Jun 2025 17:47:25 +0400 Subject: [PATCH 6/7] Fix merge conflicts --- pallets/subtensor/src/swap/swap_hotkey.rs | 21 ++++++++----------- .../src/tests/swap_hotkey_with_subnet.rs | 17 ++++++++------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/pallets/subtensor/src/swap/swap_hotkey.rs b/pallets/subtensor/src/swap/swap_hotkey.rs index 733535c2ad..604be74ac5 100644 --- a/pallets/subtensor/src/swap/swap_hotkey.rs +++ b/pallets/subtensor/src/swap/swap_hotkey.rs @@ -56,21 +56,18 @@ impl Pallet { weight.saturating_accrue(T::DbWeight::get().reads(2)); // 7. Swap LastTxBlock - // LastTxBlock( hotkey ) --> u64 -- the last transaction block for the hotkey. - let last_tx_block: u64 = LastTxBlock::::get(old_hotkey); - LastTxBlock::::insert(new_hotkey, last_tx_block); + let last_tx_block: u64 = Self::get_last_tx_block(old_hotkey); + Self::set_last_tx_block(new_hotkey, last_tx_block); weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 1)); // 8. Swap LastTxBlockDelegateTake - // LastTxBlockDelegateTake( hotkey ) --> u64 -- the last transaction block for the hotkey delegate take. - let last_tx_block_delegate_take: u64 = LastTxBlockDelegateTake::::get(old_hotkey); - LastTxBlockDelegateTake::::insert(new_hotkey, last_tx_block_delegate_take); + let last_tx_block_delegate_take: u64 = Self::get_last_tx_block_delegate_take(old_hotkey); + Self::set_last_tx_block_delegate_take(new_hotkey, last_tx_block_delegate_take); weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 1)); // 9. Swap LastTxBlockChildKeyTake - // LastTxBlockChildKeyTake( hotkey ) --> u64 -- the last transaction block for the hotkey child key take. - let last_tx_block_child_key_take: u64 = LastTxBlockChildKeyTake::::get(old_hotkey); - LastTxBlockChildKeyTake::::insert(new_hotkey, last_tx_block_child_key_take); + let last_tx_block_child_key_take: u64 = Self::get_last_tx_block_childkey_take(old_hotkey); + Self::set_last_tx_block_childkey(new_hotkey, last_tx_block_child_key_take); weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 1)); // 10. fork for swap hotkey on a specific subnet case after do the common check @@ -194,17 +191,17 @@ impl Pallet { // 6. Swap LastTxBlock // LastTxBlock( hotkey ) --> u64 -- the last transaction block for the hotkey. - LastTxBlock::::remove(old_hotkey); + Self::remove_last_tx_block(old_hotkey); weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 2)); // 7. Swap LastTxBlockDelegateTake // LastTxBlockDelegateTake( hotkey ) --> u64 -- the last transaction block for the hotkey delegate take. - LastTxBlockDelegateTake::::remove(old_hotkey); + Self::remove_last_tx_block_delegate_take(old_hotkey); weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 2)); // 8. Swap LastTxBlockChildKeyTake // LastTxBlockChildKeyTake( hotkey ) --> u64 -- the last transaction block for the hotkey child key take. - LastTxBlockChildKeyTake::::remove(old_hotkey); + Self::remove_last_tx_block_childkey(old_hotkey); weight.saturating_accrue(T::DbWeight::get().reads_writes(1, 2)); // 9. Swap Senate members. diff --git a/pallets/subtensor/src/tests/swap_hotkey_with_subnet.rs b/pallets/subtensor/src/tests/swap_hotkey_with_subnet.rs index 583a8cf448..88e0369783 100644 --- a/pallets/subtensor/src/tests/swap_hotkey_with_subnet.rs +++ b/pallets/subtensor/src/tests/swap_hotkey_with_subnet.rs @@ -998,7 +998,7 @@ fn test_swap_hotkey_error_cases() { // Set up initial state Owner::::insert(old_hotkey, coldkey); TotalNetworks::::put(1); - LastTxBlock::::insert(coldkey, 0); + SubtensorModule::set_last_tx_block(&coldkey, 0); // Test not enough balance let swap_cost = SubtensorModule::get_key_swap_cost(); @@ -1408,11 +1408,11 @@ fn test_swap_hotkey_swap_rate_limits() { SubtensorModule::add_balance_to_coldkey_account(&coldkey, u64::MAX); // Set the last tx block for the old hotkey - LastTxBlock::::insert(old_hotkey, last_tx_block); + SubtensorModule::set_last_tx_block(&old_hotkey, last_tx_block); // Set the last delegate take block for the old hotkey - LastTxBlockDelegateTake::::insert(old_hotkey, delegate_take_block); + SubtensorModule::set_last_tx_block_delegate_take(&old_hotkey, delegate_take_block); // Set last childkey take block for the old hotkey - LastTxBlockChildKeyTake::::insert(old_hotkey, child_key_take_block); + SubtensorModule::set_last_tx_block_childkey(&old_hotkey, child_key_take_block); // Perform the swap System::set_block_number(System::block_number() + HotkeySwapOnSubnetInterval::get()); @@ -1424,13 +1424,16 @@ fn test_swap_hotkey_swap_rate_limits() { ),); // Check for new hotkey - assert_eq!(LastTxBlock::::get(new_hotkey), last_tx_block); assert_eq!( - LastTxBlockDelegateTake::::get(new_hotkey), + SubtensorModule::get_last_tx_block(&new_hotkey), + last_tx_block + ); + assert_eq!( + SubtensorModule::get_last_tx_block_delegate_take(&new_hotkey), delegate_take_block ); assert_eq!( - LastTxBlockChildKeyTake::::get(new_hotkey), + SubtensorModule::get_last_tx_block_childkey_take(&new_hotkey), child_key_take_block ); }); From 915700ad54acba9ed617cf9822230c354a66e574 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 3 Sep 2025 17:42:28 +0000 Subject: [PATCH 7/7] auto-update benchmark weights --- pallets/subtensor/src/macros/dispatches.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index c842709208..5906abae89 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -2031,7 +2031,7 @@ mod dispatches { /// * commit_reveal_version (`u16`): /// - The client (bittensor-drand) version #[pallet::call_index(113)] - #[pallet::weight((Weight::from_parts(64_530_000, 0) + #[pallet::weight((Weight::from_parts(80_690_000, 0) .saturating_add(T::DbWeight::get().reads(7_u64)) .saturating_add(T::DbWeight::get().writes(2)), DispatchClass::Normal, Pays::No))] pub fn commit_timelocked_weights(