From 86b4b1988444b094589ec149041fc338a9591b99 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Wed, 4 Jun 2025 14:01:00 +0400 Subject: [PATCH 001/147] 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 002/147] 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 003/147] 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 004/147] 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 005/147] 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 006/147] 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 9e22239266a74d1109c511dd67227fb7fc3b017a Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Wed, 13 Aug 2025 05:12:45 -0400 Subject: [PATCH 007/147] make reg_network pays::yes --- pallets/subtensor/src/macros/dispatches.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index d7e9b9ab1e..3b88528e45 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -1195,7 +1195,7 @@ mod dispatches { #[pallet::call_index(59)] #[pallet::weight((Weight::from_parts(191_600_000, 0) .saturating_add(T::DbWeight::get().reads(36)) - .saturating_add(T::DbWeight::get().writes(52)), DispatchClass::Operational, Pays::No))] + .saturating_add(T::DbWeight::get().writes(52)), DispatchClass::Operational, Pays::Yes))] pub fn register_network(origin: OriginFor, hotkey: T::AccountId) -> DispatchResult { Self::do_register_network(origin, &hotkey, 1, None) } @@ -1540,7 +1540,7 @@ mod dispatches { #[pallet::call_index(79)] #[pallet::weight((Weight::from_parts(185_500_000, 0) .saturating_add(T::DbWeight::get().reads(35)) - .saturating_add(T::DbWeight::get().writes(51)), DispatchClass::Operational, Pays::No))] + .saturating_add(T::DbWeight::get().writes(51)), DispatchClass::Operational, Pays::Yes))] pub fn register_network_with_identity( origin: OriginFor, hotkey: T::AccountId, From 11aba9cd7e91334ebf4804472039f75bce016ca0 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Wed, 13 Aug 2025 05:12:56 -0400 Subject: [PATCH 008/147] add validation for last lock to reg_network --- pallets/subtensor/src/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index 17f7c69672..1e7ad50216 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -2365,6 +2365,12 @@ where Ok((validity, Some(who.clone()), origin)) } Some(Call::register_network { .. }) => { + let current_block = Self::get_current_block_as_u64(); + let last_lock_block = Self::get_network_last_lock_block(); + if current_block.saturating_sub(last_lock_block) >= NetworkRateLimit::::get() { + return Err(CustomTransactionError::RateLimitExceeded.into()); + } + let validity = Self::validity_ok(Self::get_priority_vanilla()); Ok((validity, Some(who.clone()), origin)) } From f90fc58e15771ac80f195d5655f718228dc0d384 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Wed, 13 Aug 2025 11:41:47 -0400 Subject: [PATCH 009/147] fix references --- pallets/subtensor/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index 1e7ad50216..1b3d2fafdc 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -2365,8 +2365,8 @@ where Ok((validity, Some(who.clone()), origin)) } Some(Call::register_network { .. }) => { - let current_block = Self::get_current_block_as_u64(); - let last_lock_block = Self::get_network_last_lock_block(); + let current_block = Pallet::::get_current_block_as_u64(); + let last_lock_block = Pallet::::get_network_last_lock_block(); if current_block.saturating_sub(last_lock_block) >= NetworkRateLimit::::get() { return Err(CustomTransactionError::RateLimitExceeded.into()); } From 552e135d05009034c684783eb748b36f42252c60 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Wed, 13 Aug 2025 12:39:11 -0400 Subject: [PATCH 010/147] fix test --- pallets/subtensor/src/tests/registration.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/subtensor/src/tests/registration.rs b/pallets/subtensor/src/tests/registration.rs index 09b129dc67..b9fad0be02 100644 --- a/pallets/subtensor/src/tests/registration.rs +++ b/pallets/subtensor/src/tests/registration.rs @@ -42,7 +42,7 @@ fn test_registration_subscribe_ok_dispatch_info_ok() { call_weight: frame_support::weights::Weight::from_parts(3_111_800_000, 0), extension_weight: frame_support::weights::Weight::zero(), class: DispatchClass::Normal, - pays_fee: Pays::No + pays_fee: Pays::Yes } ); }); From bc4e3f14adaa770c244b0498680715f8dd9b50de Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 13 Aug 2025 18:22:28 +0000 Subject: [PATCH 011/147] auto-update benchmark weights --- pallets/subtensor/src/macros/dispatches.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 3b88528e45..5018e72a14 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -413,7 +413,7 @@ mod dispatches { /// - Attempting to set weights with max value exceeding limit. /// #[pallet::call_index(8)] - #[pallet::weight((Weight::from_parts(2_684_000, 0) + #[pallet::weight((Weight::from_parts(2_023_000, 0) .saturating_add(T::DbWeight::get().reads(0_u64)) .saturating_add(T::DbWeight::get().writes(0_u64)), DispatchClass::Normal, Pays::No))] pub fn set_tao_weights( @@ -454,7 +454,7 @@ mod dispatches { /// - The hotkey we are delegating is not owned by the calling coldket. /// #[pallet::call_index(1)] - #[pallet::weight((Weight::from_parts(2_363_000, 0) + #[pallet::weight((Weight::from_parts(2_864_000, 0) .saturating_add(T::DbWeight::get().reads(0)) .saturating_add(T::DbWeight::get().writes(0)), DispatchClass::Normal, Pays::Yes))] pub fn become_delegate(_origin: OriginFor, _hotkey: T::AccountId) -> DispatchResult { @@ -827,7 +827,7 @@ mod dispatches { /// - The ip type v4 or v6. /// #[pallet::call_index(5)] - #[pallet::weight((Weight::from_parts(22_640_000, 0) + #[pallet::weight((Weight::from_parts(30_730_000, 0) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Normal, Pays::No))] pub fn serve_prometheus( @@ -1465,7 +1465,7 @@ mod dispatches { /// - The ip type v4 or v6. /// #[pallet::call_index(68)] - #[pallet::weight((Weight::from_parts(24_350_000, 0) + #[pallet::weight((Weight::from_parts(31_590_000, 0) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Normal, Pays::Yes))] pub fn set_identity( @@ -1575,7 +1575,7 @@ mod dispatches { /// * `TxRateLimitExceeded`: /// - Thrown if key has hit transaction rate limit #[pallet::call_index(83)] - #[pallet::weight((Weight::from_parts(28_910_000, 0) + #[pallet::weight((Weight::from_parts(22_790_000, 0) .saturating_add(T::DbWeight::get().reads(6)) .saturating_add(T::DbWeight::get().writes(0)), DispatchClass::Operational, Pays::Yes))] pub fn unstake_all(origin: OriginFor, hotkey: T::AccountId) -> DispatchResult { @@ -1608,7 +1608,7 @@ mod dispatches { /// * `TxRateLimitExceeded`: /// - Thrown if key has hit transaction rate limit #[pallet::call_index(84)] - #[pallet::weight((Weight::from_parts(395_800_000, 0) + #[pallet::weight((Weight::from_parts(294_000_000, 0) .saturating_add(T::DbWeight::get().reads(33)) .saturating_add(T::DbWeight::get().writes(16)), DispatchClass::Operational, Pays::Yes))] pub fn unstake_all_alpha(origin: OriginFor, hotkey: T::AccountId) -> DispatchResult { @@ -2075,7 +2075,7 @@ mod dispatches { /// at which or better (higher) the staking should execute. /// Without limit_price it remove all the stake similar to `remove_stake` extrinsic #[pallet::call_index(103)] - #[pallet::weight((Weight::from_parts(421_500_000, 10142) + #[pallet::weight((Weight::from_parts(321_900_000, 10142) .saturating_add(T::DbWeight::get().reads(30_u64)) .saturating_add(T::DbWeight::get().writes(14_u64)), DispatchClass::Normal, Pays::Yes))] pub fn remove_stake_full_limit( @@ -2156,7 +2156,7 @@ mod dispatches { /// Emits a `SymbolUpdated` event on success. #[pallet::call_index(112)] #[pallet::weight(( - Weight::from_parts(28_910_000, 0).saturating_add(T::DbWeight::get().reads_writes(4, 1)), + Weight::from_parts(20_530_000, 0).saturating_add(T::DbWeight::get().reads_writes(4, 1)), DispatchClass::Operational, Pays::Yes ))] From 90662c43baa9389a3ffed85bb51032afc4669972 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 13 Aug 2025 22:05:17 +0000 Subject: [PATCH 012/147] auto-update benchmark weights --- pallets/subtensor/src/macros/dispatches.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index e7f06df53c..afc2fdc647 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -693,7 +693,7 @@ mod dispatches { /// - Attempting to set prometheus information withing the rate limit min. /// #[pallet::call_index(4)] - #[pallet::weight((Weight::from_parts(36_090_000, 0) + #[pallet::weight((Weight::from_parts(25_950_000, 0) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Normal, Pays::No))] pub fn serve_axon( @@ -827,7 +827,7 @@ mod dispatches { /// - The ip type v4 or v6. /// #[pallet::call_index(5)] - #[pallet::weight((Weight::from_parts(30_730_000, 0) + #[pallet::weight((Weight::from_parts(22_520_000, 0) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Normal, Pays::No))] pub fn serve_prometheus( @@ -1465,7 +1465,7 @@ mod dispatches { /// - The ip type v4 or v6. /// #[pallet::call_index(68)] - #[pallet::weight((Weight::from_parts(31_590_000, 0) + #[pallet::weight((Weight::from_parts(23_870_000, 0) .saturating_add(T::DbWeight::get().reads(3)) .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Normal, Pays::Yes))] pub fn set_identity( @@ -1609,8 +1609,8 @@ mod dispatches { /// - Thrown if key has hit transaction rate limit #[pallet::call_index(84)] #[pallet::weight((Weight::from_parts(294_000_000, 0) - .saturating_add(T::DbWeight::get().reads(33)) - .saturating_add(T::DbWeight::get().writes(16)), DispatchClass::Operational, Pays::Yes))] + .saturating_add(T::DbWeight::get().reads(38_u64)) + .saturating_add(T::DbWeight::get().writes(21_u64)), DispatchClass::Operational, Pays::Yes))] pub fn unstake_all_alpha(origin: OriginFor, hotkey: T::AccountId) -> DispatchResult { Self::do_unstake_all_alpha(origin, hotkey) } @@ -1723,8 +1723,8 @@ mod dispatches { #[pallet::call_index(87)] #[pallet::weight(( Weight::from_parts(274_400_000, 0) - .saturating_add(T::DbWeight::get().reads(32)) - .saturating_add(T::DbWeight::get().writes(17)), + .saturating_add(T::DbWeight::get().reads(37_u64)) + .saturating_add(T::DbWeight::get().writes(22_u64)), DispatchClass::Operational, Pays::Yes ))] @@ -1896,8 +1896,8 @@ mod dispatches { #[pallet::call_index(90)] #[pallet::weight(( Weight::from_parts(330_400_000, 0) - .saturating_add(T::DbWeight::get().reads(32)) - .saturating_add(T::DbWeight::get().writes(17)), + .saturating_add(T::DbWeight::get().reads(37_u64)) + .saturating_add(T::DbWeight::get().writes(22_u64)), DispatchClass::Operational, Pays::Yes ))] From 66f08de184b29fb90b74e85251750b083bd829d0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 14 Aug 2025 18:20:51 +0000 Subject: [PATCH 013/147] auto-update benchmark weights --- pallets/subtensor/src/macros/dispatches.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 869ead77b9..be066f0bfc 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -693,7 +693,7 @@ mod dispatches { /// - Attempting to set prometheus information withing the rate limit min. /// #[pallet::call_index(4)] - #[pallet::weight((Weight::from_parts(25_950_000, 0) + #[pallet::weight((Weight::from_parts(35_800_000, 0) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Normal, Pays::No))] pub fn serve_axon( @@ -1045,7 +1045,7 @@ mod dispatches { /// #[pallet::call_index(69)] #[pallet::weight(( - Weight::from_parts(5_912_000, 0) + Weight::from_parts(7_394_000, 0) .saturating_add(T::DbWeight::get().reads(0)) .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Operational, From 90fb1650eeaad30a801e8b56a75ccdad6b7b6e45 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Thu, 14 Aug 2025 14:48:39 -0400 Subject: [PATCH 014/147] remove test again --- pallets/subtensor/src/tests/registration.rs | 30 --------------------- 1 file changed, 30 deletions(-) diff --git a/pallets/subtensor/src/tests/registration.rs b/pallets/subtensor/src/tests/registration.rs index 173074ed4a..67c3fd3c4d 100644 --- a/pallets/subtensor/src/tests/registration.rs +++ b/pallets/subtensor/src/tests/registration.rs @@ -18,36 +18,6 @@ use crate::{AxonInfoOf, CustomTransactionError, Error, SubtensorTransactionExten subscribing::subscribe() tests *********************************************/ -// Tests a basic registration dispatch passes. -#[test] -fn test_registration_subscribe_ok_dispatch_info_ok() { - new_test_ext(1).execute_with(|| { - let block_number: u64 = 0; - let nonce: u64 = 0; - let netuid = NetUid::from(1); - let work: Vec = vec![0; 32]; - let hotkey: U256 = U256::from(0); - let coldkey: U256 = U256::from(0); - let call = RuntimeCall::SubtensorModule(SubtensorCall::register { - netuid, - block_number, - nonce, - work, - hotkey, - coldkey, - }); - assert_eq!( - call.get_dispatch_info(), - DispatchInfo { - call_weight: frame_support::weights::Weight::from_parts(3_111_800_000, 0), - extension_weight: frame_support::weights::Weight::zero(), - class: DispatchClass::Normal, - pays_fee: Pays::Yes - } - ); - }); -} - #[test] fn test_registration_difficulty() { new_test_ext(1).execute_with(|| { From c95fd8eafbf0a7da21c8139ca19235a9a5894178 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Thu, 14 Aug 2025 14:55:16 -0400 Subject: [PATCH 015/147] cargo lock --- Cargo.lock | 96 +++++++++++++++++++++++------------------------------- 1 file changed, 40 insertions(+), 56 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 895b55e447..e0c155108a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -972,11 +972,11 @@ dependencies = [ [[package]] name = "async-lock" -version = "3.4.1" +version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fd03604047cee9b6ce9de9f70c6cd540a0520c813cbd49bae61f33ab80ed1dc" +checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" dependencies = [ - "event-listener 5.4.1", + "event-listener 5.4.0", "event-listener-strategy", "pin-project-lite", ] @@ -1005,7 +1005,7 @@ dependencies = [ "async-task", "blocking", "cfg-if", - "event-listener 5.4.1", + "event-listener 5.4.0", "futures-lite", "rustix 1.0.8", ] @@ -1544,9 +1544,9 @@ checksum = "fd6c0e7b807d60291f42f33f58480c0bfafe28ed08286446f45e463728cf9c1c" [[package]] name = "cc" -version = "1.2.31" +version = "1.2.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3a42d84bb6b69d3a8b3eaacf0d88f179e1929695e1ad012b6cf64d9caaa5fd2" +checksum = "deec109607ca693028562ed836a5f1c4b8bd77755c4e132fc5ce11b0b6211ae7" dependencies = [ "jobserver", "libc", @@ -3052,9 +3052,9 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "event-listener" -version = "5.4.1" +version = "5.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13b66accf52311f30a0db42147dadea9850cb48cd070028831ae5f5d4b856ab" +checksum = "3492acde4c3fc54c845eaab3eed8bd00c7a7d881f78bfc801e43a93dec1331ae" dependencies = [ "concurrent-queue", "parking", @@ -3067,7 +3067,7 @@ version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93" dependencies = [ - "event-listener 5.4.1", + "event-listener 5.4.0", "pin-project-lite", ] @@ -3501,12 +3501,6 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" -[[package]] -name = "fixedbitset" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" - [[package]] name = "flume" version = "0.11.1" @@ -4114,9 +4108,9 @@ checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-lite" -version = "2.6.1" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad" +checksum = "f5edaec856126859abb19ed65f39e90fea3a9574b9707f13539acf4abf7eb532" dependencies = [ "fastrand", "futures-core", @@ -7313,7 +7307,7 @@ dependencies = [ "expander", "indexmap 2.10.0", "itertools 0.11.0", - "petgraph 0.6.5", + "petgraph", "proc-macro-crate 3.3.0", "proc-macro2", "quote", @@ -8639,17 +8633,7 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4c5cc86750666a3ed20bdaf5ca2a0344f9c67674cae0515bec2da16fbaa47db" dependencies = [ - "fixedbitset 0.4.2", - "indexmap 2.10.0", -] - -[[package]] -name = "petgraph" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3672b37090dbd86368a4145bc067582552b29c27377cad4e0a306c97f9bd7772" -dependencies = [ - "fixedbitset 0.5.7", + "fixedbitset", "indexmap 2.10.0", ] @@ -9178,9 +9162,9 @@ checksum = "23eff02c070c70f31878a3d915e88a914ecf3e153741e2fb572dde28cce20fde" [[package]] name = "polling" -version = "3.10.0" +version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5bd19146350fe804f7cb2669c851c03d69da628803dab0d98018142aaa5d829" +checksum = "8ee9b2fa7a4517d2c91ff5bc6c297a427a96749d15f98fcdbb22c05571a4d4b7" dependencies = [ "cfg-if", "concurrent-queue", @@ -9553,7 +9537,7 @@ dependencies = [ "log", "multimap", "once_cell", - "petgraph 0.7.1", + "petgraph", "prettyplease", "prost 0.13.5", "prost-types", @@ -10121,9 +10105,9 @@ dependencies = [ [[package]] name = "ruint" -version = "1.16.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ecb38f82477f20c5c3d62ef52d7c4e536e38ea9b73fb570a20c5cae0e14bcf6" +checksum = "11256b5fe8c68f56ac6f39ef0720e592f33d2367a4782740d9c9142e889c7fb4" dependencies = [ "alloy-rlp", "ark-ff 0.3.0", @@ -12023,9 +12007,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.142" +version = "1.0.141" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "030fedb782600dcbd6f02d479bf0d817ac3bb40d644745b769d6a96bc3afc5a7" +checksum = "30b9eff21ebe718216c6ec64e1d9ac57087aad11efc64e32002bce4a0d4c03d3" dependencies = [ "itoa", "memchr", @@ -12177,9 +12161,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "signal-hook-registry" -version = "1.4.6" +version = "1.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2a4719bff48cee6b39d12c020eeb490953ad2443b7055bd0b21fca26bd8c28b" +checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410" dependencies = [ "libc", ] @@ -12298,7 +12282,7 @@ dependencies = [ "derive_more 0.99.20", "ed25519-zebra", "either", - "event-listener 5.4.1", + "event-listener 5.4.0", "fnv", "futures-lite", "futures-util", @@ -12347,7 +12331,7 @@ dependencies = [ "bs58", "derive_more 0.99.20", "either", - "event-listener 5.4.1", + "event-listener 5.4.0", "fnv", "futures-channel", "futures-lite", @@ -12667,7 +12651,7 @@ dependencies = [ [[package]] name = "sp-crypto-ec-utils" version = "0.10.0" -source = "git+https://github.com/paritytech/polkadot-sdk#59fb2e7482d471a7ec4e8d3b30499497efa7b34c" +source = "git+https://github.com/paritytech/polkadot-sdk#177b03958c766fe053f28424ee6f6748644bb794" dependencies = [ "ark-bls12-377", "ark-bls12-377-ext", @@ -12763,7 +12747,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#59fb2e7482d471a7ec4e8d3b30499497efa7b34c" +source = "git+https://github.com/paritytech/polkadot-sdk#177b03958c766fe053f28424ee6f6748644bb794" dependencies = [ "proc-macro2", "quote", @@ -12773,7 +12757,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.25.0" -source = "git+https://github.com/paritytech/polkadot-sdk#59fb2e7482d471a7ec4e8d3b30499497efa7b34c" +source = "git+https://github.com/paritytech/polkadot-sdk#177b03958c766fe053f28424ee6f6748644bb794" dependencies = [ "environmental", "parity-scale-codec", @@ -12983,7 +12967,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "24.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#59fb2e7482d471a7ec4e8d3b30499497efa7b34c" +source = "git+https://github.com/paritytech/polkadot-sdk#177b03958c766fe053f28424ee6f6748644bb794" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -13020,7 +13004,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "17.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#59fb2e7482d471a7ec4e8d3b30499497efa7b34c" +source = "git+https://github.com/paritytech/polkadot-sdk#177b03958c766fe053f28424ee6f6748644bb794" dependencies = [ "Inflector", "expander", @@ -13122,12 +13106,12 @@ source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable [[package]] name = "sp-std" version = "14.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#59fb2e7482d471a7ec4e8d3b30499497efa7b34c" +source = "git+https://github.com/paritytech/polkadot-sdk#177b03958c766fe053f28424ee6f6748644bb794" [[package]] name = "sp-storage" version = "19.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#59fb2e7482d471a7ec4e8d3b30499497efa7b34c" +source = "git+https://github.com/paritytech/polkadot-sdk#177b03958c766fe053f28424ee6f6748644bb794" dependencies = [ "impl-serde 0.5.0", "parity-scale-codec", @@ -13163,7 +13147,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "16.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#59fb2e7482d471a7ec4e8d3b30499497efa7b34c" +source = "git+https://github.com/paritytech/polkadot-sdk#177b03958c766fe053f28424ee6f6748644bb794" dependencies = [ "parity-scale-codec", "regex", @@ -13260,7 +13244,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "20.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk#59fb2e7482d471a7ec4e8d3b30499497efa7b34c" +source = "git+https://github.com/paritytech/polkadot-sdk#177b03958c766fe053f28424ee6f6748644bb794" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -13350,7 +13334,7 @@ dependencies = [ "crc", "crossbeam-queue", "either", - "event-listener 5.4.1", + "event-listener 5.4.0", "futures-core", "futures-intrusive", "futures-io", @@ -14373,9 +14357,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.47.1" +version = "1.47.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038" +checksum = "43864ed400b6043a4757a25c7a64a8efde741aed79a056a2fb348a406701bb35" dependencies = [ "backtrace", "bytes", @@ -14442,9 +14426,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.16" +version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14307c986784f72ef81c89db7d9e28d6ac26d16213b109ea501696195e6e3ce5" +checksum = "66a539a9ad6d5d281510d5bd368c973d636c02dbf8a67300bfb6b950696ad7df" dependencies = [ "bytes", "futures-core", @@ -16193,9 +16177,9 @@ dependencies = [ [[package]] name = "zerovec" -version = "0.11.3" +version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bdbb9122ea75b11bf96e7492afb723e8a7fbe12c67417aa95e7e3d18144d37cd" +checksum = "4a05eb080e015ba39cc9e23bbe5e7fb04d5fb040350f99f34e338d5fdd294428" dependencies = [ "yoke", "zerofrom", From 0aa0cb07bc4b9457e3b8728b275874ba7764d7cd Mon Sep 17 00:00:00 2001 From: Moose Date: Thu, 14 Aug 2025 14:41:41 +0200 Subject: [PATCH 016/147] Ignore zero alpha stake in `clear_small_nomination_if_required` --- pallets/subtensor/src/staking/helpers.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/subtensor/src/staking/helpers.rs b/pallets/subtensor/src/staking/helpers.rs index 7b8d0ba1de..3f07115b7b 100644 --- a/pallets/subtensor/src/staking/helpers.rs +++ b/pallets/subtensor/src/staking/helpers.rs @@ -184,7 +184,7 @@ impl Pallet { ) { // Verify if the account is a nominator account by checking ownership of the hotkey by the coldkey. if !Self::coldkey_owns_hotkey(coldkey, hotkey) { - // If the stake is below the minimum required, it's considered a small nomination and needs to be cleared. + // If the stake is non-zero and below the minimum required, it's considered a small nomination and needs to be cleared. // Log if the stake is below the minimum required let alpha_stake = Self::get_stake_for_hotkey_and_coldkey_on_subnet(hotkey, coldkey, netuid); @@ -192,7 +192,7 @@ impl Pallet { U96F32::saturating_from_num(Self::get_nominator_min_required_stake()) .safe_div(T::SwapInterface::current_alpha_price(netuid)) .saturating_to_num::(); - if alpha_stake < min_alpha_stake.into() { + if alpha_stake > 0.into() && alpha_stake < min_alpha_stake.into() { // Log the clearing of a small nomination // Remove the stake from the nominator account. (this is a more forceful unstake operation which ) // Actually deletes the staking account. From d84da7bcff59515318fdb092a8d7fe1087ea3d67 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Mon, 18 Aug 2025 20:40:49 -0400 Subject: [PATCH 017/147] use existing helpers and fix > --- pallets/subtensor/src/lib.rs | 4 +--- pallets/subtensor/src/subnets/subnet.rs | 10 +++++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index f4f98c3e83..57fa5eef1b 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -2361,9 +2361,7 @@ where Ok((validity, Some(who.clone()), origin)) } Some(Call::register_network { .. }) => { - let current_block = Pallet::::get_current_block_as_u64(); - let last_lock_block = Pallet::::get_network_last_lock_block(); - if current_block.saturating_sub(last_lock_block) >= NetworkRateLimit::::get() { + if !Pallet::::passes_rate_limit(&TransactionType::RegisterNetwork, who) { return Err(CustomTransactionError::RateLimitExceeded.into()); } diff --git a/pallets/subtensor/src/subnets/subnet.rs b/pallets/subtensor/src/subnets/subnet.rs index 17e349c995..a9da369ad5 100644 --- a/pallets/subtensor/src/subnets/subnet.rs +++ b/pallets/subtensor/src/subnets/subnet.rs @@ -134,9 +134,8 @@ impl Pallet { // --- 4. Rate limit for network registrations. let current_block = Self::get_current_block_as_u64(); - let last_lock_block = Self::get_network_last_lock_block(); ensure!( - current_block.saturating_sub(last_lock_block) >= NetworkRateLimit::::get(), + Self::passes_rate_limit(&TransactionType::RegisterNetwork, &coldkey), Error::::NetworkTxRateLimitExceeded ); @@ -174,7 +173,12 @@ impl Pallet { log::debug!("SubnetMechanism for netuid {netuid_to_register:?} set to: {mechid:?}"); // --- 12. Set the creation terms. - NetworkLastRegistered::::set(current_block); + Self::set_last_transaction_block_on_subnet( + &coldkey, + netuid_to_register, + &TransactionType::RegisterNetwork, + current_block, + ); NetworkRegisteredAt::::insert(netuid_to_register, current_block); // --- 13. Set the symbol. From 6b2628c57d57addab11b223c606551c5fcbf851b Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Mon, 18 Aug 2025 21:12:14 -0400 Subject: [PATCH 018/147] bump spec --- 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 16af31170e..d2b7ed9831 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -213,7 +213,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: 302, + spec_version: 303, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From 107824312f0701aad6f95980554cd222d2b29f41 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Tue, 19 Aug 2025 14:34:49 +0300 Subject: [PATCH 019/147] Refactor transaction extension --- pallets/subtensor/src/tests/swap_coldkey.rs | 30 ++++++- .../subtensor/src/transaction_extension.rs | 79 +++---------------- 2 files changed, 38 insertions(+), 71 deletions(-) diff --git a/pallets/subtensor/src/tests/swap_coldkey.rs b/pallets/subtensor/src/tests/swap_coldkey.rs index 54bdc253ce..59792d5602 100644 --- a/pallets/subtensor/src/tests/swap_coldkey.rs +++ b/pallets/subtensor/src/tests/swap_coldkey.rs @@ -2493,8 +2493,12 @@ fn test_coldkey_in_swap_schedule_prevents_funds_usage() { &TxBaseImplication(()), TransactionSource::External, ); - // Should pass, not in list. - assert_ok!(result); + // Should fail + assert_eq!( + // Should get an invalid transaction error + result.unwrap_err(), + CustomTransactionError::ColdkeyInSwapSchedule.into() + ); // Remove stake limit let call = RuntimeCall::SubtensorModule(SubtensorCall::remove_stake_limit { @@ -2513,7 +2517,27 @@ fn test_coldkey_in_swap_schedule_prevents_funds_usage() { &TxBaseImplication(()), TransactionSource::External, ); - // Should pass, not in list. + // Should fail + assert_eq!( + // Should get an invalid transaction error + result.unwrap_err(), + CustomTransactionError::ColdkeyInSwapSchedule.into() + ); + + // Schedule swap should succeed + let call = RuntimeCall::SubtensorModule(SubtensorCall::schedule_swap_coldkey { + new_coldkey: hotkey, + }); + let result = extension.validate( + RawOrigin::Signed(who).into(), + &call.clone(), + &info, + 10, + (), + &TxBaseImplication(()), + TransactionSource::External, + ); + // Should be ok assert_ok!(result); }); } diff --git a/pallets/subtensor/src/transaction_extension.rs b/pallets/subtensor/src/transaction_extension.rs index deb42efabf..99749032ad 100644 --- a/pallets/subtensor/src/transaction_extension.rs +++ b/pallets/subtensor/src/transaction_extension.rs @@ -120,6 +120,16 @@ where return Ok((Default::default(), None, origin)); }; + // Verify ColdkeySwapScheduled map for coldkey + match call.is_sub_type() { + // Whitelist + Some(Call::schedule_swap_coldkey { .. }) => {} + _ => { + if ColdkeySwapScheduled::::contains_key(who) { + return Err(CustomTransactionError::ColdkeyInSwapSchedule.into()); + } + } + } match call.is_sub_type() { Some(Call::commit_weights { netuid, .. }) => { if Self::check_weights_min_stake(who, *netuid) { @@ -248,54 +258,7 @@ where Err(CustomTransactionError::StakeAmountTooLow.into()) } } - Some(Call::add_stake { .. }) => { - if ColdkeySwapScheduled::::contains_key(who) { - return Err(CustomTransactionError::ColdkeyInSwapSchedule.into()); - } - - Ok((Default::default(), Some(who.clone()), origin)) - } - Some(Call::add_stake_limit { .. }) => { - if ColdkeySwapScheduled::::contains_key(who) { - return Err(CustomTransactionError::ColdkeyInSwapSchedule.into()); - } - - Ok((Default::default(), Some(who.clone()), origin)) - } - Some(Call::remove_stake { .. }) => Ok((Default::default(), Some(who.clone()), origin)), - Some(Call::remove_stake_limit { .. }) => { - Ok((Default::default(), Some(who.clone()), origin)) - } - Some(Call::move_stake { .. }) => { - if ColdkeySwapScheduled::::contains_key(who) { - return Err(CustomTransactionError::ColdkeyInSwapSchedule.into()); - } - Ok((Default::default(), Some(who.clone()), origin)) - } - Some(Call::transfer_stake { .. }) => { - if ColdkeySwapScheduled::::contains_key(who) { - return Err(CustomTransactionError::ColdkeyInSwapSchedule.into()); - } - - Ok((Default::default(), Some(who.clone()), origin)) - } - Some(Call::swap_stake { .. }) => { - if ColdkeySwapScheduled::::contains_key(who) { - return Err(CustomTransactionError::ColdkeyInSwapSchedule.into()); - } - Ok((Default::default(), Some(who.clone()), origin)) - } - Some(Call::swap_stake_limit { .. }) => { - if ColdkeySwapScheduled::::contains_key(who) { - return Err(CustomTransactionError::ColdkeyInSwapSchedule.into()); - } - Ok((Default::default(), Some(who.clone()), origin)) - } Some(Call::register { netuid, .. } | Call::burned_register { netuid, .. }) => { - if ColdkeySwapScheduled::::contains_key(who) { - return Err(CustomTransactionError::ColdkeyInSwapSchedule.into()); - } - let registrations_this_interval = Pallet::::get_registrations_this_interval(*netuid); let max_registrations_per_interval = @@ -308,13 +271,6 @@ where Ok((Default::default(), Some(who.clone()), origin)) } - Some(Call::dissolve_network { .. }) => { - if ColdkeySwapScheduled::::contains_key(who) { - Err(CustomTransactionError::ColdkeyInSwapSchedule.into()) - } else { - Ok((Default::default(), Some(who.clone()), origin)) - } - } Some(Call::serve_axon { netuid, version, @@ -342,20 +298,7 @@ where ) .map(|validity| (validity, Some(who.clone()), origin.clone())) } - _ => { - if let Some( - BalancesCall::transfer_keep_alive { .. } - | BalancesCall::transfer_all { .. } - | BalancesCall::transfer_allow_death { .. }, - ) = call.is_sub_type() - { - if ColdkeySwapScheduled::::contains_key(who) { - return Err(CustomTransactionError::ColdkeyInSwapSchedule.into()); - } - } - - Ok((Default::default(), Some(who.clone()), origin)) - } + _ => Ok((Default::default(), Some(who.clone()), origin)), } } From 5be820e41d4fe9bc044bbfba94ece41959afa4a8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 19 Aug 2025 16:19:11 +0000 Subject: [PATCH 020/147] auto-update benchmark weights --- pallets/subtensor/src/macros/dispatches.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index aea2eac3f7..13169e2599 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -693,7 +693,7 @@ mod dispatches { /// - Attempting to set prometheus information withing the rate limit min. /// #[pallet::call_index(4)] - #[pallet::weight((Weight::from_parts(43_680_000, 0) + #[pallet::weight((Weight::from_parts(33_780_000, 0) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Normal, Pays::No))] pub fn serve_axon( @@ -2156,7 +2156,7 @@ mod dispatches { /// Emits a `SymbolUpdated` event on success. #[pallet::call_index(112)] #[pallet::weight(( - Weight::from_parts(26_880_000, 0).saturating_add(T::DbWeight::get().reads_writes(4, 1)), + Weight::from_parts(35_510_000, 0).saturating_add(T::DbWeight::get().reads_writes(4, 1)), DispatchClass::Operational, Pays::Yes ))] @@ -2201,7 +2201,7 @@ mod dispatches { /// * commit_reveal_version (`u16`): /// - The client (bittensor-drand) version #[pallet::call_index(113)] - #[pallet::weight((Weight::from_parts(81_920_000, 0) + #[pallet::weight((Weight::from_parts(64_220_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( From bf552a3d39b01cf219e8964f4a036321514f67a9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 22 Aug 2025 16:02:25 +0000 Subject: [PATCH 021/147] 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 819fe53c1f..aed0c150de 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -2156,7 +2156,7 @@ mod dispatches { /// Emits a `SymbolUpdated` event on success. #[pallet::call_index(112)] #[pallet::weight(( - Weight::from_parts(35_510_000, 0).saturating_add(T::DbWeight::get().reads_writes(4, 1)), + Weight::from_parts(26_200_000, 0).saturating_add(T::DbWeight::get().reads_writes(4, 1)), DispatchClass::Operational, Pays::Yes ))] 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 022/147] 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 023/147] 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 024/147] 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 025/147] 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 b5b6278f321d5a679ddc3918d70a211019721b1d Mon Sep 17 00:00:00 2001 From: open-junius Date: Wed, 27 Aug 2025 15:31:20 +0800 Subject: [PATCH 026/147] add commitments data into metagraph --- Cargo.lock | 2 +- pallets/commitments/Cargo.toml | 8 ++--- pallets/commitments/src/lib.rs | 36 ++++++++++++++++++--- pallets/subtensor/Cargo.toml | 4 +++ pallets/subtensor/src/macros/config.rs | 4 +++ pallets/subtensor/src/rpc_info/metagraph.rs | 32 +++++++++++++++++- runtime/src/lib.rs | 12 +++++-- 7 files changed, 85 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7d65c7aac9..d7ec1b6845 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7557,7 +7557,6 @@ dependencies = [ "log", "pallet-balances", "pallet-drand", - "pallet-subtensor", "parity-scale-codec", "rand_chacha 0.3.1", "scale-info", @@ -8151,6 +8150,7 @@ dependencies = [ "num-traits", "pallet-balances", "pallet-collective", + "pallet-commitments", "pallet-crowdloan", "pallet-drand", "pallet-membership", diff --git a/pallets/commitments/Cargo.toml b/pallets/commitments/Cargo.toml index bedc0d945c..351af75061 100644 --- a/pallets/commitments/Cargo.toml +++ b/pallets/commitments/Cargo.toml @@ -36,7 +36,7 @@ sha2.workspace = true log.workspace = true -pallet-subtensor.workspace = true +# pallet-subtensor.workspace = true subtensor-runtime-common.workspace = true [dev-dependencies] @@ -57,7 +57,7 @@ std = [ "log/std", "pallet-balances/std", "pallet-drand/std", - "pallet-subtensor/std", + # "pallet-subtensor/std", "rand_chacha/std", "scale-info/std", "sha2/std", @@ -76,7 +76,7 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-drand/runtime-benchmarks", - "pallet-subtensor/runtime-benchmarks", + # "pallet-subtensor/runtime-benchmarks", ] try-runtime = [ "frame-support/try-runtime", @@ -84,5 +84,5 @@ try-runtime = [ "pallet-balances/try-runtime", "sp-runtime/try-runtime", "pallet-drand/try-runtime", - "pallet-subtensor/try-runtime", + # "pallet-subtensor/try-runtime", ] diff --git a/pallets/commitments/src/lib.rs b/pallets/commitments/src/lib.rs index 34192b6fa2..579e9dacab 100644 --- a/pallets/commitments/src/lib.rs +++ b/pallets/commitments/src/lib.rs @@ -10,12 +10,12 @@ mod mock; pub mod types; pub mod weights; -pub use pallet::*; -pub use types::*; -pub use weights::WeightInfo; - use ark_serialize::CanonicalDeserialize; +use codec::Encode; +use frame_support::IterableStorageDoubleMap; use frame_support::{BoundedVec, traits::Currency}; +use frame_system::pallet_prelude::BlockNumberFor; +pub use pallet::*; use scale_info::prelude::collections::BTreeSet; use sp_runtime::SaturatedConversion; use sp_runtime::{Saturating, traits::Zero}; @@ -26,7 +26,9 @@ use tle::{ stream_ciphers::AESGCMStreamCipherProvider, tlock::{TLECiphertext, tld}, }; +pub use types::*; use w3f_bls::EngineBLS; +pub use weights::WeightInfo; type BalanceOf = <::Currency as Currency<::AccountId>>::Balance; @@ -130,7 +132,7 @@ pub mod pallet { /// Identity data by account #[pallet::storage] #[pallet::getter(fn commitment_of)] - pub(super) type CommitmentOf = StorageDoubleMap< + pub type CommitmentOf = StorageDoubleMap< _, Identity, NetUid, @@ -537,4 +539,28 @@ impl Pallet { Ok(()) } + pub fn get_commitments(netuid: NetUid) -> Vec<(T::AccountId, Vec)> { + let commitments: Vec<(T::AccountId, Vec)> = + as IterableStorageDoubleMap< + NetUid, + T::AccountId, + Registration, T::MaxFields, BlockNumberFor>, + >>::iter_prefix(netuid) + .map(|(account, registration)| { + let bytes = registration.encode(); + (account, bytes) + }) + .collect(); + commitments + } +} + +pub trait GetCommitments { + fn get_commitments(netuid: NetUid) -> Vec<(AccountId, Vec)>; +} + +impl GetCommitments for () { + fn get_commitments(_netuid: NetUid) -> Vec<(AccountId, Vec)> { + Vec::new() + } } diff --git a/pallets/subtensor/Cargo.toml b/pallets/subtensor/Cargo.toml index 44d873c8a6..6734ba6883 100644 --- a/pallets/subtensor/Cargo.toml +++ b/pallets/subtensor/Cargo.toml @@ -47,6 +47,7 @@ runtime-common.workspace = true subtensor-runtime-common = { workspace = true, features = ["approx"] } pallet-drand.workspace = true +pallet-commitments.workspace = true pallet-collective.workspace = true pallet-membership.workspace = true hex-literal.workspace = true @@ -87,6 +88,7 @@ std = [ "ndarray/std", "num-traits/std", "pallet-balances/std", + "pallet-commitments/std", "pallet-collective/std", "pallet-drand/std", "pallet-membership/std", @@ -132,6 +134,7 @@ runtime-benchmarks = [ "frame-system/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-collective/runtime-benchmarks", + "pallet-commitments/runtime-benchmarks", "pallet-drand/runtime-benchmarks", "pallet-membership/runtime-benchmarks", "pallet-preimage/runtime-benchmarks", @@ -156,6 +159,7 @@ try-runtime = [ "sp-runtime/try-runtime", "pallet-collective/try-runtime", "pallet-drand/try-runtime", + "pallet-commitments/try-runtime", "pallet-proxy/try-runtime", "pallet-crowdloan/try-runtime", "runtime-common/try-runtime" diff --git a/pallets/subtensor/src/macros/config.rs b/pallets/subtensor/src/macros/config.rs index 3479ad8101..8a794a550c 100644 --- a/pallets/subtensor/src/macros/config.rs +++ b/pallets/subtensor/src/macros/config.rs @@ -6,6 +6,7 @@ use frame_support::pallet_macros::pallet_section; #[pallet_section] mod config { + use pallet_commitments::GetCommitments; use subtensor_swap_interface::SwapHandler; /// Configure the pallet by specifying the parameters and types on which it depends. @@ -58,6 +59,9 @@ mod config { /// Interface to allow interacting with the proxy pallet. type ProxyInterface: crate::ProxyInterface; + /// Interface to get commitments. + type GetCommitments: GetCommitments; + /// ================================= /// ==== Initial Value Constants ==== /// ================================= diff --git a/pallets/subtensor/src/rpc_info/metagraph.rs b/pallets/subtensor/src/rpc_info/metagraph.rs index 7f9dc46bee..45a6614ba3 100644 --- a/pallets/subtensor/src/rpc_info/metagraph.rs +++ b/pallets/subtensor/src/rpc_info/metagraph.rs @@ -4,6 +4,7 @@ use crate::epoch::math::*; use codec::Compact; use frame_support::IterableStorageDoubleMap; use frame_support::pallet_prelude::{Decode, Encode}; +use pallet_commitments::GetCommitments; use substrate_fixed::types::I64F64; use substrate_fixed::types::I96F32; use subtensor_macros::freeze_struct; @@ -109,7 +110,7 @@ pub struct Metagraph { alpha_dividends_per_hotkey: Vec<(AccountId, Compact)>, // List of dividend payout in alpha via subnet. } -#[freeze_struct("7604bd3817c55848")] +#[freeze_struct("56156d51c66190e8")] #[derive(Decode, Encode, PartialEq, Eq, Clone, Debug, TypeInfo)] pub struct SelectiveMetagraph { // Subnet index @@ -210,6 +211,8 @@ pub struct SelectiveMetagraph { // validators validators: Option>>, // List of validators + // commitments + commitments: Option>)>>, // List of commitments } impl SelectiveMetagraph @@ -367,6 +370,9 @@ where self.alpha_dividends_per_hotkey = other.alpha_dividends_per_hotkey.clone() } Some(SelectiveMetagraphIndex::Validators) => self.validators = other.validators.clone(), + Some(SelectiveMetagraphIndex::Commitments) => { + self.commitments = other.commitments.clone() + } None => {} }; } @@ -451,6 +457,7 @@ where tao_dividends_per_hotkey: None, alpha_dividends_per_hotkey: None, validators: None, + commitments: None, } } } @@ -529,6 +536,7 @@ pub enum SelectiveMetagraphIndex { TaoDividendsPerHotkey, AlphaDividendsPerHotkey, Validators, + Commitments, } impl SelectiveMetagraphIndex { @@ -607,6 +615,7 @@ impl SelectiveMetagraphIndex { 70 => Some(SelectiveMetagraphIndex::TaoDividendsPerHotkey), 71 => Some(SelectiveMetagraphIndex::AlphaDividendsPerHotkey), 72 => Some(SelectiveMetagraphIndex::Validators), + 73 => Some(SelectiveMetagraphIndex::Commitments), _ => None, } } @@ -1367,6 +1376,7 @@ impl Pallet { } } Some(SelectiveMetagraphIndex::Validators) => Self::get_validators(netuid), + Some(SelectiveMetagraphIndex::Commitments) => Self::get_commitments(netuid), None => SelectiveMetagraph { // Subnet index netuid: netuid.into(), @@ -1413,6 +1423,25 @@ impl Pallet { ..Default::default() } } + + fn get_commitments(netuid: NetUid) -> SelectiveMetagraph { + let commitments = ::GetCommitments::get_commitments(netuid); + let commitments: Vec<(T::AccountId, Vec>)> = commitments + .iter() + .map(|(account, commitment)| { + let compact_commitment = commitment + .iter() + .map(|c| Compact::from(c.clone())) + .collect::>>(); + (account.clone(), compact_commitment) + }) + .collect(); + + SelectiveMetagraph { + commitments: Some(commitments), + ..Default::default() + } + } } #[test] @@ -1492,6 +1521,7 @@ fn test_selective_metagraph() { tao_dividends_per_hotkey: None, alpha_dividends_per_hotkey: None, validators: None, + commitments: None, }; // test init value diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 60687d3a30..b78bf0b206 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -83,13 +83,13 @@ pub use frame_support::{ }; pub use frame_system::Call as SystemCall; pub use pallet_balances::Call as BalancesCall; +use pallet_commitments::GetCommitments; pub use pallet_timestamp::Call as TimestampCall; use pallet_transaction_payment::{ConstFeeMultiplier, Multiplier}; -use subtensor_transaction_fee::{SubtensorTxFeeHandler, TransactionFeeHandler}; - #[cfg(any(feature = "std", test))] pub use sp_runtime::BuildStorage; pub use sp_runtime::{Perbill, Permill}; +use subtensor_transaction_fee::{SubtensorTxFeeHandler, TransactionFeeHandler}; use core::marker::PhantomData; @@ -1068,6 +1068,13 @@ impl OnMetadataCommitment for ResetBondsOnCommit { fn on_metadata_commitment(_: NetUid, _: &AccountId) {} } +pub struct GetCommitmentsStruct; +impl GetCommitments for GetCommitmentsStruct { + fn get_commitments(netuid: NetUid) -> Vec<(AccountId, Vec)> { + pallet_commitments::Pallet::::get_commitments(netuid) + } +} + impl pallet_commitments::Config for Runtime { type RuntimeEvent = RuntimeEvent; type Currency = Balances; @@ -1239,6 +1246,7 @@ impl pallet_subtensor::Config for Runtime { type HotkeySwapOnSubnetInterval = HotkeySwapOnSubnetInterval; type ProxyInterface = Proxier; type LeaseDividendsDistributionInterval = LeaseDividendsDistributionInterval; + type GetCommitments = GetCommitmentsStruct; } parameter_types! { From 7e370319dd8799396e3439f68996b0994cab35d3 Mon Sep 17 00:00:00 2001 From: open-junius Date: Wed, 27 Aug 2025 15:41:10 +0800 Subject: [PATCH 027/147] commit Cargo.lock --- pallets/subtensor/src/rpc_info/metagraph.rs | 2 +- pallets/subtensor/src/tests/mock.rs | 1 + pallets/transaction-fee/src/tests/mock.rs | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pallets/subtensor/src/rpc_info/metagraph.rs b/pallets/subtensor/src/rpc_info/metagraph.rs index 45a6614ba3..1ad09d4bbb 100644 --- a/pallets/subtensor/src/rpc_info/metagraph.rs +++ b/pallets/subtensor/src/rpc_info/metagraph.rs @@ -1431,7 +1431,7 @@ impl Pallet { .map(|(account, commitment)| { let compact_commitment = commitment .iter() - .map(|c| Compact::from(c.clone())) + .map(|c| Compact::from(*c)) .collect::>>(); (account.clone(), compact_commitment) }) diff --git a/pallets/subtensor/src/tests/mock.rs b/pallets/subtensor/src/tests/mock.rs index 8aa6fe6cdd..f298f4743c 100644 --- a/pallets/subtensor/src/tests/mock.rs +++ b/pallets/subtensor/src/tests/mock.rs @@ -454,6 +454,7 @@ impl crate::Config for Test { type HotkeySwapOnSubnetInterval = HotkeySwapOnSubnetInterval; type ProxyInterface = FakeProxier; type LeaseDividendsDistributionInterval = LeaseDividendsDistributionInterval; + type GetCommitments = (); } // Swap-related parameter types diff --git a/pallets/transaction-fee/src/tests/mock.rs b/pallets/transaction-fee/src/tests/mock.rs index c2f5caa432..8db3fd9155 100644 --- a/pallets/transaction-fee/src/tests/mock.rs +++ b/pallets/transaction-fee/src/tests/mock.rs @@ -288,6 +288,7 @@ impl pallet_subtensor::Config for Test { type HotkeySwapOnSubnetInterval = HotkeySwapOnSubnetInterval; type ProxyInterface = (); type LeaseDividendsDistributionInterval = LeaseDividendsDistributionInterval; + type GetCommitments = (); } parameter_types! { From f8807763a6e6a1a8b1d53d38d26c15f19ce864c5 Mon Sep 17 00:00:00 2001 From: open-junius Date: Wed, 27 Aug 2025 15:41:54 +0800 Subject: [PATCH 028/147] cargo clippy --- pallets/admin-utils/src/tests/mock.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/pallets/admin-utils/src/tests/mock.rs b/pallets/admin-utils/src/tests/mock.rs index 35934bc846..c90b1d56c0 100644 --- a/pallets/admin-utils/src/tests/mock.rs +++ b/pallets/admin-utils/src/tests/mock.rs @@ -223,6 +223,7 @@ impl pallet_subtensor::Config for Test { type HotkeySwapOnSubnetInterval = HotkeySwapOnSubnetInterval; type ProxyInterface = (); type LeaseDividendsDistributionInterval = LeaseDividendsDistributionInterval; + type GetCommitments = (); } parameter_types! { From 31d9118053ba763e62ee991fc118a70a19a53b3d Mon Sep 17 00:00:00 2001 From: open-junius Date: Wed, 27 Aug 2025 15:50:00 +0800 Subject: [PATCH 029/147] bump runtime --- 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 b78bf0b206..65c46b96f6 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, From a4ed4838ad40407a692ebeb778034ac82e105a19 Mon Sep 17 00:00:00 2001 From: open-junius Date: Wed, 27 Aug 2025 17:26:28 +0800 Subject: [PATCH 030/147] convert unused code change --- pallets/commitments/Cargo.toml | 5 ----- pallets/commitments/src/lib.rs | 2 +- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/pallets/commitments/Cargo.toml b/pallets/commitments/Cargo.toml index 351af75061..d2873673bc 100644 --- a/pallets/commitments/Cargo.toml +++ b/pallets/commitments/Cargo.toml @@ -35,8 +35,6 @@ hex.workspace = true sha2.workspace = true log.workspace = true - -# pallet-subtensor.workspace = true subtensor-runtime-common.workspace = true [dev-dependencies] @@ -57,7 +55,6 @@ std = [ "log/std", "pallet-balances/std", "pallet-drand/std", - # "pallet-subtensor/std", "rand_chacha/std", "scale-info/std", "sha2/std", @@ -76,7 +73,6 @@ runtime-benchmarks = [ "sp-runtime/runtime-benchmarks", "pallet-balances/runtime-benchmarks", "pallet-drand/runtime-benchmarks", - # "pallet-subtensor/runtime-benchmarks", ] try-runtime = [ "frame-support/try-runtime", @@ -84,5 +80,4 @@ try-runtime = [ "pallet-balances/try-runtime", "sp-runtime/try-runtime", "pallet-drand/try-runtime", - # "pallet-subtensor/try-runtime", ] diff --git a/pallets/commitments/src/lib.rs b/pallets/commitments/src/lib.rs index 579e9dacab..fbce46f710 100644 --- a/pallets/commitments/src/lib.rs +++ b/pallets/commitments/src/lib.rs @@ -132,7 +132,7 @@ pub mod pallet { /// Identity data by account #[pallet::storage] #[pallet::getter(fn commitment_of)] - pub type CommitmentOf = StorageDoubleMap< + pub(super) type CommitmentOf = StorageDoubleMap< _, Identity, NetUid, From a04425fdf770a6c0c852fd87984a03b2ed6ac2a9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 27 Aug 2025 11:24:00 +0000 Subject: [PATCH 031/147] auto-update benchmark weights --- pallets/subtensor/src/macros/dispatches.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 35439479ab..7dc0aad8fb 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -120,9 +120,9 @@ mod dispatches { /// - On failure for each failed item in the batch. /// #[pallet::call_index(80)] - #[pallet::weight((Weight::from_parts(95_160_000, 0) - .saturating_add(T::DbWeight::get().reads(14)) - .saturating_add(T::DbWeight::get().writes(2)), DispatchClass::Normal, Pays::No))] + #[pallet::weight((Weight::from_parts(19_580_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(0_u64)), DispatchClass::Normal, Pays::No))] pub fn batch_set_weights( origin: OriginFor, netuids: Vec>, From 3f1497ee0c1a73fe6f35fd766da0112bf1ca31d9 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 27 Aug 2025 10:32:04 -0700 Subject: [PATCH 032/147] reveal_timelocked_commitments returns weight --- pallets/commitments/src/lib.rs | 44 +++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/pallets/commitments/src/lib.rs b/pallets/commitments/src/lib.rs index 34192b6fa2..f9e9ac579c 100644 --- a/pallets/commitments/src/lib.rs +++ b/pallets/commitments/src/lib.rs @@ -15,10 +15,13 @@ pub use types::*; pub use weights::WeightInfo; use ark_serialize::CanonicalDeserialize; -use frame_support::{BoundedVec, traits::Currency}; +use frame_support::{ + BoundedVec, + traits::{Currency, Get}, +}; use scale_info::prelude::collections::BTreeSet; use sp_runtime::SaturatedConversion; -use sp_runtime::{Saturating, traits::Zero}; +use sp_runtime::{Saturating, Weight, traits::Zero}; use sp_std::{boxed::Box, vec::Vec}; use subtensor_runtime_common::NetUid; use tle::{ @@ -359,10 +362,13 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { fn on_initialize(n: BlockNumberFor) -> Weight { - if let Err(e) = Self::reveal_timelocked_commitments() { - log::debug!("Failed to unveil matured commitments on block {n:?}: {e:?}"); + match Self::reveal_timelocked_commitments() { + Ok(w) => w, + Err(e) => { + log::debug!("Failed to unveil matured commitments on block {n:?}: {e:?}"); + Weight::from_parts(0, 0) + } } - Weight::from_parts(0, 0) } } } @@ -399,13 +405,22 @@ pub enum CallType { use frame_support::{dispatch::DispatchResult, pallet_prelude::TypeInfo}; impl Pallet { - pub fn reveal_timelocked_commitments() -> DispatchResult { + pub fn reveal_timelocked_commitments() -> Result { + let mut total_weight = Weight::from_parts(0, 0); + let index = TimelockedIndex::::get(); + total_weight = total_weight.saturating_add(T::DbWeight::get().reads(1)); + for (netuid, who) in index.clone() { - let Some(mut registration) = >::get(netuid, &who) else { + let maybe_registration = >::get(netuid, &who); + total_weight = total_weight.saturating_add(T::DbWeight::get().reads(1)); + + let Some(mut registration) = maybe_registration else { TimelockedIndex::::mutate(|idx| { idx.remove(&(netuid, who.clone())); }); + + total_weight = total_weight.saturating_add(T::DbWeight::get().reads_writes(1, 1)); continue; }; @@ -419,6 +434,7 @@ impl Pallet { encrypted, reveal_round, } => { + total_weight = total_weight.saturating_add(T::DbWeight::get().reads(1)); let pulse = match pallet_drand::Pulses::::get(reveal_round) { Some(p) => p, None => { @@ -486,6 +502,7 @@ impl Pallet { if !revealed_fields.is_empty() { let mut existing_reveals = RevealedCommitments::::get(netuid, &who).unwrap_or_default(); + total_weight = total_weight.saturating_add(T::DbWeight::get().reads(1)); let current_block = >::block_number(); let block_u64 = current_block.saturated_into::(); @@ -507,6 +524,7 @@ impl Pallet { } RevealedCommitments::::insert(netuid, &who, existing_reveals); + total_weight = total_weight.saturating_add(T::DbWeight::get().writes(1)); } registration.info.fields = BoundedVec::try_from(remain_fields) @@ -515,12 +533,19 @@ impl Pallet { match registration.info.fields.is_empty() { true => { >::remove(netuid, &who); + total_weight = total_weight.saturating_add(T::DbWeight::get().writes(1)); + TimelockedIndex::::mutate(|idx| { idx.remove(&(netuid, who.clone())); }); + + total_weight = + total_weight.saturating_add(T::DbWeight::get().reads_writes(1, 1)); } false => { >::insert(netuid, &who, ®istration); + total_weight = total_weight.saturating_add(T::DbWeight::get().writes(1)); + let has_timelock = registration .info .fields @@ -530,11 +555,14 @@ impl Pallet { TimelockedIndex::::mutate(|idx| { idx.remove(&(netuid, who.clone())); }); + + total_weight = + total_weight.saturating_add(T::DbWeight::get().reads_writes(1, 1)); } } } } - Ok(()) + Ok(total_weight) } } From a271c9003923f12e724bd197685275aba3204b58 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 27 Aug 2025 19:39:19 +0000 Subject: [PATCH 033/147] auto-update benchmark weights --- pallets/subtensor/src/macros/dispatches.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 35439479ab..8123fc5d22 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -120,9 +120,9 @@ mod dispatches { /// - On failure for each failed item in the batch. /// #[pallet::call_index(80)] - #[pallet::weight((Weight::from_parts(95_160_000, 0) - .saturating_add(T::DbWeight::get().reads(14)) - .saturating_add(T::DbWeight::get().writes(2)), DispatchClass::Normal, Pays::No))] + #[pallet::weight((Weight::from_parts(19_540_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(0_u64)), DispatchClass::Normal, Pays::No))] pub fn batch_set_weights( origin: OriginFor, netuids: Vec>, 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 034/147] 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, From 1f7ee1d20965b504dc3ac3b4c07878a160175721 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Thu, 28 Aug 2025 07:48:11 -0700 Subject: [PATCH 035/147] fix benchmark batch-set-weights --- pallets/subtensor/src/benchmarks.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/pallets/subtensor/src/benchmarks.rs b/pallets/subtensor/src/benchmarks.rs index 5cdb47685d..31040649ef 100644 --- a/pallets/subtensor/src/benchmarks.rs +++ b/pallets/subtensor/src/benchmarks.rs @@ -1073,6 +1073,7 @@ mod pallet_benchmarks { Subtensor::::init_new_network(netuid, 1); Subtensor::::set_network_registration_allowed(netuid, true); SubtokenEnabled::::insert(netuid, true); + Subtensor::::set_commit_reveal_weights_enabled(netuid, false); let reg_fee = Subtensor::::get_burn(netuid); Subtensor::::add_balance_to_coldkey_account(&hotkey, reg_fee.to_u64().saturating_mul(2)); From dbae3f607e822e423779796391e5dc043ebe189e Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Thu, 28 Aug 2025 08:36:50 -0700 Subject: [PATCH 036/147] bump spec --- 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, From 630f7dfd2d1e673f9efb2eb23bb107480f9e831d Mon Sep 17 00:00:00 2001 From: open-junius Date: Thu, 28 Aug 2025 23:46:52 +0800 Subject: [PATCH 037/147] not support commit reveal v3 --- pallets/subtensor/src/benchmarks.rs | 36 --------------- pallets/subtensor/src/macros/dispatches.rs | 44 ------------------- .../subtensor/src/transaction_extension.rs | 14 ------ 3 files changed, 94 deletions(-) diff --git a/pallets/subtensor/src/benchmarks.rs b/pallets/subtensor/src/benchmarks.rs index 5cdb47685d..0329638e35 100644 --- a/pallets/subtensor/src/benchmarks.rs +++ b/pallets/subtensor/src/benchmarks.rs @@ -1599,40 +1599,4 @@ mod pallet_benchmarks { assert_eq!(TokenSymbol::::get(netuid), new_symbol); } - - #[benchmark] - fn commit_timelocked_weights() { - let hotkey: T::AccountId = whitelisted_caller(); - let netuid = NetUid::from(1); - let vec_commit: Vec = vec![0; MAX_CRV3_COMMIT_SIZE_BYTES as usize]; - let commit: BoundedVec<_, _> = vec_commit.try_into().unwrap(); - let round: u64 = 0; - - Subtensor::::init_new_network(netuid, 1); - Subtensor::::set_network_pow_registration_allowed(netuid, true); - SubtokenEnabled::::insert(netuid, true); - - let reg_fee = Subtensor::::get_burn(netuid); - Subtensor::::add_balance_to_coldkey_account( - &hotkey, - reg_fee.saturating_mul(2.into()).into(), - ); - - assert_ok!(Subtensor::::burned_register( - RawOrigin::Signed(hotkey.clone()).into(), - netuid, - hotkey.clone() - )); - - Subtensor::::set_commit_reveal_weights_enabled(netuid, true); - - #[extrinsic_call] - _( - RawOrigin::Signed(hotkey.clone()), - netuid, - commit.clone(), - round, - Subtensor::::get_commit_reveal_weights_version(), - ); - } } diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index aed0c150de..2f7587db9f 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -2175,49 +2175,5 @@ mod dispatches { Self::deposit_event(Event::SymbolUpdated { netuid, symbol }); Ok(()) } - - /// ---- Used to commit timelock encrypted commit-reveal weight values to later be revealed. - /// - /// # Args: - /// * `origin`: (`::RuntimeOrigin`): - /// - The committing hotkey. - /// - /// * `netuid` (`u16`): - /// - The u16 network identifier. - /// - /// * `commit` (`Vec`): - /// - The encrypted compressed commit. - /// The steps for this are: - /// 1. Instantiate [`WeightsTlockPayload`] - /// 2. Serialize it using the `parity_scale_codec::Encode` trait - /// 3. Encrypt it following the steps (here)[https://github.com/ideal-lab5/tle/blob/f8e6019f0fb02c380ebfa6b30efb61786dede07b/timelock/src/tlock.rs#L283-L336] - /// to produce a [`TLECiphertext`] type. - /// 4. Serialize and compress using the `ark-serialize` `CanonicalSerialize` trait. - /// - /// * reveal_round (`u64`): - /// - The drand reveal round which will be avaliable during epoch `n+1` from the current - /// epoch. - /// - /// * commit_reveal_version (`u16`): - /// - The client (bittensor-drand) version - #[pallet::call_index(113)] - #[pallet::weight((Weight::from_parts(64_530_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( - origin: T::RuntimeOrigin, - netuid: NetUid, - commit: BoundedVec>, - reveal_round: u64, - commit_reveal_version: u16, - ) -> DispatchResult { - Self::do_commit_timelocked_weights( - origin, - netuid, - commit, - reveal_round, - commit_reveal_version, - ) - } } } diff --git a/pallets/subtensor/src/transaction_extension.rs b/pallets/subtensor/src/transaction_extension.rs index 99749032ad..7a955ccc30 100644 --- a/pallets/subtensor/src/transaction_extension.rs +++ b/pallets/subtensor/src/transaction_extension.rs @@ -244,20 +244,6 @@ where Err(CustomTransactionError::StakeAmountTooLow.into()) } } - Some(Call::commit_timelocked_weights { - netuid, - reveal_round, - .. - }) => { - if Self::check_weights_min_stake(who, *netuid) { - if *reveal_round < pallet_drand::LastStoredRound::::get() { - return Err(CustomTransactionError::InvalidRevealRound.into()); - } - Ok((Default::default(), Some(who.clone()), origin)) - } else { - Err(CustomTransactionError::StakeAmountTooLow.into()) - } - } Some(Call::register { netuid, .. } | Call::burned_register { netuid, .. }) => { let registrations_this_interval = Pallet::::get_registrations_this_interval(*netuid); From 5e2094a0fb7b9c0770dea1e0dfda936e21dae057 Mon Sep 17 00:00:00 2001 From: open-junius Date: Thu, 28 Aug 2025 23:48:34 +0800 Subject: [PATCH 038/147] bump version --- 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, From e570914a65f946f27e04bfea0d646ffaa7431ee0 Mon Sep 17 00:00:00 2001 From: open-junius Date: Thu, 28 Aug 2025 23:52:57 +0800 Subject: [PATCH 039/147] remove correct function --- pallets/subtensor/src/benchmarks.rs | 68 ++++++++------- pallets/subtensor/src/macros/dispatches.rs | 86 ++++++++++--------- .../subtensor/src/transaction_extension.rs | 2 +- 3 files changed, 81 insertions(+), 75 deletions(-) diff --git a/pallets/subtensor/src/benchmarks.rs b/pallets/subtensor/src/benchmarks.rs index 0329638e35..fa7913f584 100644 --- a/pallets/subtensor/src/benchmarks.rs +++ b/pallets/subtensor/src/benchmarks.rs @@ -1092,38 +1092,6 @@ mod pallet_benchmarks { ); } - #[benchmark] - fn commit_crv3_weights() { - let hotkey: T::AccountId = whitelisted_caller(); - let netuid = NetUid::from(1); - let vec_commit: Vec = vec![0; MAX_CRV3_COMMIT_SIZE_BYTES as usize]; - let commit: BoundedVec<_, _> = vec_commit.try_into().unwrap(); - let round: u64 = 0; - - Subtensor::::init_new_network(netuid, 1); - Subtensor::::set_network_pow_registration_allowed(netuid, true); - SubtokenEnabled::::insert(netuid, true); - - let reg_fee = Subtensor::::get_burn(netuid); - Subtensor::::add_balance_to_coldkey_account(&hotkey, reg_fee.to_u64().saturating_mul(2)); - - assert_ok!(Subtensor::::burned_register( - RawOrigin::Signed(hotkey.clone()).into(), - netuid, - hotkey.clone() - )); - - Subtensor::::set_commit_reveal_weights_enabled(netuid, true); - - #[extrinsic_call] - _( - RawOrigin::Signed(hotkey.clone()), - netuid, - commit.clone(), - round, - ); - } - #[benchmark] fn decrease_take() { let coldkey: T::AccountId = whitelisted_caller(); @@ -1599,4 +1567,40 @@ mod pallet_benchmarks { assert_eq!(TokenSymbol::::get(netuid), new_symbol); } + + #[benchmark] + fn commit_timelocked_weights() { + let hotkey: T::AccountId = whitelisted_caller(); + let netuid = NetUid::from(1); + let vec_commit: Vec = vec![0; MAX_CRV3_COMMIT_SIZE_BYTES as usize]; + let commit: BoundedVec<_, _> = vec_commit.try_into().unwrap(); + let round: u64 = 0; + + Subtensor::::init_new_network(netuid, 1); + Subtensor::::set_network_pow_registration_allowed(netuid, true); + SubtokenEnabled::::insert(netuid, true); + + let reg_fee = Subtensor::::get_burn(netuid); + Subtensor::::add_balance_to_coldkey_account( + &hotkey, + reg_fee.saturating_mul(2.into()).into(), + ); + + assert_ok!(Subtensor::::burned_register( + RawOrigin::Signed(hotkey.clone()).into(), + netuid, + hotkey.clone() + )); + + Subtensor::::set_commit_reveal_weights_enabled(netuid, true); + + #[extrinsic_call] + _( + RawOrigin::Signed(hotkey.clone()), + netuid, + commit.clone(), + round, + Subtensor::::get_commit_reveal_weights_version(), + ); + } } diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 2f7587db9f..7b559e45e0 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -249,48 +249,6 @@ mod dispatches { Self::do_reveal_weights(origin, netuid, uids, values, salt, version_key) } - /// ---- Used to commit encrypted commit-reveal v3 weight values to later be revealed. - /// - /// # Args: - /// * `origin`: (`::RuntimeOrigin`): - /// - The committing hotkey. - /// - /// * `netuid` (`u16`): - /// - The u16 network identifier. - /// - /// * `commit` (`Vec`): - /// - The encrypted compressed commit. - /// The steps for this are: - /// 1. Instantiate [`WeightsTlockPayload`] - /// 2. Serialize it using the `parity_scale_codec::Encode` trait - /// 3. Encrypt it following the steps (here)[https://github.com/ideal-lab5/tle/blob/f8e6019f0fb02c380ebfa6b30efb61786dede07b/timelock/src/tlock.rs#L283-L336] - /// to produce a [`TLECiphertext`] type. - /// 4. Serialize and compress using the `ark-serialize` `CanonicalSerialize` trait. - /// - /// * reveal_round (`u64`): - /// - The drand reveal round which will be avaliable during epoch `n+1` from the current - /// epoch. - /// - /// # Raises: - /// * `CommitRevealV3Disabled`: - /// - Attempting to commit when the commit-reveal mechanism is disabled. - /// - /// * `TooManyUnrevealedCommits`: - /// - Attempting to commit when the user has more than the allowed limit of unrevealed commits. - /// - #[pallet::call_index(99)] - #[pallet::weight((Weight::from_parts(77_750_000, 0) - .saturating_add(T::DbWeight::get().reads(7_u64)) - .saturating_add(T::DbWeight::get().writes(2)), DispatchClass::Normal, Pays::No))] - pub fn commit_crv3_weights( - origin: T::RuntimeOrigin, - netuid: NetUid, - commit: BoundedVec>, - reveal_round: u64, - ) -> DispatchResult { - Self::do_commit_timelocked_weights(origin, netuid, commit, reveal_round, 4) - } - /// ---- The implementation for batch revealing committed weights. /// /// # Args: @@ -2175,5 +2133,49 @@ mod dispatches { Self::deposit_event(Event::SymbolUpdated { netuid, symbol }); Ok(()) } + + /// ---- Used to commit timelock encrypted commit-reveal weight values to later be revealed. + /// + /// # Args: + /// * `origin`: (`::RuntimeOrigin`): + /// - The committing hotkey. + /// + /// * `netuid` (`u16`): + /// - The u16 network identifier. + /// + /// * `commit` (`Vec`): + /// - The encrypted compressed commit. + /// The steps for this are: + /// 1. Instantiate [`WeightsTlockPayload`] + /// 2. Serialize it using the `parity_scale_codec::Encode` trait + /// 3. Encrypt it following the steps (here)[https://github.com/ideal-lab5/tle/blob/f8e6019f0fb02c380ebfa6b30efb61786dede07b/timelock/src/tlock.rs#L283-L336] + /// to produce a [`TLECiphertext`] type. + /// 4. Serialize and compress using the `ark-serialize` `CanonicalSerialize` trait. + /// + /// * reveal_round (`u64`): + /// - The drand reveal round which will be avaliable during epoch `n+1` from the current + /// epoch. + /// + /// * commit_reveal_version (`u16`): + /// - The client (bittensor-drand) version + #[pallet::call_index(113)] + #[pallet::weight((Weight::from_parts(64_530_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( + origin: T::RuntimeOrigin, + netuid: NetUid, + commit: BoundedVec>, + reveal_round: u64, + commit_reveal_version: u16, + ) -> DispatchResult { + Self::do_commit_timelocked_weights( + origin, + netuid, + commit, + reveal_round, + commit_reveal_version, + ) + } } } diff --git a/pallets/subtensor/src/transaction_extension.rs b/pallets/subtensor/src/transaction_extension.rs index 7a955ccc30..ccf7bbad2f 100644 --- a/pallets/subtensor/src/transaction_extension.rs +++ b/pallets/subtensor/src/transaction_extension.rs @@ -230,7 +230,7 @@ where Err(CustomTransactionError::StakeAmountTooLow.into()) } } - Some(Call::commit_crv3_weights { + Some(Call::commit_timelocked_weights { netuid, reveal_round, .. From aeb5852bfbbe9fcbd648f6d85006f1229063fa82 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 28 Aug 2025 18:02:04 +0000 Subject: [PATCH 040/147] auto-update benchmark weights --- pallets/subtensor/src/macros/dispatches.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 7b559e45e0..d6767af8ce 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -120,9 +120,9 @@ mod dispatches { /// - On failure for each failed item in the batch. /// #[pallet::call_index(80)] - #[pallet::weight((Weight::from_parts(95_160_000, 0) - .saturating_add(T::DbWeight::get().reads(14)) - .saturating_add(T::DbWeight::get().writes(2)), DispatchClass::Normal, Pays::No))] + #[pallet::weight((Weight::from_parts(19_170_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(0_u64)), DispatchClass::Normal, Pays::No))] pub fn batch_set_weights( origin: OriginFor, netuids: Vec>, From a9aa32afe6e2e7dd6f7510477e6f7783d071f835 Mon Sep 17 00:00:00 2001 From: prop-opentensor Date: Thu, 28 Aug 2025 21:31:07 +0200 Subject: [PATCH 041/147] upgrade instance type for docker builds --- .github/workflows/docker-localnet.yml | 2 +- .github/workflows/docker.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-localnet.yml b/.github/workflows/docker-localnet.yml index 96f3ca56a0..da9732f186 100644 --- a/.github/workflows/docker-localnet.yml +++ b/.github/workflows/docker-localnet.yml @@ -28,7 +28,7 @@ permissions: jobs: publish: - runs-on: [self-hosted, type-ccx33] + runs-on: [self-hosted, type-ccx53, type-ccx43, type-ccx33] steps: - name: Determine Docker tag and ref diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index f0cfd84853..a60f0f9d82 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -27,7 +27,7 @@ permissions: jobs: publish: - runs-on: [self-hosted, type-ccx33] + runs-on: [self-hosted, type-ccx53, type-ccx43, type-ccx33] steps: - name: Determine Docker tag and ref From af1b33ef2f099ae07c945e67c40c89522146d226 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 28 Aug 2025 21:39:24 +0000 Subject: [PATCH 042/147] auto-update benchmark weights --- pallets/subtensor/src/macros/dispatches.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index aed0c150de..46b4aaf92b 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -120,9 +120,9 @@ mod dispatches { /// - On failure for each failed item in the batch. /// #[pallet::call_index(80)] - #[pallet::weight((Weight::from_parts(95_160_000, 0) - .saturating_add(T::DbWeight::get().reads(14)) - .saturating_add(T::DbWeight::get().writes(2)), DispatchClass::Normal, Pays::No))] + #[pallet::weight((Weight::from_parts(19_330_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(0_u64)), DispatchClass::Normal, Pays::No))] pub fn batch_set_weights( origin: OriginFor, netuids: Vec>, From baaa25d227a07fbe18685873613201b7db4579ac Mon Sep 17 00:00:00 2001 From: mateusfigmelo Date: Fri, 29 Aug 2025 14:49:53 +0000 Subject: [PATCH 043/147] chore: fix minor in log::debug --- pallets/subtensor/src/subnets/uids.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/subtensor/src/subnets/uids.rs b/pallets/subtensor/src/subnets/uids.rs index f5a14c490b..d6b776252e 100644 --- a/pallets/subtensor/src/subnets/uids.rs +++ b/pallets/subtensor/src/subnets/uids.rs @@ -81,7 +81,7 @@ impl Pallet { // 1. Get the next uid. This is always equal to subnetwork_n. let next_uid: u16 = Self::get_subnetwork_n(netuid); log::debug!( - "append_neuron( netuid: {netuid:?} | next_uid: {new_hotkey:?} | new_hotkey: {next_uid:?} ) " + "append_neuron( netuid: {netuid:?} | next_uid: {next_uid:?} | new_hotkey: {new_hotkey:?} ) " ); // 2. Get and increase the uid count. From 033e7022dd6a640c13d9de2e46138b6e18bb0603 Mon Sep 17 00:00:00 2001 From: unconst Date: Fri, 29 Aug 2025 10:26:04 -0500 Subject: [PATCH 044/147] allow to set min burn and max burn --- pallets/admin-utils/src/lib.rs | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index 03a20a5f21..0b1498fd44 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -107,6 +107,8 @@ pub mod pallet { BondsMovingAverageMaxReached, /// Only root can set negative sigmoid steepness values NegativeSigmoidSteepness, + /// Value not in allowed bounds. + ValueNotInBounds, } /// Enum for specifying the type of precompile operation. #[derive( @@ -665,12 +667,22 @@ pub mod pallet { netuid: NetUid, min_burn: TaoCurrency, ) -> DispatchResult { - ensure_root(origin)?; - + pallet_subtensor::Pallet::::ensure_subnet_owner_or_root(origin.clone(), netuid)?; + // Allow set min_burn but only up to 1 TAO for spamming. ensure!( pallet_subtensor::Pallet::::if_subnet_exist(netuid), Error::::SubnetDoesNotExist ); + // Min burn must be less than 1 TAO. + ensure!( + min_burn < TaoCurrency::from(1_000_000_000), + Error::::ValueNotInBounds + ) + // Min burn must be less than max burn + ensure!( + min_burn > pallet_subtensor::Pallet::::MaxBurn(netuid), + Error::::ValueNotInBounds + ) pallet_subtensor::Pallet::::set_min_burn(netuid, min_burn); log::debug!("MinBurnSet( netuid: {netuid:?} min_burn: {min_burn:?} ) "); Ok(()) @@ -688,12 +700,21 @@ pub mod pallet { netuid: NetUid, max_burn: TaoCurrency, ) -> DispatchResult { - ensure_root(origin)?; - + pallet_subtensor::Pallet::::ensure_subnet_owner_or_root(origin.clone(), netuid)?; ensure!( pallet_subtensor::Pallet::::if_subnet_exist(netuid), Error::::SubnetDoesNotExist ); + // Max burn must be greater than 0.1 TAO. + ensure!( + max_burn > TaoCurrency::from(100_000_000), + Error::::ValueNotInBounds + ) + // Max burn must be greater than min burn + ensure!( + max_burn > pallet_subtensor::Pallet::::MinBurn(netuid), + Error::::ValueNotInBounds + ) pallet_subtensor::Pallet::::set_max_burn(netuid, max_burn); log::debug!("MaxBurnSet( netuid: {netuid:?} max_burn: {max_burn:?} ) "); Ok(()) From 53a2d104b8fe7ac9a5368804f91ac7b5dd70c9a3 Mon Sep 17 00:00:00 2001 From: unconst Date: Fri, 29 Aug 2025 10:59:34 -0500 Subject: [PATCH 045/147] ckburn added --- pallets/admin-utils/src/lib.rs | 18 ++++++++++ .../subtensor/src/coinbase/run_coinbase.rs | 33 ++++++++----------- pallets/subtensor/src/lib.rs | 3 ++ pallets/subtensor/src/staking/stake_utils.rs | 10 ++++++ precompiles/src/alpha.rs | 7 ++++ 5 files changed, 52 insertions(+), 19 deletions(-) diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index 0b1498fd44..cb0dec173e 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -1703,6 +1703,24 @@ pub mod pallet { pallet_subtensor::Pallet::::set_owner_immune_neuron_limit(netuid, immune_neurons)?; Ok(()) } + + /// The extrinsic sets the difficulty for a subnet. + /// It is only callable by the root account or subnet owner. + /// The extrinsic will call the Subtensor pallet to set the difficulty. + #[pallet::call_index(73)] + #[pallet::weight(Weight::from_parts(15_650_000, 0) + .saturating_add(::DbWeight::get().reads(1_u64)) + .saturating_add(::DbWeight::get().writes(1_u64)))] + pub fn sudo_set_ck_burn( + origin: OriginFor, + netuid: NetUid, + burn: u64, + ) -> DispatchResult { + ensure_root(origin)?; + pallet_subtensor::Pallet::::set_ck_burn( burn ); + log::debug!("CKBurnSet( burn: {burn:?} ) "); + Ok(()) + } } } diff --git a/pallets/subtensor/src/coinbase/run_coinbase.rs b/pallets/subtensor/src/coinbase/run_coinbase.rs index 73fc928e90..cc20a72219 100644 --- a/pallets/subtensor/src/coinbase/run_coinbase.rs +++ b/pallets/subtensor/src/coinbase/run_coinbase.rs @@ -743,10 +743,11 @@ impl Pallet { // Calculate the hotkey's share of the validator emission based on its childkey take let validating_emission: U96F32 = U96F32::saturating_from_num(dividends); let mut remaining_emission: U96F32 = validating_emission; - let childkey_take_proportion: U96F32 = + let burn_take_proportion: U96F32 = Self::get_ck_burn_proportion(); + let child_take_proportion: U96F32 = U96F32::saturating_from_num(Self::get_childkey_take(hotkey, netuid)) .safe_div(U96F32::saturating_from_num(u16::MAX)); - log::debug!("Childkey take proportion: {childkey_take_proportion:?} for hotkey {hotkey:?}"); + log::debug!("Childkey take proportion: {child_take_proportion:?} for hotkey {hotkey:?}"); // NOTE: Only the validation emission should be split amongst parents. // Grab the owner of the childkey. @@ -754,7 +755,7 @@ impl Pallet { // Initialize variables to track emission distribution let mut to_parents: u64 = 0; - let mut total_child_emission_take: U96F32 = U96F32::saturating_from_num(0); + let mut total_child_take: U96F32 = U96F32::saturating_from_num(0); // Initialize variables to calculate total stakes from parents let mut total_contribution: U96F32 = U96F32::saturating_from_num(0); @@ -818,21 +819,16 @@ impl Pallet { remaining_emission = remaining_emission.saturating_sub(parent_emission); // Get the childkey take for this parent. - let child_emission_take: U96F32 = if parent_owner == childkey_owner { - // The parent is from the same coldkey, so we don't remove any childkey take. - U96F32::saturating_from_num(0) - } else { - childkey_take_proportion - .saturating_mul(U96F32::saturating_from_num(parent_emission)) + let mut burn_take: U96F32 = U96F32::saturating_from_num(0); + let mut child_take: U96F32 = U96F32::saturating_from_num(0); + if parent_owner != childkey_owner { + // The parent is from a different coldkey, we burn some proportion + burn_take = burn_take_proportion * parent_emission; + child_take = child_take_proportion * parent_emission; + parent_emission = parent_emission.saturating_sub(burn_take); + parent_emission = parent_emission.saturating_sub(child_take); + total_child_take = total_child_take.saturating_add(child_take); }; - - // Remove the childkey take from the parent's emission. - parent_emission = parent_emission.saturating_sub(child_emission_take); - - // Add the childkey take to the total childkey take tracker. - total_child_emission_take = - total_child_emission_take.saturating_add(child_emission_take); - log::debug!("Child emission take: {child_emission_take:?} for hotkey {hotkey:?}"); log::debug!("Parent emission: {parent_emission:?} for hotkey {hotkey:?}"); log::debug!("remaining emission: {remaining_emission:?}"); @@ -852,13 +848,12 @@ impl Pallet { // Calculate the final emission for the hotkey itself. // This includes the take left from the parents and the self contribution. let child_emission = remaining_emission - .saturating_add(total_child_emission_take) + .saturating_add(total_child_take) .saturating_to_num::() .into(); // Add the hotkey's own emission to the distribution list dividend_tuples.push((hotkey.clone(), child_emission)); - dividend_tuples } diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index ef41b07c78..35435c8a83 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -920,6 +920,9 @@ pub mod pallet { /// --- ITEM --> Global weight pub type TaoWeight = StorageValue<_, u64, ValueQuery, DefaultTaoWeight>; #[pallet::storage] + /// --- ITEM --> CK burn + pub type CKBurn = StorageValue<_, u64, ValueQuery, DefaultZeroU64>; + #[pallet::storage] /// --- ITEM ( default_delegate_take ) pub type MaxDelegateTake = StorageValue<_, u16, ValueQuery, DefaultDelegateTake>; #[pallet::storage] diff --git a/pallets/subtensor/src/staking/stake_utils.rs b/pallets/subtensor/src/staking/stake_utils.rs index 8dff984099..84485b74a8 100644 --- a/pallets/subtensor/src/staking/stake_utils.rs +++ b/pallets/subtensor/src/staking/stake_utils.rs @@ -96,6 +96,11 @@ impl Pallet { // This ensures the result is always between 0 and 1 weight_fixed.safe_div(U96F32::saturating_from_num(u64::MAX)) } + pub fn get_ck_burn() -> U96F32 { + let stored_weight = CKBurn::::get(); + let weight_fixed = U96F32::saturating_from_num(stored_weight); + weight_fixed.safe_div(U96F32::saturating_from_num(u64::MAX)) + } /// Sets the global global weight in storage. /// @@ -117,6 +122,11 @@ impl Pallet { // Update the TaoWeight storage with the new weight value TaoWeight::::set(weight); } + // Set the amount burned on non owned CK + pub fn set_ck_burn(weight: u64) { + // Update the ck burn value. + CKBurn::::set(weight); + } /// Calculates the weighted combination of alpha and global tao for a single hotkey onet a subnet. /// diff --git a/precompiles/src/alpha.rs b/precompiles/src/alpha.rs index 42261674d9..29f7cab568 100644 --- a/precompiles/src/alpha.rs +++ b/precompiles/src/alpha.rs @@ -90,6 +90,13 @@ where Ok(U256::from(tao_weight)) } + #[precompile::public("getCKBurn()")] + #[precompile::view] + fn get_ck_burn(_handle: &mut impl PrecompileHandle) -> EvmResult { + let ck_burn = pallet_subtensor::CKBurn::::get(); + Ok(U256::from(ck_burn)) + } + #[precompile::public("simSwapTaoForAlpha(uint16,uint64)")] #[precompile::view] fn sim_swap_tao_for_alpha( From b42a765184d6dd2a8596f981d0ebb88e6be35eba Mon Sep 17 00:00:00 2001 From: unconst Date: Fri, 29 Aug 2025 11:51:39 -0500 Subject: [PATCH 046/147] burn take subtracts fro alpha out --- pallets/subtensor/src/coinbase/run_coinbase.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pallets/subtensor/src/coinbase/run_coinbase.rs b/pallets/subtensor/src/coinbase/run_coinbase.rs index cc20a72219..60caf9a3db 100644 --- a/pallets/subtensor/src/coinbase/run_coinbase.rs +++ b/pallets/subtensor/src/coinbase/run_coinbase.rs @@ -743,7 +743,7 @@ impl Pallet { // Calculate the hotkey's share of the validator emission based on its childkey take let validating_emission: U96F32 = U96F32::saturating_from_num(dividends); let mut remaining_emission: U96F32 = validating_emission; - let burn_take_proportion: U96F32 = Self::get_ck_burn_proportion(); + let burn_take_proportion: U96F32 = Self::get_ck_burn(); let child_take_proportion: U96F32 = U96F32::saturating_from_num(Self::get_childkey_take(hotkey, netuid)) .safe_div(U96F32::saturating_from_num(u16::MAX)); @@ -828,6 +828,7 @@ impl Pallet { parent_emission = parent_emission.saturating_sub(burn_take); parent_emission = parent_emission.saturating_sub(child_take); total_child_take = total_child_take.saturating_add(child_take); + SubnetAlphaOut::::mutate( |total| *total = total.saturating_sub(burn_take) ); }; log::debug!("Child emission take: {child_emission_take:?} for hotkey {hotkey:?}"); log::debug!("Parent emission: {parent_emission:?} for hotkey {hotkey:?}"); From 7e06314099d227fc0021edc941a28ba6d580ae17 Mon Sep 17 00:00:00 2001 From: unconst Date: Fri, 29 Aug 2025 12:06:30 -0500 Subject: [PATCH 047/147] commit Cargo.lock --- pallets/admin-utils/src/lib.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index 0b1498fd44..6d3e102a33 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -677,12 +677,12 @@ pub mod pallet { ensure!( min_burn < TaoCurrency::from(1_000_000_000), Error::::ValueNotInBounds - ) + ); // Min burn must be less than max burn ensure!( - min_burn > pallet_subtensor::Pallet::::MaxBurn(netuid), + min_burn > pallet_subtensor::Pallet::::get_max_burn(netuid), Error::::ValueNotInBounds - ) + ); pallet_subtensor::Pallet::::set_min_burn(netuid, min_burn); log::debug!("MinBurnSet( netuid: {netuid:?} min_burn: {min_burn:?} ) "); Ok(()) @@ -709,12 +709,12 @@ pub mod pallet { ensure!( max_burn > TaoCurrency::from(100_000_000), Error::::ValueNotInBounds - ) + ); // Max burn must be greater than min burn ensure!( - max_burn > pallet_subtensor::Pallet::::MinBurn(netuid), + max_burn > pallet_subtensor::Pallet::::get_min_burn(netuid), Error::::ValueNotInBounds - ) + ); pallet_subtensor::Pallet::::set_max_burn(netuid, max_burn); log::debug!("MaxBurnSet( netuid: {netuid:?} max_burn: {max_burn:?} ) "); Ok(()) From cdc7a22f9f3d3cccfd6b9bc18af4036b825002a5 Mon Sep 17 00:00:00 2001 From: unconst Date: Fri, 29 Aug 2025 12:17:10 -0500 Subject: [PATCH 048/147] commit Cargo.lock --- pallets/admin-utils/src/lib.rs | 13 ++++++------- pallets/subtensor/src/coinbase/run_coinbase.rs | 9 ++++++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index cb0dec173e..d363490f16 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -677,12 +677,12 @@ pub mod pallet { ensure!( min_burn < TaoCurrency::from(1_000_000_000), Error::::ValueNotInBounds - ) + ); // Min burn must be less than max burn ensure!( - min_burn > pallet_subtensor::Pallet::::MaxBurn(netuid), + min_burn > pallet_subtensor::Pallet::::get_max_burn(netuid), Error::::ValueNotInBounds - ) + ); pallet_subtensor::Pallet::::set_min_burn(netuid, min_burn); log::debug!("MinBurnSet( netuid: {netuid:?} min_burn: {min_burn:?} ) "); Ok(()) @@ -709,12 +709,12 @@ pub mod pallet { ensure!( max_burn > TaoCurrency::from(100_000_000), Error::::ValueNotInBounds - ) + ); // Max burn must be greater than min burn ensure!( - max_burn > pallet_subtensor::Pallet::::MinBurn(netuid), + max_burn > pallet_subtensor::Pallet::::get_min_burn(netuid), Error::::ValueNotInBounds - ) + ); pallet_subtensor::Pallet::::set_max_burn(netuid, max_burn); log::debug!("MaxBurnSet( netuid: {netuid:?} max_burn: {max_burn:?} ) "); Ok(()) @@ -1713,7 +1713,6 @@ pub mod pallet { .saturating_add(::DbWeight::get().writes(1_u64)))] pub fn sudo_set_ck_burn( origin: OriginFor, - netuid: NetUid, burn: u64, ) -> DispatchResult { ensure_root(origin)?; diff --git a/pallets/subtensor/src/coinbase/run_coinbase.rs b/pallets/subtensor/src/coinbase/run_coinbase.rs index 60caf9a3db..ec3a6ff287 100644 --- a/pallets/subtensor/src/coinbase/run_coinbase.rs +++ b/pallets/subtensor/src/coinbase/run_coinbase.rs @@ -828,10 +828,13 @@ impl Pallet { parent_emission = parent_emission.saturating_sub(burn_take); parent_emission = parent_emission.saturating_sub(child_take); total_child_take = total_child_take.saturating_add(child_take); - SubnetAlphaOut::::mutate( |total| *total = total.saturating_sub(burn_take) ); + SubnetAlphaOut::::mutate( netuid, |total| { *total = total.saturating_sub( AlphaCurrency::from(burn_take.saturating_to_num::()) ); }); }; - log::debug!("Child emission take: {child_emission_take:?} for hotkey {hotkey:?}"); - log::debug!("Parent emission: {parent_emission:?} for hotkey {hotkey:?}"); + log::debug!("burn_takee: {burn_take:?} for hotkey {hotkey:?}"); + log::debug!("child_take: {child_take:?} for hotkey {hotkey:?}"); + log::debug!("parent_emission: {parent_emission:?} for hotkey {hotkey:?}"); + log::debug!("total_child_take: {total_child_take:?} for hotkey {hotkey:?}"); + log::debug!("remaining emission: {remaining_emission:?}"); // Add the parent's emission to the distribution list From 167b1cce083142f8231fe2f473fb1c263c091832 Mon Sep 17 00:00:00 2001 From: unconst Date: Fri, 29 Aug 2025 12:18:23 -0500 Subject: [PATCH 049/147] commit Cargo.lock --- 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 ec3a6ff287..a84c2b29fb 100644 --- a/pallets/subtensor/src/coinbase/run_coinbase.rs +++ b/pallets/subtensor/src/coinbase/run_coinbase.rs @@ -823,8 +823,8 @@ impl Pallet { let mut child_take: U96F32 = U96F32::saturating_from_num(0); if parent_owner != childkey_owner { // The parent is from a different coldkey, we burn some proportion - burn_take = burn_take_proportion * parent_emission; - child_take = child_take_proportion * parent_emission; + burn_take = burn_take_proportion.saturating_mul(parent_emission); + child_take = child_take_proportion.saturating_mul(parent_emission); parent_emission = parent_emission.saturating_sub(burn_take); parent_emission = parent_emission.saturating_sub(child_take); total_child_take = total_child_take.saturating_add(child_take); From 505b3580d374315eb79da4e388a9f308bfba3951 Mon Sep 17 00:00:00 2001 From: unconst Date: Fri, 29 Aug 2025 12:20:31 -0500 Subject: [PATCH 050/147] cargo fmt --- pallets/admin-utils/src/lib.rs | 7 ++----- pallets/subtensor/src/coinbase/run_coinbase.rs | 5 ++++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index d363490f16..babcfb1225 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -1711,12 +1711,9 @@ pub mod pallet { #[pallet::weight(Weight::from_parts(15_650_000, 0) .saturating_add(::DbWeight::get().reads(1_u64)) .saturating_add(::DbWeight::get().writes(1_u64)))] - pub fn sudo_set_ck_burn( - origin: OriginFor, - burn: u64, - ) -> DispatchResult { + pub fn sudo_set_ck_burn(origin: OriginFor, burn: u64) -> DispatchResult { ensure_root(origin)?; - pallet_subtensor::Pallet::::set_ck_burn( burn ); + pallet_subtensor::Pallet::::set_ck_burn(burn); log::debug!("CKBurnSet( burn: {burn:?} ) "); Ok(()) } diff --git a/pallets/subtensor/src/coinbase/run_coinbase.rs b/pallets/subtensor/src/coinbase/run_coinbase.rs index a84c2b29fb..c029f0ed13 100644 --- a/pallets/subtensor/src/coinbase/run_coinbase.rs +++ b/pallets/subtensor/src/coinbase/run_coinbase.rs @@ -828,7 +828,10 @@ impl Pallet { parent_emission = parent_emission.saturating_sub(burn_take); parent_emission = parent_emission.saturating_sub(child_take); total_child_take = total_child_take.saturating_add(child_take); - SubnetAlphaOut::::mutate( netuid, |total| { *total = total.saturating_sub( AlphaCurrency::from(burn_take.saturating_to_num::()) ); }); + SubnetAlphaOut::::mutate(netuid, |total| { + *total = total + .saturating_sub(AlphaCurrency::from(burn_take.saturating_to_num::())); + }); }; log::debug!("burn_takee: {burn_take:?} for hotkey {hotkey:?}"); log::debug!("child_take: {child_take:?} for hotkey {hotkey:?}"); From f32849fb6926276cdf4e4b02ea44a1905c68b7f7 Mon Sep 17 00:00:00 2001 From: mateusfigmelo Date: Fri, 29 Aug 2025 18:14:02 +0000 Subject: [PATCH 051/147] chore: remove unused codec in dependency list --- Cargo.lock | 1 - precompiles/Cargo.toml | 2 -- 2 files changed, 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7d65c7aac9..32ece81a48 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13814,7 +13814,6 @@ dependencies = [ "pallet-proxy 38.0.0", "pallet-subtensor", "pallet-subtensor-swap", - "parity-scale-codec", "precompile-utils", "sp-core", "sp-io", diff --git a/precompiles/Cargo.toml b/precompiles/Cargo.toml index 4045408268..79f70f6005 100644 --- a/precompiles/Cargo.toml +++ b/precompiles/Cargo.toml @@ -11,7 +11,6 @@ repository = "https://github.com/opentensor/subtensor/" targets = ["x86_64-unknown-linux-gnu"] [dependencies] -codec = { workspace = true, features = ["derive"] } ed25519-dalek = { workspace = true, features = ["alloc"] } fp-evm.workspace = true frame-support.workspace = true @@ -44,7 +43,6 @@ workspace = true [features] default = ["std"] std = [ - "codec/std", "ed25519-dalek/std", "fp-evm/std", "frame-support/std", From 75892d32fd55b890d05815ecd280b54f1fee760d Mon Sep 17 00:00:00 2001 From: mateusfigmelo Date: Fri, 29 Aug 2025 18:30:58 +0000 Subject: [PATCH 052/147] chore: remove frame-support & serde in deps --- Cargo.lock | 2 -- pallets/subtensor/runtime-api/Cargo.toml | 4 ---- 2 files changed, 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7d65c7aac9..d8a230a71b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13764,10 +13764,8 @@ dependencies = [ name = "subtensor-custom-rpc-runtime-api" version = "0.0.2" dependencies = [ - "frame-support", "pallet-subtensor", "parity-scale-codec", - "serde", "sp-api", "sp-runtime", "subtensor-runtime-common", diff --git a/pallets/subtensor/runtime-api/Cargo.toml b/pallets/subtensor/runtime-api/Cargo.toml index 1951f77fd3..b427fc333c 100644 --- a/pallets/subtensor/runtime-api/Cargo.toml +++ b/pallets/subtensor/runtime-api/Cargo.toml @@ -14,8 +14,6 @@ workspace = true [dependencies] sp-api.workspace = true sp-runtime.workspace = true -frame-support.workspace = true -serde = { workspace = true, features = ["derive"] } codec = { workspace = true, features = ["derive"] } subtensor-runtime-common.workspace = true # local @@ -25,9 +23,7 @@ pallet-subtensor.workspace = true default = ["std"] std = [ "codec/std", - "frame-support/std", "pallet-subtensor/std", - "serde/std", "sp-api/std", "sp-runtime/std", "subtensor-runtime-common/std", From 5255388f2d3ffdbc2561ae407572acc3900ec19b Mon Sep 17 00:00:00 2001 From: mateusfigmelo Date: Fri, 29 Aug 2025 18:49:03 +0000 Subject: [PATCH 053/147] chore: remove unused deps in pallets_subtensor_rpc --- Cargo.lock | 3 --- pallets/subtensor/rpc/Cargo.toml | 5 ----- 2 files changed, 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7d65c7aac9..891c61b318 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13749,12 +13749,9 @@ name = "subtensor-custom-rpc" version = "0.0.2" dependencies = [ "jsonrpsee", - "pallet-subtensor", "parity-scale-codec", - "serde", "sp-api", "sp-blockchain", - "sp-rpc", "sp-runtime", "subtensor-custom-rpc-runtime-api", "subtensor-runtime-common", diff --git a/pallets/subtensor/rpc/Cargo.toml b/pallets/subtensor/rpc/Cargo.toml index e3512b82d1..80fc0eb908 100644 --- a/pallets/subtensor/rpc/Cargo.toml +++ b/pallets/subtensor/rpc/Cargo.toml @@ -14,25 +14,20 @@ workspace = true [dependencies] codec = { workspace = true, features = ["derive"] } jsonrpsee = { workspace = true, features = ["client-core", "server", "macros"] } -serde = { workspace = true, features = ["derive"] } # Substrate packages sp-api.workspace = true sp-blockchain.workspace = true -sp-rpc.workspace = true sp-runtime.workspace = true # local packages subtensor-runtime-common.workspace = true subtensor-custom-rpc-runtime-api.workspace = true -pallet-subtensor.workspace = true [features] default = ["std"] std = [ "codec/std", - "pallet-subtensor/std", - "serde/std", "sp-api/std", "sp-runtime/std", "subtensor-custom-rpc-runtime-api/std", From 7b9bb25198df1218636a1fa921fb1ca1f456f422 Mon Sep 17 00:00:00 2001 From: mateusfigmelo Date: Fri, 29 Aug 2025 19:07:00 +0000 Subject: [PATCH 054/147] chore: remove unused deps in pallets_subtensor --- Cargo.lock | 88 ------------------------------------ pallets/subtensor/Cargo.toml | 17 ------- 2 files changed, 105 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7d65c7aac9..5d5205afbb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1639,7 +1639,6 @@ dependencies = [ "iana-time-zone", "js-sys", "num-traits", - "serde", "wasm-bindgen", "windows-link", ] @@ -2508,7 +2507,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e" dependencies = [ "powerfmt", - "serde", ] [[package]] @@ -5118,7 +5116,6 @@ checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661" dependencies = [ "equivalent", "hashbrown 0.15.4", - "serde", ] [[package]] @@ -6688,19 +6685,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "ndarray" -version = "0.15.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb12d4e967ec485a5f71c6311fe28158e9d6f4bc4a447b474184d0f91a8fa32" -dependencies = [ - "matrixmultiply", - "num-complex", - "num-integer", - "num-traits", - "rawpointer", -] - [[package]] name = "netlink-packet-core" version = "0.7.0" @@ -8138,7 +8122,6 @@ name = "pallet-subtensor" version = "4.0.0-dev" dependencies = [ "approx", - "ark-bls12-381 0.4.0", "ark-serialize 0.4.2", "frame-benchmarking", "frame-support", @@ -8147,7 +8130,6 @@ dependencies = [ "hex-literal", "libsecp256k1", "log", - "ndarray", "num-traits", "pallet-balances", "pallet-collective", @@ -8155,10 +8137,8 @@ dependencies = [ "pallet-drand", "pallet-membership", "pallet-preimage", - "pallet-proxy 38.0.0", "pallet-scheduler", "pallet-subtensor-swap", - "pallet-transaction-payment", "pallet-utility 38.0.0", "parity-scale-codec", "parity-util-mem", @@ -8168,10 +8148,7 @@ dependencies = [ "safe-math", "scale-info", "serde", - "serde-tuple-vec-map", - "serde_bytes", "serde_json", - "serde_with", "sha2 0.10.9", "share-pool", "sp-core", @@ -11720,30 +11697,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "schemars" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd191f9397d57d581cddd31014772520aa448f65ef991055d7f61582c65165f" -dependencies = [ - "dyn-clone", - "ref-cast", - "serde", - "serde_json", -] - -[[package]] -name = "schemars" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82d20c4491bc164fa2f6c5d44565947a52ad80b9505d8e36f8d54c27c739fcd0" -dependencies = [ - "dyn-clone", - "ref-cast", - "serde", - "serde_json", -] - [[package]] name = "schnellru" version = "0.2.4" @@ -11989,15 +11942,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde-tuple-vec-map" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a04d0ebe0de77d7d445bb729a895dcb0a288854b267ca85f030ce51cdc578c82" -dependencies = [ - "serde", -] - [[package]] name = "serde_bytes" version = "0.11.17" @@ -12061,38 +12005,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_with" -version = "3.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2c45cd61fefa9db6f254525d46e392b852e0e61d9a1fd36e5bd183450a556d5" -dependencies = [ - "base64 0.22.1", - "chrono", - "hex", - "indexmap 1.9.3", - "indexmap 2.10.0", - "schemars 0.9.0", - "schemars 1.0.4", - "serde", - "serde_derive", - "serde_json", - "serde_with_macros", - "time", -] - -[[package]] -name = "serde_with_macros" -version = "3.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de90945e6565ce0d9a25098082ed4ee4002e047cb59892c318d66821e14bb30f" -dependencies = [ - "darling", - "proc-macro2", - "quote", - "syn 2.0.104", -] - [[package]] name = "serdect" version = "0.2.0" diff --git a/pallets/subtensor/Cargo.toml b/pallets/subtensor/Cargo.toml index 44d873c8a6..a63f63b599 100644 --- a/pallets/subtensor/Cargo.toml +++ b/pallets/subtensor/Cargo.toml @@ -27,17 +27,12 @@ frame-system.workspace = true sp-io.workspace = true serde = { workspace = true, features = ["derive"] } serde_json.workspace = true -serde-tuple-vec-map.workspace = true -serde_bytes = { workspace = true, features = ["alloc"] } -serde_with = { workspace = true, features = ["macros"] } sp-runtime.workspace = true sp-std.workspace = true libsecp256k1.workspace = true log.workspace = true substrate-fixed.workspace = true -pallet-transaction-payment.workspace = true pallet-utility.workspace = true -ndarray.workspace = true hex.workspace = true share-pool.workspace = true safe-math.workspace = true @@ -52,13 +47,11 @@ pallet-membership.workspace = true hex-literal.workspace = true num-traits = { workspace = true, features = ["libm"] } tle.workspace = true -ark-bls12-381 = { workspace = true, features = ["curve"] } ark-serialize = { workspace = true, features = ["derive"] } w3f-bls.workspace = true sha2.workspace = true rand_chacha.workspace = true pallet-crowdloan.workspace = true -pallet-proxy.workspace = true [dev-dependencies] pallet-balances = { workspace = true, features = ["std"] } @@ -75,7 +68,6 @@ pallet-preimage.workspace = true [features] std = [ - "ark-bls12-381/std", "ark-serialize/std", "codec/std", "frame-benchmarking/std", @@ -84,7 +76,6 @@ std = [ "hex/std", "libsecp256k1/std", "log/std", - "ndarray/std", "num-traits/std", "pallet-balances/std", "pallet-collective/std", @@ -93,15 +84,12 @@ std = [ "pallet-preimage/std", "pallet-scheduler/std", "pallet-subtensor-swap/std", - "pallet-transaction-payment/std", "pallet-utility/std", "rand_chacha/std", "safe-math/std", "scale-info/std", "serde/std", - "serde_bytes/std", "serde_json/std", - "serde_with/std", "sha2/std", "share-pool/std", "sp-core/std", @@ -121,7 +109,6 @@ std = [ "sha2/std", "share-pool/std", "subtensor-runtime-common/std", - "pallet-proxy/std", "pallet-crowdloan/std", "runtime-common/std" ] @@ -137,8 +124,6 @@ runtime-benchmarks = [ "pallet-preimage/runtime-benchmarks", "pallet-scheduler/runtime-benchmarks", "pallet-subtensor-swap/runtime-benchmarks", - "pallet-transaction-payment/runtime-benchmarks", - "pallet-proxy/runtime-benchmarks", "pallet-crowdloan/runtime-benchmarks", "pallet-utility/runtime-benchmarks", "sp-runtime/runtime-benchmarks", @@ -151,12 +136,10 @@ try-runtime = [ "pallet-membership/try-runtime", "pallet-preimage/try-runtime", "pallet-scheduler/try-runtime", - "pallet-transaction-payment/try-runtime", "pallet-utility/try-runtime", "sp-runtime/try-runtime", "pallet-collective/try-runtime", "pallet-drand/try-runtime", - "pallet-proxy/try-runtime", "pallet-crowdloan/try-runtime", "runtime-common/try-runtime" ] From d57ebd4a2a8ca55d7f81b2e3424975cab03a6123 Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Thu, 21 Aug 2025 13:36:03 +0300 Subject: [PATCH 055/147] Remove deprecated code. --- pallets/admin-utils/src/lib.rs | 91 ----------- pallets/commitments/src/lib.rs | 15 -- pallets/subtensor/src/macros/dispatches.rs | 170 --------------------- 3 files changed, 276 deletions(-) diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index 03a20a5f21..abc5e7a443 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -957,21 +957,6 @@ pub mod pallet { Ok(()) } - /// The extrinsic sets the subnet limit for the network. - /// It is only callable by the root account. - /// The extrinsic will call the Subtensor pallet to set the subnet limit. - #[pallet::call_index(37)] - #[pallet::weight(( - Weight::from_parts(14_000_000, 0) - .saturating_add(::DbWeight::get().writes(1)), - DispatchClass::Operational, - Pays::No - ))] - pub fn sudo_set_subnet_limit(origin: OriginFor, _max_subnets: u16) -> DispatchResult { - ensure_root(origin)?; - Ok(()) - } - /// The extrinsic sets the lock reduction interval for the network. /// It is only callable by the root account. /// The extrinsic will call the Subtensor pallet to set the lock reduction interval. @@ -1076,26 +1061,6 @@ pub mod pallet { Ok(()) } - // The extrinsic sets the target stake per interval. - // It is only callable by the root account. - // The extrinsic will call the Subtensor pallet to set target stake per interval. - // #[pallet::call_index(47)] - // #[pallet::weight((0, DispatchClass::Operational, Pays::No))] - // pub fn sudo_set_target_stakes_per_interval( - // origin: OriginFor, - // target_stakes_per_interval: u64, - // ) -> DispatchResult { - // ensure_root(origin)?; - // pallet_subtensor::Pallet::::set_target_stakes_per_interval( - // target_stakes_per_interval, - // ); - // log::debug!( - // "TxTargetStakesPerIntervalSet( set_target_stakes_per_interval: {:?} ) ", - // target_stakes_per_interval - // ); (DEPRECATED) - // Ok(()) - // } (DEPRECATED) - /// The extrinsic enabled/disables commit/reaveal for a given subnet. /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the value. @@ -1157,62 +1122,6 @@ pub mod pallet { ) } - // DEPRECATED - // #[pallet::call_index(52)] - // #[pallet::weight((0, DispatchClass::Operational, Pays::No))] - // pub fn sudo_set_hotkey_emission_tempo( - // origin: OriginFor, - // emission_tempo: u64, - // ) -> DispatchResult { - // ensure_root(origin)?; - // pallet_subtensor::Pallet::::set_hotkey_emission_tempo(emission_tempo); - // log::debug!( - // "HotkeyEmissionTempoSet( emission_tempo: {:?} )", - // emission_tempo - // ); - // Ok(()) - // } - - /// Sets the maximum stake allowed for a specific network. - /// - /// This function allows the root account to set the maximum stake for a given network. - /// It updates the network's maximum stake value and logs the change. - /// - /// # Arguments - /// - /// * `origin` - The origin of the call, which must be the root account. - /// * `netuid` - The unique identifier of the network. - /// * `max_stake` - The new maximum stake value to set. - /// - /// # Returns - /// - /// Returns `Ok(())` if the operation is successful, or an error if it fails. - /// - /// # Example - /// - /// - /// # Notes - /// - /// - This function can only be called by the root account. - /// - The `netuid` should correspond to an existing network. - /// - /// # TODO - /// - // - Consider adding a check to ensure the `netuid` corresponds to an existing network. - // - Implement a mechanism to gradually adjust the max stake to prevent sudden changes. - // #[pallet::weight(::WeightInfo::sudo_set_network_max_stake())] - #[pallet::call_index(53)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] - pub fn sudo_set_network_max_stake( - origin: OriginFor, - _netuid: NetUid, - _max_stake: u64, - ) -> DispatchResult { - // Ensure the call is made by the root account - ensure_root(origin)?; - Ok(()) - } - /// Sets the duration of the coldkey swap schedule. /// /// This extrinsic allows the root account to set the duration for the coldkey swap schedule. diff --git a/pallets/commitments/src/lib.rs b/pallets/commitments/src/lib.rs index 34192b6fa2..a7d887b877 100644 --- a/pallets/commitments/src/lib.rs +++ b/pallets/commitments/src/lib.rs @@ -325,21 +325,6 @@ pub mod pallet { Ok(()) } - /// *DEPRECATED* Sudo-set the commitment rate limit - #[pallet::call_index(1)] - #[pallet::weight(( - Weight::from_parts(3_596_000, 0) - .saturating_add(T::DbWeight::get().reads(0_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)), - DispatchClass::Operational, - Pays::No - ))] - pub fn set_rate_limit(origin: OriginFor, _rate_limit_blocks: u32) -> DispatchResult { - ensure_root(origin)?; - // RateLimit::::set(rate_limit_blocks.into()); - Ok(()) - } - /// Sudo-set MaxSpace #[pallet::call_index(2)] #[pallet::weight(( diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 46b4aaf92b..284cf82c3c 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -352,118 +352,6 @@ mod dispatches { ) } - /// # Args: - /// * `origin`: (Origin): - /// - The caller, a hotkey who wishes to set their weights. - /// - /// * `netuid` (u16): - /// - The network uid we are setting these weights on. - /// - /// * `hotkey` (T::AccountId): - /// - The hotkey associated with the operation and the calling coldkey. - /// - /// * `dests` (Vec): - /// - The edge endpoint for the weight, i.e. j for w_ij. - /// - /// * 'weights' (Vec): - /// - The u16 integer encoded weights. Interpreted as rational - /// 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. - /// - /// # Event: - /// - /// * WeightsSet; - /// - On successfully setting the weights on chain. - /// - /// # Raises: - /// - /// * NonAssociatedColdKey; - /// - Attempting to set weights on a non-associated cold key. - /// - /// * 'SubNetworkDoesNotExist': - /// - Attempting to set weights on a non-existent network. - /// - /// * 'NotRootSubnet': - /// - Attempting to set weights on a subnet that is not the root network. - /// - /// * 'WeightVecNotEqualSize': - /// - Attempting to set weights with uids not of same length. - /// - /// * 'UidVecContainInvalidOne': - /// - Attempting to set weights with invalid uids. - /// - /// * 'NotRegistered': - /// - Attempting to set weights from a non registered account. - /// - /// * 'WeightVecLengthIsLow': - /// - Attempting to set weights with fewer weights than min. - /// - /// * 'IncorrectWeightVersionKey': - /// - Attempting to set weights with the incorrect network version key. - /// - /// * 'SettingWeightsTooFast': - /// - Attempting to set weights too fast. - /// - /// * 'WeightVecLengthIsLow': - /// - Attempting to set weights with fewer weights than min. - /// - /// * 'MaxWeightExceeded': - /// - Attempting to set weights with max value exceeding limit. - /// - #[pallet::call_index(8)] - #[pallet::weight((Weight::from_parts(3_176_000, 0) - .saturating_add(T::DbWeight::get().reads(0_u64)) - .saturating_add(T::DbWeight::get().writes(0_u64)), DispatchClass::Normal, Pays::No))] - pub fn set_tao_weights( - _origin: OriginFor, - _netuid: NetUid, - _hotkey: T::AccountId, - _dests: Vec, - _weights: Vec, - _version_key: u64, - ) -> DispatchResult { - // DEPRECATED - // Self::do_set_root_weights(origin, netuid, hotkey, dests, weights, version_key) - // Self::do_set_tao_weights(origin, netuid, hotkey, dests, weights, version_key) - Ok(()) - } - - /// --- Sets the key as a delegate. - /// - /// # Args: - /// * 'origin': (Origin): - /// - The signature of the caller's coldkey. - /// - /// * 'hotkey' (T::AccountId): - /// - The hotkey we are delegating (must be owned by the coldkey.) - /// - /// * 'take' (u64): - /// - The stake proportion that this hotkey takes from delegations. - /// - /// # Event: - /// * DelegateAdded; - /// - On successfully setting a hotkey as a delegate. - /// - /// # Raises: - /// * 'NotRegistered': - /// - The hotkey we are delegating is not registered on the network. - /// - /// * 'NonAssociatedColdKey': - /// - The hotkey we are delegating is not owned by the calling coldket. - /// - #[pallet::call_index(1)] - #[pallet::weight((Weight::from_parts(3_406_000, 0) - .saturating_add(T::DbWeight::get().reads(0)) - .saturating_add(T::DbWeight::get().writes(0)), DispatchClass::Normal, Pays::Yes))] - pub fn become_delegate(_origin: OriginFor, _hotkey: T::AccountId) -> DispatchResult { - // DEPRECATED - // Self::do_become_delegate(origin, hotkey, Self::get_default_delegate_take()) - - Ok(()) - } - /// --- Allows delegates to decrease its take value. /// /// # Args: @@ -1386,64 +1274,6 @@ mod dispatches { Ok(().into()) } - /// Schedule the dissolution of a network at a specified block number. - /// - /// # Arguments - /// - /// * `origin` - The origin of the call, must be signed by the sender. - /// * `netuid` - The u16 network identifier to be dissolved. - /// - /// # Returns - /// - /// Returns a `DispatchResultWithPostInfo` indicating success or failure of the operation. - /// - /// # Weight - /// - /// Weight is calculated based on the number of database reads and writes. - - #[pallet::call_index(74)] - #[pallet::weight((Weight::from_parts(119_000_000, 0) - .saturating_add(T::DbWeight::get().reads(6)) - .saturating_add(T::DbWeight::get().writes(31)), DispatchClass::Normal, Pays::Yes))] - pub fn schedule_dissolve_network( - _origin: OriginFor, - _netuid: NetUid, - ) -> DispatchResultWithPostInfo { - Err(Error::::CallDisabled.into()) - - // let who = ensure_signed(origin)?; - - // let current_block: BlockNumberFor = >::block_number(); - // let duration: BlockNumberFor = DissolveNetworkScheduleDuration::::get(); - // let when: BlockNumberFor = current_block.saturating_add(duration); - - // let call = Call::::dissolve_network { - // coldkey: who.clone(), - // netuid, - // }; - - // let bound_call = T::Preimages::bound(LocalCallOf::::from(call.clone())) - // .map_err(|_| Error::::FailedToSchedule)?; - - // T::Scheduler::schedule( - // DispatchTime::At(when), - // None, - // 63, - // frame_system::RawOrigin::Root.into(), - // bound_call, - // ) - // .map_err(|_| Error::::FailedToSchedule)?; - - // // Emit the SwapScheduled event - // Self::deposit_event(Event::DissolveNetworkScheduled { - // account: who.clone(), - // netuid, - // execution_block: when, - // }); - - // Ok(().into()) - } - /// ---- Set prometheus information for the neuron. /// # Args: /// * 'origin': (Origin): From 53f574fe76c982820c1404630404b8b690a94ead Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Thu, 21 Aug 2025 17:05:46 +0300 Subject: [PATCH 056/147] Remove tests, benchmarks and alter transaction extension. --- common/src/lib.rs | 2 +- pallets/subtensor/src/benchmarks.rs | 48 -------- pallets/subtensor/src/tests/weights.rs | 113 ------------------ .../subtensor/src/transaction_extension.rs | 7 -- runtime/src/lib.rs | 7 +- 5 files changed, 2 insertions(+), 175 deletions(-) diff --git a/common/src/lib.rs b/common/src/lib.rs index a3882a88fc..67fe4be51b 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -154,7 +154,7 @@ pub enum ProxyType { Registration, Transfer, SmallTransfer, - RootWeights, + RootWeights, // deprecated ChildKeys, SudoUncheckedSetCode, SwapHotkey, diff --git a/pallets/subtensor/src/benchmarks.rs b/pallets/subtensor/src/benchmarks.rs index 31040649ef..42e3d79a23 100644 --- a/pallets/subtensor/src/benchmarks.rs +++ b/pallets/subtensor/src/benchmarks.rs @@ -98,33 +98,6 @@ mod pallet_benchmarks { ); } - #[benchmark] - fn become_delegate() { - let netuid = NetUid::from(1); - let tempo: u16 = 1; - - Subtensor::::init_new_network(netuid, tempo); - SubtokenEnabled::::insert(netuid, true); - Subtensor::::set_burn(netuid, 1.into()); - Subtensor::::set_max_allowed_uids(netuid, 4096); - Subtensor::::set_network_registration_allowed(netuid, true); - - let seed: u32 = 1; - let coldkey: T::AccountId = account("Test", 0, seed); - let hotkey: T::AccountId = account("Alice", 0, seed); - let amount_to_be_staked: u64 = 1_000_000_000; - - Subtensor::::add_balance_to_coldkey_account(&coldkey, amount_to_be_staked); - assert_ok!(Subtensor::::do_burned_registration( - RawOrigin::Signed(coldkey.clone()).into(), - netuid, - hotkey.clone() - )); - - #[extrinsic_call] - _(RawOrigin::Signed(coldkey.clone()), hotkey.clone()); - } - #[benchmark] fn add_stake() { let netuid = NetUid::from(1); @@ -1280,27 +1253,6 @@ mod pallet_benchmarks { ); } - #[benchmark] - fn set_tao_weights() { - let netuid = NetUid::from(1); - let hotkey: T::AccountId = account("A", 0, 6); - let dests = vec![0u16]; - let weights = vec![0u16]; - let version: u64 = 1; - - Subtensor::::init_new_network(netuid, 1); - - #[extrinsic_call] - _( - RawOrigin::None, - netuid, - hotkey.clone(), - dests.clone(), - weights.clone(), - version, - ); - } - #[benchmark] fn swap_hotkey() { let coldkey: T::AccountId = whitelisted_caller(); diff --git a/pallets/subtensor/src/tests/weights.rs b/pallets/subtensor/src/tests/weights.rs index 4784c6b00e..d25a3eb34f 100644 --- a/pallets/subtensor/src/tests/weights.rs +++ b/pallets/subtensor/src/tests/weights.rs @@ -62,119 +62,6 @@ fn test_set_weights_dispatch_info_ok() { }); } -// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --package pallet-subtensor --lib -- tests::weights::test_set_rootweights_validate --exact --show-output --nocapture -#[test] -fn test_set_rootweights_validate() { - // Testing the signed extension validate function - // correctly filters this transaction. - - new_test_ext(0).execute_with(|| { - let dests = vec![1, 1]; - let weights = vec![1, 1]; - let netuid = NetUid::from(1); - let version_key: u64 = 0; - let coldkey = U256::from(0); - let hotkey: U256 = U256::from(1); // Add the hotkey field - assert_ne!(hotkey, coldkey); // Ensure hotkey is NOT the same as coldkey !!! - let fee: u64 = 0; // FIXME: DefaultStakingFee is deprecated - - let who = coldkey; // The coldkey signs this transaction - - let call = RuntimeCall::SubtensorModule(SubtensorCall::set_tao_weights { - netuid, - dests, - weights, - version_key, - hotkey, // Include the hotkey field - }); - - // Create netuid - add_network(netuid, 1, 0); - // Register the hotkey - SubtensorModule::append_neuron(netuid, &hotkey, 0); - crate::Owner::::insert(hotkey, coldkey); - - SubtensorModule::add_balance_to_coldkey_account(&hotkey, u64::MAX); - - let min_stake = TaoCurrency::from(500_000_000_000); - // Set the minimum stake - SubtensorModule::set_stake_threshold(min_stake.into()); - - // Verify stake is less than minimum - assert!(SubtensorModule::get_total_stake_for_hotkey(&hotkey) < min_stake); - let info: DispatchInfo = - DispatchInfoOf::<::RuntimeCall>::default(); - - let extension = SubtensorTransactionExtension::::new(); - // Submit to the signed extension validate function - let result_no_stake = extension.validate( - RawOrigin::Signed(who).into(), - &call.clone(), - &info, - 10, - (), - &TxBaseImplication(()), - TransactionSource::External, - ); - // Should fail - assert_eq!( - // Should get an invalid transaction error - result_no_stake.unwrap_err(), - CustomTransactionError::StakeAmountTooLow.into() - ); - - // Increase the stake to be equal to the minimum - assert_ok!(SubtensorModule::do_add_stake( - RuntimeOrigin::signed(hotkey), - hotkey, - netuid, - min_stake + fee.into() - )); - - // Verify stake is equal to minimum - assert_eq!( - SubtensorModule::get_total_stake_for_hotkey(&hotkey), - min_stake - ); - - // Submit to the signed extension validate function - let result_min_stake = extension.validate( - RawOrigin::Signed(who).into(), - &call.clone(), - &info, - 10, - (), - &TxBaseImplication(()), - TransactionSource::External, - ); - // Now the call should pass - assert_ok!(result_min_stake); - - // Try with more stake than minimum - assert_ok!(SubtensorModule::do_add_stake( - RuntimeOrigin::signed(hotkey), - hotkey, - netuid, - DefaultMinStake::::get() * 10.into() - )); - - // Verify stake is more than minimum - assert!(SubtensorModule::get_total_stake_for_hotkey(&hotkey) > min_stake); - - let result_more_stake = extension.validate( - RawOrigin::Signed(who).into(), - &call.clone(), - &info, - 10, - (), - &TxBaseImplication(()), - TransactionSource::External, - ); - // The call should still pass - assert_ok!(result_more_stake); - }); -} - // SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --package pallet-subtensor --lib -- tests::weights::test_commit_weights_dispatch_info_ok --exact --show-output --nocapture #[test] fn test_commit_weights_dispatch_info_ok() { diff --git a/pallets/subtensor/src/transaction_extension.rs b/pallets/subtensor/src/transaction_extension.rs index 99749032ad..537562fab7 100644 --- a/pallets/subtensor/src/transaction_extension.rs +++ b/pallets/subtensor/src/transaction_extension.rs @@ -223,13 +223,6 @@ where Err(CustomTransactionError::StakeAmountTooLow.into()) } } - Some(Call::set_tao_weights { netuid, hotkey, .. }) => { - if Self::check_weights_min_stake(hotkey, *netuid) { - Ok((Default::default(), Some(who.clone()), origin)) - } else { - Err(CustomTransactionError::StakeAmountTooLow.into()) - } - } Some(Call::commit_crv3_weights { netuid, reveal_round, diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 00cc24b411..7675c962c6 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -398,7 +398,6 @@ impl Contains for SafeModeWhitelistedCalls { | RuntimeCall::Timestamp(_) | RuntimeCall::SubtensorModule( pallet_subtensor::Call::set_weights { .. } - | pallet_subtensor::Call::set_tao_weights { .. } | pallet_subtensor::Call::serve_axon { .. } ) | RuntimeCall::Commitments(pallet_commitments::Call::set_commitment { .. }) @@ -733,7 +732,6 @@ impl InstanceFilter for ProxyType { | RuntimeCall::SubtensorModule(pallet_subtensor::Call::root_register { .. }) | RuntimeCall::SubtensorModule(pallet_subtensor::Call::burned_register { .. }) | RuntimeCall::Triumvirate(..) - | RuntimeCall::SubtensorModule(pallet_subtensor::Call::set_tao_weights { .. }) | RuntimeCall::Sudo(..) ), ProxyType::Triumvirate => matches!( @@ -771,10 +769,7 @@ impl InstanceFilter for ProxyType { RuntimeCall::SubtensorModule(pallet_subtensor::Call::burned_register { .. }) | RuntimeCall::SubtensorModule(pallet_subtensor::Call::register { .. }) ), - ProxyType::RootWeights => matches!( - c, - RuntimeCall::SubtensorModule(pallet_subtensor::Call::set_tao_weights { .. }) - ), + ProxyType::RootWeights => false, // deprecated ProxyType::ChildKeys => matches!( c, RuntimeCall::SubtensorModule(pallet_subtensor::Call::set_children { .. }) From fee24593ee4c764937dd579f046bd3a80d56fd7f Mon Sep 17 00:00:00 2001 From: open-junius Date: Tue, 2 Sep 2025 20:32:55 +0800 Subject: [PATCH 057/147] bump version --- 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 00cc24b411..679e5e55b2 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: 307, + spec_version: 308, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From 5d8926fd5ef93f68b3c4d959a77a629ca1191870 Mon Sep 17 00:00:00 2001 From: open-junius Date: Tue, 2 Sep 2025 20:39:53 +0800 Subject: [PATCH 058/147] bump version --- 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 65c46b96f6..9892ae3f9c 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: 307, + spec_version: 308, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From 924b1f904dd47a1735d73792ed12a3984c624d61 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 2 Sep 2025 13:18:23 +0000 Subject: [PATCH 059/147] auto-update benchmark weights --- pallets/subtensor/src/macros/dispatches.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 284cf82c3c..0383f3edee 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -120,9 +120,9 @@ mod dispatches { /// - On failure for each failed item in the batch. /// #[pallet::call_index(80)] - #[pallet::weight((Weight::from_parts(19_330_000, 0) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(0_u64)), DispatchClass::Normal, Pays::No))] + #[pallet::weight((Weight::from_parts(95_460_000, 0) + .saturating_add(T::DbWeight::get().reads(14_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)), DispatchClass::Normal, Pays::No))] pub fn batch_set_weights( origin: OriginFor, netuids: Vec>, From 0d34e1b1c91a36ce05a3f1fa998ae5814843c62a Mon Sep 17 00:00:00 2001 From: unconst Date: Tue, 2 Sep 2025 09:13:41 -0500 Subject: [PATCH 060/147] auto stake feature --- pallets/subtensor/src/coinbase/run_coinbase.rs | 13 +++++++++---- pallets/subtensor/src/lib.rs | 5 +++-- pallets/subtensor/src/macros/dispatches.rs | 16 ++++++++++++++++ pallets/subtensor/src/swap/swap_coldkey.rs | 4 ++++ 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/pallets/subtensor/src/coinbase/run_coinbase.rs b/pallets/subtensor/src/coinbase/run_coinbase.rs index 73fc928e90..dd64cdfbf5 100644 --- a/pallets/subtensor/src/coinbase/run_coinbase.rs +++ b/pallets/subtensor/src/coinbase/run_coinbase.rs @@ -510,11 +510,16 @@ impl Pallet { ); continue; } - - // Increase stake for miner. + let destination: T::AccountId; + let owner: T::AccountId = Owner::::get(&hotkey); + if AutoStakeDestination::::contains_key(&owner) { + destination = AutoStakeDestination::::get(&owner); + } else { + destination = hotkey.clone(); + } Self::increase_stake_for_hotkey_and_coldkey_on_subnet( - &hotkey.clone(), - &Owner::::get(hotkey.clone()), + &destination, + &owner, netuid, incentive, ); diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index ef41b07c78..1fb22b349f 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -1081,8 +1081,9 @@ pub mod pallet { pub type StakingHotkeys = StorageMap<_, Blake2_128Concat, T::AccountId, Vec, ValueQuery>; #[pallet::storage] // --- MAP ( cold ) --> Vec | Returns the vector of hotkeys controlled by this coldkey. - pub type OwnedHotkeys = - StorageMap<_, Blake2_128Concat, T::AccountId, Vec, ValueQuery>; + pub type OwnedHotkeys = StorageMap<_, Blake2_128Concat, T::AccountId, Vec, ValueQuery>; + #[pallet::storage] // --- MAP ( cold ) --> hot | Returns the hotkey a coldkey will autostake to with mining rewards. + pub type AutoStakeDestination = StorageMap<_, Blake2_128Concat, T::AccountId, T::AccountId, ValueQuery>; #[pallet::storage] // --- DMAP ( cold ) --> (block_expected, new_coldkey) | Maps coldkey to the block to swap at and new coldkey. pub type ColdkeySwapScheduled = StorageMap< diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 46b4aaf92b..2dfcdb69ab 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -2219,5 +2219,21 @@ mod dispatches { commit_reveal_version, ) } + + #[pallet::call_index(114)] + #[pallet::weight((Weight::from_parts(64_530_000, 0) + .saturating_add(T::DbWeight::get().reads(7_u64)) + .saturating_add(T::DbWeight::get().writes(2)), DispatchClass::Normal, Pays::Yes))] + pub fn set_coldkey_auto_stake_hotkey( + origin: T::RuntimeOrigin, + hotkey: T::AccountId, + ) -> DispatchResult { + let coldkey = ensure_signed(origin)?; + log::debug!( + "set_coldkey_auto_stake_hotkey( origin:{coldkey:?} hotkey:{hotkey:?} )" + ); + AutoStakeDestination::::insert( coldkey, hotkey.clone() ); + Ok(()) + } } } diff --git a/pallets/subtensor/src/swap/swap_coldkey.rs b/pallets/subtensor/src/swap/swap_coldkey.rs index 91da83e4e7..97458b27d6 100644 --- a/pallets/subtensor/src/swap/swap_coldkey.rs +++ b/pallets/subtensor/src/swap/swap_coldkey.rs @@ -178,6 +178,10 @@ impl Pallet { weight.saturating_accrue(T::DbWeight::get().reads_writes(2, 2)); } + let old_auto_stake_hotkey: T::AccountId = AutoStakeDestination::::get(old_coldkey); + AutoStakeDestination::::remove(old_coldkey); + AutoStakeDestination::::insert(new_coldkey, old_auto_stake_hotkey); + // 4. Swap TotalColdkeyAlpha (DEPRECATED) // for netuid in Self::get_all_subnet_netuids() { // let old_alpha_stake: u64 = TotalColdkeyAlpha::::get(old_coldkey, netuid); From d3e26da68bddb676418c36572c5df3bce2185731 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Tue, 2 Sep 2025 11:20:17 -0300 Subject: [PATCH 061/147] added tests --- pallets/admin-utils/src/lib.rs | 2 +- pallets/admin-utils/src/tests/mod.rs | 94 ++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 1 deletion(-) diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index 6d3e102a33..7fc4205173 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -680,7 +680,7 @@ pub mod pallet { ); // Min burn must be less than max burn ensure!( - min_burn > pallet_subtensor::Pallet::::get_max_burn(netuid), + min_burn < pallet_subtensor::Pallet::::get_max_burn(netuid), Error::::ValueNotInBounds ); pallet_subtensor::Pallet::::set_min_burn(netuid, min_burn); diff --git a/pallets/admin-utils/src/tests/mod.rs b/pallets/admin-utils/src/tests/mod.rs index 5290d3ddfc..9a2c52df77 100644 --- a/pallets/admin-utils/src/tests/mod.rs +++ b/pallets/admin-utils/src/tests/mod.rs @@ -1951,3 +1951,97 @@ fn test_sudo_set_commit_reveal_version() { ); }); } + +#[test] +fn test_sudo_set_min_burn() { + new_test_ext().execute_with(|| { + let netuid = NetUid::from(1); + let to_be_set = TaoCurrency::from(1_000_000); + add_network(netuid, 10); + let init_value = SubtensorModule::get_min_burn(netuid); + + // Simple case + assert_ok!(AdminUtils::sudo_set_min_burn( + <::RuntimeOrigin>::root(), + netuid, + TaoCurrency::from(to_be_set) + )); + assert_ne!(SubtensorModule::get_min_burn(netuid), init_value); + assert_eq!(SubtensorModule::get_min_burn(netuid), to_be_set); + + // Unknown subnet + assert_err!(AdminUtils::sudo_set_min_burn( + <::RuntimeOrigin>::root(), + NetUid::from(42), + TaoCurrency::from(to_be_set) + ), Error::::SubnetDoesNotExist); + + // Non subnet owner + assert_err!(AdminUtils::sudo_set_min_burn( + <::RuntimeOrigin>::signed(U256::from(1)), + netuid, + TaoCurrency::from(to_be_set) + ), DispatchError::BadOrigin); + + // Above min bound + assert_err!(AdminUtils::sudo_set_min_burn( + <::RuntimeOrigin>::root(), + netuid, + TaoCurrency::from(1_000_000_000 + 1) + ), Error::::ValueNotInBounds); + + // Above max burn + assert_err!(AdminUtils::sudo_set_min_burn( + <::RuntimeOrigin>::root(), + netuid, + SubtensorModule::get_max_burn(netuid) + 1.into() + ), Error::::ValueNotInBounds); + }); +} + +#[test] +fn test_sudo_set_max_burn() { + new_test_ext().execute_with(|| { + let netuid = NetUid::from(1); + let to_be_set = TaoCurrency::from(100_000_001); + add_network(netuid, 10); + let init_value = SubtensorModule::get_max_burn(netuid); + + // Simple case + assert_ok!(AdminUtils::sudo_set_max_burn( + <::RuntimeOrigin>::root(), + netuid, + TaoCurrency::from(to_be_set) + )); + assert_ne!(SubtensorModule::get_max_burn(netuid), init_value); + assert_eq!(SubtensorModule::get_max_burn(netuid), to_be_set); + + // Unknown subnet + assert_err!(AdminUtils::sudo_set_max_burn( + <::RuntimeOrigin>::root(), + NetUid::from(42), + TaoCurrency::from(to_be_set) + ), Error::::SubnetDoesNotExist); + + // Non subnet owner + assert_err!(AdminUtils::sudo_set_max_burn( + <::RuntimeOrigin>::signed(U256::from(1)), + netuid, + TaoCurrency::from(to_be_set) + ), DispatchError::BadOrigin); + + // Above min bound + assert_err!(AdminUtils::sudo_set_max_burn( + <::RuntimeOrigin>::root(), + netuid, + TaoCurrency::from(100_000_000 - 1) + ), Error::::ValueNotInBounds); + + // Below min burn + assert_err!(AdminUtils::sudo_set_max_burn( + <::RuntimeOrigin>::root(), + netuid, + SubtensorModule::get_min_burn(netuid) - 1.into() + ), Error::::ValueNotInBounds); + }); +} \ No newline at end of file From 5d27fc6bfa2bedbe89889aace5d7615c1eeb261a Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Mon, 25 Aug 2025 16:05:33 +0300 Subject: [PATCH 062/147] =?UTF-8?q?Update=20dispatch=20class=20and=20?= =?UTF-8?q?=E2=80=9Cpays::yes=E2=80=9D=20for=20extrinsics.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pallets/admin-utils/src/lib.rs | 30 ++++++++++------------ pallets/admin-utils/src/tests/mod.rs | 4 +-- pallets/subtensor/src/macros/dispatches.rs | 2 +- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index abc5e7a443..3f0c19f7a9 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -376,13 +376,11 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the adjustment alpha. #[pallet::call_index(9)] - #[pallet::weight(( + #[pallet::weight( Weight::from_parts(14_000_000, 0) .saturating_add(::DbWeight::get().writes(1)) - .saturating_add(::DbWeight::get().reads(1)), - DispatchClass::Operational, - Pays::No - ))] + .saturating_add(::DbWeight::get().reads(1)) + )] pub fn sudo_set_adjustment_alpha( origin: OriginFor, netuid: NetUid, @@ -602,12 +600,10 @@ pub mod pallet { /// It is only callable by the root account or subnet owner. /// The extrinsic will call the Subtensor pallet to set the network PoW registration allowed. #[pallet::call_index(20)] - #[pallet::weight(( + #[pallet::weight( Weight::from_parts(14_000_000, 0) - .saturating_add(::DbWeight::get().writes(1)), - DispatchClass::Operational, - Pays::No - ))] + .saturating_add(::DbWeight::get().writes(1)) + )] pub fn sudo_set_network_pow_registration_allowed( origin: OriginFor, netuid: NetUid, @@ -1095,7 +1091,7 @@ pub mod pallet { /// # Weight /// This function has a fixed weight of 0 and is classified as an operational transaction that does not incur any fees. #[pallet::call_index(50)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + #[pallet::weight((1_000_000, DispatchClass::Normal, Pays::Yes))] // TODO: add proper weights pub fn sudo_set_liquid_alpha_enabled( origin: OriginFor, netuid: NetUid, @@ -1109,7 +1105,7 @@ pub mod pallet { /// Sets values for liquid alpha #[pallet::call_index(51)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + #[pallet::weight((1_000_000, DispatchClass::Normal, Pays::Yes))] // TODO: add proper weights pub fn sudo_set_alpha_values( origin: OriginFor, netuid: NetUid, @@ -1288,7 +1284,7 @@ pub mod pallet { /// # Weight /// This function has a fixed weight of 0 and is classified as an operational transaction that does not incur any fees. #[pallet::call_index(61)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + #[pallet::weight((1_000_000, DispatchClass::Normal, Pays::Yes))] // TODO: add proper weights pub fn sudo_set_toggle_transfer( origin: OriginFor, netuid: NetUid, @@ -1418,7 +1414,7 @@ pub mod pallet { /// # Weight /// Weight is handled by the `#[pallet::weight]` attribute. #[pallet::call_index(68)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + #[pallet::weight((1_000_000, DispatchClass::Normal, Pays::Yes))] // TODO: add proper weights pub fn sudo_set_alpha_sigmoid_steepness( origin: OriginFor, netuid: NetUid, @@ -1453,7 +1449,7 @@ pub mod pallet { /// # Weight /// This function has a fixed weight of 0 and is classified as an operational transaction that does not incur any fees. #[pallet::call_index(69)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + #[pallet::weight((1_000_000, DispatchClass::Normal, Pays::Yes))] // TODO: add proper weights pub fn sudo_set_yuma3_enabled( origin: OriginFor, netuid: NetUid, @@ -1477,7 +1473,7 @@ pub mod pallet { /// # Weight /// This function has a fixed weight of 0 and is classified as an operational transaction that does not incur any fees. #[pallet::call_index(70)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + #[pallet::weight((1_000_000, DispatchClass::Normal, Pays::Yes))] // TODO: add proper weights pub fn sudo_set_bonds_reset_enabled( origin: OriginFor, netuid: NetUid, @@ -1522,7 +1518,7 @@ pub mod pallet { /// # Rate Limiting /// This function is rate-limited to one call per subnet per interval (e.g., one week). #[pallet::call_index(67)] - #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + #[pallet::weight((1_000_000, DispatchClass::Normal, Pays::Yes))] // TODO: add proper weights pub fn sudo_set_sn_owner_hotkey( origin: OriginFor, netuid: NetUid, diff --git a/pallets/admin-utils/src/tests/mod.rs b/pallets/admin-utils/src/tests/mod.rs index 5290d3ddfc..1ad4a20d63 100644 --- a/pallets/admin-utils/src/tests/mod.rs +++ b/pallets/admin-utils/src/tests/mod.rs @@ -1227,8 +1227,8 @@ fn test_set_alpha_values_dispatch_info_ok() { let dispatch_info = call.get_dispatch_info(); - assert_eq!(dispatch_info.class, DispatchClass::Operational); - assert_eq!(dispatch_info.pays_fee, Pays::No); + assert_eq!(dispatch_info.class, DispatchClass::Normal); + assert_eq!(dispatch_info.pays_fee, Pays::Yes); }); } diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 0383f3edee..1a712276fa 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -1987,7 +1987,7 @@ mod dispatches { #[pallet::call_index(112)] #[pallet::weight(( Weight::from_parts(26_200_000, 0).saturating_add(T::DbWeight::get().reads_writes(4, 1)), - DispatchClass::Operational, + DispatchClass::Normal, Pays::Yes ))] pub fn update_symbol( From 251ad7088341845cb05ca72d36e2b495dbf07a84 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 2 Sep 2025 14:39:35 +0000 Subject: [PATCH 063/147] auto-update benchmark weights --- pallets/subtensor/src/macros/dispatches.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 38d6d959ab..1a08024317 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -120,9 +120,9 @@ mod dispatches { /// - On failure for each failed item in the batch. /// #[pallet::call_index(80)] - #[pallet::weight((Weight::from_parts(19_330_000, 0) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(0_u64)), DispatchClass::Normal, Pays::No))] + #[pallet::weight((Weight::from_parts(94_660_000, 0) + .saturating_add(T::DbWeight::get().reads(14_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)), DispatchClass::Normal, Pays::No))] pub fn batch_set_weights( origin: OriginFor, netuids: Vec>, @@ -2159,7 +2159,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(83_450_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( From 7ea38c797cecf0123385aa0a63fa4089d300661c Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Tue, 2 Sep 2025 11:41:31 -0300 Subject: [PATCH 064/147] extract min/max burn bounds as config params --- pallets/admin-utils/src/lib.rs | 11 ++++------- pallets/admin-utils/src/tests/mock.rs | 6 +++++- pallets/admin-utils/src/tests/mod.rs | 8 ++++---- pallets/subtensor/src/macros/config.rs | 6 ++++++ 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index 7fc4205173..afbd417725 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -656,7 +656,7 @@ pub mod pallet { } /// The extrinsic sets the minimum burn for a subnet. - /// It is only callable by the root account. + /// It is only callable by root and subnet owner. /// The extrinsic will call the Subtensor pallet to set the minimum burn. #[pallet::call_index(22)] #[pallet::weight(Weight::from_parts(15_440_000, 0) @@ -668,14 +668,12 @@ pub mod pallet { min_burn: TaoCurrency, ) -> DispatchResult { pallet_subtensor::Pallet::::ensure_subnet_owner_or_root(origin.clone(), netuid)?; - // Allow set min_burn but only up to 1 TAO for spamming. ensure!( pallet_subtensor::Pallet::::if_subnet_exist(netuid), Error::::SubnetDoesNotExist ); - // Min burn must be less than 1 TAO. ensure!( - min_burn < TaoCurrency::from(1_000_000_000), + min_burn < T::MinBurnUpperBound::get(), Error::::ValueNotInBounds ); // Min burn must be less than max burn @@ -689,7 +687,7 @@ pub mod pallet { } /// The extrinsic sets the maximum burn for a subnet. - /// It is only callable by the root account or subnet owner. + /// It is only callable by root and subnet owner. /// The extrinsic will call the Subtensor pallet to set the maximum burn. #[pallet::call_index(23)] #[pallet::weight(Weight::from_parts(15_940_000, 0) @@ -705,9 +703,8 @@ pub mod pallet { pallet_subtensor::Pallet::::if_subnet_exist(netuid), Error::::SubnetDoesNotExist ); - // Max burn must be greater than 0.1 TAO. ensure!( - max_burn > TaoCurrency::from(100_000_000), + max_burn > T::MaxBurnLowerBound::get(), Error::::ValueNotInBounds ); // Max burn must be greater than min burn diff --git a/pallets/admin-utils/src/tests/mock.rs b/pallets/admin-utils/src/tests/mock.rs index 35934bc846..67099a1906 100644 --- a/pallets/admin-utils/src/tests/mock.rs +++ b/pallets/admin-utils/src/tests/mock.rs @@ -19,7 +19,7 @@ use sp_runtime::{ }; use sp_std::cmp::Ordering; use sp_weights::Weight; -use subtensor_runtime_common::NetUid; +use subtensor_runtime_common::{NetUid, TaoCurrency}; type Block = frame_system::mocking::MockBlock; // Configure a mock runtime to test the pallet. @@ -110,6 +110,8 @@ parameter_types! { pub const InitialBurn: u64 = 0; pub const InitialMinBurn: u64 = 500_000; pub const InitialMaxBurn: u64 = 1_000_000_000; + pub const MinBurnUpperBound: TaoCurrency = TaoCurrency::new(1_000_000_000); // 1 TAO + pub const MaxBurnLowerBound: TaoCurrency = TaoCurrency::new(100_000_000); // 0.1 TAO pub const InitialValidatorPruneLen: u64 = 0; pub const InitialScalingLawPower: u16 = 50; pub const InitialMaxAllowedValidators: u16 = 100; @@ -198,6 +200,8 @@ impl pallet_subtensor::Config for Test { type InitialBurn = InitialBurn; type InitialMaxBurn = InitialMaxBurn; type InitialMinBurn = InitialMinBurn; + type MinBurnUpperBound = MinBurnUpperBound; + type MaxBurnLowerBound = MaxBurnLowerBound; type InitialRAORecycledForRegistration = InitialRAORecycledForRegistration; type InitialSenateRequiredStakePercentage = InitialSenateRequiredStakePercentage; type InitialNetworkImmunityPeriod = InitialNetworkImmunityPeriod; diff --git a/pallets/admin-utils/src/tests/mod.rs b/pallets/admin-utils/src/tests/mod.rs index 9a2c52df77..37d5f37300 100644 --- a/pallets/admin-utils/src/tests/mod.rs +++ b/pallets/admin-utils/src/tests/mod.rs @@ -1983,11 +1983,11 @@ fn test_sudo_set_min_burn() { TaoCurrency::from(to_be_set) ), DispatchError::BadOrigin); - // Above min bound + // Above upper bound assert_err!(AdminUtils::sudo_set_min_burn( <::RuntimeOrigin>::root(), netuid, - TaoCurrency::from(1_000_000_000 + 1) + ::MinBurnUpperBound::get() + 1.into() ), Error::::ValueNotInBounds); // Above max burn @@ -2030,11 +2030,11 @@ fn test_sudo_set_max_burn() { TaoCurrency::from(to_be_set) ), DispatchError::BadOrigin); - // Above min bound + // Below lower bound assert_err!(AdminUtils::sudo_set_max_burn( <::RuntimeOrigin>::root(), netuid, - TaoCurrency::from(100_000_000 - 1) + ::MaxBurnLowerBound::get() - 1.into() ), Error::::ValueNotInBounds); // Below min burn diff --git a/pallets/subtensor/src/macros/config.rs b/pallets/subtensor/src/macros/config.rs index 3479ad8101..b89fe8e865 100644 --- a/pallets/subtensor/src/macros/config.rs +++ b/pallets/subtensor/src/macros/config.rs @@ -98,6 +98,12 @@ mod config { /// Initial Min Burn. #[pallet::constant] type InitialMinBurn: Get; + /// Min burn upper bound. + #[pallet::constant] + type MinBurnUpperBound: Get; + /// Max burn lower bound. + #[pallet::constant] + type MaxBurnLowerBound: Get; /// Initial adjustment interval. #[pallet::constant] type InitialAdjustmentInterval: Get; From 4763b867cdc797a9212792b7526f25617ac1cdd7 Mon Sep 17 00:00:00 2001 From: Greg Zaitsev Date: Tue, 2 Sep 2025 10:49:00 -0400 Subject: [PATCH 065/147] Fix wrong way ensure for min value --- pallets/admin-utils/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index babcfb1225..2587eada62 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -680,7 +680,7 @@ pub mod pallet { ); // Min burn must be less than max burn ensure!( - min_burn > pallet_subtensor::Pallet::::get_max_burn(netuid), + min_burn <= pallet_subtensor::Pallet::::get_max_burn(netuid), Error::::ValueNotInBounds ); pallet_subtensor::Pallet::::set_min_burn(netuid, min_burn); @@ -712,7 +712,7 @@ pub mod pallet { ); // Max burn must be greater than min burn ensure!( - max_burn > pallet_subtensor::Pallet::::get_min_burn(netuid), + max_burn >= pallet_subtensor::Pallet::::get_min_burn(netuid), Error::::ValueNotInBounds ); pallet_subtensor::Pallet::::set_max_burn(netuid, max_burn); From c60f7d8e33850e571ea473db7b8cb61747a3de04 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 2 Sep 2025 14:49:01 +0000 Subject: [PATCH 066/147] auto-update benchmark weights --- pallets/subtensor/src/macros/dispatches.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 46b4aaf92b..d59b0415d0 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -120,9 +120,9 @@ mod dispatches { /// - On failure for each failed item in the batch. /// #[pallet::call_index(80)] - #[pallet::weight((Weight::from_parts(19_330_000, 0) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(0_u64)), DispatchClass::Normal, Pays::No))] + #[pallet::weight((Weight::from_parts(94_280_000, 0) + .saturating_add(T::DbWeight::get().reads(14_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)), DispatchClass::Normal, Pays::No))] pub fn batch_set_weights( origin: OriginFor, netuids: Vec>, From b10087d3303e0f1a5ccb2661c9c988b493029564 Mon Sep 17 00:00:00 2001 From: open-junius Date: Tue, 2 Sep 2025 22:52:20 +0800 Subject: [PATCH 067/147] fix conflict --- pallets/admin-utils/src/lib.rs | 35 ++++--------------- .../subtensor/src/coinbase/run_coinbase.rs | 9 ++--- pallets/subtensor/src/staking/helpers.rs | 6 ++++ 3 files changed, 18 insertions(+), 32 deletions(-) diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index 2587eada62..0a183fcea1 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -107,8 +107,6 @@ pub mod pallet { BondsMovingAverageMaxReached, /// Only root can set negative sigmoid steepness values NegativeSigmoidSteepness, - /// Value not in allowed bounds. - ValueNotInBounds, } /// Enum for specifying the type of precompile operation. #[derive( @@ -667,22 +665,12 @@ pub mod pallet { netuid: NetUid, min_burn: TaoCurrency, ) -> DispatchResult { - pallet_subtensor::Pallet::::ensure_subnet_owner_or_root(origin.clone(), netuid)?; - // Allow set min_burn but only up to 1 TAO for spamming. + ensure_root(origin)?; + ensure!( pallet_subtensor::Pallet::::if_subnet_exist(netuid), Error::::SubnetDoesNotExist ); - // Min burn must be less than 1 TAO. - ensure!( - min_burn < TaoCurrency::from(1_000_000_000), - Error::::ValueNotInBounds - ); - // Min burn must be less than max burn - ensure!( - min_burn <= pallet_subtensor::Pallet::::get_max_burn(netuid), - Error::::ValueNotInBounds - ); pallet_subtensor::Pallet::::set_min_burn(netuid, min_burn); log::debug!("MinBurnSet( netuid: {netuid:?} min_burn: {min_burn:?} ) "); Ok(()) @@ -700,21 +688,12 @@ pub mod pallet { netuid: NetUid, max_burn: TaoCurrency, ) -> DispatchResult { - pallet_subtensor::Pallet::::ensure_subnet_owner_or_root(origin.clone(), netuid)?; + ensure_root(origin)?; + ensure!( pallet_subtensor::Pallet::::if_subnet_exist(netuid), Error::::SubnetDoesNotExist ); - // Max burn must be greater than 0.1 TAO. - ensure!( - max_burn > TaoCurrency::from(100_000_000), - Error::::ValueNotInBounds - ); - // Max burn must be greater than min burn - ensure!( - max_burn >= pallet_subtensor::Pallet::::get_min_burn(netuid), - Error::::ValueNotInBounds - ); pallet_subtensor::Pallet::::set_max_burn(netuid, max_burn); log::debug!("MaxBurnSet( netuid: {netuid:?} max_burn: {max_burn:?} ) "); Ok(()) @@ -1704,9 +1683,9 @@ pub mod pallet { Ok(()) } - /// The extrinsic sets the difficulty for a subnet. - /// It is only callable by the root account or subnet owner. - /// The extrinsic will call the Subtensor pallet to set the difficulty. + /// Sets the childkey burn for a subnet. + /// It is only callable by the root account. + /// The extrinsic will call the Subtensor pallet to set the childkey burn. #[pallet::call_index(73)] #[pallet::weight(Weight::from_parts(15_650_000, 0) .saturating_add(::DbWeight::get().reads(1_u64)) diff --git a/pallets/subtensor/src/coinbase/run_coinbase.rs b/pallets/subtensor/src/coinbase/run_coinbase.rs index c029f0ed13..0379494710 100644 --- a/pallets/subtensor/src/coinbase/run_coinbase.rs +++ b/pallets/subtensor/src/coinbase/run_coinbase.rs @@ -828,10 +828,11 @@ impl Pallet { parent_emission = parent_emission.saturating_sub(burn_take); parent_emission = parent_emission.saturating_sub(child_take); total_child_take = total_child_take.saturating_add(child_take); - SubnetAlphaOut::::mutate(netuid, |total| { - *total = total - .saturating_sub(AlphaCurrency::from(burn_take.saturating_to_num::())); - }); + + Self::burn_subnet_alpha( + netuid, + AlphaCurrency::from(burn_take.saturating_to_num::()), + ); }; log::debug!("burn_takee: {burn_take:?} for hotkey {hotkey:?}"); log::debug!("child_take: {child_take:?} for hotkey {hotkey:?}"); diff --git a/pallets/subtensor/src/staking/helpers.rs b/pallets/subtensor/src/staking/helpers.rs index 3f07115b7b..c89a762f91 100644 --- a/pallets/subtensor/src/staking/helpers.rs +++ b/pallets/subtensor/src/staking/helpers.rs @@ -321,4 +321,10 @@ impl Pallet { pub fn is_user_liquidity_enabled(netuid: NetUid) -> bool { T::SwapInterface::is_user_liquidity_enabled(netuid) } + + pub fn burn_subnet_alpha(netuid: NetUid, amount: AlphaCurrency) { + SubnetAlphaOut::::mutate(netuid, |total| { + *total = total.saturating_sub(amount); + }); + } } From 17acaae18c172bb199d015e8d369e4126e3ef20d Mon Sep 17 00:00:00 2001 From: open-junius Date: Tue, 2 Sep 2025 23:09:07 +0800 Subject: [PATCH 068/147] default ck burn --- pallets/subtensor/src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index 35435c8a83..057126e13e 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -867,6 +867,12 @@ pub mod pallet { 50400 } + #[pallet::type_value] + /// Default value for ck burn, 18%. + pub fn DefaultCKBurn() -> u64 { + u64::MAX / 18 + } + #[pallet::storage] pub type MinActivityCutoff = StorageValue<_, u16, ValueQuery, DefaultMinActivityCutoff>; @@ -921,7 +927,7 @@ pub mod pallet { pub type TaoWeight = StorageValue<_, u64, ValueQuery, DefaultTaoWeight>; #[pallet::storage] /// --- ITEM --> CK burn - pub type CKBurn = StorageValue<_, u64, ValueQuery, DefaultZeroU64>; + pub type CKBurn = StorageValue<_, u64, ValueQuery, DefaultCKBurn>; #[pallet::storage] /// --- ITEM ( default_delegate_take ) pub type MaxDelegateTake = StorageValue<_, u16, ValueQuery, DefaultDelegateTake>; From 596bd6bda480de0a077b3637584444c5c7b2fc44 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Tue, 2 Sep 2025 12:13:47 -0300 Subject: [PATCH 069/147] fix missing params to configs --- pallets/subtensor/src/tests/mock.rs | 4 ++++ pallets/transaction-fee/src/tests/mock.rs | 4 ++++ runtime/src/lib.rs | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/pallets/subtensor/src/tests/mock.rs b/pallets/subtensor/src/tests/mock.rs index 8aa6fe6cdd..5ade0da02e 100644 --- a/pallets/subtensor/src/tests/mock.rs +++ b/pallets/subtensor/src/tests/mock.rs @@ -183,6 +183,8 @@ parameter_types! { pub const InitialBurn: u64 = 0; pub const InitialMinBurn: u64 = 500_000; pub const InitialMaxBurn: u64 = 1_000_000_000; + pub const MinBurnUpperBound: TaoCurrency = TaoCurrency::new(1_000_000_000); // 1 TAO + pub const MaxBurnLowerBound: TaoCurrency = TaoCurrency::new(100_000_000); // 0.1 TAO pub const InitialValidatorPruneLen: u64 = 0; pub const InitialScalingLawPower: u16 = 50; pub const InitialMaxAllowedValidators: u16 = 100; @@ -429,6 +431,8 @@ impl crate::Config for Test { type InitialBurn = InitialBurn; type InitialMaxBurn = InitialMaxBurn; type InitialMinBurn = InitialMinBurn; + type MinBurnUpperBound = MinBurnUpperBound; + type MaxBurnLowerBound = MaxBurnLowerBound; type InitialRAORecycledForRegistration = InitialRAORecycledForRegistration; type InitialSenateRequiredStakePercentage = InitialSenateRequiredStakePercentage; type InitialNetworkImmunityPeriod = InitialNetworkImmunityPeriod; diff --git a/pallets/transaction-fee/src/tests/mock.rs b/pallets/transaction-fee/src/tests/mock.rs index c2f5caa432..3248c45e60 100644 --- a/pallets/transaction-fee/src/tests/mock.rs +++ b/pallets/transaction-fee/src/tests/mock.rs @@ -175,6 +175,8 @@ parameter_types! { pub const InitialBurn: u64 = 0; pub const InitialMinBurn: u64 = 500_000; pub const InitialMaxBurn: u64 = 1_000_000_000; + pub const MinBurnUpperBound: TaoCurrency = TaoCurrency::new(1_000_000_000); // 1 TAO + pub const MaxBurnLowerBound: TaoCurrency = TaoCurrency::new(100_000_000); // 0.1 TAO pub const InitialValidatorPruneLen: u64 = 0; pub const InitialScalingLawPower: u16 = 50; pub const InitialMaxAllowedValidators: u16 = 100; @@ -263,6 +265,8 @@ impl pallet_subtensor::Config for Test { type InitialBurn = InitialBurn; type InitialMaxBurn = InitialMaxBurn; type InitialMinBurn = InitialMinBurn; + type MinBurnUpperBound = MinBurnUpperBound; + type MaxBurnLowerBound = MaxBurnLowerBound; type InitialRAORecycledForRegistration = InitialRAORecycledForRegistration; type InitialSenateRequiredStakePercentage = InitialSenateRequiredStakePercentage; type InitialNetworkImmunityPeriod = InitialNetworkImmunityPeriod; diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 00cc24b411..6f76396d3f 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -1137,6 +1137,8 @@ parameter_types! { pub const SubtensorInitialBurn: u64 = 100_000_000; // 0.1 tao pub const SubtensorInitialMinBurn: u64 = 500_000; // 500k RAO pub const SubtensorInitialMaxBurn: u64 = 100_000_000_000; // 100 tao + pub const MinBurnUpperBound: TaoCurrency = TaoCurrency::new(1_000_000_000); // 1 TAO + pub const MaxBurnLowerBound: TaoCurrency = TaoCurrency::new(100_000_000); // 0.1 TAO pub const SubtensorInitialTxRateLimit: u64 = 1000; pub const SubtensorInitialTxDelegateTakeRateLimit: u64 = 216000; // 30 days at 12 seconds per block pub const SubtensorInitialTxChildKeyTakeRateLimit: u64 = INITIAL_CHILDKEY_TAKE_RATELIMIT; @@ -1210,6 +1212,8 @@ impl pallet_subtensor::Config for Runtime { type InitialBurn = SubtensorInitialBurn; type InitialMaxBurn = SubtensorInitialMaxBurn; type InitialMinBurn = SubtensorInitialMinBurn; + type MinBurnUpperBound = MinBurnUpperBound; + type MaxBurnLowerBound = MaxBurnLowerBound; type InitialTxRateLimit = SubtensorInitialTxRateLimit; type InitialTxDelegateTakeRateLimit = SubtensorInitialTxDelegateTakeRateLimit; type InitialTxChildKeyTakeRateLimit = SubtensorInitialTxChildKeyTakeRateLimit; From ae25b5f53d11cdf6db6e8a2c1c16eb805886568b Mon Sep 17 00:00:00 2001 From: open-junius Date: Tue, 2 Sep 2025 23:19:10 +0800 Subject: [PATCH 070/147] bump version --- pallets/subtensor/src/coinbase/run_coinbase.rs | 1 + runtime/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pallets/subtensor/src/coinbase/run_coinbase.rs b/pallets/subtensor/src/coinbase/run_coinbase.rs index 0379494710..b026f73988 100644 --- a/pallets/subtensor/src/coinbase/run_coinbase.rs +++ b/pallets/subtensor/src/coinbase/run_coinbase.rs @@ -862,6 +862,7 @@ impl Pallet { // Add the hotkey's own emission to the distribution list dividend_tuples.push((hotkey.clone(), child_emission)); + dividend_tuples } diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 00cc24b411..679e5e55b2 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: 307, + spec_version: 308, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From 1e0f8e5c97864a06e4dc1eeda417158ebf44ee78 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Tue, 2 Sep 2025 12:32:16 -0300 Subject: [PATCH 071/147] cargo fmt --- pallets/admin-utils/src/tests/mod.rs | 130 ++++++++++++++++----------- 1 file changed, 77 insertions(+), 53 deletions(-) diff --git a/pallets/admin-utils/src/tests/mod.rs b/pallets/admin-utils/src/tests/mod.rs index 37d5f37300..c8efd1066f 100644 --- a/pallets/admin-utils/src/tests/mod.rs +++ b/pallets/admin-utils/src/tests/mod.rs @@ -1959,7 +1959,7 @@ fn test_sudo_set_min_burn() { let to_be_set = TaoCurrency::from(1_000_000); add_network(netuid, 10); let init_value = SubtensorModule::get_min_burn(netuid); - + // Simple case assert_ok!(AdminUtils::sudo_set_min_burn( <::RuntimeOrigin>::root(), @@ -1968,45 +1968,57 @@ fn test_sudo_set_min_burn() { )); assert_ne!(SubtensorModule::get_min_burn(netuid), init_value); assert_eq!(SubtensorModule::get_min_burn(netuid), to_be_set); - + // Unknown subnet - assert_err!(AdminUtils::sudo_set_min_burn( - <::RuntimeOrigin>::root(), - NetUid::from(42), - TaoCurrency::from(to_be_set) - ), Error::::SubnetDoesNotExist); + assert_err!( + AdminUtils::sudo_set_min_burn( + <::RuntimeOrigin>::root(), + NetUid::from(42), + TaoCurrency::from(to_be_set) + ), + Error::::SubnetDoesNotExist + ); // Non subnet owner - assert_err!(AdminUtils::sudo_set_min_burn( - <::RuntimeOrigin>::signed(U256::from(1)), - netuid, - TaoCurrency::from(to_be_set) - ), DispatchError::BadOrigin); - + assert_err!( + AdminUtils::sudo_set_min_burn( + <::RuntimeOrigin>::signed(U256::from(1)), + netuid, + TaoCurrency::from(to_be_set) + ), + DispatchError::BadOrigin + ); + // Above upper bound - assert_err!(AdminUtils::sudo_set_min_burn( - <::RuntimeOrigin>::root(), - netuid, - ::MinBurnUpperBound::get() + 1.into() - ), Error::::ValueNotInBounds); - - // Above max burn - assert_err!(AdminUtils::sudo_set_min_burn( - <::RuntimeOrigin>::root(), - netuid, - SubtensorModule::get_max_burn(netuid) + 1.into() - ), Error::::ValueNotInBounds); + assert_err!( + AdminUtils::sudo_set_min_burn( + <::RuntimeOrigin>::root(), + netuid, + ::MinBurnUpperBound::get() + 1.into() + ), + Error::::ValueNotInBounds + ); + + // Above max burn + assert_err!( + AdminUtils::sudo_set_min_burn( + <::RuntimeOrigin>::root(), + netuid, + SubtensorModule::get_max_burn(netuid) + 1.into() + ), + Error::::ValueNotInBounds + ); }); } #[test] fn test_sudo_set_max_burn() { - new_test_ext().execute_with(|| { + new_test_ext().execute_with(|| { let netuid = NetUid::from(1); let to_be_set = TaoCurrency::from(100_000_001); add_network(netuid, 10); let init_value = SubtensorModule::get_max_burn(netuid); - + // Simple case assert_ok!(AdminUtils::sudo_set_max_burn( <::RuntimeOrigin>::root(), @@ -2015,33 +2027,45 @@ fn test_sudo_set_max_burn() { )); assert_ne!(SubtensorModule::get_max_burn(netuid), init_value); assert_eq!(SubtensorModule::get_max_burn(netuid), to_be_set); - + // Unknown subnet - assert_err!(AdminUtils::sudo_set_max_burn( - <::RuntimeOrigin>::root(), - NetUid::from(42), - TaoCurrency::from(to_be_set) - ), Error::::SubnetDoesNotExist); - + assert_err!( + AdminUtils::sudo_set_max_burn( + <::RuntimeOrigin>::root(), + NetUid::from(42), + TaoCurrency::from(to_be_set) + ), + Error::::SubnetDoesNotExist + ); + // Non subnet owner - assert_err!(AdminUtils::sudo_set_max_burn( - <::RuntimeOrigin>::signed(U256::from(1)), - netuid, - TaoCurrency::from(to_be_set) - ), DispatchError::BadOrigin); - + assert_err!( + AdminUtils::sudo_set_max_burn( + <::RuntimeOrigin>::signed(U256::from(1)), + netuid, + TaoCurrency::from(to_be_set) + ), + DispatchError::BadOrigin + ); + // Below lower bound - assert_err!(AdminUtils::sudo_set_max_burn( - <::RuntimeOrigin>::root(), - netuid, - ::MaxBurnLowerBound::get() - 1.into() - ), Error::::ValueNotInBounds); - - // Below min burn - assert_err!(AdminUtils::sudo_set_max_burn( - <::RuntimeOrigin>::root(), - netuid, - SubtensorModule::get_min_burn(netuid) - 1.into() - ), Error::::ValueNotInBounds); + assert_err!( + AdminUtils::sudo_set_max_burn( + <::RuntimeOrigin>::root(), + netuid, + ::MaxBurnLowerBound::get() - 1.into() + ), + Error::::ValueNotInBounds + ); + + // Below min burn + assert_err!( + AdminUtils::sudo_set_max_burn( + <::RuntimeOrigin>::root(), + netuid, + SubtensorModule::get_min_burn(netuid) - 1.into() + ), + Error::::ValueNotInBounds + ); }); -} \ No newline at end of file +} From f08bc1ea5d448493b1161afc808423e07c5a11ed Mon Sep 17 00:00:00 2001 From: open-junius Date: Wed, 3 Sep 2025 00:15:46 +0800 Subject: [PATCH 072/147] fix unit tests --- pallets/subtensor/src/tests/children.rs | 5 +++++ pallets/subtensor/src/tests/coinbase.rs | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/pallets/subtensor/src/tests/children.rs b/pallets/subtensor/src/tests/children.rs index 2ffc21ea1d..a0505fa9f3 100644 --- a/pallets/subtensor/src/tests/children.rs +++ b/pallets/subtensor/src/tests/children.rs @@ -2861,6 +2861,7 @@ fn test_childkey_take_drain() { // Add network, register hotkeys, and setup network parameters add_network(netuid, subnet_tempo, 0); + SubtensorModule::set_ck_burn(0); mock::setup_reserves(netuid, (stake * 10_000).into(), (stake * 10_000).into()); register_ok_neuron(netuid, child_hotkey, child_coldkey, 0); register_ok_neuron(netuid, parent_hotkey, parent_coldkey, 1); @@ -2980,6 +2981,7 @@ fn test_parent_child_chain_emission() { let subnet_owner_coldkey = U256::from(1001); let subnet_owner_hotkey = U256::from(1002); let netuid = add_dynamic_network(&subnet_owner_hotkey, &subnet_owner_coldkey); + SubtensorModule::set_ck_burn(0); Tempo::::insert(netuid, 1); // Setup large LPs to prevent slippage @@ -3192,6 +3194,7 @@ fn test_parent_child_chain_epoch() { new_test_ext(1).execute_with(|| { let netuid = NetUid::from(1); add_network(netuid, 1, 0); + SubtensorModule::set_ck_burn(0); // Set owner cut to 0 SubtensorModule::set_subnet_owner_cut(0_u16); @@ -3336,6 +3339,7 @@ fn test_dividend_distribution_with_children() { new_test_ext(1).execute_with(|| { let netuid = NetUid::from(1); add_network(netuid, 1, 0); + SubtensorModule::set_ck_burn(0); mock::setup_reserves( netuid, 1_000_000_000_000_000.into(), @@ -3570,6 +3574,7 @@ fn test_dividend_distribution_with_children() { fn test_dynamic_parent_child_relationships() { new_test_ext(1).execute_with(|| { let netuid = NetUid::from(1); + SubtensorModule::set_ck_burn(0); add_network_disable_commit_reveal(netuid, 1, 0); // Define hotkeys and coldkeys diff --git a/pallets/subtensor/src/tests/coinbase.rs b/pallets/subtensor/src/tests/coinbase.rs index 927f98e2fa..5b0f7316b0 100644 --- a/pallets/subtensor/src/tests/coinbase.rs +++ b/pallets/subtensor/src/tests/coinbase.rs @@ -1063,6 +1063,7 @@ fn test_drain_alpha_childkey_parentkey() { new_test_ext(1).execute_with(|| { let netuid = NetUid::from(1); add_network(netuid, 1, 0); + SubtensorModule::set_ck_burn(0); let parent = U256::from(1); let child = U256::from(2); let coldkey = U256::from(3); @@ -1238,6 +1239,7 @@ fn test_get_root_children_drain() { let alpha = NetUid::from(1); add_network(NetUid::ROOT, 1, 0); add_network(alpha, 1, 0); + SubtensorModule::set_ck_burn(0); // Set TAO weight to 1. SubtensorModule::set_tao_weight(u64::MAX); // Set TAO weight to 1. // Create keys. @@ -1399,6 +1401,7 @@ fn test_get_root_children_drain_half_proportion() { let alpha = NetUid::from(1); add_network(NetUid::ROOT, 1, 0); add_network(alpha, 1, 0); + SubtensorModule::set_ck_burn(0); // Set TAO weight to 1. SubtensorModule::set_tao_weight(u64::MAX); // Set TAO weight to 1. // Create keys. @@ -1576,6 +1579,7 @@ fn test_get_root_children_drain_with_half_take() { add_network(alpha, 1, 0); // Set TAO weight to 1. SubtensorModule::set_tao_weight(u64::MAX); // Set TAO weight to 1. + SubtensorModule::set_ck_burn(0); // Create keys. let cold_alice = U256::from(0); let cold_bob = U256::from(1); From 2451f18b36e7cc38a62ab5038b670344280fb80c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 2 Sep 2025 18:12:34 +0000 Subject: [PATCH 073/147] auto-update benchmark weights --- pallets/subtensor/src/macros/dispatches.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index aed0c150de..6c89dfcfca 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -120,9 +120,9 @@ mod dispatches { /// - On failure for each failed item in the batch. /// #[pallet::call_index(80)] - #[pallet::weight((Weight::from_parts(95_160_000, 0) - .saturating_add(T::DbWeight::get().reads(14)) - .saturating_add(T::DbWeight::get().writes(2)), DispatchClass::Normal, Pays::No))] + #[pallet::weight((Weight::from_parts(19_010_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(0_u64)), DispatchClass::Normal, Pays::No))] pub fn batch_set_weights( origin: OriginFor, netuids: Vec>, From 9e1caa5a85c1ba82310b4b8689d404879d17f0b3 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Tue, 2 Sep 2025 16:19:30 -0300 Subject: [PATCH 074/147] fix failing benchmark --- pallets/admin-utils/src/benchmarking.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/admin-utils/src/benchmarking.rs b/pallets/admin-utils/src/benchmarking.rs index 61df5d55f8..4d2ac21045 100644 --- a/pallets/admin-utils/src/benchmarking.rs +++ b/pallets/admin-utils/src/benchmarking.rs @@ -266,7 +266,7 @@ mod benchmarks { ); #[extrinsic_call] - _(RawOrigin::Root, 1u16.into()/*netuid*/, 10.into()/*max_burn*/)/*sudo_set_max_burn*/; + _(RawOrigin::Root, 1u16.into()/*netuid*/, 2_000_000_000.into()/*max_burn*/)/*sudo_set_max_burn*/; } #[benchmark] From 96c70a2a8910e8a7e31929d8bc1b172019490f07 Mon Sep 17 00:00:00 2001 From: Greg Zaitsev Date: Tue, 2 Sep 2025 15:58:39 -0400 Subject: [PATCH 075/147] Fix fee bypass issue --- pallets/subtensor/src/staking/add_stake.rs | 11 ++++++- pallets/subtensor/src/staking/move_stake.rs | 7 ++++- pallets/subtensor/src/staking/remove_stake.rs | 1 + pallets/subtensor/src/staking/stake_utils.rs | 3 +- pallets/subtensor/src/tests/mock.rs | 1 + pallets/subtensor/src/tests/move_stake.rs | 29 +++++++++++++++++++ pallets/subtensor/src/tests/staking.rs | 6 ++++ 7 files changed, 55 insertions(+), 3 deletions(-) diff --git a/pallets/subtensor/src/staking/add_stake.rs b/pallets/subtensor/src/staking/add_stake.rs index fe90de270a..740d42d09e 100644 --- a/pallets/subtensor/src/staking/add_stake.rs +++ b/pallets/subtensor/src/staking/add_stake.rs @@ -76,6 +76,7 @@ impl Pallet { tao_staked.saturating_to_num::().into(), T::SwapInterface::max_price().into(), true, + false, )?; // Ok and return. @@ -164,7 +165,15 @@ impl Pallet { // 6. Swap the stake into alpha on the subnet and increase counters. // Emit the staking event. - Self::stake_into_subnet(&hotkey, &coldkey, netuid, tao_staked, limit_price, true)?; + Self::stake_into_subnet( + &hotkey, + &coldkey, + netuid, + tao_staked, + limit_price, + true, + false, + )?; // Ok and return. Ok(()) diff --git a/pallets/subtensor/src/staking/move_stake.rs b/pallets/subtensor/src/staking/move_stake.rs index c81569e49d..589da2b4b8 100644 --- a/pallets/subtensor/src/staking/move_stake.rs +++ b/pallets/subtensor/src/staking/move_stake.rs @@ -350,6 +350,10 @@ impl Pallet { }; if origin_netuid != destination_netuid { + // Any way to charge fees that works + let drop_fee_origin = origin_netuid == NetUid::ROOT; + let drop_fee_destination = !drop_fee_origin; + // do not pay remove fees to avoid double fees in moves transactions let tao_unstaked = Self::unstake_from_subnet( origin_hotkey, @@ -357,7 +361,7 @@ impl Pallet { origin_netuid, move_amount, T::SwapInterface::min_price().into(), - true, + drop_fee_origin, )?; // Stake the unstaked amount into the destination. @@ -376,6 +380,7 @@ impl Pallet { tao_unstaked, T::SwapInterface::max_price().into(), set_limit, + drop_fee_destination, )?; } diff --git a/pallets/subtensor/src/staking/remove_stake.rs b/pallets/subtensor/src/staking/remove_stake.rs index c0311f7f33..fd9a974645 100644 --- a/pallets/subtensor/src/staking/remove_stake.rs +++ b/pallets/subtensor/src/staking/remove_stake.rs @@ -281,6 +281,7 @@ impl Pallet { total_tao_unstaked, T::SwapInterface::max_price().into(), false, // no limit for Root subnet + false, )?; // 5. Done and ok. diff --git a/pallets/subtensor/src/staking/stake_utils.rs b/pallets/subtensor/src/staking/stake_utils.rs index 8dff984099..a44eb67afd 100644 --- a/pallets/subtensor/src/staking/stake_utils.rs +++ b/pallets/subtensor/src/staking/stake_utils.rs @@ -767,9 +767,10 @@ impl Pallet { tao: TaoCurrency, price_limit: TaoCurrency, set_limit: bool, + drop_fees: bool, ) -> Result { // Swap the tao to alpha. - let swap_result = Self::swap_tao_for_alpha(netuid, tao, price_limit, false)?; + let swap_result = Self::swap_tao_for_alpha(netuid, tao, price_limit, drop_fees)?; ensure!(swap_result.amount_paid_out > 0, Error::::AmountTooLow); diff --git a/pallets/subtensor/src/tests/mock.rs b/pallets/subtensor/src/tests/mock.rs index 8aa6fe6cdd..4d99c80d6e 100644 --- a/pallets/subtensor/src/tests/mock.rs +++ b/pallets/subtensor/src/tests/mock.rs @@ -965,6 +965,7 @@ pub fn increase_stake_on_coldkey_hotkey_account( tao_staked, ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); } diff --git a/pallets/subtensor/src/tests/move_stake.rs b/pallets/subtensor/src/tests/move_stake.rs index 46f2a77e27..e49903aa86 100644 --- a/pallets/subtensor/src/tests/move_stake.rs +++ b/pallets/subtensor/src/tests/move_stake.rs @@ -35,6 +35,7 @@ fn test_do_move_success() { stake_amount, ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); let alpha = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( @@ -111,6 +112,7 @@ fn test_do_move_different_subnets() { stake_amount.into(), ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); let alpha = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( @@ -180,6 +182,7 @@ fn test_do_move_nonexistent_subnet() { stake_amount.into(), ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); let alpha = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( @@ -283,6 +286,7 @@ fn test_do_move_nonexistent_destination_hotkey() { stake_amount.into(), ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); @@ -347,6 +351,7 @@ fn test_do_move_partial_stake() { total_stake.into(), ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); let alpha = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( @@ -415,6 +420,7 @@ fn test_do_move_multiple_times() { initial_stake.into(), ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); let alpha = @@ -486,6 +492,7 @@ fn test_do_move_wrong_origin() { stake_amount.into(), ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); let alpha = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( @@ -552,6 +559,7 @@ fn test_do_move_same_hotkey_fails() { stake_amount.into(), ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); let alpha = @@ -602,6 +610,7 @@ fn test_do_move_event_emission() { stake_amount.into(), ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); let alpha = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( @@ -662,6 +671,7 @@ fn test_do_move_storage_updates() { stake_amount.into(), ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); @@ -728,6 +738,7 @@ fn test_move_full_amount_same_netuid() { stake_amount.into(), ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); @@ -795,6 +806,7 @@ fn test_do_move_max_values() { max_stake.into(), ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); let alpha = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( @@ -900,6 +912,7 @@ fn test_do_transfer_success() { stake_amount.into(), ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); let alpha = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( @@ -1008,6 +1021,7 @@ fn test_do_transfer_insufficient_stake() { stake_amount.into(), ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); @@ -1048,6 +1062,7 @@ fn test_do_transfer_wrong_origin() { stake_amount.into(), ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); @@ -1085,6 +1100,7 @@ fn test_do_transfer_minimum_stake_check() { stake_amount, ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); @@ -1132,6 +1148,7 @@ fn test_do_transfer_different_subnets() { stake_amount.into(), ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); @@ -1197,6 +1214,7 @@ fn test_do_swap_success() { stake_amount.into(), ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); let alpha_before = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( @@ -1304,6 +1322,7 @@ fn test_do_swap_insufficient_stake() { stake_amount.into(), ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); @@ -1338,6 +1357,7 @@ fn test_do_swap_wrong_origin() { stake_amount.into(), ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); @@ -1375,6 +1395,7 @@ fn test_do_swap_minimum_stake_check() { total_stake, ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); @@ -1410,6 +1431,7 @@ fn test_do_swap_same_subnet() { stake_amount.into(), ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); @@ -1454,6 +1476,7 @@ fn test_do_swap_partial_stake() { total_stake_tao.into(), ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); let total_stake_alpha = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( @@ -1505,6 +1528,7 @@ fn test_do_swap_storage_updates() { stake_amount.into(), ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); @@ -1564,6 +1588,7 @@ fn test_do_swap_multiple_times() { initial_stake.into(), ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); @@ -1634,6 +1659,7 @@ fn test_do_swap_allows_non_owned_hotkey() { stake_amount.into(), ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); let alpha_before = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( @@ -1781,6 +1807,7 @@ fn test_transfer_stake_rate_limited() { stake_amount.into(), ::SwapInterface::max_price().into(), true, + false, ) .unwrap(); let alpha = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( @@ -1825,6 +1852,7 @@ fn test_transfer_stake_doesnt_limit_destination_coldkey() { stake_amount.into(), ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); let alpha = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( @@ -1870,6 +1898,7 @@ fn test_swap_stake_limits_destination_netuid() { stake_amount.into(), ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); let alpha = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet( diff --git a/pallets/subtensor/src/tests/staking.rs b/pallets/subtensor/src/tests/staking.rs index 8345d24fff..38895348cc 100644 --- a/pallets/subtensor/src/tests/staking.rs +++ b/pallets/subtensor/src/tests/staking.rs @@ -864,6 +864,7 @@ fn test_remove_stake_insufficient_liquidity() { amount_staked.into(), ::SwapInterface::max_price().into(), false, + false, ) .unwrap(); @@ -4481,6 +4482,7 @@ fn test_stake_into_subnet_ok() { amount.into(), TaoCurrency::MAX, false, + false, )); let fee_rate = pallet_subtensor_swap::FeeRate::::get(NetUid::from(netuid)) as f64 / u16::MAX as f64; @@ -4534,6 +4536,7 @@ fn test_stake_into_subnet_low_amount() { amount.into(), TaoCurrency::MAX, false, + false, )); let expected_stake = AlphaCurrency::from(((amount as f64) * 0.997 / current_price) as u64); @@ -4581,6 +4584,7 @@ fn test_unstake_from_subnet_low_amount() { amount.into(), TaoCurrency::MAX, false, + false, )); // Remove stake @@ -4694,6 +4698,7 @@ fn test_unstake_from_subnet_prohibitive_limit() { amount.into(), TaoCurrency::MAX, false, + false, )); // Remove stake @@ -4769,6 +4774,7 @@ fn test_unstake_full_amount() { amount.into(), TaoCurrency::MAX, false, + false, )); // Remove stake From c2e5300f698085bb4e77f8e5ae847d3d316df4a0 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Tue, 2 Sep 2025 17:16:54 -0300 Subject: [PATCH 076/147] try to fix evm e2e failure --- evm-tests/get-metadata.sh | 2 +- evm-tests/package.json | 15 +- evm-tests/run-ci.sh | 3 - evm-tests/yarn.lock | 1071 ++++++++++++++++++------------------- 4 files changed, 536 insertions(+), 555 deletions(-) diff --git a/evm-tests/get-metadata.sh b/evm-tests/get-metadata.sh index 6d7727009d..b99915ebac 100755 --- a/evm-tests/get-metadata.sh +++ b/evm-tests/get-metadata.sh @@ -1,3 +1,3 @@ rm -rf .papi -npx papi add devnet -w ws://localhost:9944 +npx -y polkadot-api add devnet -w ws://localhost:9944 diff --git a/evm-tests/package.json b/evm-tests/package.json index 9970967a88..ae756ae55f 100644 --- a/evm-tests/package.json +++ b/evm-tests/package.json @@ -7,15 +7,15 @@ "license": "ISC", "dependencies": { "@polkadot-api/descriptors": "file:.papi/descriptors", - "@polkadot-labs/hdkd": "^0.0.10", - "@polkadot-labs/hdkd-helpers": "^0.0.11", - "@polkadot/api": "15.1.1", + "@polkadot-labs/hdkd": "^0.0.23", + "@polkadot-labs/hdkd-helpers": "^0.0.23", + "@polkadot/api": "^16.4.6", "@types/mocha": "^10.0.10", - "crypto": "^1.0.1", - "dotenv": "16.4.7", + "dotenv": "17.2.1", "ethers": "^6.13.5", "mocha": "^11.1.0", "polkadot-api": "^1.9.5", + "rxjs": "^7.8.2", "scale-ts": "^1.6.1", "viem": "2.23.4", "ws": "^8.18.2" @@ -23,11 +23,12 @@ "devDependencies": { "@types/bun": "^1.1.13", "@types/chai": "^5.0.1", + "@types/node": "^22.18.0", "assert": "^2.1.0", - "chai": "^5.2.0", + "chai": "^6.0.1", "prettier": "^3.3.3", "ts-node": "^10.9.2", "typescript": "^5.7.2", - "vite": "^5.4.8" + "vite": "^7.1.4" } } diff --git a/evm-tests/run-ci.sh b/evm-tests/run-ci.sh index 7ad4bb2186..6315cf11f8 100755 --- a/evm-tests/run-ci.sh +++ b/evm-tests/run-ci.sh @@ -28,9 +28,6 @@ fi cd evm-tests -# required for papi in get-metadata.sh, but we cannot run yarn before papi as it adds the descriptors to the package.json which won't resolve -npm i -g polkadot-api - bash get-metadata.sh sleep 5 diff --git a/evm-tests/yarn.lock b/evm-tests/yarn.lock index 38c4c5bde2..678576deb6 100644 --- a/evm-tests/yarn.lock +++ b/evm-tests/yarn.lock @@ -38,171 +38,86 @@ dependencies: "@jridgewell/trace-mapping" "0.3.9" -"@esbuild/aix-ppc64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz#c7184a326533fcdf1b8ee0733e21c713b975575f" - integrity sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ== - "@esbuild/aix-ppc64@0.25.5": version "0.25.5" resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.25.5.tgz#4e0f91776c2b340e75558f60552195f6fad09f18" integrity sha512-9o3TMmpmftaCMepOdA5k/yDw8SfInyzWWTjYTFCX3kPSDJMROQTb8jg+h9Cnwnmm1vOzvxN7gIfB5V2ewpjtGA== -"@esbuild/android-arm64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz#09d9b4357780da9ea3a7dfb833a1f1ff439b4052" - integrity sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A== - "@esbuild/android-arm64@0.25.5": version "0.25.5" resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.25.5.tgz#bc766407f1718923f6b8079c8c61bf86ac3a6a4f" integrity sha512-VGzGhj4lJO+TVGV1v8ntCZWJktV7SGCs3Pn1GRWI1SBFtRALoomm8k5E9Pmwg3HOAal2VDc2F9+PM/rEY6oIDg== -"@esbuild/android-arm@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.21.5.tgz#9b04384fb771926dfa6d7ad04324ecb2ab9b2e28" - integrity sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg== - "@esbuild/android-arm@0.25.5": version "0.25.5" resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.25.5.tgz#4290d6d3407bae3883ad2cded1081a234473ce26" integrity sha512-AdJKSPeEHgi7/ZhuIPtcQKr5RQdo6OO2IL87JkianiMYMPbCtot9fxPbrMiBADOWWm3T2si9stAiVsGbTQFkbA== -"@esbuild/android-x64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.21.5.tgz#29918ec2db754cedcb6c1b04de8cd6547af6461e" - integrity sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA== - "@esbuild/android-x64@0.25.5": version "0.25.5" resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.25.5.tgz#40c11d9cbca4f2406548c8a9895d321bc3b35eff" integrity sha512-D2GyJT1kjvO//drbRT3Hib9XPwQeWd9vZoBJn+bu/lVsOZ13cqNdDeqIF/xQ5/VmWvMduP6AmXvylO/PIc2isw== -"@esbuild/darwin-arm64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz#e495b539660e51690f3928af50a76fb0a6ccff2a" - integrity sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ== - "@esbuild/darwin-arm64@0.25.5": version "0.25.5" resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.25.5.tgz#49d8bf8b1df95f759ac81eb1d0736018006d7e34" integrity sha512-GtaBgammVvdF7aPIgH2jxMDdivezgFu6iKpmT+48+F8Hhg5J/sfnDieg0aeG/jfSvkYQU2/pceFPDKlqZzwnfQ== -"@esbuild/darwin-x64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz#c13838fa57372839abdddc91d71542ceea2e1e22" - integrity sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw== - "@esbuild/darwin-x64@0.25.5": version "0.25.5" resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.25.5.tgz#e27a5d92a14886ef1d492fd50fc61a2d4d87e418" integrity sha512-1iT4FVL0dJ76/q1wd7XDsXrSW+oLoquptvh4CLR4kITDtqi2e/xwXwdCVH8hVHU43wgJdsq7Gxuzcs6Iq/7bxQ== -"@esbuild/freebsd-arm64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz#646b989aa20bf89fd071dd5dbfad69a3542e550e" - integrity sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g== - "@esbuild/freebsd-arm64@0.25.5": version "0.25.5" resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.5.tgz#97cede59d638840ca104e605cdb9f1b118ba0b1c" integrity sha512-nk4tGP3JThz4La38Uy/gzyXtpkPW8zSAmoUhK9xKKXdBCzKODMc2adkB2+8om9BDYugz+uGV7sLmpTYzvmz6Sw== -"@esbuild/freebsd-x64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz#aa615cfc80af954d3458906e38ca22c18cf5c261" - integrity sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ== - "@esbuild/freebsd-x64@0.25.5": version "0.25.5" resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.25.5.tgz#71c77812042a1a8190c3d581e140d15b876b9c6f" integrity sha512-PrikaNjiXdR2laW6OIjlbeuCPrPaAl0IwPIaRv+SMV8CiM8i2LqVUHFC1+8eORgWyY7yhQY+2U2fA55mBzReaw== -"@esbuild/linux-arm64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz#70ac6fa14f5cb7e1f7f887bcffb680ad09922b5b" - integrity sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q== - "@esbuild/linux-arm64@0.25.5": version "0.25.5" resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.25.5.tgz#f7b7c8f97eff8ffd2e47f6c67eb5c9765f2181b8" integrity sha512-Z9kfb1v6ZlGbWj8EJk9T6czVEjjq2ntSYLY2cw6pAZl4oKtfgQuS4HOq41M/BcoLPzrUbNd+R4BXFyH//nHxVg== -"@esbuild/linux-arm@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz#fc6fd11a8aca56c1f6f3894f2bea0479f8f626b9" - integrity sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA== - "@esbuild/linux-arm@0.25.5": version "0.25.5" resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.25.5.tgz#2a0be71b6cd8201fa559aea45598dffabc05d911" integrity sha512-cPzojwW2okgh7ZlRpcBEtsX7WBuqbLrNXqLU89GxWbNt6uIg78ET82qifUy3W6OVww6ZWobWub5oqZOVtwolfw== -"@esbuild/linux-ia32@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz#3271f53b3f93e3d093d518d1649d6d68d346ede2" - integrity sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg== - "@esbuild/linux-ia32@0.25.5": version "0.25.5" resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.25.5.tgz#763414463cd9ea6fa1f96555d2762f9f84c61783" integrity sha512-sQ7l00M8bSv36GLV95BVAdhJ2QsIbCuCjh/uYrWiMQSUuV+LpXwIqhgJDcvMTj+VsQmqAHL2yYaasENvJ7CDKA== -"@esbuild/linux-loong64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz#ed62e04238c57026aea831c5a130b73c0f9f26df" - integrity sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg== - "@esbuild/linux-loong64@0.25.5": version "0.25.5" resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.25.5.tgz#428cf2213ff786a502a52c96cf29d1fcf1eb8506" integrity sha512-0ur7ae16hDUC4OL5iEnDb0tZHDxYmuQyhKhsPBV8f99f6Z9KQM02g33f93rNH5A30agMS46u2HP6qTdEt6Q1kg== -"@esbuild/linux-mips64el@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz#e79b8eb48bf3b106fadec1ac8240fb97b4e64cbe" - integrity sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg== - "@esbuild/linux-mips64el@0.25.5": version "0.25.5" resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.25.5.tgz#5cbcc7fd841b4cd53358afd33527cd394e325d96" integrity sha512-kB/66P1OsHO5zLz0i6X0RxlQ+3cu0mkxS3TKFvkb5lin6uwZ/ttOkP3Z8lfR9mJOBk14ZwZ9182SIIWFGNmqmg== -"@esbuild/linux-ppc64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz#5f2203860a143b9919d383ef7573521fb154c3e4" - integrity sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w== - "@esbuild/linux-ppc64@0.25.5": version "0.25.5" resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.25.5.tgz#0d954ab39ce4f5e50f00c4f8c4fd38f976c13ad9" integrity sha512-UZCmJ7r9X2fe2D6jBmkLBMQetXPXIsZjQJCjgwpVDz+YMcS6oFR27alkgGv3Oqkv07bxdvw7fyB71/olceJhkQ== -"@esbuild/linux-riscv64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz#07bcafd99322d5af62f618cb9e6a9b7f4bb825dc" - integrity sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA== - "@esbuild/linux-riscv64@0.25.5": version "0.25.5" resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.25.5.tgz#0e7dd30730505abd8088321e8497e94b547bfb1e" integrity sha512-kTxwu4mLyeOlsVIFPfQo+fQJAV9mh24xL+y+Bm6ej067sYANjyEw1dNHmvoqxJUCMnkBdKpvOn0Ahql6+4VyeA== -"@esbuild/linux-s390x@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz#b7ccf686751d6a3e44b8627ababc8be3ef62d8de" - integrity sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A== - "@esbuild/linux-s390x@0.25.5": version "0.25.5" resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.25.5.tgz#5669af81327a398a336d7e40e320b5bbd6e6e72d" integrity sha512-K2dSKTKfmdh78uJ3NcWFiqyRrimfdinS5ErLSn3vluHNeHVnBAFWC8a4X5N+7FgVE1EjXS1QDZbpqZBjfrqMTQ== -"@esbuild/linux-x64@0.21.5": - version "0.21.5" - resolved "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz" - integrity sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ== - "@esbuild/linux-x64@0.25.5": version "0.25.5" resolved "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.5.tgz" @@ -213,11 +128,6 @@ resolved "https://registry.yarnpkg.com/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.5.tgz#53b4dfb8fe1cee93777c9e366893bd3daa6ba63d" integrity sha512-pwHtMP9viAy1oHPvgxtOv+OkduK5ugofNTVDilIzBLpoWAM16r7b/mxBvfpuQDpRQFMfuVr5aLcn4yveGvBZvw== -"@esbuild/netbsd-x64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz#bbe430f60d378ecb88decb219c602667387a6047" - integrity sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg== - "@esbuild/netbsd-x64@0.25.5": version "0.25.5" resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.25.5.tgz#a0206f6314ce7dc8713b7732703d0f58de1d1e79" @@ -228,51 +138,26 @@ resolved "https://registry.yarnpkg.com/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.5.tgz#2a796c87c44e8de78001d808c77d948a21ec22fd" integrity sha512-7A208+uQKgTxHd0G0uqZO8UjK2R0DDb4fDmERtARjSHWxqMTye4Erz4zZafx7Di9Cv+lNHYuncAkiGFySoD+Mw== -"@esbuild/openbsd-x64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz#99d1cf2937279560d2104821f5ccce220cb2af70" - integrity sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow== - "@esbuild/openbsd-x64@0.25.5": version "0.25.5" resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.25.5.tgz#28d0cd8909b7fa3953af998f2b2ed34f576728f0" integrity sha512-G4hE405ErTWraiZ8UiSoesH8DaCsMm0Cay4fsFWOOUcz8b8rC6uCvnagr+gnioEjWn0wC+o1/TAHt+It+MpIMg== -"@esbuild/sunos-x64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz#08741512c10d529566baba837b4fe052c8f3487b" - integrity sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg== - "@esbuild/sunos-x64@0.25.5": version "0.25.5" resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.25.5.tgz#a28164f5b997e8247d407e36c90d3fd5ddbe0dc5" integrity sha512-l+azKShMy7FxzY0Rj4RCt5VD/q8mG/e+mDivgspo+yL8zW7qEwctQ6YqKX34DTEleFAvCIUviCFX1SDZRSyMQA== -"@esbuild/win32-arm64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz#675b7385398411240735016144ab2e99a60fc75d" - integrity sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A== - "@esbuild/win32-arm64@0.25.5": version "0.25.5" resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.25.5.tgz#6eadbead38e8bd12f633a5190e45eff80e24007e" integrity sha512-O2S7SNZzdcFG7eFKgvwUEZ2VG9D/sn/eIiz8XRZ1Q/DO5a3s76Xv0mdBzVM5j5R639lXQmPmSo0iRpHqUUrsxw== -"@esbuild/win32-ia32@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz#1bfc3ce98aa6ca9a0969e4d2af72144c59c1193b" - integrity sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA== - "@esbuild/win32-ia32@0.25.5": version "0.25.5" resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.25.5.tgz#bab6288005482f9ed2adb9ded7e88eba9a62cc0d" integrity sha512-onOJ02pqs9h1iMJ1PQphR+VZv8qBMQ77Klcsqv9CNW2w6yLqoURLcgERAIurY6QE63bbLuqgP9ATqajFLK5AMQ== -"@esbuild/win32-x64@0.21.5": - version "0.21.5" - resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz#acad351d582d157bb145535db2a6ff53dd514b5c" - integrity sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw== - "@esbuild/win32-x64@0.25.5": version "0.25.5" resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.25.5.tgz#7fc114af5f6563f19f73324b5d5ff36ece0803d1" @@ -337,44 +222,46 @@ dependencies: "@noble/hashes" "1.3.2" -"@noble/curves@1.8.1", "@noble/curves@^1.3.0", "@noble/curves@^1.6.0", "@noble/curves@^1.7.0", "@noble/curves@^1.8.1", "@noble/curves@~1.8.1": +"@noble/curves@1.8.1", "@noble/curves@^1.6.0", "@noble/curves@~1.8.1": version "1.8.1" resolved "https://registry.npmjs.org/@noble/curves/-/curves-1.8.1.tgz" integrity sha512-warwspo+UYUPep0Q+vtdVB4Ugn8GGQj8iyB3gnRWsztmUHTI3S1nhdiWNsPUGL0vud7JlRRk1XEu7Lq1KGTnMQ== dependencies: "@noble/hashes" "1.7.1" -"@noble/curves@~1.7.0": - version "1.7.0" - resolved "https://registry.npmjs.org/@noble/curves/-/curves-1.7.0.tgz" - integrity sha512-UTMhXK9SeDhFJVrHeUJ5uZlI6ajXg10O6Ddocf9S6GjbSBVZsJo88HzKwXznNfGpMTRDyJkqMjNDPYgf0qFWnw== +"@noble/curves@^1.3.0": + version "1.9.7" + resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.9.7.tgz#79d04b4758a43e4bca2cbdc62e7771352fa6b951" + integrity sha512-gbKGcRUYIjA3/zCCNaWDciTMFI0dCkvou3TL8Zmy5Nc7sJ47a0jtOeZoTaMxkuqRo9cRhjOdZJXegxYE5FN/xw== dependencies: - "@noble/hashes" "1.6.0" + "@noble/hashes" "1.8.0" + +"@noble/curves@^2.0.0", "@noble/curves@~2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-2.0.0.tgz#1b1d75b447e5ccfaa6a4a3c34280f0c02a763f57" + integrity sha512-RiwZZeJnsTnhT+/gg2KvITJZhK5oagQrpZo+yQyd3mv3D5NAG2qEeEHpw7IkXRlpkoD45wl2o4ydHAvY9wyEfw== + dependencies: + "@noble/hashes" "2.0.0" "@noble/hashes@1.3.2": version "1.3.2" resolved "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz" integrity sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ== -"@noble/hashes@1.6.0": - version "1.6.0" - resolved "https://registry.npmjs.org/@noble/hashes/-/hashes-1.6.0.tgz" - integrity sha512-YUULf0Uk4/mAA89w+k3+yUYh6NrEvxZa5T6SY3wlMvE2chHkxFUUIDI8/XW1QSC357iA5pSnqt7XEhvFOqmDyQ== - -"@noble/hashes@1.7.1", "@noble/hashes@^1.3.1", "@noble/hashes@^1.3.3", "@noble/hashes@^1.5.0", "@noble/hashes@^1.6.1", "@noble/hashes@^1.7.1", "@noble/hashes@~1.7.1": +"@noble/hashes@1.7.1", "@noble/hashes@^1.5.0", "@noble/hashes@~1.7.1": version "1.7.1" resolved "https://registry.npmjs.org/@noble/hashes/-/hashes-1.7.1.tgz" integrity sha512-B8XBPsn4vT/KJAGqDzbwztd+6Yte3P4V7iafm24bxgDe/mlRuK6xmWPuCNrKt2vDafZ8MfJLlchDG/vYafQEjQ== -"@noble/hashes@^1.8.0": +"@noble/hashes@1.8.0", "@noble/hashes@^1.3.1", "@noble/hashes@^1.3.3", "@noble/hashes@^1.8.0": version "1.8.0" resolved "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz" integrity sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A== -"@noble/hashes@~1.6.0": - version "1.6.1" - resolved "https://registry.npmjs.org/@noble/hashes/-/hashes-1.6.1.tgz" - integrity sha512-pq5D8h10hHBjyqX+cfBm0i8JUXJ0UhczFc4r74zbuT9XgewFo2E3J1cOaGtdZynILNmQ685YWGzGE1Zv6io50w== +"@noble/hashes@2.0.0", "@noble/hashes@^2.0.0", "@noble/hashes@~2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-2.0.0.tgz#5c39388259a0868cadb17d688cd8cf07eae344a4" + integrity sha512-h8VUBlE8R42+XIDO229cgisD287im3kdY6nbNZJFjc6ZvKIXPYXe6Vc/t+kyjFdMFyt5JpapzTsEg8n63w5/lw== "@pkgjs/parseargs@^0.11.0": version "0.11.0" @@ -425,7 +312,7 @@ "@polkadot-api/utils" "0.2.0" "@polkadot-api/descriptors@file:.papi/descriptors": - version "0.1.0-autogenerated.1186735750961316967" + version "0.1.0-autogenerated.1855018811236749851" "@polkadot-api/ink-contracts@0.3.7": version "0.3.7" @@ -443,12 +330,12 @@ "@polkadot-api/json-rpc-provider-proxy@^0.1.0": version "0.1.0" - resolved "https://registry.npmjs.org/@polkadot-api/json-rpc-provider-proxy/-/json-rpc-provider-proxy-0.1.0.tgz" + resolved "https://registry.yarnpkg.com/@polkadot-api/json-rpc-provider-proxy/-/json-rpc-provider-proxy-0.1.0.tgz#6e191f28e7d0fbbe8b540fc51d12a0adaeba297e" integrity sha512-8GSFE5+EF73MCuLQm8tjrbCqlgclcHBSRaswvXziJ0ZW7iw3UEMsKkkKvELayWyBuOPa2T5i1nj6gFOeIsqvrg== "@polkadot-api/json-rpc-provider@0.0.1", "@polkadot-api/json-rpc-provider@^0.0.1": version "0.0.1" - resolved "https://registry.npmjs.org/@polkadot-api/json-rpc-provider/-/json-rpc-provider-0.0.1.tgz" + resolved "https://registry.yarnpkg.com/@polkadot-api/json-rpc-provider/-/json-rpc-provider-0.0.1.tgz#333645d40ccd9bccfd1f32503f17e4e63e76e297" integrity sha512-/SMC/l7foRjpykLTUTacIH05H3mr9ip8b5xxfwXlVezXrNVLp3Cv0GX6uItkKd+ZjzVPf3PFrDF2B2/HLSNESA== "@polkadot-api/json-rpc-provider@0.0.4": @@ -492,7 +379,7 @@ "@polkadot-api/metadata-builders@0.3.2": version "0.3.2" - resolved "https://registry.npmjs.org/@polkadot-api/metadata-builders/-/metadata-builders-0.3.2.tgz" + resolved "https://registry.yarnpkg.com/@polkadot-api/metadata-builders/-/metadata-builders-0.3.2.tgz#007f158c9e0546cf79ba440befc0c753ab1a6629" integrity sha512-TKpfoT6vTb+513KDzMBTfCb/ORdgRnsS3TDFpOhAhZ08ikvK+hjHMt5plPiAX/OWkm1Wc9I3+K6W0hX5Ab7MVg== dependencies: "@polkadot-api/substrate-bindings" "0.6.0" @@ -517,7 +404,7 @@ "@polkadot-api/observable-client@^0.3.0": version "0.3.2" - resolved "https://registry.npmjs.org/@polkadot-api/observable-client/-/observable-client-0.3.2.tgz" + resolved "https://registry.yarnpkg.com/@polkadot-api/observable-client/-/observable-client-0.3.2.tgz#fd91efee350595a6e0ecfd3f294cc80de86c0cf7" integrity sha512-HGgqWgEutVyOBXoGOPp4+IAq6CNdK/3MfQJmhCJb8YaJiaK4W6aRGrdQuQSTPHfERHCARt9BrOmEvTXAT257Ug== dependencies: "@polkadot-api/metadata-builders" "0.3.2" @@ -604,7 +491,7 @@ "@polkadot-api/substrate-bindings@0.6.0": version "0.6.0" - resolved "https://registry.npmjs.org/@polkadot-api/substrate-bindings/-/substrate-bindings-0.6.0.tgz" + resolved "https://registry.yarnpkg.com/@polkadot-api/substrate-bindings/-/substrate-bindings-0.6.0.tgz#889b0c3ba19dc95282286506bf6e370a43ce119a" integrity sha512-lGuhE74NA1/PqdN7fKFdE5C1gNYX357j1tWzdlPXI0kQ7h3kN0zfxNOpPUN7dIrPcOFZ6C0tRRVrBylXkI6xPw== dependencies: "@noble/hashes" "^1.3.1" @@ -623,7 +510,7 @@ "@polkadot-api/substrate-client@^0.1.2": version "0.1.4" - resolved "https://registry.npmjs.org/@polkadot-api/substrate-client/-/substrate-client-0.1.4.tgz" + resolved "https://registry.yarnpkg.com/@polkadot-api/substrate-client/-/substrate-client-0.1.4.tgz#7a808e5cb85ecb9fa2b3a43945090a6c807430ce" integrity sha512-MljrPobN0ZWTpn++da9vOvt+Ex+NlqTlr/XT7zi9sqPtDJiQcYl+d29hFAgpaeTqbeQKZwz3WDE9xcEfLE8c5A== dependencies: "@polkadot-api/json-rpc-provider" "0.0.1" @@ -631,7 +518,7 @@ "@polkadot-api/utils@0.1.0": version "0.1.0" - resolved "https://registry.npmjs.org/@polkadot-api/utils/-/utils-0.1.0.tgz" + resolved "https://registry.yarnpkg.com/@polkadot-api/utils/-/utils-0.1.0.tgz#d36937cdc465c2ea302f3278cf53157340ab33a0" integrity sha512-MXzWZeuGxKizPx2Xf/47wx9sr/uxKw39bVJUptTJdsaQn/TGq+z310mHzf1RCGvC1diHM8f593KrnDgc9oNbJA== "@polkadot-api/utils@0.2.0": @@ -653,357 +540,346 @@ "@polkadot-api/json-rpc-provider-proxy" "0.2.4" ws "^8.18.3" -"@polkadot-labs/hdkd-helpers@0.0.10": - version "0.0.10" - resolved "https://registry.npmjs.org/@polkadot-labs/hdkd-helpers/-/hdkd-helpers-0.0.10.tgz" - integrity sha512-wBKenhN7TjNiMXxBvQWzFf+su8xTaRGqyOKAlAfpyY9oWTOt3G05yMvDHEZ4g/NRLoE4P3fQYQ0bdcMKl7KkDw== - dependencies: - "@noble/curves" "^1.7.0" - "@noble/hashes" "^1.6.1" - "@scure/base" "^1.2.1" - micro-sr25519 "^0.1.0" - scale-ts "^1.6.1" - -"@polkadot-labs/hdkd-helpers@^0.0.11": - version "0.0.11" - resolved "https://registry.npmjs.org/@polkadot-labs/hdkd-helpers/-/hdkd-helpers-0.0.11.tgz" - integrity sha512-qPlWqC3NNV/2NYc5GEy+Ovi4UBAgkMGvMfyiYuj2BQN4lW59Q1T9coNx0Yp6XzsnJ1ddaF9PWaUtxj3LdM0IDw== +"@polkadot-labs/hdkd-helpers@^0.0.23", "@polkadot-labs/hdkd-helpers@~0.0.23": + version "0.0.23" + resolved "https://registry.yarnpkg.com/@polkadot-labs/hdkd-helpers/-/hdkd-helpers-0.0.23.tgz#68b8ec8fb3e26e1eaeed289db2fa54eb13adefe9" + integrity sha512-wfayRSCqOhcg4eaTltdynQHrn53FftGZ3Ws1HmxlE4N6VJYTfsTrfHAWI7l3BZz14nUUDDZe7IlvyX14Qqaakw== dependencies: - "@noble/curves" "^1.8.1" - "@noble/hashes" "^1.7.1" - "@scure/base" "^1.2.4" - micro-sr25519 "^0.1.0" + "@noble/curves" "^2.0.0" + "@noble/hashes" "^2.0.0" + "@scure/base" "^2.0.0" + "@scure/sr25519" "^0.3.0" scale-ts "^1.6.1" -"@polkadot-labs/hdkd@^0.0.10": - version "0.0.10" - resolved "https://registry.npmjs.org/@polkadot-labs/hdkd/-/hdkd-0.0.10.tgz" - integrity sha512-jD8l+Ls/kZjvZja4T2Y0G6Be3rfGn0qNs3hvcNeV2CmOMtI7yRkkWPXI7WiJ8AyEoBwBuZt0rm6yzGla6o2HXQ== - dependencies: - "@polkadot-labs/hdkd-helpers" "0.0.10" - -"@polkadot/api-augment@15.1.1": - version "15.1.1" - resolved "https://registry.npmjs.org/@polkadot/api-augment/-/api-augment-15.1.1.tgz" - integrity sha512-tYASON7vVLz7FGcXVX9dWSd/9pR6FckayEkc08Z6RyjH7HfjtCZ3/Dz7MlGRNql4SnPi4+xpjSD6rwrZcETU1g== - dependencies: - "@polkadot/api-base" "15.1.1" - "@polkadot/rpc-augment" "15.1.1" - "@polkadot/types" "15.1.1" - "@polkadot/types-augment" "15.1.1" - "@polkadot/types-codec" "15.1.1" - "@polkadot/util" "^13.2.3" - tslib "^2.8.0" - -"@polkadot/api-base@15.1.1": - version "15.1.1" - resolved "https://registry.npmjs.org/@polkadot/api-base/-/api-base-15.1.1.tgz" - integrity sha512-OXLZ7/k2RXLIA8hKA8oyii6o8MuGlqujIDcLVaMdtWnQsBg26h8pv/mujT2YSz2OguLxrfdvD+lUGtwZC8kw4A== - dependencies: - "@polkadot/rpc-core" "15.1.1" - "@polkadot/types" "15.1.1" - "@polkadot/util" "^13.2.3" +"@polkadot-labs/hdkd@^0.0.23": + version "0.0.23" + resolved "https://registry.yarnpkg.com/@polkadot-labs/hdkd/-/hdkd-0.0.23.tgz#fecacb353c7f9d15aa9f826ba4208e8828935399" + integrity sha512-EyBNsdoX2SQrjp3PpBv2kvtkvL3714ydqKwXH1t3kWOuBq6VwnOm0zRMkmGawhFA+25aUEnBC/dmwI4Xb4hCYg== + dependencies: + "@polkadot-labs/hdkd-helpers" "~0.0.23" + +"@polkadot/api-augment@16.4.6": + version "16.4.6" + resolved "https://registry.yarnpkg.com/@polkadot/api-augment/-/api-augment-16.4.6.tgz#9c23c100736ccf469091153b992547037a2b1e06" + integrity sha512-YoNOKNk5dca/32Lu5aaLdafGkkUbMHjKRSzrOUAx48jVUWaQYz0WXps2zfx1zDM2hqIgcmkgCQfMdzwHRnj63w== + dependencies: + "@polkadot/api-base" "16.4.6" + "@polkadot/rpc-augment" "16.4.6" + "@polkadot/types" "16.4.6" + "@polkadot/types-augment" "16.4.6" + "@polkadot/types-codec" "16.4.6" + "@polkadot/util" "^13.5.6" + tslib "^2.8.1" + +"@polkadot/api-base@16.4.6": + version "16.4.6" + resolved "https://registry.yarnpkg.com/@polkadot/api-base/-/api-base-16.4.6.tgz#223b28f93b58734b3d3cb37874de0cbaf535ba01" + integrity sha512-tR7rtNmK+NSqqYLzj0C0OPBqqTMOFiyIxKRj2D3/d1IiS6/pUUo455xdwDPTyuUj7adAinSSUOcTtFOcI5BLOA== + dependencies: + "@polkadot/rpc-core" "16.4.6" + "@polkadot/types" "16.4.6" + "@polkadot/util" "^13.5.6" rxjs "^7.8.1" - tslib "^2.8.0" - -"@polkadot/api-derive@15.1.1": - version "15.1.1" - resolved "https://registry.npmjs.org/@polkadot/api-derive/-/api-derive-15.1.1.tgz" - integrity sha512-UPcKr9FplfYKPaP7FYEF917Sm1rKnQFX4AzQJn3f8ySp7DDf6EYiHrNICtGifPEAoANTSW+YHlSchhtnvfSIhw== - dependencies: - "@polkadot/api" "15.1.1" - "@polkadot/api-augment" "15.1.1" - "@polkadot/api-base" "15.1.1" - "@polkadot/rpc-core" "15.1.1" - "@polkadot/types" "15.1.1" - "@polkadot/types-codec" "15.1.1" - "@polkadot/util" "^13.2.3" - "@polkadot/util-crypto" "^13.2.3" + tslib "^2.8.1" + +"@polkadot/api-derive@16.4.6": + version "16.4.6" + resolved "https://registry.yarnpkg.com/@polkadot/api-derive/-/api-derive-16.4.6.tgz#bc7e9ba2695d6d5ed5347e911870aed89ca0912b" + integrity sha512-kh57AhyLtKU3dM2SLCitMEqUJ3cIjwtLtMpiMB7yNH/OvaE7BZ3VO1TuWoU2+kKgyL8DdX6vhdmM5G9/ni+B3w== + dependencies: + "@polkadot/api" "16.4.6" + "@polkadot/api-augment" "16.4.6" + "@polkadot/api-base" "16.4.6" + "@polkadot/rpc-core" "16.4.6" + "@polkadot/types" "16.4.6" + "@polkadot/types-codec" "16.4.6" + "@polkadot/util" "^13.5.6" + "@polkadot/util-crypto" "^13.5.6" rxjs "^7.8.1" - tslib "^2.8.0" - -"@polkadot/api@15.1.1": - version "15.1.1" - resolved "https://registry.npmjs.org/@polkadot/api/-/api-15.1.1.tgz" - integrity sha512-n3QeQ1CXlzjqyh2eFbEQPcnkXO3J4QYNTIj0Lnz/XFUpzKimHPDA2iUfaXuy5dXjnzS21jFANGSUFoZ+XKi/8g== - dependencies: - "@polkadot/api-augment" "15.1.1" - "@polkadot/api-base" "15.1.1" - "@polkadot/api-derive" "15.1.1" - "@polkadot/keyring" "^13.2.3" - "@polkadot/rpc-augment" "15.1.1" - "@polkadot/rpc-core" "15.1.1" - "@polkadot/rpc-provider" "15.1.1" - "@polkadot/types" "15.1.1" - "@polkadot/types-augment" "15.1.1" - "@polkadot/types-codec" "15.1.1" - "@polkadot/types-create" "15.1.1" - "@polkadot/types-known" "15.1.1" - "@polkadot/util" "^13.2.3" - "@polkadot/util-crypto" "^13.2.3" + tslib "^2.8.1" + +"@polkadot/api@16.4.6", "@polkadot/api@^16.4.6": + version "16.4.6" + resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-16.4.6.tgz#86fbecb60867ae6eae1ed11a7962819e4abdfd80" + integrity sha512-/RYqejRoAgTR0PJpxRYWgYO7iKMXS/mIhFr7vLKzYNOzEA0nePUHE3iYkrhAj2Rluwy1gPcVoUU8/EYGVsWLGQ== + dependencies: + "@polkadot/api-augment" "16.4.6" + "@polkadot/api-base" "16.4.6" + "@polkadot/api-derive" "16.4.6" + "@polkadot/keyring" "^13.5.6" + "@polkadot/rpc-augment" "16.4.6" + "@polkadot/rpc-core" "16.4.6" + "@polkadot/rpc-provider" "16.4.6" + "@polkadot/types" "16.4.6" + "@polkadot/types-augment" "16.4.6" + "@polkadot/types-codec" "16.4.6" + "@polkadot/types-create" "16.4.6" + "@polkadot/types-known" "16.4.6" + "@polkadot/util" "^13.5.6" + "@polkadot/util-crypto" "^13.5.6" eventemitter3 "^5.0.1" rxjs "^7.8.1" - tslib "^2.8.0" + tslib "^2.8.1" -"@polkadot/keyring@^13.2.3": - version "13.5.4" - resolved "https://registry.npmjs.org/@polkadot/keyring/-/keyring-13.5.4.tgz" - integrity sha512-dQ/yq2OAl6jvjH+drxyqcfprsU2J9h74GSy5X4499W6YNwCt/2pxAJbmsM3lDWUlGOV1Wnp/aNHHs9kjb8GaJw== +"@polkadot/keyring@^13.5.6": + version "13.5.6" + resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-13.5.6.tgz#b26d0cba323bb0520826211317701aa540428406" + integrity sha512-Ybe6Mflrh96FKR5tfEaf/93RxJD7x9UigseNOJW6Yd8LF+GesdxrqmZD7zh+53Hb7smGQWf/0FCfwhoWZVgPUQ== dependencies: - "@polkadot/util" "13.5.4" - "@polkadot/util-crypto" "13.5.4" + "@polkadot/util" "13.5.6" + "@polkadot/util-crypto" "13.5.6" tslib "^2.8.0" -"@polkadot/networks@13.5.4", "@polkadot/networks@^13.2.3": - version "13.5.4" - resolved "https://registry.npmjs.org/@polkadot/networks/-/networks-13.5.4.tgz" - integrity sha512-JD7brNZsWTWbT3bDnEsAYkJfESvmn1XcoFMLoivVrg8dPXqYxoWcYveKPORjPyMPP6wgJ498vJGq7Ce0ihZ8ig== +"@polkadot/networks@13.5.6", "@polkadot/networks@^13.5.6": + version "13.5.6" + resolved "https://registry.yarnpkg.com/@polkadot/networks/-/networks-13.5.6.tgz#fc74b556dc2aa03a49ee6543df0ae74a280da7a5" + integrity sha512-9HqUIBOHnz9x/ssPb0aOD/7XcU8vGokEYpLoNgexFNIJzqDgrDHXR197iFpkbMqA/+98zagrvYUyPYj1yYs9Jw== dependencies: - "@polkadot/util" "13.5.4" + "@polkadot/util" "13.5.6" "@substrate/ss58-registry" "^1.51.0" tslib "^2.8.0" -"@polkadot/rpc-augment@15.1.1": - version "15.1.1" - resolved "https://registry.npmjs.org/@polkadot/rpc-augment/-/rpc-augment-15.1.1.tgz" - integrity sha512-s6i4nTy7/1Q5svIMT4TR55GLRv9asG7xbJcntHEsQ2nDs8zZV/mvPWfEUxgup0xVO8sDgyrf6KTTVRKJjySjUg== - dependencies: - "@polkadot/rpc-core" "15.1.1" - "@polkadot/types" "15.1.1" - "@polkadot/types-codec" "15.1.1" - "@polkadot/util" "^13.2.3" - tslib "^2.8.0" - -"@polkadot/rpc-core@15.1.1": - version "15.1.1" - resolved "https://registry.npmjs.org/@polkadot/rpc-core/-/rpc-core-15.1.1.tgz" - integrity sha512-KErbVgPChps7NsxcGch5JCArZHNqs81fDEzs+XoHnD05nzuxcO38v4Yu+M04lHLax2m8ky8K6o3gurBglJENlA== - dependencies: - "@polkadot/rpc-augment" "15.1.1" - "@polkadot/rpc-provider" "15.1.1" - "@polkadot/types" "15.1.1" - "@polkadot/util" "^13.2.3" +"@polkadot/rpc-augment@16.4.6": + version "16.4.6" + resolved "https://registry.yarnpkg.com/@polkadot/rpc-augment/-/rpc-augment-16.4.6.tgz#ee4c56c9c0feb281adbbdd23ec6768d487ff53e3" + integrity sha512-Fqx41st3KTCfk831OrAh69ftBzqxklEi5e5S/rB2l5F+OQYAsbGMfTSFWTRRVGgBliWZO+T/Tpw2zJqUwrgn3Q== + dependencies: + "@polkadot/rpc-core" "16.4.6" + "@polkadot/types" "16.4.6" + "@polkadot/types-codec" "16.4.6" + "@polkadot/util" "^13.5.6" + tslib "^2.8.1" + +"@polkadot/rpc-core@16.4.6": + version "16.4.6" + resolved "https://registry.yarnpkg.com/@polkadot/rpc-core/-/rpc-core-16.4.6.tgz#f46bd58e31f04846abc9e2bf02620f1cba1dc943" + integrity sha512-xi3VIGRXjebdz0jctZpa7y2A+JaI9LSBdUgkHoUOmGrpNzDpMXoE2xWdxg3M/0hql69mSLhatWS9JvSb5MrBTQ== + dependencies: + "@polkadot/rpc-augment" "16.4.6" + "@polkadot/rpc-provider" "16.4.6" + "@polkadot/types" "16.4.6" + "@polkadot/util" "^13.5.6" rxjs "^7.8.1" - tslib "^2.8.0" - -"@polkadot/rpc-provider@15.1.1": - version "15.1.1" - resolved "https://registry.npmjs.org/@polkadot/rpc-provider/-/rpc-provider-15.1.1.tgz" - integrity sha512-9OWV1dyX+vmAbKkhMU8J7Q0sCaovPrkwZqo2ejmEpZ/Lr12Hw5JAk4gdvB869QEVP7zj0gH3HuYVajmsxesYKg== - dependencies: - "@polkadot/keyring" "^13.2.3" - "@polkadot/types" "15.1.1" - "@polkadot/types-support" "15.1.1" - "@polkadot/util" "^13.2.3" - "@polkadot/util-crypto" "^13.2.3" - "@polkadot/x-fetch" "^13.2.3" - "@polkadot/x-global" "^13.2.3" - "@polkadot/x-ws" "^13.2.3" + tslib "^2.8.1" + +"@polkadot/rpc-provider@16.4.6": + version "16.4.6" + resolved "https://registry.yarnpkg.com/@polkadot/rpc-provider/-/rpc-provider-16.4.6.tgz#d0b47f4c67076a89a60857e8cc47881bf7a15eba" + integrity sha512-/ZD1rOWBRoMxnp039pOa8Czpjr/l4+3YYY5OcW9WZj16dRcJK84qVi1m91Hro+Gfe9Dus8VeOD/ncJB+a+haRA== + dependencies: + "@polkadot/keyring" "^13.5.6" + "@polkadot/types" "16.4.6" + "@polkadot/types-support" "16.4.6" + "@polkadot/util" "^13.5.6" + "@polkadot/util-crypto" "^13.5.6" + "@polkadot/x-fetch" "^13.5.6" + "@polkadot/x-global" "^13.5.6" + "@polkadot/x-ws" "^13.5.6" eventemitter3 "^5.0.1" mock-socket "^9.3.1" nock "^13.5.5" - tslib "^2.8.0" + tslib "^2.8.1" optionalDependencies: "@substrate/connect" "0.8.11" -"@polkadot/types-augment@15.1.1": - version "15.1.1" - resolved "https://registry.npmjs.org/@polkadot/types-augment/-/types-augment-15.1.1.tgz" - integrity sha512-6v/FsN/JYCupyGYW+MbS0iOCiWvf6PXJ5+m8ORYYYDPFgQqaQPxKMKWJpnO0s9cCR33QcyNYhErPGuZ62UMJjw== - dependencies: - "@polkadot/types" "15.1.1" - "@polkadot/types-codec" "15.1.1" - "@polkadot/util" "^13.2.3" - tslib "^2.8.0" - -"@polkadot/types-codec@15.1.1": - version "15.1.1" - resolved "https://registry.npmjs.org/@polkadot/types-codec/-/types-codec-15.1.1.tgz" - integrity sha512-cm99CFvDf4UXmw7DeMkRqa/hf7wEgjJZoZZW/B12Js0ObwRmSXMk/gDbyiT6hqPnQ81sU726E72p39DolaEatQ== - dependencies: - "@polkadot/util" "^13.2.3" - "@polkadot/x-bigint" "^13.2.3" - tslib "^2.8.0" - -"@polkadot/types-create@15.1.1": - version "15.1.1" - resolved "https://registry.npmjs.org/@polkadot/types-create/-/types-create-15.1.1.tgz" - integrity sha512-AOgz+UsUqsGSENrc+p/dHyXH2TC9qVtUTAxlqaHfOnwqjMWfEqc78mc5a1mk0a+RqxmIHw8nQNSdBdhv+UdtyQ== - dependencies: - "@polkadot/types-codec" "15.1.1" - "@polkadot/util" "^13.2.3" - tslib "^2.8.0" - -"@polkadot/types-known@15.1.1": - version "15.1.1" - resolved "https://registry.npmjs.org/@polkadot/types-known/-/types-known-15.1.1.tgz" - integrity sha512-L934pYxXdHB3GHlVu57ihO6llhxuggSuQZuJ9kHunG0I6tezXLIgAhwaPgACMVbmBYlkJPqm4Nr6pC3kpIsGow== - dependencies: - "@polkadot/networks" "^13.2.3" - "@polkadot/types" "15.1.1" - "@polkadot/types-codec" "15.1.1" - "@polkadot/types-create" "15.1.1" - "@polkadot/util" "^13.2.3" - tslib "^2.8.0" - -"@polkadot/types-support@15.1.1": - version "15.1.1" - resolved "https://registry.npmjs.org/@polkadot/types-support/-/types-support-15.1.1.tgz" - integrity sha512-uyn5N7XERHosVq0+aCpEwYnkUroOr7OX8B8/00UkgmfVOXskp/cukEVcGlmI/YGAS+9+V2BZN2GBX7Lz0eeKmw== - dependencies: - "@polkadot/util" "^13.2.3" - tslib "^2.8.0" - -"@polkadot/types@15.1.1": - version "15.1.1" - resolved "https://registry.npmjs.org/@polkadot/types/-/types-15.1.1.tgz" - integrity sha512-n6lg/quhLp3Zmt/6gHAg2uoSmMmXk3NR19I7qCyeDJ30pP1UhOjtmuWOQDl6SwSEwuHtudLp3p2nCJsymXjgsw== - dependencies: - "@polkadot/keyring" "^13.2.3" - "@polkadot/types-augment" "15.1.1" - "@polkadot/types-codec" "15.1.1" - "@polkadot/types-create" "15.1.1" - "@polkadot/util" "^13.2.3" - "@polkadot/util-crypto" "^13.2.3" +"@polkadot/types-augment@16.4.6": + version "16.4.6" + resolved "https://registry.yarnpkg.com/@polkadot/types-augment/-/types-augment-16.4.6.tgz#6b9f712dd755b6bc1d771b6238521698e4ff0261" + integrity sha512-ZFe6j+HHK+ST4D2MwV7oC4y6pyBMZV1b8ZZT2htTtWf03PE0W2ziQVM+Fg42iSHpgmCyJLSABU11QkGSGtRfyQ== + dependencies: + "@polkadot/types" "16.4.6" + "@polkadot/types-codec" "16.4.6" + "@polkadot/util" "^13.5.6" + tslib "^2.8.1" + +"@polkadot/types-codec@16.4.6": + version "16.4.6" + resolved "https://registry.yarnpkg.com/@polkadot/types-codec/-/types-codec-16.4.6.tgz#54ef45a84b807c73054d739cf77cb21f62acb462" + integrity sha512-KCDDJNPTrScQV1HEMNjBIvtx12/J+DPV/niC+klb39wqeBAt7+wYNd8zSnFQzrLvx+n2eWlJjq0dxQiK+Ljc5A== + dependencies: + "@polkadot/util" "^13.5.6" + "@polkadot/x-bigint" "^13.5.6" + tslib "^2.8.1" + +"@polkadot/types-create@16.4.6": + version "16.4.6" + resolved "https://registry.yarnpkg.com/@polkadot/types-create/-/types-create-16.4.6.tgz#55bf3178daeb82345f9e858c007aac0b4aa4974d" + integrity sha512-+ABF/SKX+xuCPyKvcHIFNybQYQID7bTfvQPkRhK1QxssMwdVtpYCb6RxYU7gYQhlMBAyEZUwele6/JwT/J5VqA== + dependencies: + "@polkadot/types-codec" "16.4.6" + "@polkadot/util" "^13.5.6" + tslib "^2.8.1" + +"@polkadot/types-known@16.4.6": + version "16.4.6" + resolved "https://registry.yarnpkg.com/@polkadot/types-known/-/types-known-16.4.6.tgz#6b2c028f19dcf55dc5272b9038f99edd9177db9d" + integrity sha512-aYCWhn0l+19Vasn32SbXbxf19RX1IHaCizYtSW02FlNKpVlZGfOdqebtpQZUz5TmPIkvk1LGPo+qF0xiJSVlOA== + dependencies: + "@polkadot/networks" "^13.5.6" + "@polkadot/types" "16.4.6" + "@polkadot/types-codec" "16.4.6" + "@polkadot/types-create" "16.4.6" + "@polkadot/util" "^13.5.6" + tslib "^2.8.1" + +"@polkadot/types-support@16.4.6": + version "16.4.6" + resolved "https://registry.yarnpkg.com/@polkadot/types-support/-/types-support-16.4.6.tgz#35fc46454193b73df150040b8f268c9e3c9f87c7" + integrity sha512-e83H4MzamzNzxZdxf104xqzsl1YUCF24i2pw19I/6zPVxpt6a9zn4+7VzSVMclaztxxSTITCLbks7/9dLiNhEw== + dependencies: + "@polkadot/util" "^13.5.6" + tslib "^2.8.1" + +"@polkadot/types@16.4.6": + version "16.4.6" + resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-16.4.6.tgz#9594f6f80e249f270f9092016957860a4554de5e" + integrity sha512-vfZSOxs64oy1XOcMY3fAbSCBwqLeWvsUYSOhDkZaaC5zIbKdtimPQgbV1QA2fMli568rehmmpLXpZZtj2CNnmA== + dependencies: + "@polkadot/keyring" "^13.5.6" + "@polkadot/types-augment" "16.4.6" + "@polkadot/types-codec" "16.4.6" + "@polkadot/types-create" "16.4.6" + "@polkadot/util" "^13.5.6" + "@polkadot/util-crypto" "^13.5.6" rxjs "^7.8.1" - tslib "^2.8.0" + tslib "^2.8.1" -"@polkadot/util-crypto@13.5.4", "@polkadot/util-crypto@^13.2.3": - version "13.5.4" - resolved "https://registry.npmjs.org/@polkadot/util-crypto/-/util-crypto-13.5.4.tgz" - integrity sha512-XkKtiUi6I60DxT0dblGajZsqX4jWTnMpj4Pqxddz61KbpmvyybtAUqgmXOmO/Mob6TgGTutPuFeE7uMNEdFdJw== +"@polkadot/util-crypto@13.5.6", "@polkadot/util-crypto@^13.5.6": + version "13.5.6" + resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-13.5.6.tgz#aef44d6c201d7c47897288aa268532f396e4cd5f" + integrity sha512-1l+t5lVc9UWxvbJe7/3V+QK8CwrDPuQjDK6FKtDZgZCU0JRrjySOxV0J4PeDIv8TgXZtbIcQFVUhIsJTyKZZJQ== dependencies: "@noble/curves" "^1.3.0" "@noble/hashes" "^1.3.3" - "@polkadot/networks" "13.5.4" - "@polkadot/util" "13.5.4" - "@polkadot/wasm-crypto" "^7.4.1" - "@polkadot/wasm-util" "^7.4.1" - "@polkadot/x-bigint" "13.5.4" - "@polkadot/x-randomvalues" "13.5.4" + "@polkadot/networks" "13.5.6" + "@polkadot/util" "13.5.6" + "@polkadot/wasm-crypto" "^7.5.1" + "@polkadot/wasm-util" "^7.5.1" + "@polkadot/x-bigint" "13.5.6" + "@polkadot/x-randomvalues" "13.5.6" "@scure/base" "^1.1.7" tslib "^2.8.0" -"@polkadot/util@13.5.4", "@polkadot/util@^13.2.3": - version "13.5.4" - resolved "https://registry.npmjs.org/@polkadot/util/-/util-13.5.4.tgz" - integrity sha512-w/D7tqfx5a+yHcVBTb+CWGwpJTwcFRNJaVIBxl/MjF3x8JUZCtcKNwklpWJH5HtwaXT1Mt2aBKjoxlNdnd6FYg== +"@polkadot/util@13.5.6", "@polkadot/util@^13.5.6": + version "13.5.6" + resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-13.5.6.tgz#fceb7fe823724535516b304a5675566974cb60e6" + integrity sha512-V+CkW2VdhcMWvl7eXdmlCLGqLxrKvXZtXE76KBbPP5n0Z+8DqQ58IHNOE9xe2LOgqDwIzdLlOUwkyF9Zj19y+Q== dependencies: - "@polkadot/x-bigint" "13.5.4" - "@polkadot/x-global" "13.5.4" - "@polkadot/x-textdecoder" "13.5.4" - "@polkadot/x-textencoder" "13.5.4" + "@polkadot/x-bigint" "13.5.6" + "@polkadot/x-global" "13.5.6" + "@polkadot/x-textdecoder" "13.5.6" + "@polkadot/x-textencoder" "13.5.6" "@types/bn.js" "^5.1.6" bn.js "^5.2.1" tslib "^2.8.0" -"@polkadot/wasm-bridge@7.4.1": - version "7.4.1" - resolved "https://registry.npmjs.org/@polkadot/wasm-bridge/-/wasm-bridge-7.4.1.tgz" - integrity sha512-tdkJaV453tezBxhF39r4oeG0A39sPKGDJmN81LYLf+Fihb7astzwju+u75BRmDrHZjZIv00un3razJEWCxze6g== +"@polkadot/wasm-bridge@7.5.1": + version "7.5.1" + resolved "https://registry.yarnpkg.com/@polkadot/wasm-bridge/-/wasm-bridge-7.5.1.tgz#f738858213a8a599ae8bf6a6c179b325dcf091f4" + integrity sha512-E+N3CSnX3YaXpAmfIQ+4bTyiAqJQKvVcMaXjkuL8Tp2zYffClWLG5e+RY15Uh+EWfUl9If4y6cLZi3D5NcpAGQ== dependencies: - "@polkadot/wasm-util" "7.4.1" + "@polkadot/wasm-util" "7.5.1" tslib "^2.7.0" -"@polkadot/wasm-crypto-asmjs@7.4.1": - version "7.4.1" - resolved "https://registry.npmjs.org/@polkadot/wasm-crypto-asmjs/-/wasm-crypto-asmjs-7.4.1.tgz" - integrity sha512-pwU8QXhUW7IberyHJIQr37IhbB6DPkCG5FhozCiNTq4vFBsFPjm9q8aZh7oX1QHQaiAZa2m2/VjIVE+FHGbvHQ== +"@polkadot/wasm-crypto-asmjs@7.5.1": + version "7.5.1" + resolved "https://registry.yarnpkg.com/@polkadot/wasm-crypto-asmjs/-/wasm-crypto-asmjs-7.5.1.tgz#87e07aa340249d5c978cd03eb58b395563066a4c" + integrity sha512-jAg7Uusk+xeHQ+QHEH4c/N3b1kEGBqZb51cWe+yM61kKpQwVGZhNdlWetW6U23t/BMyZArIWMsZqmK/Ij0PHog== dependencies: tslib "^2.7.0" -"@polkadot/wasm-crypto-init@7.4.1": - version "7.4.1" - resolved "https://registry.npmjs.org/@polkadot/wasm-crypto-init/-/wasm-crypto-init-7.4.1.tgz" - integrity sha512-AVka33+f7MvXEEIGq5U0dhaA2SaXMXnxVCQyhJTaCnJ5bRDj0Xlm3ijwDEQUiaDql7EikbkkRtmlvs95eSUWYQ== +"@polkadot/wasm-crypto-init@7.5.1": + version "7.5.1" + resolved "https://registry.yarnpkg.com/@polkadot/wasm-crypto-init/-/wasm-crypto-init-7.5.1.tgz#0434850b7f05619ff312d5cbfd33629a54f9b31a" + integrity sha512-Obu4ZEo5jYO6sN31eqCNOXo88rPVkP9TrUOyynuFCnXnXr8V/HlmY/YkAd9F87chZnkTJRlzak17kIWr+i7w3A== dependencies: - "@polkadot/wasm-bridge" "7.4.1" - "@polkadot/wasm-crypto-asmjs" "7.4.1" - "@polkadot/wasm-crypto-wasm" "7.4.1" - "@polkadot/wasm-util" "7.4.1" + "@polkadot/wasm-bridge" "7.5.1" + "@polkadot/wasm-crypto-asmjs" "7.5.1" + "@polkadot/wasm-crypto-wasm" "7.5.1" + "@polkadot/wasm-util" "7.5.1" tslib "^2.7.0" -"@polkadot/wasm-crypto-wasm@7.4.1": - version "7.4.1" - resolved "https://registry.npmjs.org/@polkadot/wasm-crypto-wasm/-/wasm-crypto-wasm-7.4.1.tgz" - integrity sha512-PE1OAoupFR0ZOV2O8tr7D1FEUAwaggzxtfs3Aa5gr+yxlSOaWUKeqsOYe1KdrcjmZVV3iINEAXxgrbzCmiuONg== +"@polkadot/wasm-crypto-wasm@7.5.1": + version "7.5.1" + resolved "https://registry.yarnpkg.com/@polkadot/wasm-crypto-wasm/-/wasm-crypto-wasm-7.5.1.tgz#b3996007875db6945d29f94f4d4719fce2b3bb8f" + integrity sha512-S2yQSGbOGTcaV6UdipFVyEGanJvG6uD6Tg7XubxpiGbNAblsyYKeFcxyH1qCosk/4qf+GIUwlOL4ydhosZflqg== dependencies: - "@polkadot/wasm-util" "7.4.1" + "@polkadot/wasm-util" "7.5.1" tslib "^2.7.0" -"@polkadot/wasm-crypto@^7.4.1": - version "7.4.1" - resolved "https://registry.npmjs.org/@polkadot/wasm-crypto/-/wasm-crypto-7.4.1.tgz" - integrity sha512-kHN/kF7hYxm1y0WeFLWeWir6oTzvcFmR4N8fJJokR+ajYbdmrafPN+6iLgQVbhZnDdxyv9jWDuRRsDnBx8tPMQ== +"@polkadot/wasm-crypto@^7.5.1": + version "7.5.1" + resolved "https://registry.yarnpkg.com/@polkadot/wasm-crypto/-/wasm-crypto-7.5.1.tgz#324ebf9a86a30fd19bf4b02a6582367bdddb62c9" + integrity sha512-acjt4VJ3w19v7b/SIPsV/5k9s6JsragHKPnwoZ0KTfBvAFXwzz80jUzVGxA06SKHacfCUe7vBRlz7M5oRby1Pw== dependencies: - "@polkadot/wasm-bridge" "7.4.1" - "@polkadot/wasm-crypto-asmjs" "7.4.1" - "@polkadot/wasm-crypto-init" "7.4.1" - "@polkadot/wasm-crypto-wasm" "7.4.1" - "@polkadot/wasm-util" "7.4.1" + "@polkadot/wasm-bridge" "7.5.1" + "@polkadot/wasm-crypto-asmjs" "7.5.1" + "@polkadot/wasm-crypto-init" "7.5.1" + "@polkadot/wasm-crypto-wasm" "7.5.1" + "@polkadot/wasm-util" "7.5.1" tslib "^2.7.0" -"@polkadot/wasm-util@7.4.1", "@polkadot/wasm-util@^7.4.1": - version "7.4.1" - resolved "https://registry.npmjs.org/@polkadot/wasm-util/-/wasm-util-7.4.1.tgz" - integrity sha512-RAcxNFf3zzpkr+LX/ItAsvj+QyM56TomJ0xjUMo4wKkHjwsxkz4dWJtx5knIgQz/OthqSDMR59VNEycQeNuXzA== +"@polkadot/wasm-util@7.5.1", "@polkadot/wasm-util@^7.5.1": + version "7.5.1" + resolved "https://registry.yarnpkg.com/@polkadot/wasm-util/-/wasm-util-7.5.1.tgz#4568a9bf8d02d2d68fc139f331719865300e5233" + integrity sha512-sbvu71isFhPXpvMVX+EkRnUg/+54Tx7Sf9BEMqxxoPj7cG1I/MKeDEwbQz6MaU4gm7xJqvEWCAemLFcXfHQ/2A== dependencies: tslib "^2.7.0" -"@polkadot/x-bigint@13.5.4", "@polkadot/x-bigint@^13.2.3": - version "13.5.4" - resolved "https://registry.npmjs.org/@polkadot/x-bigint/-/x-bigint-13.5.4.tgz" - integrity sha512-vA4vjHWDUAnoAxzp1kSQMCzaArdagGXCNlooI2EOZ0pcFnEf4NkKCVjYg8i5L1QOYRAeJjgoKjKwCFBx63vtRw== +"@polkadot/x-bigint@13.5.6", "@polkadot/x-bigint@^13.5.6": + version "13.5.6" + resolved "https://registry.yarnpkg.com/@polkadot/x-bigint/-/x-bigint-13.5.6.tgz#1468aab88e9bc41ea7ca118ab72d111681d7a4be" + integrity sha512-HpqZJ9ud94iK/+0Ofacw7QdtvzFp6SucBBml4XwWZTWoLaLOGDsO7FoWE7yCuwPbX8nLgIM6YmQBeUoZmBtVqQ== dependencies: - "@polkadot/x-global" "13.5.4" + "@polkadot/x-global" "13.5.6" tslib "^2.8.0" -"@polkadot/x-fetch@^13.2.3": - version "13.5.4" - resolved "https://registry.npmjs.org/@polkadot/x-fetch/-/x-fetch-13.5.4.tgz" - integrity sha512-VVhmfPaQwFVopgtMUCNhodyZXBy9P4wkQwwYWpkQv2KqYOEQVck/Hhq8IVhGdbtPJxCAWsj/EyYTzUIHZ9aBlw== +"@polkadot/x-fetch@^13.5.6": + version "13.5.6" + resolved "https://registry.yarnpkg.com/@polkadot/x-fetch/-/x-fetch-13.5.6.tgz#39393a4873199320c2474d48af883be853c6deca" + integrity sha512-gqx8c6lhnD7Qht+56J+4oeTA8YZ9bAPqzOt2cRJf9MTplMy44W6671T2p6hA3QMvzy4aBTxMie3uKc4tGpLu4A== dependencies: - "@polkadot/x-global" "13.5.4" + "@polkadot/x-global" "13.5.6" node-fetch "^3.3.2" tslib "^2.8.0" -"@polkadot/x-global@13.5.4", "@polkadot/x-global@^13.2.3": - version "13.5.4" - resolved "https://registry.npmjs.org/@polkadot/x-global/-/x-global-13.5.4.tgz" - integrity sha512-oRUdO8/uKOEmLoPUFYgGascE/nyjT2ObRdf7jgwXOd9f+uUHPiE3K/MNAEi9t9sRKs8dbqgyaGWLTRYCDyzMag== +"@polkadot/x-global@13.5.6", "@polkadot/x-global@^13.5.6": + version "13.5.6" + resolved "https://registry.yarnpkg.com/@polkadot/x-global/-/x-global-13.5.6.tgz#37a52d1cd32fde6d385cb745c0cec534753be1e5" + integrity sha512-iw97n0Bnl2284WgAK732LYR4DW6w5+COfBfHzkhiHqs5xwPEwWMgWGrf2hM8WAQqNIz6Ni8w/jagucPyQBur3Q== dependencies: tslib "^2.8.0" -"@polkadot/x-randomvalues@13.5.4": - version "13.5.4" - resolved "https://registry.npmjs.org/@polkadot/x-randomvalues/-/x-randomvalues-13.5.4.tgz" - integrity sha512-jKVEj+wVO83drbFFGGxhHJqwsOZCzyy6HVwQ/M9G6zhNXHrT46OWK+myd3dB4KbHoxWuH03Nvh540vMC3ah8Fw== +"@polkadot/x-randomvalues@13.5.6": + version "13.5.6" + resolved "https://registry.yarnpkg.com/@polkadot/x-randomvalues/-/x-randomvalues-13.5.6.tgz#a05e0e4fb188c99c5a84043668a27ae6f05259bc" + integrity sha512-w1F9G7FxrJ7+hGC8bh9/VpPH4KN8xmyzgiQdR7+rVB2V8KsKQBQidG69pj5Kwsh3oODOz0yQYsTG6Rm6TAJbGA== dependencies: - "@polkadot/x-global" "13.5.4" + "@polkadot/x-global" "13.5.6" tslib "^2.8.0" -"@polkadot/x-textdecoder@13.5.4": - version "13.5.4" - resolved "https://registry.npmjs.org/@polkadot/x-textdecoder/-/x-textdecoder-13.5.4.tgz" - integrity sha512-+5rWIs+mhvBR2D7+/gWQyKKDoQzyHRIUrygphxdpBsFSvsJkTTGeGXLiD/ls0gTTE31Kb6StQJi1b9h6ywOvfg== +"@polkadot/x-textdecoder@13.5.6": + version "13.5.6" + resolved "https://registry.yarnpkg.com/@polkadot/x-textdecoder/-/x-textdecoder-13.5.6.tgz#a9c37f1033e41747856674d47ce149f71a0cbb1b" + integrity sha512-jTGeYCxFh89KRrP7bNj1CPqKO36Onsi0iA6A+5YtRS5wjdQU+/OFM/EHLTP2nvkvZo/tOkOewMR9sausisUvVQ== dependencies: - "@polkadot/x-global" "13.5.4" + "@polkadot/x-global" "13.5.6" tslib "^2.8.0" -"@polkadot/x-textencoder@13.5.4": - version "13.5.4" - resolved "https://registry.npmjs.org/@polkadot/x-textencoder/-/x-textencoder-13.5.4.tgz" - integrity sha512-GQ4kVJLtiirjI3NAKCnXCSIRudpTKog5SFPqouImV4X5rSsxnLf2xOqLwgYobdv3SIpTHBA1vy2RpQqUQUF6vw== +"@polkadot/x-textencoder@13.5.6": + version "13.5.6" + resolved "https://registry.yarnpkg.com/@polkadot/x-textencoder/-/x-textencoder-13.5.6.tgz#e6468a0a97a0cb9e64363aae35e932baad1abe37" + integrity sha512-iVwz9+OrYCEF9QbNfr9M206mmWvY/AhDmGPfAIeTR4fRgKGVYqcP8RIF8iu/x0MVQWqiVO3vlhlUk7MfrmAnoQ== dependencies: - "@polkadot/x-global" "13.5.4" + "@polkadot/x-global" "13.5.6" tslib "^2.8.0" -"@polkadot/x-ws@^13.2.3": - version "13.5.4" - resolved "https://registry.npmjs.org/@polkadot/x-ws/-/x-ws-13.5.4.tgz" - integrity sha512-tznbRjPnb3QW8v6+7zUoJINL84DW2dHJjwd0rkU0dtwzc9Y92faxz3bgOrCpgC2oVDpyUUg2PsyjokVBQHqLSA== +"@polkadot/x-ws@^13.5.6": + version "13.5.6" + resolved "https://registry.yarnpkg.com/@polkadot/x-ws/-/x-ws-13.5.6.tgz#394bc6c5408e2cecbd8742c883c1b73ce1b23258" + integrity sha512-247ktVp/iE57NTXjFpHaoPoDcvoEPb8+16r2Eq0IBQ2umOV7P6KmxvdNx5eFUvRsgXvBpNwUXE1WVnXjK/eDtA== dependencies: - "@polkadot/x-global" "13.5.4" + "@polkadot/x-global" "13.5.6" tslib "^2.8.0" ws "^8.18.0" @@ -1012,111 +888,221 @@ resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.34.8.tgz#731df27dfdb77189547bcef96ada7bf166bbb2fb" integrity sha512-q217OSE8DTp8AFHuNHXo0Y86e1wtlfVrXiAlwkIvGRQv9zbc6mE3sjIVfwI8sYUyNxwOg0j/Vm1RKM04JcWLJw== +"@rollup/rollup-android-arm-eabi@4.50.0": + version "4.50.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.50.0.tgz#939c1be9625d428d8513e4ab60d406fe8db23718" + integrity sha512-lVgpeQyy4fWN5QYebtW4buT/4kn4p4IJ+kDNB4uYNT5b8c8DLJDg6titg20NIg7E8RWwdWZORW6vUFfrLyG3KQ== + "@rollup/rollup-android-arm64@4.34.8": version "4.34.8" resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.34.8.tgz#4bea6db78e1f6927405df7fe0faf2f5095e01343" integrity sha512-Gigjz7mNWaOL9wCggvoK3jEIUUbGul656opstjaUSGC3eT0BM7PofdAJaBfPFWWkXNVAXbaQtC99OCg4sJv70Q== +"@rollup/rollup-android-arm64@4.50.0": + version "4.50.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.50.0.tgz#b74005775903f7a8f4e363d2840c1dcef3776ff3" + integrity sha512-2O73dR4Dc9bp+wSYhviP6sDziurB5/HCym7xILKifWdE9UsOe2FtNcM+I4xZjKrfLJnq5UR8k9riB87gauiQtw== + "@rollup/rollup-darwin-arm64@4.34.8": version "4.34.8" resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.34.8.tgz#a7aab77d44be3c44a20f946e10160f84e5450e7f" integrity sha512-02rVdZ5tgdUNRxIUrFdcMBZQoaPMrxtwSb+/hOfBdqkatYHR3lZ2A2EGyHq2sGOd0Owk80oV3snlDASC24He3Q== +"@rollup/rollup-darwin-arm64@4.50.0": + version "4.50.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.50.0.tgz#8c04603cdcf1ec0cd6b27152b3827e49295f2962" + integrity sha512-vwSXQN8T4sKf1RHr1F0s98Pf8UPz7pS6P3LG9NSmuw0TVh7EmaE+5Ny7hJOZ0M2yuTctEsHHRTMi2wuHkdS6Hg== + "@rollup/rollup-darwin-x64@4.34.8": version "4.34.8" resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.34.8.tgz#c572c024b57ee8ddd1b0851703ace9eb6cc0dd82" integrity sha512-qIP/elwR/tq/dYRx3lgwK31jkZvMiD6qUtOycLhTzCvrjbZ3LjQnEM9rNhSGpbLXVJYQ3rq39A6Re0h9tU2ynw== +"@rollup/rollup-darwin-x64@4.50.0": + version "4.50.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.50.0.tgz#19ec976f1cc663def2692cd7ffb32981f2b0b733" + integrity sha512-cQp/WG8HE7BCGyFVuzUg0FNmupxC+EPZEwWu2FCGGw5WDT1o2/YlENbm5e9SMvfDFR6FRhVCBePLqj0o8MN7Vw== + "@rollup/rollup-freebsd-arm64@4.34.8": version "4.34.8" resolved "https://registry.yarnpkg.com/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.34.8.tgz#cf74f8113b5a83098a5c026c165742277cbfb88b" integrity sha512-IQNVXL9iY6NniYbTaOKdrlVP3XIqazBgJOVkddzJlqnCpRi/yAeSOa8PLcECFSQochzqApIOE1GHNu3pCz+BDA== +"@rollup/rollup-freebsd-arm64@4.50.0": + version "4.50.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.50.0.tgz#a96b4ad8346229f6fcbd9d57f1c53040b037c2da" + integrity sha512-UR1uTJFU/p801DvvBbtDD7z9mQL8J80xB0bR7DqW7UGQHRm/OaKzp4is7sQSdbt2pjjSS72eAtRh43hNduTnnQ== + "@rollup/rollup-freebsd-x64@4.34.8": version "4.34.8" resolved "https://registry.yarnpkg.com/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.34.8.tgz#39561f3a2f201a4ad6a01425b1ff5928154ecd7c" integrity sha512-TYXcHghgnCqYFiE3FT5QwXtOZqDj5GmaFNTNt3jNC+vh22dc/ukG2cG+pi75QO4kACohZzidsq7yKTKwq/Jq7Q== +"@rollup/rollup-freebsd-x64@4.50.0": + version "4.50.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.50.0.tgz#fa565a282bc57967ee6668607b181678bdd74e4a" + integrity sha512-G/DKyS6PK0dD0+VEzH/6n/hWDNPDZSMBmqsElWnCRGrYOb2jC0VSupp7UAHHQ4+QILwkxSMaYIbQ72dktp8pKA== + "@rollup/rollup-linux-arm-gnueabihf@4.34.8": version "4.34.8" resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.34.8.tgz#980d6061e373bfdaeb67925c46d2f8f9b3de537f" integrity sha512-A4iphFGNkWRd+5m3VIGuqHnG3MVnqKe7Al57u9mwgbyZ2/xF9Jio72MaY7xxh+Y87VAHmGQr73qoKL9HPbXj1g== +"@rollup/rollup-linux-arm-gnueabihf@4.50.0": + version "4.50.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.50.0.tgz#dfc88f7295e1f98d77f25296be787e8a5d6ced75" + integrity sha512-u72Mzc6jyJwKjJbZZcIYmd9bumJu7KNmHYdue43vT1rXPm2rITwmPWF0mmPzLm9/vJWxIRbao/jrQmxTO0Sm9w== + "@rollup/rollup-linux-arm-musleabihf@4.34.8": version "4.34.8" resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.34.8.tgz#f91a90f30dc00d5a64ac2d9bbedc829cd3cfaa78" integrity sha512-S0lqKLfTm5u+QTxlFiAnb2J/2dgQqRy/XvziPtDd1rKZFXHTyYLoVL58M/XFwDI01AQCDIevGLbQrMAtdyanpA== +"@rollup/rollup-linux-arm-musleabihf@4.50.0": + version "4.50.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.50.0.tgz#32cd70c87455ca031f0361090cf17da5a2ef66d5" + integrity sha512-S4UefYdV0tnynDJV1mdkNawp0E5Qm2MtSs330IyHgaccOFrwqsvgigUD29uT+B/70PDY1eQ3t40+xf6wIvXJyg== + "@rollup/rollup-linux-arm64-gnu@4.34.8": version "4.34.8" resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.34.8.tgz#fac700fa5c38bc13a0d5d34463133093da4c92a0" integrity sha512-jpz9YOuPiSkL4G4pqKrus0pn9aYwpImGkosRKwNi+sJSkz+WU3anZe6hi73StLOQdfXYXC7hUfsQlTnjMd3s1A== +"@rollup/rollup-linux-arm64-gnu@4.50.0": + version "4.50.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.50.0.tgz#0e7e1fe7241e3384f6c6b4ccdbcfa8ad8c78b869" + integrity sha512-1EhkSvUQXJsIhk4msxP5nNAUWoB4MFDHhtc4gAYvnqoHlaL9V3F37pNHabndawsfy/Tp7BPiy/aSa6XBYbaD1g== + "@rollup/rollup-linux-arm64-musl@4.34.8": version "4.34.8" resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.34.8.tgz#f50ecccf8c78841ff6df1706bc4782d7f62bf9c3" integrity sha512-KdSfaROOUJXgTVxJNAZ3KwkRc5nggDk+06P6lgi1HLv1hskgvxHUKZ4xtwHkVYJ1Rep4GNo+uEfycCRRxht7+Q== +"@rollup/rollup-linux-arm64-musl@4.50.0": + version "4.50.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.50.0.tgz#5d421f2f3e4a84786c4dfd9ce97e595c9b59e7f4" + integrity sha512-EtBDIZuDtVg75xIPIK1l5vCXNNCIRM0OBPUG+tbApDuJAy9mKago6QxX+tfMzbCI6tXEhMuZuN1+CU8iDW+0UQ== + "@rollup/rollup-linux-loongarch64-gnu@4.34.8": version "4.34.8" resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.34.8.tgz#5869dc0b28242da6553e2b52af41374f4038cd6e" integrity sha512-NyF4gcxwkMFRjgXBM6g2lkT58OWztZvw5KkV2K0qqSnUEqCVcqdh2jN4gQrTn/YUpAcNKyFHfoOZEer9nwo6uQ== +"@rollup/rollup-linux-loongarch64-gnu@4.50.0": + version "4.50.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.50.0.tgz#a0fb5c7d0e88319e18acfd9436f19ee39354b027" + integrity sha512-BGYSwJdMP0hT5CCmljuSNx7+k+0upweM2M4YGfFBjnFSZMHOLYR0gEEj/dxyYJ6Zc6AiSeaBY8dWOa11GF/ppQ== + "@rollup/rollup-linux-powerpc64le-gnu@4.34.8": version "4.34.8" resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.34.8.tgz#5cdd9f851ce1bea33d6844a69f9574de335f20b1" integrity sha512-LMJc999GkhGvktHU85zNTDImZVUCJ1z/MbAJTnviiWmmjyckP5aQsHtcujMjpNdMZPT2rQEDBlJfubhs3jsMfw== +"@rollup/rollup-linux-ppc64-gnu@4.50.0": + version "4.50.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.50.0.tgz#a65b598af12f25210c3295da551a6e3616ea488d" + integrity sha512-I1gSMzkVe1KzAxKAroCJL30hA4DqSi+wGc5gviD0y3IL/VkvcnAqwBf4RHXHyvH66YVHxpKO8ojrgc4SrWAnLg== + "@rollup/rollup-linux-riscv64-gnu@4.34.8": version "4.34.8" resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.34.8.tgz#ef5dc37f4388f5253f0def43e1440ec012af204d" integrity sha512-xAQCAHPj8nJq1PI3z8CIZzXuXCstquz7cIOL73HHdXiRcKk8Ywwqtx2wrIy23EcTn4aZ2fLJNBB8d0tQENPCmw== +"@rollup/rollup-linux-riscv64-gnu@4.50.0": + version "4.50.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.50.0.tgz#10ba776214ae2857c5bf4389690dabb2fbaf7d98" + integrity sha512-bSbWlY3jZo7molh4tc5dKfeSxkqnf48UsLqYbUhnkdnfgZjgufLS/NTA8PcP/dnvct5CCdNkABJ56CbclMRYCA== + +"@rollup/rollup-linux-riscv64-musl@4.50.0": + version "4.50.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.50.0.tgz#c2a46cbaa329d5f21e5808f5a66bb9c78cf68aac" + integrity sha512-LSXSGumSURzEQLT2e4sFqFOv3LWZsEF8FK7AAv9zHZNDdMnUPYH3t8ZlaeYYZyTXnsob3htwTKeWtBIkPV27iQ== + "@rollup/rollup-linux-s390x-gnu@4.34.8": version "4.34.8" resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.34.8.tgz#7dbc3ccbcbcfb3e65be74538dfb6e8dd16178fde" integrity sha512-DdePVk1NDEuc3fOe3dPPTb+rjMtuFw89gw6gVWxQFAuEqqSdDKnrwzZHrUYdac7A7dXl9Q2Vflxpme15gUWQFA== +"@rollup/rollup-linux-s390x-gnu@4.50.0": + version "4.50.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.50.0.tgz#a07447be069d64462e30c66611be20c4513963ed" + integrity sha512-CxRKyakfDrsLXiCyucVfVWVoaPA4oFSpPpDwlMcDFQvrv3XY6KEzMtMZrA+e/goC8xxp2WSOxHQubP8fPmmjOQ== + "@rollup/rollup-linux-x64-gnu@4.34.8": version "4.34.8" resolved "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.34.8.tgz" integrity sha512-8y7ED8gjxITUltTUEJLQdgpbPh1sUQ0kMTmufRF/Ns5tI9TNMNlhWtmPKKHCU0SilX+3MJkZ0zERYYGIVBYHIA== +"@rollup/rollup-linux-x64-gnu@4.50.0": + version "4.50.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.50.0.tgz#8887c58bd51242754ae9c56947d6e883332dcc74" + integrity sha512-8PrJJA7/VU8ToHVEPu14FzuSAqVKyo5gg/J8xUerMbyNkWkO9j2ExBho/68RnJsMGNJq4zH114iAttgm7BZVkA== + "@rollup/rollup-linux-x64-musl@4.34.8": version "4.34.8" resolved "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.34.8.tgz" integrity sha512-SCXcP0ZpGFIe7Ge+McxY5zKxiEI5ra+GT3QRxL0pMMtxPfpyLAKleZODi1zdRHkz5/BhueUrYtYVgubqe9JBNQ== +"@rollup/rollup-linux-x64-musl@4.50.0": + version "4.50.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.50.0.tgz#6403fda72a2b3b9fbbeeff93d14f1c45ef9775f3" + integrity sha512-SkE6YQp+CzpyOrbw7Oc4MgXFvTw2UIBElvAvLCo230pyxOLmYwRPwZ/L5lBe/VW/qT1ZgND9wJfOsdy0XptRvw== + +"@rollup/rollup-openharmony-arm64@4.50.0": + version "4.50.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.50.0.tgz#52809afccaff47e731b965a0c16e5686be819d5f" + integrity sha512-PZkNLPfvXeIOgJWA804zjSFH7fARBBCpCXxgkGDRjjAhRLOR8o0IGS01ykh5GYfod4c2yiiREuDM8iZ+pVsT+Q== + "@rollup/rollup-win32-arm64-msvc@4.34.8": version "4.34.8" resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.34.8.tgz#cbfee01f1fe73791c35191a05397838520ca3cdd" integrity sha512-YHYsgzZgFJzTRbth4h7Or0m5O74Yda+hLin0irAIobkLQFRQd1qWmnoVfwmKm9TXIZVAD0nZ+GEb2ICicLyCnQ== +"@rollup/rollup-win32-arm64-msvc@4.50.0": + version "4.50.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.50.0.tgz#23fe00ddbb40b27a3889bc1e99e6310d97353ad5" + integrity sha512-q7cIIdFvWQoaCbLDUyUc8YfR3Jh2xx3unO8Dn6/TTogKjfwrax9SyfmGGK6cQhKtjePI7jRfd7iRYcxYs93esg== + "@rollup/rollup-win32-ia32-msvc@4.34.8": version "4.34.8" resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.34.8.tgz#95cdbdff48fe6c948abcf6a1d500b2bd5ce33f62" integrity sha512-r3NRQrXkHr4uWy5TOjTpTYojR9XmF0j/RYgKCef+Ag46FWUTltm5ziticv8LdNsDMehjJ543x/+TJAek/xBA2w== +"@rollup/rollup-win32-ia32-msvc@4.50.0": + version "4.50.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.50.0.tgz#520b588076b593413d919912d69dfd5728a1f305" + integrity sha512-XzNOVg/YnDOmFdDKcxxK410PrcbcqZkBmz+0FicpW5jtjKQxcW1BZJEQOF0NJa6JO7CZhett8GEtRN/wYLYJuw== + "@rollup/rollup-win32-x64-msvc@4.34.8": version "4.34.8" resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.34.8.tgz#4cdb2cfae69cdb7b1a3cc58778e820408075e928" integrity sha512-U0FaE5O1BCpZSeE6gBl3c5ObhePQSfk9vDRToMmTkbhCOgW4jqvtS5LGyQ76L1fH8sM0keRp4uDTsbjiUyjk0g== +"@rollup/rollup-win32-x64-msvc@4.50.0": + version "4.50.0" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.50.0.tgz#d81efe6a12060c7feddf9805e2a94c3ab0679f48" + integrity sha512-xMmiWRR8sp72Zqwjgtf3QbZfF1wdh8X2ABu3EaozvZcyHJeU0r+XAnXdKgs4cCAp6ORoYoCygipYP1mjmbjrsg== + "@rx-state/core@^0.1.4": version "0.1.4" resolved "https://registry.npmjs.org/@rx-state/core/-/core-0.1.4.tgz" integrity sha512-Z+3hjU2xh1HisLxt+W5hlYX/eGSDaXXP+ns82gq/PLZpkXLu0uwcNUh9RLY3Clq4zT+hSsA3vcpIGt6+UAb8rQ== -"@scure/base@^1.1.1", "@scure/base@^1.1.7", "@scure/base@^1.2.1", "@scure/base@^1.2.4", "@scure/base@~1.2.2", "@scure/base@~1.2.4": - version "1.2.5" - resolved "https://registry.npmjs.org/@scure/base/-/base-1.2.5.tgz" - integrity sha512-9rE6EOVeIQzt5TSu4v+K523F8u6DhBsoZWPGKlnCshhlDhy0kJzUX4V+tr2dWmzF1GdekvThABoEQBGBQI7xZw== - -"@scure/base@^1.2.6": +"@scure/base@^1.1.1", "@scure/base@^1.1.7", "@scure/base@^1.2.6": version "1.2.6" resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.2.6.tgz#ca917184b8231394dd8847509c67a0be522e59f6" integrity sha512-g/nm5FgUa//MCj1gV09zTJTaM6KBAHqLN907YVQqf7zC49+DcO4B1so4ZX07Ef10Twr6nuqYEH9GEggFXA4Fmg== +"@scure/base@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@scure/base/-/base-2.0.0.tgz#ba6371fddf92c2727e88ad6ab485db6e624f9a98" + integrity sha512-3E1kpuZginKkek01ovG8krQ0Z44E3DHPjc5S2rjJw9lZn3KSQOs8S7wqikF/AH7iRanHypj85uGyxk0XAyC37w== + +"@scure/base@~1.2.2", "@scure/base@~1.2.4": + version "1.2.5" + resolved "https://registry.npmjs.org/@scure/base/-/base-1.2.5.tgz" + integrity sha512-9rE6EOVeIQzt5TSu4v+K523F8u6DhBsoZWPGKlnCshhlDhy0kJzUX4V+tr2dWmzF1GdekvThABoEQBGBQI7xZw== + "@scure/bip32@1.6.2", "@scure/bip32@^1.5.0": version "1.6.2" resolved "https://registry.npmjs.org/@scure/bip32/-/bip32-1.6.2.tgz" @@ -1134,6 +1120,14 @@ "@noble/hashes" "~1.7.1" "@scure/base" "~1.2.4" +"@scure/sr25519@^0.3.0": + version "0.3.0" + resolved "https://registry.yarnpkg.com/@scure/sr25519/-/sr25519-0.3.0.tgz#1fb075ef05086c1dc59f16bdda1327627a552352" + integrity sha512-SKsinX2sImunfcsH3seGrwH/OayBwwaJqVN8J1cJBNRCfbBq5q0jyTKGa9PcW1HWv9vXT6Yuq41JsxFLvF59ew== + dependencies: + "@noble/curves" "~2.0.0" + "@noble/hashes" "~2.0.0" + "@sec-ant/readable-stream@^0.4.1": version "0.4.1" resolved "https://registry.npmjs.org/@sec-ant/readable-stream/-/readable-stream-0.4.1.tgz" @@ -1146,17 +1140,17 @@ "@substrate/connect-extension-protocol@^2.0.0": version "2.2.2" - resolved "https://registry.npmjs.org/@substrate/connect-extension-protocol/-/connect-extension-protocol-2.2.2.tgz" + resolved "https://registry.yarnpkg.com/@substrate/connect-extension-protocol/-/connect-extension-protocol-2.2.2.tgz#2cf8f2eaf1879308d307a1a08df83cd5db918fe0" integrity sha512-t66jwrXA0s5Goq82ZtjagLNd7DPGCNjHeehRlE/gcJmJ+G56C0W+2plqOMRicJ8XGR1/YFnUSEqUFiSNbjGrAA== "@substrate/connect-known-chains@^1.1.5": version "1.10.3" - resolved "https://registry.npmjs.org/@substrate/connect-known-chains/-/connect-known-chains-1.10.3.tgz" + resolved "https://registry.yarnpkg.com/@substrate/connect-known-chains/-/connect-known-chains-1.10.3.tgz#71a89864f13626c412fa0a9d0ffc4f6ca39fdcec" integrity sha512-OJEZO1Pagtb6bNE3wCikc2wrmvEU5x7GxFFLqqbz1AJYYxSlrPCGu4N2og5YTExo4IcloNMQYFRkBGue0BKZ4w== "@substrate/connect@0.8.11": version "0.8.11" - resolved "https://registry.npmjs.org/@substrate/connect/-/connect-0.8.11.tgz" + resolved "https://registry.yarnpkg.com/@substrate/connect/-/connect-0.8.11.tgz#983ec69a05231636e217b573b8130a6b942af69f" integrity sha512-ofLs1PAO9AtDdPbdyTYj217Pe+lBfTLltdHDs3ds8no0BseoLeAGxpz1mHfi7zB4IxI3YyAiLjH6U8cw4pj4Nw== dependencies: "@substrate/connect-extension-protocol" "^2.0.0" @@ -1166,7 +1160,7 @@ "@substrate/light-client-extension-helpers@^1.0.0": version "1.0.0" - resolved "https://registry.npmjs.org/@substrate/light-client-extension-helpers/-/light-client-extension-helpers-1.0.0.tgz" + resolved "https://registry.yarnpkg.com/@substrate/light-client-extension-helpers/-/light-client-extension-helpers-1.0.0.tgz#7b60368c57e06e5cf798c6557422d12e6d81f1ff" integrity sha512-TdKlni1mBBZptOaeVrKnusMg/UBpWUORNDv5fdCaJklP4RJiFOzBCrzC+CyVI5kQzsXBisZ+2pXm+rIjS38kHg== dependencies: "@polkadot-api/json-rpc-provider" "^0.0.1" @@ -1179,7 +1173,7 @@ "@substrate/ss58-registry@^1.51.0": version "1.51.0" - resolved "https://registry.npmjs.org/@substrate/ss58-registry/-/ss58-registry-1.51.0.tgz" + resolved "https://registry.yarnpkg.com/@substrate/ss58-registry/-/ss58-registry-1.51.0.tgz#39e0341eb4069c2d3e684b93f0d8cb0bec572383" integrity sha512-TWDurLiPxndFgKjVavCniytBIw+t4ViOi7TYp9h/D0NMmkEc9klFTo+827eyEJ0lELpqO207Ey7uGxUa+BS1jQ== "@tsconfig/node10@^1.0.7": @@ -1204,7 +1198,7 @@ "@types/bn.js@^5.1.6": version "5.2.0" - resolved "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.2.0.tgz" + resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-5.2.0.tgz#4349b9710e98f9ab3cdc50f1c5e4dcbd8ef29c80" integrity sha512-DLbJ1BPqxvQhIGbeu8VbUC1DiAiahHtAYvA0ZEAa4P31F7IaArc8z3C3BRQdWX4mtLQuABG4yzp76ZrS02Ui1Q== dependencies: "@types/node" "*" @@ -1233,6 +1227,11 @@ resolved "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz" integrity sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw== +"@types/estree@1.0.8": + version "1.0.8" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.8.tgz#958b91c991b1867ced318bedea0e215ee050726e" + integrity sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w== + "@types/mocha@^10.0.10": version "10.0.10" resolved "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.10.tgz" @@ -1259,6 +1258,13 @@ dependencies: undici-types "~6.21.0" +"@types/node@^22.18.0": + version "22.18.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-22.18.0.tgz#9e4709be4f104e3568f7dd1c71e2949bf147a47b" + integrity sha512-m5ObIqwsUp6BZzyiy4RdZpzWGub9bqLJMvZDD0QMXhxjqMHMENlj+SqF5QxoUwaQNFe+8kz8XM8ZQhqkQPTgMQ== + dependencies: + undici-types "~6.21.0" + "@types/node@^24.0.14": version "24.2.0" resolved "https://registry.yarnpkg.com/@types/node/-/node-24.2.0.tgz#cde712f88c5190006d6b069232582ecd1f94a760" @@ -1361,11 +1367,6 @@ assert@^2.1.0: object.assign "^4.1.4" util "^0.12.5" -assertion-error@^2.0.1: - version "2.0.1" - resolved "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz" - integrity sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA== - available-typed-arrays@^1.0.7: version "1.0.7" resolved "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz" @@ -1385,7 +1386,7 @@ binary-extensions@^2.0.0: bn.js@^5.2.1: version "5.2.2" - resolved "https://registry.npmjs.org/bn.js/-/bn.js-5.2.2.tgz" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.2.tgz#82c09f9ebbb17107cd72cb7fd39bd1f9d0aaa566" integrity sha512-v2YAxEmKaBLahNwE1mjp4WON6huMNeuDvagFZW+ASCuA/ku0bXR9hSMw0XpiqMoA3+rmnyck/tPRSFQkoC9Cuw== brace-expansion@^2.0.1: @@ -1458,16 +1459,10 @@ camelcase@^6.0.0: resolved "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz" integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== -chai@^5.2.0: - version "5.2.0" - resolved "https://registry.npmjs.org/chai/-/chai-5.2.0.tgz" - integrity sha512-mCuXncKXk5iCLhfhwTc0izo0gtEmpz5CtG2y8GiOINBlMVS6v8TMRc5TaLWKS6692m9+dVVfzgeVxR5UxWHTYw== - dependencies: - assertion-error "^2.0.1" - check-error "^2.1.1" - deep-eql "^5.0.1" - loupe "^3.1.0" - pathval "^2.0.0" +chai@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/chai/-/chai-6.0.1.tgz#88c2b4682fb56050647e222d2cf9d6772f2607b3" + integrity sha512-/JOoU2//6p5vCXh00FpNgtlw0LjvhGttaWc+y7wpW9yjBm3ys0dI8tSKZxIOgNruz5J0RleccatSIC3uxEZP0g== chalk@^4.1.0: version "4.1.2" @@ -1482,11 +1477,6 @@ chalk@^5.3.0: resolved "https://registry.npmjs.org/chalk/-/chalk-5.4.1.tgz" integrity sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w== -check-error@^2.1.1: - version "2.1.1" - resolved "https://registry.npmjs.org/check-error/-/check-error-2.1.1.tgz" - integrity sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw== - chokidar@^3.5.3: version "3.6.0" resolved "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz" @@ -1576,17 +1566,19 @@ cross-spawn@^7.0.6: shebang-command "^2.0.0" which "^2.0.1" -crypto@^1.0.1: - version "1.0.1" - resolved "https://registry.npmjs.org/crypto/-/crypto-1.0.1.tgz" - integrity sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig== - data-uri-to-buffer@^4.0.0: version "4.0.1" - resolved "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz" + resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz#d8feb2b2881e6a4f58c2e08acfd0e2834e26222e" integrity sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A== -debug@^4.1.0, debug@^4.3.5, debug@^4.4.0: +debug@^4.1.0: + version "4.4.1" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.4.1.tgz#e5a8bc6cbc4c6cd3e64308b0693a3d4fa550189b" + integrity sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ== + dependencies: + ms "^2.1.3" + +debug@^4.3.5, debug@^4.4.0: version "4.4.0" resolved "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz" integrity sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA== @@ -1598,11 +1590,6 @@ decamelize@^4.0.0: resolved "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz" integrity sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ== -deep-eql@^5.0.1: - version "5.0.2" - resolved "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz" - integrity sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q== - deepmerge-ts@^7.1.0: version "7.1.5" resolved "https://registry.npmjs.org/deepmerge-ts/-/deepmerge-ts-7.1.5.tgz" @@ -1641,10 +1628,10 @@ diff@^5.2.0: resolved "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz" integrity sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A== -dotenv@16.4.7: - version "16.4.7" - resolved "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz" - integrity sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ== +dotenv@17.2.1: + version "17.2.1" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-17.2.1.tgz#6f32e10faf014883515538dc922a0fb8765d9b32" + integrity sha512-kQhDYKZecqnM0fCnzI5eIv5L4cAe/iRI+HqMbO/hbRdTAeXDG+M9FjipUxNfbARuEg4iHIbhnhs78BCHNbSxEQ== dunder-proto@^1.0.1: version "1.0.1" @@ -1692,35 +1679,6 @@ es-object-atoms@^1.0.0, es-object-atoms@^1.1.1: dependencies: es-errors "^1.3.0" -esbuild@^0.21.3: - version "0.21.5" - resolved "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz" - integrity sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw== - optionalDependencies: - "@esbuild/aix-ppc64" "0.21.5" - "@esbuild/android-arm" "0.21.5" - "@esbuild/android-arm64" "0.21.5" - "@esbuild/android-x64" "0.21.5" - "@esbuild/darwin-arm64" "0.21.5" - "@esbuild/darwin-x64" "0.21.5" - "@esbuild/freebsd-arm64" "0.21.5" - "@esbuild/freebsd-x64" "0.21.5" - "@esbuild/linux-arm" "0.21.5" - "@esbuild/linux-arm64" "0.21.5" - "@esbuild/linux-ia32" "0.21.5" - "@esbuild/linux-loong64" "0.21.5" - "@esbuild/linux-mips64el" "0.21.5" - "@esbuild/linux-ppc64" "0.21.5" - "@esbuild/linux-riscv64" "0.21.5" - "@esbuild/linux-s390x" "0.21.5" - "@esbuild/linux-x64" "0.21.5" - "@esbuild/netbsd-x64" "0.21.5" - "@esbuild/openbsd-x64" "0.21.5" - "@esbuild/sunos-x64" "0.21.5" - "@esbuild/win32-arm64" "0.21.5" - "@esbuild/win32-ia32" "0.21.5" - "@esbuild/win32-x64" "0.21.5" - esbuild@^0.25.0: version "0.25.5" resolved "https://registry.npmjs.org/esbuild/-/esbuild-0.25.5.tgz" @@ -1803,9 +1761,14 @@ fdir@^6.4.4: resolved "https://registry.npmjs.org/fdir/-/fdir-6.4.4.tgz" integrity sha512-1NZP+GK4GfuAv3PqKvxQRDMjdSRZjnkq7KfhlNrCNNlZ0ygQFpebfrnfnq/W7fpUnAv9aGWmY1zKx7FYL3gwhg== +fdir@^6.5.0: + version "6.5.0" + resolved "https://registry.yarnpkg.com/fdir/-/fdir-6.5.0.tgz#ed2ab967a331ade62f18d077dae192684d50d350" + integrity sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg== + fetch-blob@^3.1.2, fetch-blob@^3.1.4: version "3.2.0" - resolved "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz" + resolved "https://registry.yarnpkg.com/fetch-blob/-/fetch-blob-3.2.0.tgz#f09b8d4bbd45adc6f0c20b7e787e793e309dcce9" integrity sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ== dependencies: node-domexception "^1.0.0" @@ -1864,7 +1827,7 @@ foreground-child@^3.1.0: formdata-polyfill@^4.0.10: version "4.0.10" - resolved "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz" + resolved "https://registry.yarnpkg.com/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz#24807c31c9d402e002ab3d8c720144ceb8848423" integrity sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g== dependencies: fetch-blob "^3.1.2" @@ -2163,7 +2126,7 @@ js-yaml@^4.1.0: json-stringify-safe@^5.0.1: version "5.0.1" - resolved "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz" + resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb" integrity sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA== lilconfig@^3.1.1: @@ -2209,11 +2172,6 @@ log-symbols@^6.0.0: chalk "^5.3.0" is-unicode-supported "^1.3.0" -loupe@^3.1.0: - version "3.1.3" - resolved "https://registry.npmjs.org/loupe/-/loupe-3.1.3.tgz" - integrity sha512-kkIp7XSkP78ZxJEsSxW3712C6teJVoeHHwgo9zJ380de7IYyJ2ISlxojcH2pC5OFLewESmnRi/+XCDIEEVyoug== - lru-cache@^10.0.1, lru-cache@^10.2.0: version "10.4.3" resolved "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz" @@ -2236,14 +2194,6 @@ math-intrinsics@^1.1.0: resolved "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz" integrity sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g== -micro-sr25519@^0.1.0: - version "0.1.0" - resolved "https://registry.npmjs.org/micro-sr25519/-/micro-sr25519-0.1.0.tgz" - integrity sha512-at5zfxiKNhh07v4GPb8Sc6wCW+jd18FMMgPM0ACIQMcgvMfB9a34mfOlXr5B04J4yFZ6imlvJfRaFbOxMA7ytw== - dependencies: - "@noble/curves" "~1.7.0" - "@noble/hashes" "~1.6.0" - mimic-function@^5.0.0: version "5.0.1" resolved "https://registry.npmjs.org/mimic-function/-/mimic-function-5.0.1.tgz" @@ -2306,7 +2256,7 @@ mocha@^11.1.0: mock-socket@^9.3.1: version "9.3.1" - resolved "https://registry.npmjs.org/mock-socket/-/mock-socket-9.3.1.tgz" + resolved "https://registry.yarnpkg.com/mock-socket/-/mock-socket-9.3.1.tgz#24fb00c2f573c84812aa4a24181bb025de80cc8e" integrity sha512-qxBgB7Qa2sEQgHFjj0dSigq7fX4k6Saisd5Nelwp2q8mlbAFh5dHV9JTTlF8viYJLSSWgMCZFUom8PJcMNBoJw== ms@^2.1.3: @@ -2323,14 +2273,14 @@ mz@^2.7.0: object-assign "^4.0.1" thenify-all "^1.0.0" -nanoid@^3.3.8: - version "3.3.8" - resolved "https://registry.npmjs.org/nanoid/-/nanoid-3.3.8.tgz" - integrity sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w== +nanoid@^3.3.11: + version "3.3.11" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.11.tgz#4f4f112cefbe303202f2199838128936266d185b" + integrity sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w== nock@^13.5.5: version "13.5.6" - resolved "https://registry.npmjs.org/nock/-/nock-13.5.6.tgz" + resolved "https://registry.yarnpkg.com/nock/-/nock-13.5.6.tgz#5e693ec2300bbf603b61dae6df0225673e6c4997" integrity sha512-o2zOYiCpzRqSzPj0Zt/dQ/DqZeYoaQ7TUonc/xUPjCGl9WeHpNbxgVvOquXYAaJzI0M9BXV3HTzG0p8IUAbBTQ== dependencies: debug "^4.1.0" @@ -2339,12 +2289,12 @@ nock@^13.5.5: node-domexception@^1.0.0: version "1.0.0" - resolved "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz" + resolved "https://registry.yarnpkg.com/node-domexception/-/node-domexception-1.0.0.tgz#6888db46a1f71c0b76b3f7555016b63fe64766e5" integrity sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ== node-fetch@^3.3.2: version "3.3.2" - resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-3.3.2.tgz#d1e889bacdf733b4ff3b2b243eb7a12866a0b78b" integrity sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA== dependencies: data-uri-to-buffer "^4.0.0" @@ -2499,11 +2449,6 @@ pathe@^2.0.1: resolved "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz" integrity sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w== -pathval@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/pathval/-/pathval-2.0.0.tgz" - integrity sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA== - picocolors@^1.1.1: version "1.1.1" resolved "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz" @@ -2519,6 +2464,11 @@ picomatch@^4.0.2: resolved "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz" integrity sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg== +picomatch@^4.0.3: + version "4.0.3" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-4.0.3.tgz#796c76136d1eead715db1e7bad785dedd695a042" + integrity sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q== + pirates@^4.0.1: version "4.0.7" resolved "https://registry.npmjs.org/pirates/-/pirates-4.0.7.tgz" @@ -2570,12 +2520,12 @@ postcss-load-config@^6.0.1: dependencies: lilconfig "^3.1.1" -postcss@^8.4.43: - version "8.5.3" - resolved "https://registry.npmjs.org/postcss/-/postcss-8.5.3.tgz" - integrity sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A== +postcss@^8.5.6: + version "8.5.6" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.5.6.tgz#2825006615a619b4f62a9e7426cc120b349a8f3c" + integrity sha512-3Ybi1tAuwAP9s0r1UQ2J4n5Y0G05bJkpUIO0/bI9MhwmD70S5aTWbXGBwxHrelT+XM1k6dM0pk+SwNkpTRN7Pg== dependencies: - nanoid "^3.3.8" + nanoid "^3.3.11" picocolors "^1.1.1" source-map-js "^1.2.1" @@ -2593,7 +2543,7 @@ pretty-ms@^9.2.0: propagate@^2.0.0: version "2.0.1" - resolved "https://registry.npmjs.org/propagate/-/propagate-2.0.1.tgz" + resolved "https://registry.yarnpkg.com/propagate/-/propagate-2.0.1.tgz#40cdedab18085c792334e64f0ac17256d38f9a45" integrity sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag== punycode@^2.1.0: @@ -2649,7 +2599,7 @@ restore-cursor@^5.0.0: onetime "^7.0.0" signal-exit "^4.1.0" -rollup@^4.20.0, rollup@^4.34.8: +rollup@^4.34.8: version "4.34.8" resolved "https://registry.npmjs.org/rollup/-/rollup-4.34.8.tgz" integrity sha512-489gTVMzAYdiZHFVA/ig/iYFllCcWFHMvUHI1rpFmkoUtRlQxqh6/yiNqnYibjMZ2b/+FUQwldG+aLsEt6bglQ== @@ -2677,9 +2627,39 @@ rollup@^4.20.0, rollup@^4.34.8: "@rollup/rollup-win32-x64-msvc" "4.34.8" fsevents "~2.3.2" +rollup@^4.43.0: + version "4.50.0" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.50.0.tgz#6f237f598b7163ede33ce827af8534c929aaa186" + integrity sha512-/Zl4D8zPifNmyGzJS+3kVoyXeDeT/GrsJM94sACNg9RtUE0hrHa1bNPtRSrfHTMH5HjRzce6K7rlTh3Khiw+pw== + dependencies: + "@types/estree" "1.0.8" + optionalDependencies: + "@rollup/rollup-android-arm-eabi" "4.50.0" + "@rollup/rollup-android-arm64" "4.50.0" + "@rollup/rollup-darwin-arm64" "4.50.0" + "@rollup/rollup-darwin-x64" "4.50.0" + "@rollup/rollup-freebsd-arm64" "4.50.0" + "@rollup/rollup-freebsd-x64" "4.50.0" + "@rollup/rollup-linux-arm-gnueabihf" "4.50.0" + "@rollup/rollup-linux-arm-musleabihf" "4.50.0" + "@rollup/rollup-linux-arm64-gnu" "4.50.0" + "@rollup/rollup-linux-arm64-musl" "4.50.0" + "@rollup/rollup-linux-loongarch64-gnu" "4.50.0" + "@rollup/rollup-linux-ppc64-gnu" "4.50.0" + "@rollup/rollup-linux-riscv64-gnu" "4.50.0" + "@rollup/rollup-linux-riscv64-musl" "4.50.0" + "@rollup/rollup-linux-s390x-gnu" "4.50.0" + "@rollup/rollup-linux-x64-gnu" "4.50.0" + "@rollup/rollup-linux-x64-musl" "4.50.0" + "@rollup/rollup-openharmony-arm64" "4.50.0" + "@rollup/rollup-win32-arm64-msvc" "4.50.0" + "@rollup/rollup-win32-ia32-msvc" "4.50.0" + "@rollup/rollup-win32-x64-msvc" "4.50.0" + fsevents "~2.3.2" + rxjs@^7.8.1, rxjs@^7.8.2: version "7.8.2" - resolved "https://registry.npmjs.org/rxjs/-/rxjs-7.8.2.tgz" + resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.8.2.tgz#955bc473ed8af11a002a2be52071bf475638607b" integrity sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA== dependencies: tslib "^2.1.0" @@ -2746,7 +2726,7 @@ signal-exit@^4.0.1, signal-exit@^4.1.0: smoldot@2.0.26: version "2.0.26" - resolved "https://registry.npmjs.org/smoldot/-/smoldot-2.0.26.tgz" + resolved "https://registry.yarnpkg.com/smoldot/-/smoldot-2.0.26.tgz#0e64c7fcd26240fbe4c8d6b6e4b9a9aca77e00f6" integrity sha512-F+qYmH4z2s2FK+CxGj8moYcd1ekSIKH8ywkdqlOz88Dat35iB1DIYL11aILN46YSGMzQW/lbJNS307zBSDN5Ig== dependencies: ws "^8.8.1" @@ -2921,7 +2901,7 @@ tinyexec@^0.3.2: resolved "https://registry.npmjs.org/tinyexec/-/tinyexec-0.3.2.tgz" integrity sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA== -tinyglobby@^0.2.11: +tinyglobby@^0.2.11, tinyglobby@^0.2.14: version "0.2.14" resolved "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.14.tgz" integrity sha512-tX5e7OM1HnYr2+a2C/4V0htOcSQcoSTH9KgJnVvNm5zm/cyEWKJ7j7YutsH9CxMdtOkkLFy2AHrMci9IM8IPZQ== @@ -2982,7 +2962,7 @@ tslib@2.7.0: resolved "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz" integrity sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA== -tslib@^2.1.0, tslib@^2.7.0, tslib@^2.8.0: +tslib@^2.1.0, tslib@^2.7.0, tslib@^2.8.0, tslib@^2.8.1: version "2.8.1" resolved "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz" integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== @@ -3088,20 +3068,23 @@ viem@2.23.4: ox "0.6.7" ws "8.18.0" -vite@^5.4.8: - version "5.4.14" - resolved "https://registry.npmjs.org/vite/-/vite-5.4.14.tgz" - integrity sha512-EK5cY7Q1D8JNhSaPKVK4pwBFvaTmZxEnoKXLG/U9gmdDcihQGNzFlgIvaxezFR4glP1LsuiedwMBqCXH3wZccA== +vite@^7.1.4: + version "7.1.4" + resolved "https://registry.yarnpkg.com/vite/-/vite-7.1.4.tgz#354944affb55e1aff0157406b74e0d0a3232df9a" + integrity sha512-X5QFK4SGynAeeIt+A7ZWnApdUyHYm+pzv/8/A57LqSGcI88U6R6ipOs3uCesdc6yl7nl+zNO0t8LmqAdXcQihw== dependencies: - esbuild "^0.21.3" - postcss "^8.4.43" - rollup "^4.20.0" + esbuild "^0.25.0" + fdir "^6.5.0" + picomatch "^4.0.3" + postcss "^8.5.6" + rollup "^4.43.0" + tinyglobby "^0.2.14" optionalDependencies: fsevents "~2.3.3" web-streams-polyfill@^3.0.3: version "3.3.3" - resolved "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz" + resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz#2073b91a2fdb1fbfbd401e7de0ac9f8214cecb4b" integrity sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw== webidl-conversions@^4.0.2: From 5d387f59b52d287cf24e24e5a4feda22c8261874 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Tue, 2 Sep 2025 17:39:54 -0300 Subject: [PATCH 077/147] try to fix workflow --- .github/workflows/evm-tests.yml | 7 +------ evm-tests/get-metadata.sh | 2 +- evm-tests/run-ci.sh | 2 ++ 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/evm-tests.yml b/.github/workflows/evm-tests.yml index 7df1eb9733..c78d91248e 100644 --- a/.github/workflows/evm-tests.yml +++ b/.github/workflows/evm-tests.yml @@ -40,15 +40,10 @@ jobs: uses: Swatinem/rust-cache@v2 - name: Set up Node.js - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: node-version: "22" - - name: Install dependencies - run: | - sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get update - sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get install -y --no-install-recommends -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" build-essential clang curl libssl-dev llvm libudev-dev protobuf-compiler nodejs pkg-config - - name: Run tests uses: nick-fields/retry@v3 with: diff --git a/evm-tests/get-metadata.sh b/evm-tests/get-metadata.sh index b99915ebac..6d7727009d 100755 --- a/evm-tests/get-metadata.sh +++ b/evm-tests/get-metadata.sh @@ -1,3 +1,3 @@ rm -rf .papi -npx -y polkadot-api add devnet -w ws://localhost:9944 +npx papi add devnet -w ws://localhost:9944 diff --git a/evm-tests/run-ci.sh b/evm-tests/run-ci.sh index 6315cf11f8..059a49dac5 100755 --- a/evm-tests/run-ci.sh +++ b/evm-tests/run-ci.sh @@ -28,6 +28,8 @@ fi cd evm-tests +npm install -g polkadot-api + bash get-metadata.sh sleep 5 From a06670c818c0af70e505947d7738d32a6d24fb53 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Tue, 2 Sep 2025 15:32:26 -0700 Subject: [PATCH 078/147] OptionQuery & format --- pallets/subtensor/src/coinbase/run_coinbase.rs | 6 +----- pallets/subtensor/src/lib.rs | 6 ++++-- pallets/subtensor/src/macros/dispatches.rs | 6 ++---- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/pallets/subtensor/src/coinbase/run_coinbase.rs b/pallets/subtensor/src/coinbase/run_coinbase.rs index dd64cdfbf5..c3cb6a00be 100644 --- a/pallets/subtensor/src/coinbase/run_coinbase.rs +++ b/pallets/subtensor/src/coinbase/run_coinbase.rs @@ -512,11 +512,7 @@ impl Pallet { } let destination: T::AccountId; let owner: T::AccountId = Owner::::get(&hotkey); - if AutoStakeDestination::::contains_key(&owner) { - destination = AutoStakeDestination::::get(&owner); - } else { - destination = hotkey.clone(); - } + destination = AutoStakeDestination::::get(&owner).unwrap_or_else(|| hotkey.clone()); Self::increase_stake_for_hotkey_and_coldkey_on_subnet( &destination, &owner, diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index 1fb22b349f..4c2eaf0cc7 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -1081,9 +1081,11 @@ pub mod pallet { pub type StakingHotkeys = StorageMap<_, Blake2_128Concat, T::AccountId, Vec, ValueQuery>; #[pallet::storage] // --- MAP ( cold ) --> Vec | Returns the vector of hotkeys controlled by this coldkey. - pub type OwnedHotkeys = StorageMap<_, Blake2_128Concat, T::AccountId, Vec, ValueQuery>; + pub type OwnedHotkeys = + StorageMap<_, Blake2_128Concat, T::AccountId, Vec, ValueQuery>; #[pallet::storage] // --- MAP ( cold ) --> hot | Returns the hotkey a coldkey will autostake to with mining rewards. - pub type AutoStakeDestination = StorageMap<_, Blake2_128Concat, T::AccountId, T::AccountId, ValueQuery>; + pub type AutoStakeDestination = + StorageMap<_, Blake2_128Concat, T::AccountId, T::AccountId, OptionQuery>; #[pallet::storage] // --- DMAP ( cold ) --> (block_expected, new_coldkey) | Maps coldkey to the block to swap at and new coldkey. pub type ColdkeySwapScheduled = StorageMap< diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 2dfcdb69ab..8f2e505bbb 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -2229,10 +2229,8 @@ mod dispatches { hotkey: T::AccountId, ) -> DispatchResult { let coldkey = ensure_signed(origin)?; - log::debug!( - "set_coldkey_auto_stake_hotkey( origin:{coldkey:?} hotkey:{hotkey:?} )" - ); - AutoStakeDestination::::insert( coldkey, hotkey.clone() ); + log::debug!("set_coldkey_auto_stake_hotkey( origin:{coldkey:?} hotkey:{hotkey:?} )"); + AutoStakeDestination::::insert(coldkey, hotkey.clone()); Ok(()) } } From 44fc68a88540f105af6f8f50ee1bde1733a433b7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 2 Sep 2025 22:36:22 +0000 Subject: [PATCH 079/147] auto-update benchmark weights --- pallets/admin-utils/src/lib.rs | 6 +++--- pallets/subtensor/src/macros/dispatches.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index afbd417725..dc0521733e 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -659,8 +659,8 @@ pub mod pallet { /// It is only callable by root and subnet owner. /// The extrinsic will call the Subtensor pallet to set the minimum burn. #[pallet::call_index(22)] - #[pallet::weight(Weight::from_parts(15_440_000, 0) - .saturating_add(::DbWeight::get().reads(1_u64)) + #[pallet::weight(Weight::from_parts(18_870_000, 0) + .saturating_add(::DbWeight::get().reads(2_u64)) .saturating_add(::DbWeight::get().writes(1_u64)))] pub fn sudo_set_min_burn( origin: OriginFor, @@ -691,7 +691,7 @@ pub mod pallet { /// The extrinsic will call the Subtensor pallet to set the maximum burn. #[pallet::call_index(23)] #[pallet::weight(Weight::from_parts(15_940_000, 0) - .saturating_add(::DbWeight::get().reads(1_u64)) + .saturating_add(::DbWeight::get().reads(2_u64)) .saturating_add(::DbWeight::get().writes(1_u64)))] pub fn sudo_set_max_burn( origin: OriginFor, diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index aed0c150de..31d24ee6be 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -120,9 +120,9 @@ mod dispatches { /// - On failure for each failed item in the batch. /// #[pallet::call_index(80)] - #[pallet::weight((Weight::from_parts(95_160_000, 0) - .saturating_add(T::DbWeight::get().reads(14)) - .saturating_add(T::DbWeight::get().writes(2)), DispatchClass::Normal, Pays::No))] + #[pallet::weight((Weight::from_parts(18_570_000, 0) + .saturating_add(T::DbWeight::get().reads(1_u64)) + .saturating_add(T::DbWeight::get().writes(0_u64)), DispatchClass::Normal, Pays::No))] pub fn batch_set_weights( origin: OriginFor, netuids: Vec>, From 1e80f1cff0bece10724828a1a0d3a1af75eef0a1 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Tue, 2 Sep 2025 15:52:33 -0700 Subject: [PATCH 080/147] clean up the rest --- pallets/subtensor/src/macros/dispatches.rs | 11 +++++++++++ pallets/subtensor/src/swap/swap_coldkey.rs | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 8f2e505bbb..e189b9745b 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -2220,6 +2220,17 @@ mod dispatches { ) } + /// Set the autostake destination hotkey for a coldkey. + /// + /// The caller selects a hotkey where all future rewards + /// will be automatically staked. + /// + /// # Args: + /// * `origin` - (::Origin): + /// - The signature of the caller's coldkey. + /// + /// * `hotkey` (T::AccountId): + /// - The hotkey account to designate as the autostake destination. #[pallet::call_index(114)] #[pallet::weight((Weight::from_parts(64_530_000, 0) .saturating_add(T::DbWeight::get().reads(7_u64)) diff --git a/pallets/subtensor/src/swap/swap_coldkey.rs b/pallets/subtensor/src/swap/swap_coldkey.rs index 97458b27d6..6181727edd 100644 --- a/pallets/subtensor/src/swap/swap_coldkey.rs +++ b/pallets/subtensor/src/swap/swap_coldkey.rs @@ -178,9 +178,9 @@ impl Pallet { weight.saturating_accrue(T::DbWeight::get().reads_writes(2, 2)); } - let old_auto_stake_hotkey: T::AccountId = AutoStakeDestination::::get(old_coldkey); - AutoStakeDestination::::remove(old_coldkey); - AutoStakeDestination::::insert(new_coldkey, old_auto_stake_hotkey); + if let Some(old_auto_stake_hotkey) = AutoStakeDestination::::get(old_coldkey) { + AutoStakeDestination::::insert(new_coldkey, old_auto_stake_hotkey); + } // 4. Swap TotalColdkeyAlpha (DEPRECATED) // for netuid in Self::get_all_subnet_netuids() { From 05372feb758ca04e5d2a9f84404da3ae4859dc50 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Tue, 2 Sep 2025 16:09:44 -0700 Subject: [PATCH 081/147] add tests --- .../subtensor/src/coinbase/run_coinbase.rs | 2 +- pallets/subtensor/src/tests/coinbase.rs | 98 +++++++++++++++++++ 2 files changed, 99 insertions(+), 1 deletion(-) diff --git a/pallets/subtensor/src/coinbase/run_coinbase.rs b/pallets/subtensor/src/coinbase/run_coinbase.rs index c3cb6a00be..b14dd9e826 100644 --- a/pallets/subtensor/src/coinbase/run_coinbase.rs +++ b/pallets/subtensor/src/coinbase/run_coinbase.rs @@ -512,7 +512,7 @@ impl Pallet { } let destination: T::AccountId; let owner: T::AccountId = Owner::::get(&hotkey); - destination = AutoStakeDestination::::get(&owner).unwrap_or_else(|| hotkey.clone()); + destination = AutoStakeDestination::::get(&owner).unwrap_or(hotkey.clone()); Self::increase_stake_for_hotkey_and_coldkey_on_subnet( &destination, &owner, diff --git a/pallets/subtensor/src/tests/coinbase.rs b/pallets/subtensor/src/tests/coinbase.rs index 927f98e2fa..4781ad2dbd 100644 --- a/pallets/subtensor/src/tests/coinbase.rs +++ b/pallets/subtensor/src/tests/coinbase.rs @@ -2749,3 +2749,101 @@ fn test_coinbase_v3_liquidity_update() { assert!(liquidity_before < liquidity_after); }); } + +#[test] +fn test_incentive_is_autostaked_to_owner_destination() { + new_test_ext(1).execute_with(|| { + let subnet_owner_ck = U256::from(0); + let subnet_owner_hk = U256::from(1); + + let miner_ck = U256::from(10); + let miner_hk = U256::from(11); + let dest_hk = U256::from(12); + + Owner::::insert(miner_hk, miner_ck); + Owner::::insert(dest_hk, miner_ck); + OwnedHotkeys::::insert(miner_ck, vec![miner_hk, dest_hk]); + + let netuid = add_dynamic_network(&subnet_owner_hk, &subnet_owner_ck); + + Uids::::insert(netuid, miner_hk, 1); + Uids::::insert(netuid, dest_hk, 2); + + // Set autostake destination for the miner's coldkey + AutoStakeDestination::::insert(miner_ck, dest_hk); + + assert_eq!( + SubtensorModule::get_stake_for_hotkey_on_subnet(&miner_hk, netuid), + 0.into() + ); + assert_eq!( + SubtensorModule::get_stake_for_hotkey_on_subnet(&dest_hk, netuid), + 0.into() + ); + + // Distribute an incentive to the miner hotkey + let mut incentives: BTreeMap = BTreeMap::new(); + let incentive: AlphaCurrency = 10_000_000u64.into(); + incentives.insert(miner_hk, incentive); + + SubtensorModule::distribute_dividends_and_incentives( + netuid, + AlphaCurrency::ZERO, // owner_cut + incentives, + BTreeMap::new(), // alpha_dividends + BTreeMap::new(), // tao_dividends + ); + + // Expect the stake to land on the destination hotkey (not the original miner hotkey) + assert_eq!( + SubtensorModule::get_stake_for_hotkey_on_subnet(&miner_hk, netuid), + 0.into() + ); + assert_eq!( + SubtensorModule::get_stake_for_hotkey_on_subnet(&dest_hk, netuid), + incentive + ); + }); +} + +#[test] +fn test_incentive_goes_to_hotkey_when_no_autostake_destination() { + new_test_ext(1).execute_with(|| { + let subnet_owner_ck = U256::from(0); + let subnet_owner_hk = U256::from(1); + + let miner_ck = U256::from(20); + let miner_hk = U256::from(21); + + Owner::::insert(miner_hk, miner_ck); + OwnedHotkeys::::insert(miner_ck, vec![miner_hk]); + + let netuid = add_dynamic_network(&subnet_owner_hk, &subnet_owner_ck); + + Uids::::insert(netuid, miner_hk, 1); + + assert_eq!( + SubtensorModule::get_stake_for_hotkey_on_subnet(&miner_hk, netuid), + 0.into() + ); + + // Distribute an incentive to the miner hotkey + let mut incentives: BTreeMap = BTreeMap::new(); + let incentive: AlphaCurrency = 5_000_000u64.into(); + incentives.insert(miner_hk, incentive); + + SubtensorModule::distribute_dividends_and_incentives( + netuid, + AlphaCurrency::ZERO, // owner_cut + incentives, + BTreeMap::new(), // alpha_dividends + BTreeMap::new(), // tao_dividends + ); + + // With no autostake destination, the incentive should be staked to the original hotkey + assert_eq!( + SubtensorModule::get_stake_for_hotkey_on_subnet(&miner_hk, netuid), + incentive + ); + }); +} From 8b25c1de99d5ad5b1838a314304378559f9a1b55 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Tue, 2 Sep 2025 16:24:16 -0700 Subject: [PATCH 082/147] remove old key --- pallets/subtensor/src/swap/swap_coldkey.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/pallets/subtensor/src/swap/swap_coldkey.rs b/pallets/subtensor/src/swap/swap_coldkey.rs index 6181727edd..f7f9997183 100644 --- a/pallets/subtensor/src/swap/swap_coldkey.rs +++ b/pallets/subtensor/src/swap/swap_coldkey.rs @@ -179,6 +179,7 @@ impl Pallet { } if let Some(old_auto_stake_hotkey) = AutoStakeDestination::::get(old_coldkey) { + AutoStakeDestination::::remove(old_coldkey); AutoStakeDestination::::insert(new_coldkey, old_auto_stake_hotkey); } From df5e183e21d0dd42dafdfae51a9d6e3ca1e83093 Mon Sep 17 00:00:00 2001 From: open-junius Date: Wed, 3 Sep 2025 08:07:43 +0800 Subject: [PATCH 083/147] bump version --- pallets/subtensor/src/lib.rs | 2 +- runtime/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index 057126e13e..e606144170 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -870,7 +870,7 @@ pub mod pallet { #[pallet::type_value] /// Default value for ck burn, 18%. pub fn DefaultCKBurn() -> u64 { - u64::MAX / 18 + u64::MAX / 100 * 18 } #[pallet::storage] diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index f0dce12ca0..55dd9fb115 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: 308, + spec_version: 309, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From 4bed0e03b2b4a0a5e87f538fcb4a7956bedc89a5 Mon Sep 17 00:00:00 2001 From: open-junius Date: Wed, 3 Sep 2025 08:30:34 +0800 Subject: [PATCH 084/147] become deledate deprecated --- evm-tests/src/subtensor.ts | 9 --------- evm-tests/test/staking.precompile.reward.test.ts | 4 +--- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/evm-tests/src/subtensor.ts b/evm-tests/src/subtensor.ts index b1ff818038..9b351628d0 100644 --- a/evm-tests/src/subtensor.ts +++ b/evm-tests/src/subtensor.ts @@ -268,15 +268,6 @@ export async function setMinDelegateTake(api: TypedApi, minDelega assert.equal(minDelegateTake, await api.query.SubtensorModule.MinDelegateTake.getValue()) } -export async function becomeDelegate(api: TypedApi, ss58Address: string, keypair: KeyPair) { - const signer = getSignerFromKeypair(keypair) - - const tx = api.tx.SubtensorModule.become_delegate({ - hotkey: ss58Address - }) - await waitForTransactionWithRetry(api, tx, signer) -} - export async function addStake(api: TypedApi, netuid: number, ss58Address: string, amount_staked: bigint, keypair: KeyPair) { const signer = getSignerFromKeypair(keypair) let tx = api.tx.SubtensorModule.add_stake({ diff --git a/evm-tests/test/staking.precompile.reward.test.ts b/evm-tests/test/staking.precompile.reward.test.ts index 3735329ff2..79ad977515 100644 --- a/evm-tests/test/staking.precompile.reward.test.ts +++ b/evm-tests/test/staking.precompile.reward.test.ts @@ -7,7 +7,7 @@ import { tao } from "../src/balance-math" import { forceSetBalanceToSs58Address, addNewSubnetwork, burnedRegister, setTxRateLimit, setTempo, setWeightsSetRateLimit, setSubnetOwnerCut, setMaxAllowedUids, - setMinDelegateTake, becomeDelegate, setActivityCutoff, addStake, setWeight, rootRegister, + setMinDelegateTake, setActivityCutoff, addStake, setWeight, rootRegister, startCall } from "../src/subtensor" @@ -52,8 +52,6 @@ describe("Test neuron precompile reward", () => { await setActivityCutoff(api, netuid, 65535) await setMaxAllowedUids(api, netuid, 65535) await setMinDelegateTake(api, 0) - await becomeDelegate(api, convertPublicKeyToSs58(validator.publicKey), coldkey) - await becomeDelegate(api, convertPublicKeyToSs58(miner.publicKey), coldkey) }) it("Staker receives rewards", async () => { From 01efb6b8ad044759de8439accda4de2004ac6388 Mon Sep 17 00:00:00 2001 From: open-junius Date: Wed, 3 Sep 2025 09:03:07 +0800 Subject: [PATCH 085/147] bump version --- 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 7675c962c6..f0dce12ca0 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: 307, + spec_version: 308, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From 76ae063c954e769fe404b1775ecae8f4768803d0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 3 Sep 2025 01:22:53 +0000 Subject: [PATCH 086/147] auto-update benchmark weights --- pallets/subtensor/src/macros/dispatches.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index e189b9745b..d34fc0d224 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -120,9 +120,9 @@ mod dispatches { /// - On failure for each failed item in the batch. /// #[pallet::call_index(80)] - #[pallet::weight((Weight::from_parts(19_330_000, 0) - .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(0_u64)), DispatchClass::Normal, Pays::No))] + #[pallet::weight((Weight::from_parts(95_310_000, 0) + .saturating_add(T::DbWeight::get().reads(14_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)), DispatchClass::Normal, Pays::No))] pub fn batch_set_weights( origin: OriginFor, netuids: Vec>, @@ -966,7 +966,7 @@ mod dispatches { /// Weight is calculated based on the number of database reads and writes. #[pallet::call_index(71)] #[pallet::weight((Weight::from_parts(161_700_000, 0) - .saturating_add(T::DbWeight::get().reads(14)) + .saturating_add(T::DbWeight::get().reads(15_u64)) .saturating_add(T::DbWeight::get().writes(9)), DispatchClass::Operational, Pays::No))] pub fn swap_coldkey( origin: OriginFor, From addca32e0ddf0e41891f2694c23c97bca0c0f751 Mon Sep 17 00:00:00 2001 From: open-junius Date: Wed, 3 Sep 2025 10:00:02 +0800 Subject: [PATCH 087/147] add e2e case --- evm-tests/src/contracts/alpha.ts | 13 +++++++++++++ evm-tests/test/alpha.precompile.test.ts | 15 +++++++++++++++ precompiles/src/solidity/alpha.abi | 13 +++++++++++++ precompiles/src/solidity/alpha.sol | 4 ++++ 4 files changed, 45 insertions(+) diff --git a/evm-tests/src/contracts/alpha.ts b/evm-tests/src/contracts/alpha.ts index a87702eb80..ae24298048 100644 --- a/evm-tests/src/contracts/alpha.ts +++ b/evm-tests/src/contracts/alpha.ts @@ -315,5 +315,18 @@ export const IAlphaABI = [ ], "stateMutability": "view", "type": "function" + }, + { + "inputs": [], + "name": "getCKBurn", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" } ] \ No newline at end of file diff --git a/evm-tests/test/alpha.precompile.test.ts b/evm-tests/test/alpha.precompile.test.ts index 31b31da135..1982d1ea87 100644 --- a/evm-tests/test/alpha.precompile.test.ts +++ b/evm-tests/test/alpha.precompile.test.ts @@ -209,6 +209,21 @@ describe("Test Alpha Precompile", () => { assert.ok(typeof alphaIssuance === 'bigint', "Alpha issuance should be a bigint"); assert.ok(alphaIssuance >= BigInt(0), "Alpha issuance should be non-negative"); }); + + it("getCKBurn returns valid CK burn rate", async () => { + const ckBurn = await publicClient.readContract({ + abi: IAlphaABI, + address: toViemAddress(IALPHA_ADDRESS), + functionName: "getCKBurn", + args: [] + }) + + const ckBurnOnChain = await api.query.SubtensorModule.CKBurn.getValue() + + assert.strictEqual(ckBurn, ckBurnOnChain, "CK burn should match on chain"); + assert.ok(ckBurn !== undefined, "CK burn should be defined"); + assert.ok(typeof ckBurn === 'bigint', "CK burn should be a bigint"); + }); }); describe("Global Functions", () => { diff --git a/precompiles/src/solidity/alpha.abi b/precompiles/src/solidity/alpha.abi index 06975d5e61..14d6eb66dc 100644 --- a/precompiles/src/solidity/alpha.abi +++ b/precompiles/src/solidity/alpha.abi @@ -313,5 +313,18 @@ ], "stateMutability": "view", "type": "function" + }, + { + "inputs": [], + "name": "getCKBurn", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" } ] \ No newline at end of file diff --git a/precompiles/src/solidity/alpha.sol b/precompiles/src/solidity/alpha.sol index e66dcf00d9..c99252ff48 100644 --- a/precompiles/src/solidity/alpha.sol +++ b/precompiles/src/solidity/alpha.sol @@ -94,4 +94,8 @@ interface IAlpha { /// @dev Returns the sum of alpha prices for all subnets. /// @return The sum of alpha prices. function getSumAlphaPrice() external view returns (uint256); + + /// @dev Returns the CK burn rate. + /// @return The CK burn rate. + function getCKBurn() external view returns (uint256); } From 3fd2f16c3d5f01bd09d7bc9b9eb2f12fbc2d95d2 Mon Sep 17 00:00:00 2001 From: open-junius Date: Wed, 3 Sep 2025 10:05:22 +0800 Subject: [PATCH 088/147] check burn rate scope --- evm-tests/test/alpha.precompile.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/evm-tests/test/alpha.precompile.test.ts b/evm-tests/test/alpha.precompile.test.ts index 1982d1ea87..1ca3c755af 100644 --- a/evm-tests/test/alpha.precompile.test.ts +++ b/evm-tests/test/alpha.precompile.test.ts @@ -8,6 +8,7 @@ import { PublicClient } from "viem"; import { PolkadotSigner, TypedApi } from "polkadot-api"; import { toViemAddress, convertPublicKeyToSs58 } from "../src/address-utils" import { IAlphaABI, IALPHA_ADDRESS } from "../src/contracts/alpha" +import { u64 } from "@polkadot-api/substrate-bindings"; describe("Test Alpha Precompile", () => { // init substrate part @@ -222,6 +223,9 @@ describe("Test Alpha Precompile", () => { assert.strictEqual(ckBurn, ckBurnOnChain, "CK burn should match on chain"); assert.ok(ckBurn !== undefined, "CK burn should be defined"); + const ckBurnPercentage = BigInt(ckBurn) * BigInt(100) / BigInt(2 ** 64 - 1) + assert.ok(ckBurnPercentage >= BigInt(0), "CK burn percentage should be non-negative"); + assert.ok(ckBurnPercentage <= BigInt(100), "CK burn percentage should be less than or equal to 100"); assert.ok(typeof ckBurn === 'bigint', "CK burn should be a bigint"); }); }); From 6722dca93fb591fb877a612ab2d6fb55459a61a9 Mon Sep 17 00:00:00 2001 From: open-junius Date: Wed, 3 Sep 2025 11:53:19 +0800 Subject: [PATCH 089/147] add unit test --- pallets/subtensor/src/tests/coinbase.rs | 73 +++++++++++++++++++++++++ precompiles/src/solidity/subnet.abi | 3 + 2 files changed, 76 insertions(+) diff --git a/pallets/subtensor/src/tests/coinbase.rs b/pallets/subtensor/src/tests/coinbase.rs index 5b0f7316b0..6759f5c11b 100644 --- a/pallets/subtensor/src/tests/coinbase.rs +++ b/pallets/subtensor/src/tests/coinbase.rs @@ -1080,6 +1080,9 @@ fn test_drain_alpha_childkey_parentkey() { // Childkey take is 10% ChildkeyTake::::insert(child, netuid, u16::MAX / 10); + let parent_stake_before = SubtensorModule::get_stake_for_hotkey_on_subnet(&parent, netuid); + let child_stake_before = SubtensorModule::get_stake_for_hotkey_on_subnet(&child, netuid); + let pending_alpha = AlphaCurrency::from(1_000_000_000); SubtensorModule::drain_pending_emission( netuid, @@ -1099,6 +1102,7 @@ fn test_drain_alpha_childkey_parentkey() { expected.to_num::(), parent_stake_after ); + close(expected.to_num::(), parent_stake_after.into(), 10_000); let expected = I96F32::from_num(u64::from(pending_alpha)) / I96F32::from_num(10); close(expected.to_num::(), child_stake_after.into(), 10_000); @@ -2753,3 +2757,72 @@ fn test_coinbase_v3_liquidity_update() { assert!(liquidity_before < liquidity_after); }); } + +// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --package pallet-subtensor --lib -- tests::coinbase::test_drain_alpha_childkey_parentkey_with_burn --exact --show-output --nocapture +#[test] +fn test_drain_alpha_childkey_parentkey_with_burn() { + new_test_ext(1).execute_with(|| { + let netuid = NetUid::from(1); + add_network(netuid, 1, 0); + let parent = U256::from(1); + let child = U256::from(2); + let coldkey = U256::from(3); + let stake_before = AlphaCurrency::from(1_000_000_000); + register_ok_neuron(netuid, child, coldkey, 0); + SubtensorModule::increase_stake_for_hotkey_and_coldkey_on_subnet( + &parent, + &coldkey, + netuid, + stake_before, + ); + mock_set_children_no_epochs(netuid, &parent, &[(u64::MAX, child)]); + + // Childkey take is 10% + ChildkeyTake::::insert(child, netuid, u16::MAX / 10); + + let burn_rate = SubtensorModule::get_ck_burn(); + let parent_stake_before = SubtensorModule::get_stake_for_hotkey_on_subnet(&parent, netuid); + let child_stake_before = SubtensorModule::get_stake_for_hotkey_on_subnet(&child, netuid); + + let pending_alpha = AlphaCurrency::from(1_000_000_000); + SubtensorModule::drain_pending_emission( + netuid, + pending_alpha, + TaoCurrency::ZERO, + AlphaCurrency::ZERO, + AlphaCurrency::ZERO, + ); + let parent_stake_after = SubtensorModule::get_stake_for_hotkey_on_subnet(&parent, netuid); + let child_stake_after = SubtensorModule::get_stake_for_hotkey_on_subnet(&child, netuid); + + let expected_ck_burn = I96F32::from_num(pending_alpha) + * I96F32::from_num(9.0 / 10.0) + * I96F32::from_num(burn_rate); + + let expected_total = I96F32::from_num(pending_alpha) - expected_ck_burn; + let parent_ratio = (I96F32::from_num(pending_alpha) * I96F32::from_num(9.0 / 10.0) + - expected_ck_burn) + / expected_total; + let child_ratio = (I96F32::from_num(pending_alpha) / I96F32::from_num(10)) / expected_total; + + let expected = + I96F32::from_num(stake_before) + I96F32::from_num(pending_alpha) * parent_ratio; + log::info!( + "expected: {:?}, parent_stake_after: {:?}", + expected.to_num::(), + parent_stake_after + ); + + close( + expected.to_num::(), + parent_stake_after.into(), + 3_000_000, + ); + let expected = I96F32::from_num(u64::from(pending_alpha)) * child_ratio; + close( + expected.to_num::(), + child_stake_after.into(), + 3_000_000, + ); + }); +} diff --git a/precompiles/src/solidity/subnet.abi b/precompiles/src/solidity/subnet.abi index 805c0057d9..f2d97e1f90 100644 --- a/precompiles/src/solidity/subnet.abi +++ b/precompiles/src/solidity/subnet.abi @@ -1046,5 +1046,8 @@ "outputs": [], "stateMutability": "payable", "type": "function" + }, + { + "inputs" } ] From ccb23ccfc4a062403e6c81a870ce1e8f444eb7d5 Mon Sep 17 00:00:00 2001 From: open-junius Date: Wed, 3 Sep 2025 11:55:07 +0800 Subject: [PATCH 090/147] remove unused variable --- pallets/subtensor/src/tests/coinbase.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/pallets/subtensor/src/tests/coinbase.rs b/pallets/subtensor/src/tests/coinbase.rs index 6759f5c11b..dce2f7b6ad 100644 --- a/pallets/subtensor/src/tests/coinbase.rs +++ b/pallets/subtensor/src/tests/coinbase.rs @@ -1080,9 +1080,6 @@ fn test_drain_alpha_childkey_parentkey() { // Childkey take is 10% ChildkeyTake::::insert(child, netuid, u16::MAX / 10); - let parent_stake_before = SubtensorModule::get_stake_for_hotkey_on_subnet(&parent, netuid); - let child_stake_before = SubtensorModule::get_stake_for_hotkey_on_subnet(&child, netuid); - let pending_alpha = AlphaCurrency::from(1_000_000_000); SubtensorModule::drain_pending_emission( netuid, From 682cb0d157128c5bfc95308ca41e880548a4cee3 Mon Sep 17 00:00:00 2001 From: open-junius Date: Wed, 3 Sep 2025 11:56:57 +0800 Subject: [PATCH 091/147] unnecessary code change --- pallets/subtensor/src/tests/coinbase.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/pallets/subtensor/src/tests/coinbase.rs b/pallets/subtensor/src/tests/coinbase.rs index dce2f7b6ad..fc1712d161 100644 --- a/pallets/subtensor/src/tests/coinbase.rs +++ b/pallets/subtensor/src/tests/coinbase.rs @@ -1099,7 +1099,6 @@ fn test_drain_alpha_childkey_parentkey() { expected.to_num::(), parent_stake_after ); - close(expected.to_num::(), parent_stake_after.into(), 10_000); let expected = I96F32::from_num(u64::from(pending_alpha)) / I96F32::from_num(10); close(expected.to_num::(), child_stake_after.into(), 10_000); From bb7499346aed092545e083ff9362e5a804d75b0e Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Wed, 3 Sep 2025 13:34:57 +0300 Subject: [PATCH 092/147] Update autostake extrinsic. --- pallets/subtensor/src/benchmarks.rs | 9 +++++++++ pallets/subtensor/src/coinbase/run_coinbase.rs | 4 ++-- pallets/subtensor/src/macros/dispatches.rs | 9 +++++---- pallets/subtensor/src/tests/coinbase.rs | 5 ++++- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/pallets/subtensor/src/benchmarks.rs b/pallets/subtensor/src/benchmarks.rs index 42e3d79a23..6dd5390992 100644 --- a/pallets/subtensor/src/benchmarks.rs +++ b/pallets/subtensor/src/benchmarks.rs @@ -1588,4 +1588,13 @@ mod pallet_benchmarks { Subtensor::::get_commit_reveal_weights_version(), ); } + + #[benchmark] + fn set_coldkey_auto_stake_hotkey() { + let coldkey: T::AccountId = whitelisted_caller(); + let hot: T::AccountId = account("A", 0, 1); + + #[extrinsic_call] + _(RawOrigin::Signed(coldkey.clone()), hot.clone()); + } } diff --git a/pallets/subtensor/src/coinbase/run_coinbase.rs b/pallets/subtensor/src/coinbase/run_coinbase.rs index b14dd9e826..c143d16a16 100644 --- a/pallets/subtensor/src/coinbase/run_coinbase.rs +++ b/pallets/subtensor/src/coinbase/run_coinbase.rs @@ -510,9 +510,9 @@ impl Pallet { ); continue; } - let destination: T::AccountId; + let owner: T::AccountId = Owner::::get(&hotkey); - destination = AutoStakeDestination::::get(&owner).unwrap_or(hotkey.clone()); + let destination = AutoStakeDestination::::get(&owner).unwrap_or(hotkey.clone()); Self::increase_stake_for_hotkey_and_coldkey_on_subnet( &destination, &owner, diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index b758bc74cc..83c637802c 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -2062,16 +2062,17 @@ mod dispatches { /// * `hotkey` (T::AccountId): /// - The hotkey account to designate as the autostake destination. #[pallet::call_index(114)] - #[pallet::weight((Weight::from_parts(64_530_000, 0) - .saturating_add(T::DbWeight::get().reads(7_u64)) - .saturating_add(T::DbWeight::get().writes(2)), DispatchClass::Normal, Pays::Yes))] + #[pallet::weight( + Weight::from_parts(4_000_000, 0).saturating_add(T::DbWeight::get().writes(1_u64)) + )] pub fn set_coldkey_auto_stake_hotkey( origin: T::RuntimeOrigin, hotkey: T::AccountId, ) -> DispatchResult { let coldkey = ensure_signed(origin)?; - log::debug!("set_coldkey_auto_stake_hotkey( origin:{coldkey:?} hotkey:{hotkey:?} )"); + AutoStakeDestination::::insert(coldkey, hotkey.clone()); + Ok(()) } } diff --git a/pallets/subtensor/src/tests/coinbase.rs b/pallets/subtensor/src/tests/coinbase.rs index 4781ad2dbd..ccad86855b 100644 --- a/pallets/subtensor/src/tests/coinbase.rs +++ b/pallets/subtensor/src/tests/coinbase.rs @@ -2770,7 +2770,10 @@ fn test_incentive_is_autostaked_to_owner_destination() { Uids::::insert(netuid, dest_hk, 2); // Set autostake destination for the miner's coldkey - AutoStakeDestination::::insert(miner_ck, dest_hk); + assert_ok!(SubtensorModule::set_coldkey_auto_stake_hotkey( + RuntimeOrigin::signed(miner_ck), + dest_hk, + )); assert_eq!( SubtensorModule::get_stake_for_hotkey_on_subnet(&miner_hk, netuid), From 5ef002b763fb4f716c2b8082c847f0c0527ba878 Mon Sep 17 00:00:00 2001 From: Loris Moulin Date: Wed, 3 Sep 2025 09:18:42 -0300 Subject: [PATCH 093/147] restore some ci stuff --- .github/workflows/evm-tests.yml | 5 +++++ evm-tests/run-ci.sh | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/evm-tests.yml b/.github/workflows/evm-tests.yml index c78d91248e..b818695237 100644 --- a/.github/workflows/evm-tests.yml +++ b/.github/workflows/evm-tests.yml @@ -44,6 +44,11 @@ jobs: with: node-version: "22" + - name: Install dependencies + run: | + sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get update + sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get install -y --no-install-recommends -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" build-essential clang curl libssl-dev llvm libudev-dev protobuf-compiler nodejs pkg-config + - name: Run tests uses: nick-fields/retry@v3 with: diff --git a/evm-tests/run-ci.sh b/evm-tests/run-ci.sh index 059a49dac5..7ad4bb2186 100755 --- a/evm-tests/run-ci.sh +++ b/evm-tests/run-ci.sh @@ -28,7 +28,8 @@ fi cd evm-tests -npm install -g polkadot-api +# required for papi in get-metadata.sh, but we cannot run yarn before papi as it adds the descriptors to the package.json which won't resolve +npm i -g polkadot-api bash get-metadata.sh From 60fdadf6bb146ce235f231732b14c3992646ba43 Mon Sep 17 00:00:00 2001 From: open-junius Date: Wed, 3 Sep 2025 20:27:59 +0800 Subject: [PATCH 094/147] bump version --- 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 f0dce12ca0..55dd9fb115 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: 308, + spec_version: 309, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From 9e2d57512028fcb192ae640ceed2bc3e9761de64 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 3 Sep 2025 12:46:01 +0000 Subject: [PATCH 095/147] 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 83c637802c..c842709208 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -2063,7 +2063,7 @@ mod dispatches { /// - The hotkey account to designate as the autostake destination. #[pallet::call_index(114)] #[pallet::weight( - Weight::from_parts(4_000_000, 0).saturating_add(T::DbWeight::get().writes(1_u64)) + Weight::from_parts(5_170_000, 0).saturating_add(T::DbWeight::get().writes(1_u64)) )] pub fn set_coldkey_auto_stake_hotkey( origin: T::RuntimeOrigin, From 179c918bdebf174c8bc92323628ac0f110920284 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 3 Sep 2025 09:06:10 -0700 Subject: [PATCH 096/147] apply benchmark patch on label --- .github/workflows/apply-benchmark-patch.yml | 83 +++++++++++++++++++++ .github/workflows/run-benchmarks.yml | 10 ++- scripts/benchmark_action.sh | 44 ++++++----- 3 files changed, 116 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/apply-benchmark-patch.yml diff --git a/.github/workflows/apply-benchmark-patch.yml b/.github/workflows/apply-benchmark-patch.yml new file mode 100644 index 0000000000..b7e8d75766 --- /dev/null +++ b/.github/workflows/apply-benchmark-patch.yml @@ -0,0 +1,83 @@ +# .github/workflows/apply-benchmark-patch.yml +name: Apply-Benchmark-Patch + +on: + pull_request: + types: [labeled] + +permissions: + contents: write + pull-requests: write + +jobs: + apply: + if: ${{ github.event.label.name == 'apply-benchmark-patch' }} + runs-on: Benchmarking + + steps: + - name: Check out PR branch + uses: actions/checkout@v4 + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.ref }} + fetch-depth: 0 + + - name: Install GitHub CLI + run: | + sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get update + sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get install -y --no-install-recommends -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" gh + echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token + + - name: Download latest bench patch artifact from failed run + uses: dawidd6/action-download-artifact@v3 + with: + workflow: Validate-Benchmarks + pr: ${{ github.event.pull_request.number }} + workflow_conclusion: failure + name: bench-patch + path: .bench_patch + + - name: Apply and commit patch (if available) + run: | + set -euo pipefail + + if [ ! -f ".bench_patch/benchmark_patch.diff" ]; then + echo "No benchmark patch artifact found for this PR." + echo "You may need to re-run 'Validate-Benchmarks' to generate a fresh patch." + exit 0 + fi + + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + # Attempt 3-way apply; if it fails, ask to regenerate + if ! git apply --index --3way .bench_patch/benchmark_patch.diff; then + echo "Patch failed to apply cleanly. Please re-run Validate-Benchmarks to regenerate the patch." + exit 1 + fi + + if git diff --cached --quiet; then + echo "Patch applied but produced no changes (already up to date)." + exit 0 + fi + + echo "==== diff preview ====" + git diff --cached --stat + git diff --cached | head -n 80 || true + echo "======================" + + branch=$(git symbolic-ref --quiet --short HEAD || true) + if [ -z "$branch" ]; then + echo "Not on a branch - cannot push" >&2 + exit 1 + fi + + git commit -m "auto-update benchmark weights" + git push origin "HEAD:${branch}" + + - name: Remove apply-benchmark-patch label + if: ${{ success() }} + run: | + gh pr edit ${{ github.event.pull_request.number }} \ + --repo "${{ github.repository }}" \ + --remove-label "apply-benchmark-patch" || true diff --git a/.github/workflows/run-benchmarks.yml b/.github/workflows/run-benchmarks.yml index 2e9980532b..75ec1183f8 100644 --- a/.github/workflows/run-benchmarks.yml +++ b/.github/workflows/run-benchmarks.yml @@ -20,7 +20,6 @@ jobs: env: SKIP_BENCHMARKS: "0" - AUTO_COMMIT_WEIGHTS: "1" steps: # ────────────────────────────────────────────────────────────────── @@ -135,6 +134,15 @@ jobs: chmod +x scripts/benchmark_action.sh scripts/benchmark_action.sh + # Persist the prepared patch even if the previous step failed. + - name: Upload patch artifact (if prepared) + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + name: bench-patch + path: .bench_patch/** + if-no-files-found: ignore + # (6) — final check after run - name: Check skip label after run if: ${{ env.SKIP_BENCHMARKS != '1' }} diff --git a/scripts/benchmark_action.sh b/scripts/benchmark_action.sh index 50b2a3a014..8e2f2103bd 100755 --- a/scripts/benchmark_action.sh +++ b/scripts/benchmark_action.sh @@ -13,10 +13,13 @@ declare -A DISPATCH_PATHS=( THRESHOLD=20 MAX_RETRIES=3 -AUTO_COMMIT="${AUTO_COMMIT_WEIGHTS:-0}" + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" RUNTIME_WASM="$SCRIPT_DIR/../target/production/wbuild/node-subtensor-runtime/node_subtensor_runtime.compact.compressed.wasm" +PATCH_DIR="$SCRIPT_DIR/../.bench_patch" +mkdir -p "$PATCH_DIR" + die() { echo "❌ $1" >&2; exit 1; } digits_only() { echo "${1//[^0-9]/}"; } dec() { local d; d=$(digits_only "$1"); echo "$((10#${d:-0}))"; } @@ -62,25 +65,27 @@ patch_reads_writes() { after=$(sha1sum "$4" | cut -d' ' -f1); [[ "$before" != "$after" ]] } -git_commit_and_push() { - local msg="$1" - local branch; branch=$(git symbolic-ref --quiet --short HEAD || true) - [[ -z "$branch" ]] && die "Not on a branch - cannot push" +write_patch_artifacts_and_fail() { + if [ ${#PATCHED_FILES[@]} -eq 0 ]; then + die "Benchmark drift detected but no files were patched." + fi - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" git add "${PATCHED_FILES[@]}" || true - if git diff --cached --quiet; then - echo "ℹ️ No staged changes after patching."; git status --short; return - fi + { + echo "Head SHA: $(git rev-parse HEAD)" + echo + echo "==== Diffstat ====" + git diff --cached --stat || true + } > "$PATCH_DIR/summary.txt" + + git diff --cached --binary > "$PATCH_DIR/benchmark_patch.diff" - echo "==== diff preview ===="; git diff --cached --stat - git diff --cached | head -n 40 || true - echo "======================" + echo "📦 Prepared patch at: $PATCH_DIR/benchmark_patch.diff" + echo "ℹ️ Add the 'apply-benchmark-patch' label to this PR to have CI apply & commit it." - git commit -m "$msg" - git push origin "HEAD:$branch" || die "Push to '${branch}' failed." + # Fail the job so the PR is blocked until the label is set and the apply workflow runs. + exit 2 } echo "Building runtime-benchmarks…" @@ -155,13 +160,13 @@ for pallet in "${PALLET_LIST[@]}"; do done < "$TMP"; flush echo; printf ' %s\n' "${summary[@]}" + (( fail == 0 )) && { echo "✅ '$pallet' within tolerance."; break; } printf ' ❌ %s\n' "${failures[@]}" (( attempt < MAX_RETRIES )) && { echo "→ Retrying …"; (( attempt++ )); continue; } - echo "❌ '$pallet' still failing; patching …" - [[ "$AUTO_COMMIT" != "1" ]] && die "AUTO_COMMIT_WEIGHTS disabled." + echo "❌ '$pallet' still failing; patching (prepare-only) …" changed=0 for fn in $(printf "%s\n" "${!new_weight[@]}" "${!new_reads[@]}" "${!new_writes[@]}" | sort -u); do @@ -179,11 +184,10 @@ for pallet in "${PALLET_LIST[@]}"; do done ################################################################################ -# Commit & push patches +# Commit & push? No — prepare artifact and fail. ################################################################################ if (( ${#PATCHED_FILES[@]} )); then - echo -e "\n📦 Committing patched files …" - git_commit_and_push "auto-update benchmark weights" + write_patch_artifacts_and_fail fi echo -e "\n══════════════════════════════════════" From 915700ad54acba9ed617cf9822230c354a66e574 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 3 Sep 2025 17:42:28 +0000 Subject: [PATCH 097/147] 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( From 6e53d042ea6d9d28de973fce1e01ca1f026babd1 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 3 Sep 2025 11:33:30 -0700 Subject: [PATCH 098/147] fix --- .github/workflows/apply-benchmark-patch.yml | 10 ++-- pallets/subtensor/src/macros/dispatches.rs | 6 +- scripts/benchmark_action.sh | 63 +++++++++++++++------ 3 files changed, 54 insertions(+), 25 deletions(-) diff --git a/.github/workflows/apply-benchmark-patch.yml b/.github/workflows/apply-benchmark-patch.yml index b7e8d75766..0914a5c6ef 100644 --- a/.github/workflows/apply-benchmark-patch.yml +++ b/.github/workflows/apply-benchmark-patch.yml @@ -8,6 +8,7 @@ on: permissions: contents: write pull-requests: write + actions: read # required to list & download artifacts from another workflow jobs: apply: @@ -31,19 +32,20 @@ jobs: - name: Download latest bench patch artifact from failed run uses: dawidd6/action-download-artifact@v3 with: - workflow: Validate-Benchmarks + workflow: run-benchmarks.yml pr: ${{ github.event.pull_request.number }} workflow_conclusion: failure name: bench-patch path: .bench_patch + allow_forks: true - name: Apply and commit patch (if available) run: | set -euo pipefail if [ ! -f ".bench_patch/benchmark_patch.diff" ]; then - echo "No benchmark patch artifact found for this PR." - echo "You may need to re-run 'Validate-Benchmarks' to generate a fresh patch." + echo "No benchmark_patch.diff found. Either no auto-patch was possible or it wasn't generated." + echo "See .bench_patch/summary.txt for details (if present)." exit 0 fi @@ -52,7 +54,7 @@ jobs: # Attempt 3-way apply; if it fails, ask to regenerate if ! git apply --index --3way .bench_patch/benchmark_patch.diff; then - echo "Patch failed to apply cleanly. Please re-run Validate-Benchmarks to regenerate the patch." + echo "Patch failed to apply cleanly. Re-run Validate-Benchmarks to regenerate the patch." exit 1 fi diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index c842709208..f9ef39d6cf 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -2062,9 +2062,9 @@ mod dispatches { /// * `hotkey` (T::AccountId): /// - The hotkey account to designate as the autostake destination. #[pallet::call_index(114)] - #[pallet::weight( - Weight::from_parts(5_170_000, 0).saturating_add(T::DbWeight::get().writes(1_u64)) - )] + #[pallet::weight((Weight::from_parts(5_170_000, 0) + .saturating_add(T::DbWeight::get().reads(0)) + .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Normal, Pays::No))] pub fn set_coldkey_auto_stake_hotkey( origin: T::RuntimeOrigin, hotkey: T::AccountId, diff --git a/scripts/benchmark_action.sh b/scripts/benchmark_action.sh index 8e2f2103bd..fb898abd37 100755 --- a/scripts/benchmark_action.sh +++ b/scripts/benchmark_action.sh @@ -12,7 +12,7 @@ declare -A DISPATCH_PATHS=( ) THRESHOLD=20 -MAX_RETRIES=3 +MAX_RETRIES=1 SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" RUNTIME_WASM="$SCRIPT_DIR/../target/production/wbuild/node-subtensor-runtime/node_subtensor_runtime.compact.compressed.wasm" @@ -35,7 +35,8 @@ patch_weight() { FN="$1" NEWV="$2" perl -0777 -i -pe ' my $n=$ENV{NEWV}; my $hit=0; $hit+=s|(pub\s+fn\s+\Q$ENV{FN}\E\s*[^{}]*?Weight::from_parts\(\s*)[0-9A-Za-z_]+|$1$n|s; - $hit+=s|(\#\s*\[pallet::weight[^\]]*?Weight::from_parts\(\s*)[0-9A-Za-z_]+(?=[^\]]*?\]\s*pub\s+fn\s+\Q$ENV{FN}\E\b)|$1$n|s; + # attribute replacement allowing intermediate attributes (e.g., call_index) before pub fn + $hit+=s|(\#\s*\[pallet::weight[^\]]*?Weight::from_parts\(\s*)[0-9A-Za-z_]+(?=[^\]]*\](?:\s*#\[[^\]]*\])*\s*pub\s+fn\s+\Q$ENV{FN}\E\b)|$1$n|s; END{exit $hit?0:1} ' "$3" || log_warn "patch_weight: no substitution for $1" after=$(sha1sum "$3" | cut -d' ' -f1); [[ "$before" != "$after" ]] @@ -54,37 +55,55 @@ patch_reads_writes() { my $W=$neww eq "" ? $w : u64($neww); return "$pre$R$mid$W$post"; }; - $h+=s|(pub\s+fn\s+\Q$ENV{FN}\E\s*[^{}]*?reads_writes\(\s*)([^,]+)(\s*,\s*)([^)]+)|&$rw_sub($1,$2,$3,$4,"")|e; - $h+=s|(\#\s*\[pallet::weight[^\]]*?reads_writes\(\s*)([^,]+)(\s*,\s*)([^)]+)(?=[^\]]*?\]\s*pub\s+fn\s+\Q$ENV{FN}\E\b)|&$rw_sub($1,$2,$3,$4,"")|e; - $h+=s|(pub\s+fn\s+\Q$ENV{FN}\E\s*[^{}]*?\.reads\(\s*)([^)]+)|$1.($newr eq "" ? $2 : u64($newr))|e; - $h+=s|(\#\s*\[pallet::weight[^\]]*?\.reads\(\s*)([^)]+)(?=[^\]]*?\]\s*pub\s+fn\s+\Q$ENV{FN}\E\b)|$1.($newr eq "" ? $2 : u64($newr))|e; - $h+=s|(pub\s+fn\s+\Q$ENV{FN}\E\s*[^{}]*?\.writes\(\s*)([^)]+)|$1.($neww eq "" ? $2 : u64($neww))|e; - $h+=s|(\#\s*\[pallet::weight[^\]]*?\.writes\(\s*)([^)]+)(?=[^\]]*?\]\s*pub\s+fn\s+\Q$ENV{FN}\E\b)|$1.($neww eq "" ? $2 : u64($neww))|e; + # In-body: reads_writes(...) + $h+=s|(pub\s+fn\s+\Q$ENV{FN}\E\s*[^{}]*?reads_writes\(\s*)([^,]+)(\s*,\s*)([^)]+)|&$rw_sub($1,$2,$3,$4,"")|sge; + # In-body: .reads(...) and .writes(...) + $h+=s|(pub\s+fn\s+\Q$ENV{FN}\E\s*[^{}]*?\.reads\(\s*)([^)]+)|$1.($newr eq "" ? $2 : u64($newr))|sge; + $h+=s|(pub\s+fn\s+\Q$ENV{FN}\E\s*[^{}]*?\.writes\(\s*)([^)]+)|$1.($neww eq "" ? $2 : u64($neww))|sge; + + # Attribute: reads_writes(...), tolerate other attributes between ] and pub fn + $h+=s|(\#\s*\[pallet::weight[^\]]*?reads_writes\(\s*)([^,]+)(\s*,\s*)([^)]+)(?=[^\]]*\](?:\s*#\[[^\]]*\])*\s*pub\s+fn\s+\Q$ENV{FN}\E\b)|&$rw_sub($1,$2,$3,$4,"")|sge; + # Attribute: .reads(...) and .writes(...), tolerate other attributes between ] and pub fn + $h+=s|(\#\s*\[pallet::weight[^\]]*?\.reads\(\s*)([^)]+)(?=[^\]]*\](?:\s*#\[[^\]]*\])*\s*pub\s+fn\s+\Q$ENV{FN}\E\b)|$1.($newr eq "" ? $2 : u64($newr))|sge; + $h+=s|(\#\s*\[pallet::weight[^\]]*?\.writes\(\s*)([^)]+)(?=[^\]]*\](?:\s*#\[[^\]]*\])*\s*pub\s+fn\s+\Q$ENV{FN}\E\b)|$1.($neww eq "" ? $2 : u64($neww))|sge; + END{exit $h?0:1} ' "$4" || log_warn "patch_reads_writes: no substitution for $1" after=$(sha1sum "$4" | cut -d' ' -f1); [[ "$before" != "$after" ]] } write_patch_artifacts_and_fail() { - if [ ${#PATCHED_FILES[@]} -eq 0 ]; then - die "Benchmark drift detected but no files were patched." - fi - git add "${PATCHED_FILES[@]}" || true { echo "Head SHA: $(git rev-parse HEAD)" echo + echo "==== Benchmark summary ====" + printf '%s\n' "${GLOBAL_SUMMARY[@]}" || true + echo echo "==== Diffstat ====" git diff --cached --stat || true } > "$PATCH_DIR/summary.txt" - git diff --cached --binary > "$PATCH_DIR/benchmark_patch.diff" + git diff --cached --binary > "$PATCH_DIR/benchmark_patch.diff" || true echo "📦 Prepared patch at: $PATCH_DIR/benchmark_patch.diff" echo "ℹ️ Add the 'apply-benchmark-patch' label to this PR to have CI apply & commit it." + exit 2 +} - # Fail the job so the PR is blocked until the label is set and the apply workflow runs. +write_summary_only_and_fail() { + { + echo "Head SHA: $(git rev-parse HEAD)" + echo + echo "==== Benchmark summary ====" + printf '%s\n' "${GLOBAL_SUMMARY[@]}" || true + echo + echo "No auto-patch was generated for the mismatched extrinsics." + echo "Manual update may be required." + } > "$PATCH_DIR/summary.txt" + + echo "⚠️ No patch could be auto-generated. See .bench_patch/summary.txt." exit 2 } @@ -96,6 +115,8 @@ echo " Will benchmark pallets: ${PALLET_LIST[*]}" echo "─────────────────────────────────────────────" PATCHED_FILES=() +GLOBAL_SUMMARY=() +ANY_FAILURE=0 ################################################################################ # Benchmark loop @@ -160,6 +181,7 @@ for pallet in "${PALLET_LIST[@]}"; do done < "$TMP"; flush echo; printf ' %s\n' "${summary[@]}" + GLOBAL_SUMMARY+=("${summary[@]}") (( fail == 0 )) && { echo "✅ '$pallet' within tolerance."; break; } @@ -167,6 +189,7 @@ for pallet in "${PALLET_LIST[@]}"; do (( attempt < MAX_RETRIES )) && { echo "→ Retrying …"; (( attempt++ )); continue; } echo "❌ '$pallet' still failing; patching (prepare-only) …" + ANY_FAILURE=1 changed=0 for fn in $(printf "%s\n" "${!new_weight[@]}" "${!new_reads[@]}" "${!new_writes[@]}" | sort -u); do @@ -184,12 +207,16 @@ for pallet in "${PALLET_LIST[@]}"; do done ################################################################################ -# Commit & push? No — prepare artifact and fail. +# Fail if any mismatch; upload artifacts in workflow step ################################################################################ -if (( ${#PATCHED_FILES[@]} )); then - write_patch_artifacts_and_fail +if (( ANY_FAILURE )); then + if (( ${#PATCHED_FILES[@]} )); then + write_patch_artifacts_and_fail + else + write_summary_only_and_fail + fi fi echo -e "\n══════════════════════════════════════" -echo "All pallets processed ✔" +echo "All pallets processed ✔ (no drift)" echo "══════════════════════════════════════" From 2c2233102a57344ccf31f756978b5ce4bf71c0b2 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 3 Sep 2025 12:28:59 -0700 Subject: [PATCH 099/147] test patch --- 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 f9ef39d6cf..76046a9094 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -2063,7 +2063,7 @@ mod dispatches { /// - The hotkey account to designate as the autostake destination. #[pallet::call_index(114)] #[pallet::weight((Weight::from_parts(5_170_000, 0) - .saturating_add(T::DbWeight::get().reads(0)) + .saturating_add(T::DbWeight::get().reads(1)) .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Normal, Pays::No))] pub fn set_coldkey_auto_stake_hotkey( origin: T::RuntimeOrigin, From 8dda0f5724cab306b227b8d2d1e4b6f2a4d52de7 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 3 Sep 2025 13:44:00 -0700 Subject: [PATCH 100/147] test --- .github/workflows/apply-benchmark-patch.yml | 31 ++++++++++++++------- .github/workflows/run-benchmarks.yml | 2 +- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/.github/workflows/apply-benchmark-patch.yml b/.github/workflows/apply-benchmark-patch.yml index 0914a5c6ef..e578de3cbf 100644 --- a/.github/workflows/apply-benchmark-patch.yml +++ b/.github/workflows/apply-benchmark-patch.yml @@ -1,4 +1,3 @@ -# .github/workflows/apply-benchmark-patch.yml name: Apply-Benchmark-Patch on: @@ -8,7 +7,7 @@ on: permissions: contents: write pull-requests: write - actions: read # required to list & download artifacts from another workflow + actions: read # required to list & download artifacts across workflows jobs: apply: @@ -29,32 +28,44 @@ jobs: sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get install -y --no-install-recommends -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" gh echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token - - name: Download latest bench patch artifact from failed run + # Look for the most recent run of the heavy workflow for this PR + # that actually produced an artifact named "bench-patch". + - name: Download latest bench patch artifact from heavy workflow uses: dawidd6/action-download-artifact@v3 with: workflow: run-benchmarks.yml pr: ${{ github.event.pull_request.number }} - workflow_conclusion: failure name: bench-patch path: .bench_patch allow_forks: true + check_artifacts: true + search_artifacts: true + workflow_conclusion: "" + if_no_artifact_found: warn - - name: Apply and commit patch (if available) + - name: Apply and commit patch run: | set -euo pipefail + if [ ! -d ".bench_patch" ]; then + echo "No bench-patch artifact directory found." + exit 0 + fi if [ ! -f ".bench_patch/benchmark_patch.diff" ]; then - echo "No benchmark_patch.diff found. Either no auto-patch was possible or it wasn't generated." - echo "See .bench_patch/summary.txt for details (if present)." + echo "No benchmark_patch.diff found (likely no auto-patch possible)." + if [ -f ".bench_patch/summary.txt" ]; then + echo "Summary from heavy workflow:" + sed -n '1,200p' .bench_patch/summary.txt || true + fi exit 0 fi git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - # Attempt 3-way apply; if it fails, ask to regenerate + # Apply with 3-way merge to be resilient to PR changes if ! git apply --index --3way .bench_patch/benchmark_patch.diff; then - echo "Patch failed to apply cleanly. Re-run Validate-Benchmarks to regenerate the patch." + echo "Patch failed to apply cleanly. Please re-run Validate-Benchmarks to regenerate the patch." exit 1 fi @@ -65,7 +76,7 @@ jobs: echo "==== diff preview ====" git diff --cached --stat - git diff --cached | head -n 80 || true + git diff --cached | head -n 100 || true echo "======================" branch=$(git symbolic-ref --quiet --short HEAD || true) diff --git a/.github/workflows/run-benchmarks.yml b/.github/workflows/run-benchmarks.yml index 75ec1183f8..9245d0d416 100644 --- a/.github/workflows/run-benchmarks.yml +++ b/.github/workflows/run-benchmarks.yml @@ -128,7 +128,7 @@ jobs: uses: nick-fields/retry@v3 with: timeout_minutes: 180 - max_attempts: 3 + max_attempts: 1 retry_wait_seconds: 60 command: | chmod +x scripts/benchmark_action.sh From 34794e50a66f54e5b2560dcde36753574f0ffccc Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 3 Sep 2025 14:53:14 -0700 Subject: [PATCH 101/147] test --- .github/workflows/apply-benchmark-patch.yml | 8 +++++++- .github/workflows/run-benchmarks.yml | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/apply-benchmark-patch.yml b/.github/workflows/apply-benchmark-patch.yml index e578de3cbf..66d960e88d 100644 --- a/.github/workflows/apply-benchmark-patch.yml +++ b/.github/workflows/apply-benchmark-patch.yml @@ -51,6 +51,12 @@ jobs: exit 0 fi + if [ -f ".bench_patch/summary.txt" ]; then + echo "==== summary.txt ====" + sed -n '1,200p' .bench_patch/summary.txt || true + echo "=====================" + fi + if [ ! -f ".bench_patch/benchmark_patch.diff" ]; then echo "No benchmark_patch.diff found (likely no auto-patch possible)." if [ -f ".bench_patch/summary.txt" ]; then @@ -76,7 +82,7 @@ jobs: echo "==== diff preview ====" git diff --cached --stat - git diff --cached | head -n 100 || true + git diff --cached | head -n 120 || true echo "======================" branch=$(git symbolic-ref --quiet --short HEAD || true) diff --git a/.github/workflows/run-benchmarks.yml b/.github/workflows/run-benchmarks.yml index 9245d0d416..f36085176f 100644 --- a/.github/workflows/run-benchmarks.yml +++ b/.github/workflows/run-benchmarks.yml @@ -140,7 +140,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: bench-patch - path: .bench_patch/** + path: ${{ github.workspace }}/.bench_patch/** if-no-files-found: ignore # (6) — final check after run From 44470bc0f4cb7c2153dd988dccb14f7447f565d3 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 3 Sep 2025 16:11:26 -0700 Subject: [PATCH 102/147] test --- .github/workflows/run-benchmarks.yml | 38 +++++++++++++++++----------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/.github/workflows/run-benchmarks.yml b/.github/workflows/run-benchmarks.yml index f36085176f..17f3eb237f 100644 --- a/.github/workflows/run-benchmarks.yml +++ b/.github/workflows/run-benchmarks.yml @@ -1,4 +1,3 @@ -# .github/workflows/benchmarks.yml name: Validate-Benchmarks on: @@ -22,7 +21,6 @@ jobs: SKIP_BENCHMARKS: "0" steps: - # ────────────────────────────────────────────────────────────────── - name: Check out PR branch if: ${{ env.SKIP_BENCHMARKS != '1' }} uses: actions/checkout@v4 @@ -123,25 +121,35 @@ jobs: echo "SKIP_BENCHMARKS=1" >> "$GITHUB_ENV" fi - - name: Run & validate benchmarks + - name: Ensure artifact folder exists if: ${{ env.SKIP_BENCHMARKS != '1' }} - uses: nick-fields/retry@v3 - with: - timeout_minutes: 180 - max_attempts: 1 - retry_wait_seconds: 60 - command: | - chmod +x scripts/benchmark_action.sh - scripts/benchmark_action.sh - - # Persist the prepared patch even if the previous step failed. + run: mkdir -p .bench_patch + + - name: Run & validate benchmarks (script controls retries) + if: ${{ env.SKIP_BENCHMARKS != '1' }} + timeout-minutes: 180 + run: | + chmod +x scripts/benchmark_action.sh + scripts/benchmark_action.sh + + - name: List artifact contents (for debugging) + if: ${{ always() }} + run: | + echo "Workspace: $GITHUB_WORKSPACE" + if [ -d ".bench_patch" ]; then + echo "== .bench_patch ==" + ls -la .bench_patch || true + else + echo ".bench_patch directory is missing" + fi + - name: Upload patch artifact (if prepared) if: ${{ always() }} uses: actions/upload-artifact@v4 with: name: bench-patch - path: ${{ github.workspace }}/.bench_patch/** - if-no-files-found: ignore + path: ./.bench_patch + # Omit if-no-files-found so we fail loudly if missing unexpectedly # (6) — final check after run - name: Check skip label after run From b4bea14bc973ce6c9f0f783e9c2c496c60550a94 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 3 Sep 2025 17:13:37 -0700 Subject: [PATCH 103/147] test --- .github/workflows/apply-benchmark-patch.yml | 34 +++++++++++++-------- .github/workflows/run-benchmarks.yml | 15 +++++++-- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/.github/workflows/apply-benchmark-patch.yml b/.github/workflows/apply-benchmark-patch.yml index 66d960e88d..6f7e94acac 100644 --- a/.github/workflows/apply-benchmark-patch.yml +++ b/.github/workflows/apply-benchmark-patch.yml @@ -1,3 +1,4 @@ +# .github/workflows/apply-benchmark-patch.yml name: Apply-Benchmark-Patch on: @@ -28,26 +29,38 @@ jobs: sudo DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt-get install -y --no-install-recommends -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" gh echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token - # Look for the most recent run of the heavy workflow for this PR - # that actually produced an artifact named "bench-patch". - name: Download latest bench patch artifact from heavy workflow uses: dawidd6/action-download-artifact@v3 with: - workflow: run-benchmarks.yml + workflow: run-benchmarks.yml # heavy workflow FILE name pr: ${{ github.event.pull_request.number }} name: bench-patch - path: .bench_patch + path: . allow_forks: true check_artifacts: true search_artifacts: true - workflow_conclusion: "" + workflow_conclusion: "" # accept any conclusion if_no_artifact_found: warn + - name: Extract bench patch archive + run: | + set -euo pipefail + if [ -f "bench-patch.tgz" ]; then + tar -xzf bench-patch.tgz + elif [ -f "bench-patch/bench-patch.tgz" ]; then + tar -xzf bench-patch/bench-patch.tgz + else + echo "No bench-patch.tgz found after download." + exit 0 + fi + ls -la .bench_patch || true + - name: Apply and commit patch run: | set -euo pipefail + if [ ! -d ".bench_patch" ]; then - echo "No bench-patch artifact directory found." + echo "No .bench_patch directory found after extraction." exit 0 fi @@ -58,20 +71,15 @@ jobs: fi if [ ! -f ".bench_patch/benchmark_patch.diff" ]; then - echo "No benchmark_patch.diff found (likely no auto-patch possible)." - if [ -f ".bench_patch/summary.txt" ]; then - echo "Summary from heavy workflow:" - sed -n '1,200p' .bench_patch/summary.txt || true - fi + echo "No benchmark_patch.diff found (no auto-patch created)." exit 0 fi git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - # Apply with 3-way merge to be resilient to PR changes if ! git apply --index --3way .bench_patch/benchmark_patch.diff; then - echo "Patch failed to apply cleanly. Please re-run Validate-Benchmarks to regenerate the patch." + echo "Patch failed to apply cleanly. Please re-run Validate-Benchmarks to regenerate." exit 1 fi diff --git a/.github/workflows/run-benchmarks.yml b/.github/workflows/run-benchmarks.yml index 17f3eb237f..9063996046 100644 --- a/.github/workflows/run-benchmarks.yml +++ b/.github/workflows/run-benchmarks.yml @@ -1,3 +1,4 @@ +# .github/workflows/run-benchmarks.yml name: Validate-Benchmarks on: @@ -143,13 +144,23 @@ jobs: echo ".bench_patch directory is missing" fi + - name: Archive bench patch + if: ${{ always() }} + run: | + if [ -d ".bench_patch" ]; then + tar -czf bench-patch.tgz .bench_patch + ls -lh bench-patch.tgz + else + echo "No .bench_patch directory to archive." + fi + - name: Upload patch artifact (if prepared) if: ${{ always() }} uses: actions/upload-artifact@v4 with: name: bench-patch - path: ./.bench_patch - # Omit if-no-files-found so we fail loudly if missing unexpectedly + path: bench-patch.tgz + if-no-files-found: warn # (6) — final check after run - name: Check skip label after run From 633ddea1fc637c1a858edbbb79b529cd714e3563 Mon Sep 17 00:00:00 2001 From: open-junius Date: Thu, 4 Sep 2025 09:04:19 +0800 Subject: [PATCH 104/147] bump version --- 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 cc9c02eca3..644a85ebcd 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: 309, + spec_version: 310, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From 87cf264e2e55ba8ccc2e7ec7e676490975764a1e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 4 Sep 2025 01:41:23 +0000 Subject: [PATCH 105/147] auto-update benchmark weights --- pallets/subtensor/src/macros/dispatches.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 76046a9094..29654869f1 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -665,7 +665,7 @@ mod dispatches { /// - Attempting to set prometheus information withing the rate limit min. /// #[pallet::call_index(40)] - #[pallet::weight((Weight::from_parts(32_310_000, 0) + #[pallet::weight((Weight::from_parts(41_240_000, 0) .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Normal, Pays::No))] pub fn serve_axon_tls( @@ -2063,7 +2063,7 @@ mod dispatches { /// - The hotkey account to designate as the autostake destination. #[pallet::call_index(114)] #[pallet::weight((Weight::from_parts(5_170_000, 0) - .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().reads(0_u64)) .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Normal, Pays::No))] pub fn set_coldkey_auto_stake_hotkey( origin: T::RuntimeOrigin, From 31bc038e2b9d2d92518fef4542ca9453dd019b0f Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Wed, 3 Sep 2025 18:53:03 -0700 Subject: [PATCH 106/147] reset --- .github/workflows/apply-benchmark-patch.yml | 4 ++-- scripts/benchmark_action.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/apply-benchmark-patch.yml b/.github/workflows/apply-benchmark-patch.yml index 6f7e94acac..16b499bea6 100644 --- a/.github/workflows/apply-benchmark-patch.yml +++ b/.github/workflows/apply-benchmark-patch.yml @@ -32,14 +32,14 @@ jobs: - name: Download latest bench patch artifact from heavy workflow uses: dawidd6/action-download-artifact@v3 with: - workflow: run-benchmarks.yml # heavy workflow FILE name + workflow: run-benchmarks.yml pr: ${{ github.event.pull_request.number }} name: bench-patch path: . allow_forks: true check_artifacts: true search_artifacts: true - workflow_conclusion: "" # accept any conclusion + workflow_conclusion: "" if_no_artifact_found: warn - name: Extract bench patch archive diff --git a/scripts/benchmark_action.sh b/scripts/benchmark_action.sh index fb898abd37..78c38d7664 100755 --- a/scripts/benchmark_action.sh +++ b/scripts/benchmark_action.sh @@ -12,7 +12,7 @@ declare -A DISPATCH_PATHS=( ) THRESHOLD=20 -MAX_RETRIES=1 +MAX_RETRIES=3 SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" RUNTIME_WASM="$SCRIPT_DIR/../target/production/wbuild/node-subtensor-runtime/node_subtensor_runtime.compact.compressed.wasm" From fc5ef70a4a22d1df79b16dbe53339e6027480fba Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 4 Sep 2025 03:00:22 +0000 Subject: [PATCH 107/147] 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 695d9ff526..66a218d7cc 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -1989,7 +1989,7 @@ mod dispatches { /// * commit_reveal_version (`u16`): /// - The client (bittensor-drand) version #[pallet::call_index(113)] - #[pallet::weight((Weight::from_parts(83_450_000, 0) + #[pallet::weight((Weight::from_parts(65_020_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( From eb140b5e4a5797f38c8d22e2138a23b96efe077e Mon Sep 17 00:00:00 2001 From: open-junius Date: Thu, 4 Sep 2025 21:40:07 +0800 Subject: [PATCH 108/147] apply subtoken enable to more extrinsic --- common/src/lib.rs | 1 + pallets/subtensor/src/lib.rs | 4 ++++ pallets/subtensor/src/staking/add_stake.rs | 2 ++ pallets/subtensor/src/staking/remove_stake.rs | 4 ++++ pallets/swap/src/pallet/mod.rs | 18 ++++++++++++++++++ 5 files changed, 29 insertions(+) diff --git a/common/src/lib.rs b/common/src/lib.rs index 67fe4be51b..82f0916894 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -174,6 +174,7 @@ pub trait SubnetInfo { fn exists(netuid: NetUid) -> bool; fn mechanism(netuid: NetUid) -> u16; fn is_owner(account_id: &AccountId, netuid: NetUid) -> bool; + fn is_subtoken_enabled(netuid: NetUid) -> bool; } pub trait BalanceOps { diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index ce4e41e357..1c62a21ae4 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -2054,6 +2054,10 @@ impl> fn is_owner(account_id: &T::AccountId, netuid: NetUid) -> bool { SubnetOwner::::get(netuid) == *account_id } + + fn is_subtoken_enabled(netuid: NetUid) -> bool { + SubtokenEnabled::::get(netuid) + } } impl> diff --git a/pallets/subtensor/src/staking/add_stake.rs b/pallets/subtensor/src/staking/add_stake.rs index 740d42d09e..38e00fd93f 100644 --- a/pallets/subtensor/src/staking/add_stake.rs +++ b/pallets/subtensor/src/staking/add_stake.rs @@ -137,6 +137,8 @@ impl Pallet { "do_add_stake( origin:{coldkey:?} hotkey:{hotkey:?}, netuid:{netuid:?}, stake_to_be_added:{stake_to_be_added:?} )" ); + Self::ensure_subtoken_enabled(netuid)?; + // 2. Calculate the maximum amount that can be executed with price limit let max_amount: TaoCurrency = Self::get_max_amount_add(netuid, limit_price)?.into(); let mut possible_stake = stake_to_be_added; diff --git a/pallets/subtensor/src/staking/remove_stake.rs b/pallets/subtensor/src/staking/remove_stake.rs index fd9a974645..14ddf8641c 100644 --- a/pallets/subtensor/src/staking/remove_stake.rs +++ b/pallets/subtensor/src/staking/remove_stake.rs @@ -343,6 +343,8 @@ impl Pallet { "do_remove_stake( origin:{coldkey:?} hotkey:{hotkey:?}, netuid: {netuid:?}, alpha_unstaked:{alpha_unstaked:?} )" ); + Self::ensure_subtoken_enabled(netuid)?; + // 2. Calculate the maximum amount that can be executed with price limit let max_amount = Self::get_max_amount_remove(netuid, limit_price)?; let mut possible_alpha = alpha_unstaked; @@ -430,6 +432,8 @@ impl Pallet { ) -> DispatchResult { let coldkey = ensure_signed(origin.clone())?; + Self::ensure_subtoken_enabled(netuid)?; + let alpha_unstaked = Self::get_stake_for_hotkey_and_coldkey_on_subnet(&hotkey, &coldkey, netuid); diff --git a/pallets/swap/src/pallet/mod.rs b/pallets/swap/src/pallet/mod.rs index 894099de7f..116908b401 100644 --- a/pallets/swap/src/pallet/mod.rs +++ b/pallets/swap/src/pallet/mod.rs @@ -269,6 +269,9 @@ mod pallet { /// User liquidity operations are disabled for this subnet UserLiquidityDisabled, + + /// The subnet does not have subtoken enabled + SubtokenDisabled, } #[pallet::call] @@ -366,6 +369,11 @@ mod pallet { Error::::SubNetworkDoesNotExist ); + ensure!( + T::SubnetInfo::is_subtoken_enabled(netuid.into()), + Error::::SubtokenDisabled + ); + let (position_id, tao, alpha) = Self::do_add_liquidity( netuid.into(), &coldkey, @@ -429,6 +437,11 @@ mod pallet { Error::::SubNetworkDoesNotExist ); + ensure!( + T::SubnetInfo::is_subtoken_enabled(netuid.into()), + Error::::SubtokenDisabled + ); + // Remove liquidity let result = Self::do_remove_liquidity(netuid, &coldkey, position_id)?; @@ -489,6 +502,11 @@ mod pallet { Error::::SubNetworkDoesNotExist ); + ensure!( + T::SubnetInfo::is_subtoken_enabled(netuid.into()), + Error::::SubtokenDisabled + ); + // Add or remove liquidity let result = Self::do_modify_position(netuid, &coldkey, &hotkey, position_id, liquidity_delta)?; From 701a5ebd5eddf9177e192ee68393b1ca68ea5884 Mon Sep 17 00:00:00 2001 From: open-junius Date: Thu, 4 Sep 2025 21:42:51 +0800 Subject: [PATCH 109/147] commit Cargo.lock --- pallets/swap/src/mock.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pallets/swap/src/mock.rs b/pallets/swap/src/mock.rs index 78a8f925c8..74f2a30633 100644 --- a/pallets/swap/src/mock.rs +++ b/pallets/swap/src/mock.rs @@ -115,6 +115,10 @@ impl SubnetInfo for MockLiquidityProvider { fn is_owner(account_id: &AccountId, _netuid: NetUid) -> bool { *account_id != NOT_SUBNET_OWNER } + + fn is_subtoken_enabled(_netuid: NetUid) -> bool { + true + } } pub struct MockBalanceOps; From 1001f9c2830afa385284fb717d15b6d4a6a6b39a Mon Sep 17 00:00:00 2001 From: Shamil Gadelshin Date: Mon, 1 Sep 2025 00:28:30 +0300 Subject: [PATCH 110/147] Apply transaction-pool patch. --- Cargo.lock | 2 +- Cargo.toml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index f285ed7004..f84f1c0839 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -11479,7 +11479,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "39.0.0" -source = "git+https://github.com/paritytech/polkadot-sdk.git?tag=polkadot-stable2503-6#598feddb893f5ad3923a62e41a2f179b6e10c30c" +source = "git+https://github.com/opentensor/transaction-pool.git?rev=5cc8837d4c237d02c013c50b0a0eb70fdcba75bf#5cc8837d4c237d02c013c50b0a0eb70fdcba75bf" dependencies = [ "async-trait", "futures", diff --git a/Cargo.toml b/Cargo.toml index 291edb8c29..3415b8624d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -295,6 +295,7 @@ pow-faucet = [] [patch."https://github.com/paritytech/polkadot-sdk.git"] sc-consensus-grandpa = { git = "https://github.com/opentensor/grandpa.git", rev = "67ff75e915bd44586b8f8443e457b5b101920da8" } +sc-transaction-pool = { git = "https://github.com/opentensor/transaction-pool.git", rev = "5cc8837d4c237d02c013c50b0a0eb70fdcba75bf" } [patch.crates-io] w3f-bls = { git = "https://github.com/opentensor/bls", branch = "fix-no-std" } From dfd390b0933cf47a5ce38ddca11283dee9c7a955 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Thu, 4 Sep 2025 07:39:24 -0700 Subject: [PATCH 111/147] final test --- pallets/admin-utils/src/lib.rs | 2 +- scripts/benchmark_action.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index 1b0407f312..e92139d047 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -1598,7 +1598,7 @@ pub mod pallet { /// Sets the number of immune owner neurons #[pallet::call_index(72)] #[pallet::weight(Weight::from_parts(15_000_000, 0) - .saturating_add(::DbWeight::get().reads(1_u64)) + .saturating_add(::DbWeight::get().reads(0_u64)) .saturating_add(::DbWeight::get().writes(1_u64)))] pub fn sudo_set_owner_immune_neuron_limit( origin: OriginFor, diff --git a/scripts/benchmark_action.sh b/scripts/benchmark_action.sh index 78c38d7664..105cbe9bf5 100755 --- a/scripts/benchmark_action.sh +++ b/scripts/benchmark_action.sh @@ -218,5 +218,5 @@ if (( ANY_FAILURE )); then fi echo -e "\n══════════════════════════════════════" -echo "All pallets processed ✔ (no drift)" +echo "All pallets processed ✔" echo "══════════════════════════════════════" From 48d88d9f99ee2fb346993a0a0f005a21eaa2dc53 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Thu, 4 Sep 2025 08:40:25 -0700 Subject: [PATCH 112/147] add sudo_set_owner_immune_neuron_limit --- .github/workflows/run-benchmarks.yml | 2 +- pallets/admin-utils/src/benchmarking.rs | 11 +++++++++++ pallets/admin-utils/src/lib.rs | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-benchmarks.yml b/.github/workflows/run-benchmarks.yml index 9063996046..12df3f8ab6 100644 --- a/.github/workflows/run-benchmarks.yml +++ b/.github/workflows/run-benchmarks.yml @@ -126,7 +126,7 @@ jobs: if: ${{ env.SKIP_BENCHMARKS != '1' }} run: mkdir -p .bench_patch - - name: Run & validate benchmarks (script controls retries) + - name: Run & validate benchmarks if: ${{ env.SKIP_BENCHMARKS != '1' }} timeout-minutes: 180 run: | diff --git a/pallets/admin-utils/src/benchmarking.rs b/pallets/admin-utils/src/benchmarking.rs index 4d2ac21045..c824a879a5 100644 --- a/pallets/admin-utils/src/benchmarking.rs +++ b/pallets/admin-utils/src/benchmarking.rs @@ -346,5 +346,16 @@ mod benchmarks { _(RawOrigin::Root, 5u16/*version*/)/*sudo_set_commit_reveal_version()*/; } + #[benchmark] + fn sudo_set_owner_immune_neuron_limit() { + pallet_subtensor::Pallet::::init_new_network( + 1u16.into(), /*netuid*/ + 1u16, /*sudo_tempo*/ + ); + + #[extrinsic_call] + _(RawOrigin::Root, 1u16.into()/*netuid*/, 5u16/*immune_neurons*/)/*sudo_set_owner_immune_neuron_limit()*/; + } + //impl_benchmark_test_suite!(AdminUtils, crate::mock::new_test_ext(), crate::mock::Test); } diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index e92139d047..95fe4533e6 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -1599,7 +1599,7 @@ pub mod pallet { #[pallet::call_index(72)] #[pallet::weight(Weight::from_parts(15_000_000, 0) .saturating_add(::DbWeight::get().reads(0_u64)) - .saturating_add(::DbWeight::get().writes(1_u64)))] + .saturating_add(::DbWeight::get().writes(0_u64)))] pub fn sudo_set_owner_immune_neuron_limit( origin: OriginFor, netuid: NetUid, From 9d9ef8fef93ad1de1c5d1afa56c08dbb8994326d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 4 Sep 2025 15:59:54 +0000 Subject: [PATCH 113/147] auto-update benchmark weights --- pallets/subtensor/src/macros/dispatches.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index c842709208..e592161e7d 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -1682,7 +1682,7 @@ mod dispatches { /// #[pallet::call_index(89)] #[pallet::weight((Weight::from_parts(377_400_000, 0) - .saturating_add(T::DbWeight::get().reads(30)) + .saturating_add(T::DbWeight::get().reads(31_u64)) .saturating_add(T::DbWeight::get().writes(14)), DispatchClass::Normal, Pays::Yes))] pub fn remove_stake_limit( origin: OriginFor, @@ -1906,7 +1906,7 @@ mod dispatches { /// Without limit_price it remove all the stake similar to `remove_stake` extrinsic #[pallet::call_index(103)] #[pallet::weight((Weight::from_parts(395_300_000, 10142) - .saturating_add(T::DbWeight::get().reads(30_u64)) + .saturating_add(T::DbWeight::get().reads(31_u64)) .saturating_add(T::DbWeight::get().writes(14_u64)), DispatchClass::Normal, Pays::Yes))] pub fn remove_stake_full_limit( origin: T::RuntimeOrigin, @@ -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(81_510_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( From 786773b7579365f9fd619d5461f493fa080c0cb0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 4 Sep 2025 16:49:33 +0000 Subject: [PATCH 114/147] auto-update benchmark weights --- pallets/admin-utils/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pallets/admin-utils/src/lib.rs b/pallets/admin-utils/src/lib.rs index 95fe4533e6..075b8e1976 100644 --- a/pallets/admin-utils/src/lib.rs +++ b/pallets/admin-utils/src/lib.rs @@ -690,7 +690,7 @@ pub mod pallet { /// It is only callable by root and subnet owner. /// The extrinsic will call the Subtensor pallet to set the maximum burn. #[pallet::call_index(23)] - #[pallet::weight(Weight::from_parts(15_940_000, 0) + #[pallet::weight(Weight::from_parts(19_420_000, 0) .saturating_add(::DbWeight::get().reads(2_u64)) .saturating_add(::DbWeight::get().writes(1_u64)))] pub fn sudo_set_max_burn( @@ -1597,9 +1597,9 @@ pub mod pallet { /// Sets the number of immune owner neurons #[pallet::call_index(72)] - #[pallet::weight(Weight::from_parts(15_000_000, 0) + #[pallet::weight(Weight::from_parts(4_639_000, 0) .saturating_add(::DbWeight::get().reads(0_u64)) - .saturating_add(::DbWeight::get().writes(0_u64)))] + .saturating_add(::DbWeight::get().writes(1_u64)))] pub fn sudo_set_owner_immune_neuron_limit( origin: OriginFor, netuid: NetUid, From bdde256c257dbf3f257054549901ac9637a4be39 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 4 Sep 2025 17:24:26 +0000 Subject: [PATCH 115/147] 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 31ee31d561..6182444877 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -761,7 +761,7 @@ mod dispatches { /// Attempt to adjust the senate membership to include a hotkey #[pallet::call_index(63)] - #[pallet::weight((Weight::from_parts(60_720_000, 0) + #[pallet::weight((Weight::from_parts(75_430_000, 0) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)), DispatchClass::Normal, Pays::Yes))] pub fn adjust_senate(origin: OriginFor, hotkey: T::AccountId) -> DispatchResult { From 28b2f6fd6bbfecee1a849bed26185c50800e0442 Mon Sep 17 00:00:00 2001 From: open-junius Date: Fri, 5 Sep 2025 22:28:30 +0800 Subject: [PATCH 116/147] add more tests --- pallets/subtensor/src/staking/add_stake.rs | 2 - pallets/subtensor/src/staking/remove_stake.rs | 4 -- pallets/swap/src/mock.rs | 7 +-- pallets/swap/src/pallet/tests.rs | 47 +++++++++++++++++++ 4 files changed, 51 insertions(+), 9 deletions(-) diff --git a/pallets/subtensor/src/staking/add_stake.rs b/pallets/subtensor/src/staking/add_stake.rs index 38e00fd93f..740d42d09e 100644 --- a/pallets/subtensor/src/staking/add_stake.rs +++ b/pallets/subtensor/src/staking/add_stake.rs @@ -137,8 +137,6 @@ impl Pallet { "do_add_stake( origin:{coldkey:?} hotkey:{hotkey:?}, netuid:{netuid:?}, stake_to_be_added:{stake_to_be_added:?} )" ); - Self::ensure_subtoken_enabled(netuid)?; - // 2. Calculate the maximum amount that can be executed with price limit let max_amount: TaoCurrency = Self::get_max_amount_add(netuid, limit_price)?.into(); let mut possible_stake = stake_to_be_added; diff --git a/pallets/subtensor/src/staking/remove_stake.rs b/pallets/subtensor/src/staking/remove_stake.rs index 14ddf8641c..fd9a974645 100644 --- a/pallets/subtensor/src/staking/remove_stake.rs +++ b/pallets/subtensor/src/staking/remove_stake.rs @@ -343,8 +343,6 @@ impl Pallet { "do_remove_stake( origin:{coldkey:?} hotkey:{hotkey:?}, netuid: {netuid:?}, alpha_unstaked:{alpha_unstaked:?} )" ); - Self::ensure_subtoken_enabled(netuid)?; - // 2. Calculate the maximum amount that can be executed with price limit let max_amount = Self::get_max_amount_remove(netuid, limit_price)?; let mut possible_alpha = alpha_unstaked; @@ -432,8 +430,6 @@ impl Pallet { ) -> DispatchResult { let coldkey = ensure_signed(origin.clone())?; - Self::ensure_subtoken_enabled(netuid)?; - let alpha_unstaked = Self::get_stake_for_hotkey_and_coldkey_on_subnet(&hotkey, &coldkey, netuid); diff --git a/pallets/swap/src/mock.rs b/pallets/swap/src/mock.rs index 74f2a30633..7a07cc7007 100644 --- a/pallets/swap/src/mock.rs +++ b/pallets/swap/src/mock.rs @@ -36,7 +36,7 @@ pub const OK_HOTKEY_ACCOUNT_ID_RICH: AccountId = 1005; pub const NOT_SUBNET_OWNER: AccountId = 666; pub const NON_EXISTENT_NETUID: u16 = 999; pub const WRAPPING_FEES_NETUID: u16 = 124; - +pub const SUBTOKEN_DISABLED_NETUID: u16 = 13579; parameter_types! { pub const BlockHashCount: u64 = 250; pub const SS58Prefix: u8 = 42; @@ -116,8 +116,9 @@ impl SubnetInfo for MockLiquidityProvider { *account_id != NOT_SUBNET_OWNER } - fn is_subtoken_enabled(_netuid: NetUid) -> bool { - true + // Only disable one subnet for testing + fn is_subtoken_enabled(netuid: NetUid) -> bool { + netuid.inner() != SUBTOKEN_DISABLED_NETUID } } diff --git a/pallets/swap/src/pallet/tests.rs b/pallets/swap/src/pallet/tests.rs index 845acd957a..6561e6b82b 100644 --- a/pallets/swap/src/pallet/tests.rs +++ b/pallets/swap/src/pallet/tests.rs @@ -1944,3 +1944,50 @@ fn test_less_price_movement() { }); }); } + +#[test] +fn test_swap_subtoken_disabled() { + new_test_ext().execute_with(|| { + let netuid = NetUid::from(SUBTOKEN_DISABLED_NETUID); // Use a netuid not used elsewhere + let price_low = 0.1; + let price_high = 0.2; + let tick_low = price_to_tick(price_low); + let tick_high = price_to_tick(price_high); + let liquidity = 1_000_000_u64; + + assert_ok!(Pallet::::maybe_initialize_v3(netuid)); + + assert_noop!( + Pallet::::add_liquidity( + RuntimeOrigin::signed(OK_COLDKEY_ACCOUNT_ID), + OK_HOTKEY_ACCOUNT_ID, + netuid, + tick_low, + tick_high, + liquidity, + ), + Error::::SubtokenDisabled + ); + + assert_noop!( + Pallet::::remove_liquidity( + RuntimeOrigin::signed(OK_COLDKEY_ACCOUNT_ID), + OK_HOTKEY_ACCOUNT_ID, + netuid, + PositionId::from(0), + ), + Error::::SubtokenDisabled + ); + + assert_noop!( + Pallet::::modify_position( + RuntimeOrigin::signed(OK_COLDKEY_ACCOUNT_ID), + OK_HOTKEY_ACCOUNT_ID, + netuid, + PositionId::from(0), + liquidity as i64, + ), + Error::::SubtokenDisabled + ); + }); +} From 2d6e4703a93a92fd203e24534ba77f442a07c5ee Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Fri, 5 Sep 2025 09:26:19 -0700 Subject: [PATCH 117/147] blank commit From 841380ea571eae92c95ff88031ec8567601955bc Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 5 Sep 2025 16:29:44 +0000 Subject: [PATCH 118/147] auto-update benchmark weights --- pallets/subtensor/src/macros/dispatches.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index a00fb6cef0..136af3f74c 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -1682,7 +1682,7 @@ mod dispatches { /// #[pallet::call_index(89)] #[pallet::weight((Weight::from_parts(377_400_000, 0) - .saturating_add(T::DbWeight::get().reads(31_u64)) + .saturating_add(T::DbWeight::get().reads(30_u64)) .saturating_add(T::DbWeight::get().writes(14)), DispatchClass::Normal, Pays::Yes))] pub fn remove_stake_limit( origin: OriginFor, @@ -1906,7 +1906,7 @@ mod dispatches { /// Without limit_price it remove all the stake similar to `remove_stake` extrinsic #[pallet::call_index(103)] #[pallet::weight((Weight::from_parts(395_300_000, 10142) - .saturating_add(T::DbWeight::get().reads(31_u64)) + .saturating_add(T::DbWeight::get().reads(30_u64)) .saturating_add(T::DbWeight::get().writes(14_u64)), DispatchClass::Normal, Pays::Yes))] pub fn remove_stake_full_limit( origin: T::RuntimeOrigin, From 416e504964d2087020fc4403051378d1185fbb0e Mon Sep 17 00:00:00 2001 From: open-junius Date: Mon, 8 Sep 2025 09:45:01 +0800 Subject: [PATCH 119/147] bump version --- 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 644a85ebcd..a25f23482b 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: 310, + spec_version: 311, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From 018f6cdd9ecad457362bd7c12aca7c41774fc4c8 Mon Sep 17 00:00:00 2001 From: open-junius Date: Mon, 8 Sep 2025 09:51:23 +0800 Subject: [PATCH 120/147] remove liquidity is allowed --- pallets/swap/src/pallet/mod.rs | 5 ----- pallets/swap/src/pallet/tests.rs | 10 ---------- 2 files changed, 15 deletions(-) diff --git a/pallets/swap/src/pallet/mod.rs b/pallets/swap/src/pallet/mod.rs index 116908b401..442c4852aa 100644 --- a/pallets/swap/src/pallet/mod.rs +++ b/pallets/swap/src/pallet/mod.rs @@ -437,11 +437,6 @@ mod pallet { Error::::SubNetworkDoesNotExist ); - ensure!( - T::SubnetInfo::is_subtoken_enabled(netuid.into()), - Error::::SubtokenDisabled - ); - // Remove liquidity let result = Self::do_remove_liquidity(netuid, &coldkey, position_id)?; diff --git a/pallets/swap/src/pallet/tests.rs b/pallets/swap/src/pallet/tests.rs index 6561e6b82b..396bd656be 100644 --- a/pallets/swap/src/pallet/tests.rs +++ b/pallets/swap/src/pallet/tests.rs @@ -1969,16 +1969,6 @@ fn test_swap_subtoken_disabled() { Error::::SubtokenDisabled ); - assert_noop!( - Pallet::::remove_liquidity( - RuntimeOrigin::signed(OK_COLDKEY_ACCOUNT_ID), - OK_HOTKEY_ACCOUNT_ID, - netuid, - PositionId::from(0), - ), - Error::::SubtokenDisabled - ); - assert_noop!( Pallet::::modify_position( RuntimeOrigin::signed(OK_COLDKEY_ACCOUNT_ID), From 481852c7808efab53aee52a69ef5e1a15f2dd9bd Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 8 Sep 2025 04:00:25 +0000 Subject: [PATCH 121/147] 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 5e0b3dc7b5..ad7b9fb107 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -761,7 +761,7 @@ mod dispatches { /// Attempt to adjust the senate membership to include a hotkey #[pallet::call_index(63)] - #[pallet::weight((Weight::from_parts(75_430_000, 0) + #[pallet::weight((Weight::from_parts(58_980_000, 0) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)), DispatchClass::Normal, Pays::Yes))] pub fn adjust_senate(origin: OriginFor, hotkey: T::AccountId) -> DispatchResult { From 69eab05e524c40bc45b406e20482b47a3adf66cd Mon Sep 17 00:00:00 2001 From: open-junius Date: Mon, 8 Sep 2025 18:23:59 +0800 Subject: [PATCH 122/147] remove modality storage --- pallets/subtensor/src/coinbase/root.rs | 2 +- pallets/subtensor/src/lib.rs | 8 +- .../migrations/migrate_delete_subnet_21.rs | 2 +- .../src/migrations/migrate_delete_subnet_3.rs | 2 +- .../migrate_remove_network_modality.rs | 68 ++++++++++ pallets/subtensor/src/migrations/mod.rs | 1 + pallets/subtensor/src/rpc_info/subnet_info.rs | 4 +- pallets/subtensor/src/subnets/subnet.rs | 2 +- pallets/subtensor/src/tests/migration.rs | 117 ++++++++++++++++++ 9 files changed, 196 insertions(+), 10 deletions(-) create mode 100644 pallets/subtensor/src/migrations/migrate_remove_network_modality.rs diff --git a/pallets/subtensor/src/coinbase/root.rs b/pallets/subtensor/src/coinbase/root.rs index c5a92c0b99..b743e93e6e 100644 --- a/pallets/subtensor/src/coinbase/root.rs +++ b/pallets/subtensor/src/coinbase/root.rs @@ -415,7 +415,7 @@ impl Pallet { SubnetworkN::::remove(netuid); // --- 3. Remove network modality storage. - NetworkModality::::remove(netuid); + // NetworkModality::::remove(netuid); // --- 4. Remove netuid from added networks. NetworksAdded::::remove(netuid); diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index 2a0d7e1de0..fc50d9e200 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -1236,10 +1236,10 @@ pub mod pallet { #[pallet::storage] /// --- MAP ( netuid ) --> subnetwork_n (Number of UIDs in the network). pub type SubnetworkN = StorageMap<_, Identity, NetUid, u16, ValueQuery, DefaultN>; - #[pallet::storage] - /// --- MAP ( netuid ) --> modality TEXT: 0, IMAGE: 1, TENSOR: 2 - pub type NetworkModality = - StorageMap<_, Identity, NetUid, u16, ValueQuery, DefaultModality>; + // #[pallet::storage] + // /// --- MAP ( netuid ) --> modality TEXT: 0, IMAGE: 1, TENSOR: 2 + // pub type NetworkModality = + // StorageMap<_, Identity, NetUid, u16, ValueQuery, DefaultModality>; #[pallet::storage] /// --- MAP ( netuid ) --> network_is_added pub type NetworksAdded = diff --git a/pallets/subtensor/src/migrations/migrate_delete_subnet_21.rs b/pallets/subtensor/src/migrations/migrate_delete_subnet_21.rs index e6a8c72eae..3bf468b19e 100644 --- a/pallets/subtensor/src/migrations/migrate_delete_subnet_21.rs +++ b/pallets/subtensor/src/migrations/migrate_delete_subnet_21.rs @@ -60,7 +60,7 @@ pub fn migrate_delete_subnet_21() -> Weight { SubnetworkN::::remove(netuid); // Remove network modality storage - NetworkModality::::remove(netuid); + // NetworkModality::::remove(netuid); // Remove netuid from added networks NetworksAdded::::remove(netuid); diff --git a/pallets/subtensor/src/migrations/migrate_delete_subnet_3.rs b/pallets/subtensor/src/migrations/migrate_delete_subnet_3.rs index c479bd613a..853f7353bd 100644 --- a/pallets/subtensor/src/migrations/migrate_delete_subnet_3.rs +++ b/pallets/subtensor/src/migrations/migrate_delete_subnet_3.rs @@ -62,7 +62,7 @@ pub fn migrate_delete_subnet_3() -> Weight { SubnetworkN::::remove(netuid); // Remove network modality storage - NetworkModality::::remove(netuid); + // NetworkModality::::remove(netuid); // Remove netuid from added networks NetworksAdded::::remove(netuid); diff --git a/pallets/subtensor/src/migrations/migrate_remove_network_modality.rs b/pallets/subtensor/src/migrations/migrate_remove_network_modality.rs new file mode 100644 index 0000000000..5e834af41d --- /dev/null +++ b/pallets/subtensor/src/migrations/migrate_remove_network_modality.rs @@ -0,0 +1,68 @@ +use super::*; +use crate::HasMigrationRun; +use frame_support::{ + storage_alias, + traits::{Get, StorageVersion}, + weights::Weight, +}; +use scale_info::prelude::string::String; +use sp_std::vec::Vec; + +/// Module containing deprecated storage format for NetworkModality +pub mod deprecated_network_modality_format { + use super::*; + + #[storage_alias] + pub(super) type NetworkModality = + StorageMap, Identity, NetUid, u16, ValueQuery>; +} + +pub fn migrate_remove_network_modality() -> Weight { + const MIG_NAME: &[u8] = b"migrate_remove_network_modality"; + + // 1 ─ check if we already ran + if HasMigrationRun::::get(MIG_NAME) { + log::info!( + "Migration '{}' already executed - skipping", + String::from_utf8_lossy(MIG_NAME) + ); + return T::DbWeight::get().reads(1); + } + + log::info!("Running migration '{}'", String::from_utf8_lossy(MIG_NAME)); + + let mut total_weight = T::DbWeight::get().reads(1); + + // 2 ─ remove NetworkModality entries for all existing networks + let total_networks = TotalNetworks::::get(); + total_weight = total_weight.saturating_add(T::DbWeight::get().reads(1)); + + // Use raw storage operations to remove NetworkModality entries + // NetworkModality was a StorageMap<_, Identity, NetUid, u16> + let pallet_prefix = sp_io::hashing::twox_128("SubtensorModule".as_bytes()); + let storage_prefix = sp_io::hashing::twox_128("NetworkModality".as_bytes()); + + for netuid in 0..total_networks { + let netuid = NetUid::from(netuid); + let mut key = Vec::new(); + key.extend_from_slice(&pallet_prefix); + key.extend_from_slice(&storage_prefix); + // Identity encoding for netuid + key.extend_from_slice(&netuid.encode()); + + // Clear the storage entry if it exists + sp_io::storage::clear_prefix(&key, None); + total_weight = total_weight.saturating_add(T::DbWeight::get().writes(1)); + } + + // 3 ─ mark migration as done + HasMigrationRun::::insert(MIG_NAME, true); + total_weight = total_weight.saturating_add(T::DbWeight::get().writes(1)); + + log::info!( + "Migration '{}' completed: removed NetworkModality storage for {} networks", + String::from_utf8_lossy(MIG_NAME), + total_networks + ); + total_weight +} diff --git a/pallets/subtensor/src/migrations/mod.rs b/pallets/subtensor/src/migrations/mod.rs index ebd7150494..b7265cc6d0 100644 --- a/pallets/subtensor/src/migrations/mod.rs +++ b/pallets/subtensor/src/migrations/mod.rs @@ -24,6 +24,7 @@ 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_network_modality; pub mod migrate_remove_stake_map; pub mod migrate_remove_total_hotkey_coldkey_stakes_this_interval; pub mod migrate_remove_unused_maps_and_values; diff --git a/pallets/subtensor/src/rpc_info/subnet_info.rs b/pallets/subtensor/src/rpc_info/subnet_info.rs index d1e0a05419..161a109b90 100644 --- a/pallets/subtensor/src/rpc_info/subnet_info.rs +++ b/pallets/subtensor/src/rpc_info/subnet_info.rs @@ -141,7 +141,7 @@ impl Pallet { let max_allowed_uids = Self::get_max_allowed_uids(netuid); let blocks_since_last_step = Self::get_blocks_since_last_step(netuid); let tempo = Self::get_tempo(netuid); - let network_modality = >::get(netuid); + let network_modality = DefaultModality::::get(); let burn = Compact::from(Self::get_burn(netuid)); // DEPRECATED let network_connect: Vec<[u16; 2]> = Vec::<[u16; 2]>::new(); @@ -210,7 +210,7 @@ impl Pallet { let max_allowed_uids = Self::get_max_allowed_uids(netuid); let blocks_since_last_step = Self::get_blocks_since_last_step(netuid); let tempo = Self::get_tempo(netuid); - let network_modality = >::get(netuid); + let network_modality = DefaultModality::::get(); let burn = Compact::from(Self::get_burn(netuid)); let identity: Option = SubnetIdentitiesV3::::get(netuid); diff --git a/pallets/subtensor/src/subnets/subnet.rs b/pallets/subtensor/src/subnets/subnet.rs index 2674d83b60..ffc2e662e2 100644 --- a/pallets/subtensor/src/subnets/subnet.rs +++ b/pallets/subtensor/src/subnets/subnet.rs @@ -238,7 +238,7 @@ impl Pallet { Tempo::::insert(netuid, tempo); // --- 4 Fill modality item. - NetworkModality::::insert(netuid, 0); + // NetworkModality::::insert(netuid, 0); // --- 5. Increase total network count. TotalNetworks::::mutate(|n| *n = n.saturating_add(1)); diff --git a/pallets/subtensor/src/tests/migration.rs b/pallets/subtensor/src/tests/migration.rs index 25501eb27a..d67b86e42d 100644 --- a/pallets/subtensor/src/tests/migration.rs +++ b/pallets/subtensor/src/tests/migration.rs @@ -1575,3 +1575,120 @@ fn test_migrate_crv3_v2_to_timelocked() { assert_eq!(round2, round); }); } + +#[test] +fn test_migrate_remove_network_modality() { + new_test_ext(1).execute_with(|| { + // ------------------------------ + // 0. Constants / helpers + // ------------------------------ + const MIGRATION_NAME: &str = "migrate_remove_network_modality"; + + // Create multiple networks to test + let netuids: [NetUid; 3] = [1.into(), 2.into(), 3.into()]; + for netuid in netuids.iter() { + add_network(*netuid, 1, 0); + } + + // Set initial storage version to 7 (below target) + StorageVersion::new(7).put::>(); + assert_eq!( + Pallet::::on_chain_storage_version(), + StorageVersion::new(7) + ); + + // ------------------------------ + // 1. Simulate NetworkModality entries using deprecated storage alias + // ------------------------------ + // We need to manually create storage entries that would exist for NetworkModality + // Since NetworkModality was a StorageMap<_, Identity, NetUid, u16>, we simulate this + let pallet_prefix = twox_128("SubtensorModule".as_bytes()); + let storage_prefix = twox_128("NetworkModality".as_bytes()); + + // Create NetworkModality entries for each network + for (i, netuid) in netuids.iter().enumerate() { + let mut key = Vec::new(); + key.extend_from_slice(&pallet_prefix); + key.extend_from_slice(&storage_prefix); + // Identity encoding for netuid + key.extend_from_slice(&netuid.encode()); + + let modality_value: u16 = (i as u16) + 1; // Different values for testing + put_raw(&key, &modality_value.encode()); + + // Verify the entry was created + let stored_value = get_raw(&key).expect("NetworkModality entry should exist"); + assert_eq!( + u16::decode(&mut &stored_value[..]).expect("Failed to decode modality"), + modality_value + ); + } + + assert!( + !HasMigrationRun::::get(MIGRATION_NAME.as_bytes().to_vec()), + "Migration should not have run yet" + ); + + // ------------------------------ + // 2. Run migration + // ------------------------------ + let weight = + crate::migrations::migrate_remove_network_modality::migrate_remove_network_modality::< + Test, + >(); + + // ------------------------------ + // 3. Verify migration effects + // ------------------------------ + assert!( + HasMigrationRun::::get(MIGRATION_NAME.as_bytes().to_vec()), + "Migration should be marked as run" + ); + + // Verify weight is non-zero + assert!(!weight.is_zero(), "Migration weight should be non-zero"); + + // Verify weight calculation: 1 read (version check) + 1 read (total networks) + N writes (removal) + 1 write (version update) + let expected_weight = ::DbWeight::get().reads(2) + + ::DbWeight::get().writes(netuids.len() as u64 + 1); + assert_eq!( + weight, expected_weight, + "Weight calculation should be correct" + ); + }); +} + +#[test] +fn test_migrate_remove_network_modality_already_run() { + new_test_ext(1).execute_with(|| { + const MIGRATION_NAME: &str = "migrate_remove_network_modality"; + + // Mark migration as already run + HasMigrationRun::::insert(MIGRATION_NAME.as_bytes().to_vec(), true); + + // Set storage version to 8 (target version) + StorageVersion::new(8).put::>(); + assert_eq!( + Pallet::::on_chain_storage_version(), + StorageVersion::new(8) + ); + + // Run migration + let weight = + crate::migrations::migrate_remove_network_modality::migrate_remove_network_modality::< + Test, + >(); + + // Should only have read weight for checking migration status + let expected_weight = ::DbWeight::get().reads(1); + assert_eq!( + weight, expected_weight, + "Second run should only read the migration flag" + ); + + // Verify migration is still marked as run + assert!(HasMigrationRun::::get( + MIGRATION_NAME.as_bytes().to_vec() + )); + }); +} From 335363405fea3c4f45943c0cad1d7c1b35d91829 Mon Sep 17 00:00:00 2001 From: open-junius Date: Mon, 8 Sep 2025 18:25:18 +0800 Subject: [PATCH 123/147] cargo clippy --- .../subtensor/src/migrations/migrate_remove_network_modality.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/subtensor/src/migrations/migrate_remove_network_modality.rs b/pallets/subtensor/src/migrations/migrate_remove_network_modality.rs index 5e834af41d..639f23c0e0 100644 --- a/pallets/subtensor/src/migrations/migrate_remove_network_modality.rs +++ b/pallets/subtensor/src/migrations/migrate_remove_network_modality.rs @@ -2,7 +2,7 @@ use super::*; use crate::HasMigrationRun; use frame_support::{ storage_alias, - traits::{Get, StorageVersion}, + traits::Get, weights::Weight, }; use scale_info::prelude::string::String; From 1ba10ced0d56d7876f835c7045fd625f3a9148e3 Mon Sep 17 00:00:00 2001 From: open-junius Date: Mon, 8 Sep 2025 18:25:55 +0800 Subject: [PATCH 124/147] cargo fmt --- .../src/migrations/migrate_remove_network_modality.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pallets/subtensor/src/migrations/migrate_remove_network_modality.rs b/pallets/subtensor/src/migrations/migrate_remove_network_modality.rs index 639f23c0e0..c39291d3b4 100644 --- a/pallets/subtensor/src/migrations/migrate_remove_network_modality.rs +++ b/pallets/subtensor/src/migrations/migrate_remove_network_modality.rs @@ -1,10 +1,6 @@ use super::*; use crate::HasMigrationRun; -use frame_support::{ - storage_alias, - traits::Get, - weights::Weight, -}; +use frame_support::{storage_alias, traits::Get, weights::Weight}; use scale_info::prelude::string::String; use sp_std::vec::Vec; From 574cb235bb946b64c75b488197ff87ee39dbeaaf Mon Sep 17 00:00:00 2001 From: open-junius Date: Mon, 8 Sep 2025 19:34:34 +0800 Subject: [PATCH 125/147] add to hook --- pallets/subtensor/src/coinbase/root.rs | 23 ++++++++----------- pallets/subtensor/src/lib.rs | 4 ---- pallets/subtensor/src/macros/hooks.rs | 4 +++- .../migrations/migrate_delete_subnet_21.rs | 3 --- .../src/migrations/migrate_delete_subnet_3.rs | 3 --- pallets/subtensor/src/subnets/subnet.rs | 7 ++---- 6 files changed, 15 insertions(+), 29 deletions(-) diff --git a/pallets/subtensor/src/coinbase/root.rs b/pallets/subtensor/src/coinbase/root.rs index b743e93e6e..8bb10e0b16 100644 --- a/pallets/subtensor/src/coinbase/root.rs +++ b/pallets/subtensor/src/coinbase/root.rs @@ -414,28 +414,25 @@ impl Pallet { // --- 2. Remove network count. SubnetworkN::::remove(netuid); - // --- 3. Remove network modality storage. - // NetworkModality::::remove(netuid); - - // --- 4. Remove netuid from added networks. + // --- 3. Remove netuid from added networks. NetworksAdded::::remove(netuid); - // --- 5. Decrement the network counter. + // --- 4. Decrement the network counter. TotalNetworks::::mutate(|n: &mut u16| *n = n.saturating_sub(1)); - // --- 6. Remove various network-related storages. + // --- 5. Remove various network-related storages. NetworkRegisteredAt::::remove(netuid); - // --- 7. Remove incentive mechanism memory. + // --- 6. Remove incentive mechanism memory. let _ = Uids::::clear_prefix(netuid, u32::MAX, None); let keys = Keys::::iter_prefix(netuid).collect::>(); let _ = Keys::::clear_prefix(netuid, u32::MAX, None); let _ = Bonds::::clear_prefix(netuid, u32::MAX, None); - // --- 8. Removes the weights for this subnet (do not remove). + // --- 7. Removes the weights for this subnet (do not remove). let _ = Weights::::clear_prefix(netuid, u32::MAX, None); - // --- 9. Iterate over stored weights and fill the matrix. + // --- 8. Iterate over stored weights and fill the matrix. for (uid_i, weights_i) in as IterableStorageDoubleMap>>::iter_prefix( NetUid::ROOT, @@ -453,7 +450,7 @@ impl Pallet { Weights::::insert(NetUid::ROOT, uid_i, modified_weights); } - // --- 10. Remove various network-related parameters. + // --- 9. Remove various network-related parameters. Rank::::remove(netuid); Trust::::remove(netuid); Active::::remove(netuid); @@ -470,7 +467,7 @@ impl Pallet { IsNetworkMember::::remove(key, netuid); } - // --- 11. Erase network parameters. + // --- 10. Erase network parameters. Tempo::::remove(netuid); Kappa::::remove(netuid); Difficulty::::remove(netuid); @@ -483,12 +480,12 @@ impl Pallet { POWRegistrationsThisInterval::::remove(netuid); BurnRegistrationsThisInterval::::remove(netuid); - // --- 12. Add the balance back to the owner. + // --- 11. Add the balance back to the owner. Self::add_balance_to_coldkey_account(&owner_coldkey, reserved_amount.into()); Self::set_subnet_locked_balance(netuid, TaoCurrency::ZERO); SubnetOwner::::remove(netuid); - // --- 13. Remove subnet identity if it exists. + // --- 12. Remove subnet identity if it exists. if SubnetIdentitiesV3::::contains_key(netuid) { SubnetIdentitiesV3::::remove(netuid); Self::deposit_event(Event::SubnetIdentityRemoved(netuid)); diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index fc50d9e200..02da86f234 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -1236,10 +1236,6 @@ pub mod pallet { #[pallet::storage] /// --- MAP ( netuid ) --> subnetwork_n (Number of UIDs in the network). pub type SubnetworkN = StorageMap<_, Identity, NetUid, u16, ValueQuery, DefaultN>; - // #[pallet::storage] - // /// --- MAP ( netuid ) --> modality TEXT: 0, IMAGE: 1, TENSOR: 2 - // pub type NetworkModality = - // StorageMap<_, Identity, NetUid, u16, ValueQuery, DefaultModality>; #[pallet::storage] /// --- MAP ( netuid ) --> network_is_added pub type NetworksAdded = diff --git a/pallets/subtensor/src/macros/hooks.rs b/pallets/subtensor/src/macros/hooks.rs index 88e483475e..b43f9422df 100644 --- a/pallets/subtensor/src/macros/hooks.rs +++ b/pallets/subtensor/src/macros/hooks.rs @@ -137,7 +137,9 @@ mod hooks { // Migrate to fix root counters .saturating_add(migrations::migrate_fix_root_tao_and_alpha_in::migrate_fix_root_tao_and_alpha_in::()) // Migrate last block rate limiting storage items - .saturating_add(migrations::migrate_rate_limiting_last_blocks::migrate_obsolete_rate_limiting_last_blocks_storage::()); + .saturating_add(migrations::migrate_rate_limiting_last_blocks::migrate_obsolete_rate_limiting_last_blocks_storage::()) + // Migrate remove network modality + .saturating_add(migrations::migrate_remove_network_modality::migrate_remove_network_modality::()); weight } diff --git a/pallets/subtensor/src/migrations/migrate_delete_subnet_21.rs b/pallets/subtensor/src/migrations/migrate_delete_subnet_21.rs index 3bf468b19e..b8b1138b2e 100644 --- a/pallets/subtensor/src/migrations/migrate_delete_subnet_21.rs +++ b/pallets/subtensor/src/migrations/migrate_delete_subnet_21.rs @@ -59,9 +59,6 @@ pub fn migrate_delete_subnet_21() -> Weight { // Remove network count SubnetworkN::::remove(netuid); - // Remove network modality storage - // NetworkModality::::remove(netuid); - // Remove netuid from added networks NetworksAdded::::remove(netuid); diff --git a/pallets/subtensor/src/migrations/migrate_delete_subnet_3.rs b/pallets/subtensor/src/migrations/migrate_delete_subnet_3.rs index 853f7353bd..289ce6cb36 100644 --- a/pallets/subtensor/src/migrations/migrate_delete_subnet_3.rs +++ b/pallets/subtensor/src/migrations/migrate_delete_subnet_3.rs @@ -61,9 +61,6 @@ pub fn migrate_delete_subnet_3() -> Weight { // Remove network count SubnetworkN::::remove(netuid); - // Remove network modality storage - // NetworkModality::::remove(netuid); - // Remove netuid from added networks NetworksAdded::::remove(netuid); diff --git a/pallets/subtensor/src/subnets/subnet.rs b/pallets/subtensor/src/subnets/subnet.rs index ffc2e662e2..c9cfefa160 100644 --- a/pallets/subtensor/src/subnets/subnet.rs +++ b/pallets/subtensor/src/subnets/subnet.rs @@ -237,13 +237,10 @@ impl Pallet { // --- 3. Fill tempo memory item. Tempo::::insert(netuid, tempo); - // --- 4 Fill modality item. - // NetworkModality::::insert(netuid, 0); - - // --- 5. Increase total network count. + // --- 4. Increase total network count. TotalNetworks::::mutate(|n| *n = n.saturating_add(1)); - // --- 6. Set all default values **explicitly**. + // --- 5. Set all default values **explicitly**. Self::set_network_registration_allowed(netuid, true); Self::set_max_allowed_uids(netuid, 256); Self::set_max_allowed_validators(netuid, 64); From 540d0e3b0eaacc724df44c076f8d1669b20470ce Mon Sep 17 00:00:00 2001 From: open-junius Date: Mon, 8 Sep 2025 19:34:54 +0800 Subject: [PATCH 126/147] bump version --- 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 644a85ebcd..a25f23482b 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: 310, + spec_version: 311, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From 990ba522f63a39f4eb69c4b4386d2fc2788dafbd Mon Sep 17 00:00:00 2001 From: open-junius Date: Mon, 8 Sep 2025 19:42:29 +0800 Subject: [PATCH 127/147] remove default value --- pallets/subtensor/src/lib.rs | 5 ----- pallets/subtensor/src/rpc_info/subnet_info.rs | 6 ++---- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index 02da86f234..d3eac695e3 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -491,11 +491,6 @@ pub mod pallet { 0 } #[pallet::type_value] - /// Default value for modality. - pub fn DefaultModality() -> u16 { - 0 - } - #[pallet::type_value] /// Default value for hotkeys. pub fn DefaultHotkeys() -> Vec { vec![] diff --git a/pallets/subtensor/src/rpc_info/subnet_info.rs b/pallets/subtensor/src/rpc_info/subnet_info.rs index 161a109b90..8511c848ad 100644 --- a/pallets/subtensor/src/rpc_info/subnet_info.rs +++ b/pallets/subtensor/src/rpc_info/subnet_info.rs @@ -141,7 +141,6 @@ impl Pallet { let max_allowed_uids = Self::get_max_allowed_uids(netuid); let blocks_since_last_step = Self::get_blocks_since_last_step(netuid); let tempo = Self::get_tempo(netuid); - let network_modality = DefaultModality::::get(); let burn = Compact::from(Self::get_burn(netuid)); // DEPRECATED let network_connect: Vec<[u16; 2]> = Vec::<[u16; 2]>::new(); @@ -163,7 +162,7 @@ impl Pallet { max_allowed_uids: max_allowed_uids.into(), blocks_since_last_step: blocks_since_last_step.into(), tempo: tempo.into(), - network_modality: network_modality.into(), + network_modality: 0_u16.into(); network_connect, emission_values: 0.into(), burn, @@ -210,7 +209,6 @@ impl Pallet { let max_allowed_uids = Self::get_max_allowed_uids(netuid); let blocks_since_last_step = Self::get_blocks_since_last_step(netuid); let tempo = Self::get_tempo(netuid); - let network_modality = DefaultModality::::get(); let burn = Compact::from(Self::get_burn(netuid)); let identity: Option = SubnetIdentitiesV3::::get(netuid); @@ -234,7 +232,7 @@ impl Pallet { max_allowed_uids: max_allowed_uids.into(), blocks_since_last_step: blocks_since_last_step.into(), tempo: tempo.into(), - network_modality: network_modality.into(), + network_modality: 0.into(), network_connect, emission_value: 0.into(), burn, From 36f458ca1f3de19d848d9dcd4fe633b981c9b200 Mon Sep 17 00:00:00 2001 From: open-junius Date: Mon, 8 Sep 2025 19:51:40 +0800 Subject: [PATCH 128/147] commit Cargo.lock --- pallets/subtensor/src/rpc_info/subnet_info.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/subtensor/src/rpc_info/subnet_info.rs b/pallets/subtensor/src/rpc_info/subnet_info.rs index 8511c848ad..11d60b2bc9 100644 --- a/pallets/subtensor/src/rpc_info/subnet_info.rs +++ b/pallets/subtensor/src/rpc_info/subnet_info.rs @@ -162,7 +162,7 @@ impl Pallet { max_allowed_uids: max_allowed_uids.into(), blocks_since_last_step: blocks_since_last_step.into(), tempo: tempo.into(), - network_modality: 0_u16.into(); + network_modality: 0_u16.into(), network_connect, emission_values: 0.into(), burn, From d04f2e319275b50162a4c51984afdb4f7efcaf51 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 8 Sep 2025 13:49:55 +0000 Subject: [PATCH 129/147] auto-update benchmark weights --- pallets/subtensor/src/macros/dispatches.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 6182444877..282e4c9038 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -761,7 +761,7 @@ mod dispatches { /// Attempt to adjust the senate membership to include a hotkey #[pallet::call_index(63)] - #[pallet::weight((Weight::from_parts(75_430_000, 0) + #[pallet::weight((Weight::from_parts(59_540_000, 0) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)), DispatchClass::Normal, Pays::Yes))] pub fn adjust_senate(origin: OriginFor, hotkey: T::AccountId) -> DispatchResult { @@ -1041,7 +1041,7 @@ mod dispatches { #[pallet::call_index(59)] #[pallet::weight((Weight::from_parts(235_400_000, 0) .saturating_add(T::DbWeight::get().reads(36)) - .saturating_add(T::DbWeight::get().writes(52)), DispatchClass::Normal, Pays::No))] + .saturating_add(T::DbWeight::get().writes(51_u64)), DispatchClass::Normal, Pays::No))] pub fn register_network(origin: OriginFor, hotkey: T::AccountId) -> DispatchResult { Self::do_register_network(origin, &hotkey, 1, None) } @@ -1328,7 +1328,7 @@ mod dispatches { #[pallet::call_index(79)] #[pallet::weight((Weight::from_parts(234_200_000, 0) .saturating_add(T::DbWeight::get().reads(35)) - .saturating_add(T::DbWeight::get().writes(51)), DispatchClass::Normal, Pays::No))] + .saturating_add(T::DbWeight::get().writes(50_u64)), DispatchClass::Normal, Pays::No))] pub fn register_network_with_identity( origin: OriginFor, hotkey: T::AccountId, From 44bc6a9e9cba7081d042d5ff33f7a00dd66d9c38 Mon Sep 17 00:00:00 2001 From: open-junius Date: Mon, 8 Sep 2025 23:30:20 +0800 Subject: [PATCH 130/147] set default ck burn as zero --- pallets/subtensor/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/subtensor/src/lib.rs b/pallets/subtensor/src/lib.rs index ba8a8b0370..dff52d6b55 100644 --- a/pallets/subtensor/src/lib.rs +++ b/pallets/subtensor/src/lib.rs @@ -866,7 +866,7 @@ pub mod pallet { #[pallet::type_value] /// Default value for ck burn, 18%. pub fn DefaultCKBurn() -> u64 { - u64::MAX / 100 * 18 + 0 } #[pallet::storage] From e8ec65978d6a84dede3533cb2d1518b3167acdc0 Mon Sep 17 00:00:00 2001 From: open-junius Date: Mon, 8 Sep 2025 23:32:13 +0800 Subject: [PATCH 131/147] bump version --- 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 a25f23482b..39dad74c09 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: 311, + spec_version: 312, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From d61e59d77e169a2863d545bb5f5a30b4db73feac Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Mon, 8 Sep 2025 09:08:27 -0700 Subject: [PATCH 132/147] add import --- pallets/subtensor/src/transaction_extension.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/pallets/subtensor/src/transaction_extension.rs b/pallets/subtensor/src/transaction_extension.rs index c3eb95f54d..064a242f91 100644 --- a/pallets/subtensor/src/transaction_extension.rs +++ b/pallets/subtensor/src/transaction_extension.rs @@ -1,5 +1,6 @@ use crate::{ BalancesCall, Call, ColdkeySwapScheduled, Config, CustomTransactionError, Error, Pallet, + TransactionType, }; use codec::{Decode, DecodeWithMemTracking, Encode}; use frame_support::dispatch::{DispatchInfo, PostDispatchInfo}; From a6c1343a1109adacc221c7a11590e5cb5ae392d1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 8 Sep 2025 18:13:52 +0000 Subject: [PATCH 133/147] auto-update benchmark weights --- pallets/subtensor/src/macros/dispatches.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index 32c27f7bef..47997e55e8 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -186,7 +186,7 @@ mod dispatches { /// - On failure for each failed item in the batch. /// #[pallet::call_index(100)] - #[pallet::weight((Weight::from_parts(82_010_000, 0) + #[pallet::weight((Weight::from_parts(100_500_000, 0) .saturating_add(T::DbWeight::get().reads(8)) .saturating_add(T::DbWeight::get().writes(2)), DispatchClass::Normal, Pays::No))] pub fn batch_commit_weights( @@ -761,7 +761,7 @@ mod dispatches { /// Attempt to adjust the senate membership to include a hotkey #[pallet::call_index(63)] - #[pallet::weight((Weight::from_parts(75_430_000, 0) + #[pallet::weight((Weight::from_parts(58_850_000, 0) .saturating_add(T::DbWeight::get().reads(7)) .saturating_add(T::DbWeight::get().writes(4)), DispatchClass::Normal, Pays::Yes))] pub fn adjust_senate(origin: OriginFor, hotkey: T::AccountId) -> DispatchResult { @@ -891,7 +891,7 @@ mod dispatches { /// #[pallet::call_index(69)] #[pallet::weight(( - Weight::from_parts(7_394_000, 0) + Weight::from_parts(5_660_000, 0) .saturating_add(T::DbWeight::get().reads(0)) .saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Operational, From cbf5be086c762a7dcafa81b95ced76d10cdcd14f Mon Sep 17 00:00:00 2001 From: open-junius Date: Tue, 9 Sep 2025 09:27:01 +0800 Subject: [PATCH 134/147] add recycle alpha helper function --- pallets/subtensor/src/coinbase/run_coinbase.rs | 2 +- pallets/subtensor/src/staking/helpers.rs | 2 +- pallets/subtensor/src/staking/recycle_alpha.rs | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/pallets/subtensor/src/coinbase/run_coinbase.rs b/pallets/subtensor/src/coinbase/run_coinbase.rs index 21fc9bd603..c76e6941e3 100644 --- a/pallets/subtensor/src/coinbase/run_coinbase.rs +++ b/pallets/subtensor/src/coinbase/run_coinbase.rs @@ -830,7 +830,7 @@ impl Pallet { parent_emission = parent_emission.saturating_sub(child_take); total_child_take = total_child_take.saturating_add(child_take); - Self::burn_subnet_alpha( + Self::recycle_subnet_alpha( netuid, AlphaCurrency::from(burn_take.saturating_to_num::()), ); diff --git a/pallets/subtensor/src/staking/helpers.rs b/pallets/subtensor/src/staking/helpers.rs index c89a762f91..7b1b644e85 100644 --- a/pallets/subtensor/src/staking/helpers.rs +++ b/pallets/subtensor/src/staking/helpers.rs @@ -322,7 +322,7 @@ impl Pallet { T::SwapInterface::is_user_liquidity_enabled(netuid) } - pub fn burn_subnet_alpha(netuid: NetUid, amount: AlphaCurrency) { + pub fn recycle_subnet_alpha(netuid: NetUid, amount: AlphaCurrency) { SubnetAlphaOut::::mutate(netuid, |total| { *total = total.saturating_sub(amount); }); diff --git a/pallets/subtensor/src/staking/recycle_alpha.rs b/pallets/subtensor/src/staking/recycle_alpha.rs index cbd5161a4c..ccdfdb8fde 100644 --- a/pallets/subtensor/src/staking/recycle_alpha.rs +++ b/pallets/subtensor/src/staking/recycle_alpha.rs @@ -59,9 +59,7 @@ impl Pallet { ); // Recycle means we should decrease the alpha issuance tracker. - SubnetAlphaOut::::mutate(netuid, |total| { - *total = total.saturating_sub(actual_alpha_decrease); - }); + Self::recycle_subnet_alpha(netuid, amount); Self::deposit_event(Event::AlphaRecycled( coldkey, From bf96a2bb3db9d1c8135c880f0d09d1528f8c9686 Mon Sep 17 00:00:00 2001 From: open-junius Date: Tue, 9 Sep 2025 09:45:32 +0800 Subject: [PATCH 135/147] commit Cargo.lock --- pallets/subtensor/src/staking/recycle_alpha.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pallets/subtensor/src/staking/recycle_alpha.rs b/pallets/subtensor/src/staking/recycle_alpha.rs index ccdfdb8fde..4c1bbd0b9f 100644 --- a/pallets/subtensor/src/staking/recycle_alpha.rs +++ b/pallets/subtensor/src/staking/recycle_alpha.rs @@ -1,6 +1,6 @@ use super::*; use crate::{Error, system::ensure_signed}; -use subtensor_runtime_common::{AlphaCurrency, Currency, NetUid}; +use subtensor_runtime_common::{AlphaCurrency, NetUid}; impl Pallet { /// Recycles alpha from a cold/hot key pair, reducing AlphaOut on a subnet From 8d9ff93c3e1da3b91b6b6d1865bd61de5a484a05 Mon Sep 17 00:00:00 2001 From: open-junius Date: Tue, 9 Sep 2025 09:47:45 +0800 Subject: [PATCH 136/147] bump version --- 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 6df7f5df66..40c76514d4 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: 312, + spec_version: 313, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From afcb7baebeb1214f3cee31bdbe354769d92ffe97 Mon Sep 17 00:00:00 2001 From: open-junius Date: Tue, 9 Sep 2025 20:23:07 +0800 Subject: [PATCH 137/147] bump version --- 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 6df7f5df66..40c76514d4 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: 312, + spec_version: 313, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From e9572f094e40cd0d618a820076bef79572ebb0ff Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Tue, 9 Sep 2025 14:13:19 -0400 Subject: [PATCH 138/147] bench --- pallets/subtensor/src/macros/dispatches.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pallets/subtensor/src/macros/dispatches.rs b/pallets/subtensor/src/macros/dispatches.rs index c112f35ecb..f069ff0aa5 100644 --- a/pallets/subtensor/src/macros/dispatches.rs +++ b/pallets/subtensor/src/macros/dispatches.rs @@ -1041,7 +1041,7 @@ mod dispatches { #[pallet::call_index(59)] #[pallet::weight((Weight::from_parts(235_400_000, 0) .saturating_add(T::DbWeight::get().reads(36)) - .saturating_add(T::DbWeight::get().writes(51_u64)), DispatchClass::Normal, Pays::No))] + .saturating_add(T::DbWeight::get().writes(52)), DispatchClass::Normal, Pays::Yes))] pub fn register_network(origin: OriginFor, hotkey: T::AccountId) -> DispatchResult { Self::do_register_network(origin, &hotkey, 1, None) } @@ -1328,7 +1328,7 @@ mod dispatches { #[pallet::call_index(79)] #[pallet::weight((Weight::from_parts(234_200_000, 0) .saturating_add(T::DbWeight::get().reads(35)) - .saturating_add(T::DbWeight::get().writes(50_u64)), DispatchClass::Normal, Pays::No))] + .saturating_add(T::DbWeight::get().writes(51)), DispatchClass::Normal, Pays::Yes))] pub fn register_network_with_identity( origin: OriginFor, hotkey: T::AccountId, From bc24c46bb61647ab2be89fe1ae2f08ad364777c3 Mon Sep 17 00:00:00 2001 From: Cameron Fairchild Date: Tue, 9 Sep 2025 14:33:04 -0400 Subject: [PATCH 139/147] bump spec --- 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 40c76514d4..f938105bc6 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: 313, + spec_version: 314, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1, From fe0dc07080c554f86e0ba60e7a604d107ea8d52d Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Tue, 9 Sep 2025 12:31:13 -0700 Subject: [PATCH 140/147] IncentiveAlphaEmittedToMiners --- pallets/subtensor/src/coinbase/run_coinbase.rs | 7 +++++++ pallets/subtensor/src/epoch/run_epoch.rs | 5 +++++ pallets/subtensor/src/macros/events.rs | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/pallets/subtensor/src/coinbase/run_coinbase.rs b/pallets/subtensor/src/coinbase/run_coinbase.rs index c76e6941e3..989fd9b36e 100644 --- a/pallets/subtensor/src/coinbase/run_coinbase.rs +++ b/pallets/subtensor/src/coinbase/run_coinbase.rs @@ -513,6 +513,13 @@ impl Pallet { let owner: T::AccountId = Owner::::get(&hotkey); let destination = AutoStakeDestination::::get(&owner).unwrap_or(hotkey.clone()); + + Self::deposit_event(Event::::AutoStakeAdded( + netuid, + destination, + owner, + incentive, + )); Self::increase_stake_for_hotkey_and_coldkey_on_subnet( &destination, &owner, diff --git a/pallets/subtensor/src/epoch/run_epoch.rs b/pallets/subtensor/src/epoch/run_epoch.rs index 2f302c2a5e..7906064780 100644 --- a/pallets/subtensor/src/epoch/run_epoch.rs +++ b/pallets/subtensor/src/epoch/run_epoch.rs @@ -920,6 +920,11 @@ impl Pallet { } }); + Self::deposit_event(Event::IncentiveAlphaEmittedToMiners { + netuid, + emissions: server_emission.clone(), + }); + // Emission tuples ( hotkeys, server_emission, validator_emission ) hotkeys .into_iter() diff --git a/pallets/subtensor/src/macros/events.rs b/pallets/subtensor/src/macros/events.rs index 2fab5ecdb4..bb108560d8 100644 --- a/pallets/subtensor/src/macros/events.rs +++ b/pallets/subtensor/src/macros/events.rs @@ -413,5 +413,13 @@ mod events { /// - **netuid**: The network identifier. /// - **who**: The account ID of the user revealing the weights. TimelockedWeightsRevealed(NetUid, T::AccountId), + + /// Auto-staking hotkey received stake + AutoStakeAdded(NetUid, T::AccountId, T::AccountId, AlphaCurrency), + /// EpochIncentives + IncentiveAlphaEmittedToMiners { + netuid: NetUid, + emissions: Vec, + }, } } From 4af68a59abda539811cb5ed0424779f3db66e7c2 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Tue, 9 Sep 2025 12:49:15 -0700 Subject: [PATCH 141/147] fix compile --- pallets/subtensor/src/coinbase/run_coinbase.rs | 5 +++-- pallets/subtensor/src/macros/events.rs | 8 +++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pallets/subtensor/src/coinbase/run_coinbase.rs b/pallets/subtensor/src/coinbase/run_coinbase.rs index 989fd9b36e..93cc811b54 100644 --- a/pallets/subtensor/src/coinbase/run_coinbase.rs +++ b/pallets/subtensor/src/coinbase/run_coinbase.rs @@ -516,8 +516,9 @@ impl Pallet { Self::deposit_event(Event::::AutoStakeAdded( netuid, - destination, - owner, + destination.clone(), + hotkey, + owner.clone(), incentive, )); Self::increase_stake_for_hotkey_and_coldkey_on_subnet( diff --git a/pallets/subtensor/src/macros/events.rs b/pallets/subtensor/src/macros/events.rs index bb108560d8..e9a0e770f2 100644 --- a/pallets/subtensor/src/macros/events.rs +++ b/pallets/subtensor/src/macros/events.rs @@ -415,7 +415,13 @@ mod events { TimelockedWeightsRevealed(NetUid, T::AccountId), /// Auto-staking hotkey received stake - AutoStakeAdded(NetUid, T::AccountId, T::AccountId, AlphaCurrency), + AutoStakeAdded( + NetUid, + T::AccountId, + T::AccountId, + T::AccountId, + AlphaCurrency, + ), /// EpochIncentives IncentiveAlphaEmittedToMiners { netuid: NetUid, From 7e46b95f62cc0ca8d51187fd78cb118a78284ca8 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Tue, 9 Sep 2025 13:03:47 -0700 Subject: [PATCH 142/147] improve & clippy --- .../subtensor/src/coinbase/run_coinbase.rs | 8 +++--- pallets/subtensor/src/macros/events.rs | 25 +++++++++++++------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/pallets/subtensor/src/coinbase/run_coinbase.rs b/pallets/subtensor/src/coinbase/run_coinbase.rs index 93cc811b54..d525a65638 100644 --- a/pallets/subtensor/src/coinbase/run_coinbase.rs +++ b/pallets/subtensor/src/coinbase/run_coinbase.rs @@ -514,13 +514,13 @@ impl Pallet { let owner: T::AccountId = Owner::::get(&hotkey); let destination = AutoStakeDestination::::get(&owner).unwrap_or(hotkey.clone()); - Self::deposit_event(Event::::AutoStakeAdded( + Self::deposit_event(Event::::AutoStakeAdded { netuid, - destination.clone(), + destination: destination.clone(), hotkey, - owner.clone(), + owner: owner.clone(), incentive, - )); + }); Self::increase_stake_for_hotkey_and_coldkey_on_subnet( &destination, &owner, diff --git a/pallets/subtensor/src/macros/events.rs b/pallets/subtensor/src/macros/events.rs index e9a0e770f2..5d2de3b6c6 100644 --- a/pallets/subtensor/src/macros/events.rs +++ b/pallets/subtensor/src/macros/events.rs @@ -415,16 +415,25 @@ mod events { TimelockedWeightsRevealed(NetUid, T::AccountId), /// Auto-staking hotkey received stake - AutoStakeAdded( - NetUid, - T::AccountId, - T::AccountId, - T::AccountId, - AlphaCurrency, - ), - /// EpochIncentives + AutoStakeAdded { + /// Subnet identifier. + netuid: NetUid, + /// Destination account that received the auto-staked funds. + destination: T::AccountId, + /// Hotkey account whose stake was auto-staked. + hotkey: T::AccountId, + /// Owner (coldkey) account associated with the hotkey. + owner: T::AccountId, + /// Amount of alpha auto-staked. + incentive: AlphaCurrency, + }, + + /// End-of-epoch miner incentive alpha by UID (server emission). + /// `emissions[uid]` = alpha emitted to that UID (0..n-1). IncentiveAlphaEmittedToMiners { + /// Subnet identifier. netuid: NetUid, + /// UID-indexed array of miner incentive alpha; index equals UID. emissions: Vec, }, } From 7a7ab9789a7807c21ed29ba51d4aa4dd1445c6c7 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Tue, 9 Sep 2025 13:04:53 -0700 Subject: [PATCH 143/147] comment --- pallets/subtensor/src/macros/events.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pallets/subtensor/src/macros/events.rs b/pallets/subtensor/src/macros/events.rs index 5d2de3b6c6..25bf93b730 100644 --- a/pallets/subtensor/src/macros/events.rs +++ b/pallets/subtensor/src/macros/events.rs @@ -428,8 +428,7 @@ mod events { incentive: AlphaCurrency, }, - /// End-of-epoch miner incentive alpha by UID (server emission). - /// `emissions[uid]` = alpha emitted to that UID (0..n-1). + /// End-of-epoch miner incentive alpha by UID IncentiveAlphaEmittedToMiners { /// Subnet identifier. netuid: NetUid, From 5f1f7afb3fb47754a9a31403777c0b81fdbd17cd Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Tue, 9 Sep 2025 14:38:16 -0700 Subject: [PATCH 144/147] conditional AutoStakeAdded --- pallets/subtensor/src/coinbase/run_coinbase.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pallets/subtensor/src/coinbase/run_coinbase.rs b/pallets/subtensor/src/coinbase/run_coinbase.rs index d525a65638..0e1d5ffd8b 100644 --- a/pallets/subtensor/src/coinbase/run_coinbase.rs +++ b/pallets/subtensor/src/coinbase/run_coinbase.rs @@ -512,15 +512,15 @@ impl Pallet { } let owner: T::AccountId = Owner::::get(&hotkey); - let destination = AutoStakeDestination::::get(&owner).unwrap_or(hotkey.clone()); - - Self::deposit_event(Event::::AutoStakeAdded { - netuid, - destination: destination.clone(), - hotkey, - owner: owner.clone(), - incentive, - }); + if let Some(destination) = AutoStakeDestination::::get(&owner) { + Self::deposit_event(Event::::AutoStakeAdded { + netuid, + destination, + hotkey, + owner: owner.clone(), + incentive, + }); + } Self::increase_stake_for_hotkey_and_coldkey_on_subnet( &destination, &owner, From e7b4be3fa67fa97d4cf1352b69d9af3af5617c45 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Tue, 9 Sep 2025 14:42:39 -0700 Subject: [PATCH 145/147] Update run_coinbase.rs --- pallets/subtensor/src/coinbase/run_coinbase.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pallets/subtensor/src/coinbase/run_coinbase.rs b/pallets/subtensor/src/coinbase/run_coinbase.rs index 0e1d5ffd8b..28549fe685 100644 --- a/pallets/subtensor/src/coinbase/run_coinbase.rs +++ b/pallets/subtensor/src/coinbase/run_coinbase.rs @@ -512,10 +512,12 @@ impl Pallet { } let owner: T::AccountId = Owner::::get(&hotkey); - if let Some(destination) = AutoStakeDestination::::get(&owner) { + let destination = AutoStakeDestination::::get(&owner).unwrap_or(hotkey.clone()); + + if AutoStakeDestination::::contains_key(&owner) { Self::deposit_event(Event::::AutoStakeAdded { netuid, - destination, + destination: destination.clone(), hotkey, owner: owner.clone(), incentive, From 2e22929232157817669d04841a359c7b4a8d06c3 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Tue, 9 Sep 2025 14:45:22 -0700 Subject: [PATCH 146/147] only do one read --- pallets/subtensor/src/coinbase/run_coinbase.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pallets/subtensor/src/coinbase/run_coinbase.rs b/pallets/subtensor/src/coinbase/run_coinbase.rs index 28549fe685..7651a4162f 100644 --- a/pallets/subtensor/src/coinbase/run_coinbase.rs +++ b/pallets/subtensor/src/coinbase/run_coinbase.rs @@ -512,13 +512,16 @@ impl Pallet { } let owner: T::AccountId = Owner::::get(&hotkey); - let destination = AutoStakeDestination::::get(&owner).unwrap_or(hotkey.clone()); + let maybe_dest = AutoStakeDestination::::get(&owner); - if AutoStakeDestination::::contains_key(&owner) { + // Always stake but only emit event if autostake is set. + let destination = maybe_dest.clone().unwrap_or(hotkey.clone()); + + if let Some(dest) = maybe_dest { Self::deposit_event(Event::::AutoStakeAdded { netuid, - destination: destination.clone(), - hotkey, + destination: dest, + hotkey: hotkey.clone(), owner: owner.clone(), incentive, }); From 23b32c739cc312ff18e4160830d404834b6c69d9 Mon Sep 17 00:00:00 2001 From: John Reed <87283488+JohnReedV@users.noreply.github.com> Date: Tue, 9 Sep 2025 15:12:37 -0700 Subject: [PATCH 147/147] bump spec --- 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 f938105bc6..aee1e04895 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: 314, + spec_version: 315, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1,