@@ -3,6 +3,7 @@ use frame_support::pallet_prelude::{Decode, Encode};
33use frame_support:: storage:: IterableStorageMap ;
44extern crate alloc;
55use codec:: Compact ;
6+ use substrate_fixed:: types:: I32F32 ;
67use subtensor_runtime_common:: NetUid ;
78
89#[ freeze_struct( "dd2293544ffd8f2e" ) ]
@@ -52,7 +53,7 @@ pub struct SubnetInfov2<AccountId: TypeInfo + Encode + Decode> {
5253 identity : Option < SubnetIdentityV3 > ,
5354}
5455
55- #[ freeze_struct( "769dc2ca2135b525 " ) ]
56+ #[ freeze_struct( "7b506df55bd44646 " ) ]
5657#[ derive( Decode , Encode , PartialEq , Eq , Clone , Debug , TypeInfo ) ]
5758pub struct SubnetHyperparams {
5859 rho : Compact < u16 > ,
@@ -82,6 +83,43 @@ pub struct SubnetHyperparams {
8283 alpha_high : Compact < u16 > ,
8384 alpha_low : Compact < u16 > ,
8485 liquid_alpha_enabled : bool ,
86+ }
87+
88+ #[ freeze_struct( "a13c536303dec16f" ) ]
89+ #[ derive( Decode , Encode , PartialEq , Eq , Clone , Debug , TypeInfo ) ]
90+ pub struct SubnetHyperparamsV2 {
91+ rho : Compact < u16 > ,
92+ kappa : Compact < u16 > ,
93+ immunity_period : Compact < u16 > ,
94+ min_allowed_weights : Compact < u16 > ,
95+ max_weights_limit : Compact < u16 > ,
96+ tempo : Compact < u16 > ,
97+ min_difficulty : Compact < u64 > ,
98+ max_difficulty : Compact < u64 > ,
99+ weights_version : Compact < u64 > ,
100+ weights_rate_limit : Compact < u64 > ,
101+ adjustment_interval : Compact < u16 > ,
102+ activity_cutoff : Compact < u16 > ,
103+ pub registration_allowed : bool ,
104+ target_regs_per_interval : Compact < u16 > ,
105+ min_burn : Compact < u64 > ,
106+ max_burn : Compact < u64 > ,
107+ bonds_moving_avg : Compact < u64 > ,
108+ max_regs_per_block : Compact < u16 > ,
109+ serving_rate_limit : Compact < u64 > ,
110+ max_validators : Compact < u16 > ,
111+ adjustment_alpha : Compact < u64 > ,
112+ difficulty : Compact < u64 > ,
113+ commit_reveal_period : Compact < u64 > ,
114+ commit_reveal_weights_enabled : bool ,
115+ alpha_high : Compact < u16 > ,
116+ alpha_low : Compact < u16 > ,
117+ liquid_alpha_enabled : bool ,
118+ alpha_sigmoid_steepness : I32F32 ,
119+ yuma_version : Compact < u16 > ,
120+ subnet_is_active : bool ,
121+ transfers_enabled : bool ,
122+ bonds_reset_enabled : bool ,
85123 user_liquidity_enabled : bool ,
86124}
87125
@@ -258,7 +296,6 @@ impl<T: Config> Pallet<T> {
258296 let commit_reveal_weights_enabled = Self :: get_commit_reveal_weights_enabled ( netuid) ;
259297 let liquid_alpha_enabled = Self :: get_liquid_alpha_enabled ( netuid) ;
260298 let ( alpha_low, alpha_high) : ( u16 , u16 ) = Self :: get_alpha_values ( netuid) ;
261- let user_liquidity_enabled: bool = Self :: is_user_liquidity_enabled ( netuid) ;
262299
263300 Some ( SubnetHyperparams {
264301 rho : rho. into ( ) ,
@@ -288,6 +325,83 @@ impl<T: Config> Pallet<T> {
288325 alpha_high : alpha_high. into ( ) ,
289326 alpha_low : alpha_low. into ( ) ,
290327 liquid_alpha_enabled,
328+ } )
329+ }
330+
331+ pub fn get_subnet_hyperparams_v2 ( netuid : NetUid ) -> Option < SubnetHyperparamsV2 > {
332+ if !Self :: if_subnet_exist ( netuid) {
333+ return None ;
334+ }
335+
336+ let rho = Self :: get_rho ( netuid) ;
337+ let kappa = Self :: get_kappa ( netuid) ;
338+ let immunity_period = Self :: get_immunity_period ( netuid) ;
339+ let min_allowed_weights = Self :: get_min_allowed_weights ( netuid) ;
340+ let max_weights_limit = Self :: get_max_weight_limit ( netuid) ;
341+ let tempo = Self :: get_tempo ( netuid) ;
342+ let min_difficulty = Self :: get_min_difficulty ( netuid) ;
343+ let max_difficulty = Self :: get_max_difficulty ( netuid) ;
344+ let weights_version = Self :: get_weights_version_key ( netuid) ;
345+ let weights_rate_limit = Self :: get_weights_set_rate_limit ( netuid) ;
346+ let adjustment_interval = Self :: get_adjustment_interval ( netuid) ;
347+ let activity_cutoff = Self :: get_activity_cutoff ( netuid) ;
348+ let registration_allowed = Self :: get_network_registration_allowed ( netuid) ;
349+ let target_regs_per_interval = Self :: get_target_registrations_per_interval ( netuid) ;
350+ let min_burn = Self :: get_min_burn_as_u64 ( netuid) ;
351+ let max_burn = Self :: get_max_burn_as_u64 ( netuid) ;
352+ let bonds_moving_avg = Self :: get_bonds_moving_average ( netuid) ;
353+ let max_regs_per_block = Self :: get_max_registrations_per_block ( netuid) ;
354+ let serving_rate_limit = Self :: get_serving_rate_limit ( netuid) ;
355+ let max_validators = Self :: get_max_allowed_validators ( netuid) ;
356+ let adjustment_alpha = Self :: get_adjustment_alpha ( netuid) ;
357+ let difficulty = Self :: get_difficulty_as_u64 ( netuid) ;
358+ let commit_reveal_period = Self :: get_reveal_period ( netuid) ;
359+ let commit_reveal_weights_enabled = Self :: get_commit_reveal_weights_enabled ( netuid) ;
360+ let liquid_alpha_enabled = Self :: get_liquid_alpha_enabled ( netuid) ;
361+ let ( alpha_low, alpha_high) : ( u16 , u16 ) = Self :: get_alpha_values ( netuid) ;
362+ let alpha_sigmoid_steepness = Self :: get_alpha_sigmoid_steepness ( netuid) ;
363+ let yuma_version: u16 = match Self :: get_yuma3_enabled ( netuid) {
364+ true => 3u16 ,
365+ false => 2u16 ,
366+ } ;
367+ let subnet_token_enabled = Self :: get_subtoken_enabled ( netuid) ;
368+ let transfers_enabled = Self :: get_transfer_toggle ( netuid) ;
369+ let bonds_reset = Self :: get_bonds_reset ( netuid) ;
370+ let user_liquidity_enabled: bool = Self :: is_user_liquidity_enabled ( netuid) ;
371+
372+ Some ( SubnetHyperparamsV2 {
373+ rho : rho. into ( ) ,
374+ kappa : kappa. into ( ) ,
375+ immunity_period : immunity_period. into ( ) ,
376+ min_allowed_weights : min_allowed_weights. into ( ) ,
377+ max_weights_limit : max_weights_limit. into ( ) ,
378+ tempo : tempo. into ( ) ,
379+ min_difficulty : min_difficulty. into ( ) ,
380+ max_difficulty : max_difficulty. into ( ) ,
381+ weights_version : weights_version. into ( ) ,
382+ weights_rate_limit : weights_rate_limit. into ( ) ,
383+ adjustment_interval : adjustment_interval. into ( ) ,
384+ activity_cutoff : activity_cutoff. into ( ) ,
385+ registration_allowed,
386+ target_regs_per_interval : target_regs_per_interval. into ( ) ,
387+ min_burn : min_burn. into ( ) ,
388+ max_burn : max_burn. into ( ) ,
389+ bonds_moving_avg : bonds_moving_avg. into ( ) ,
390+ max_regs_per_block : max_regs_per_block. into ( ) ,
391+ serving_rate_limit : serving_rate_limit. into ( ) ,
392+ max_validators : max_validators. into ( ) ,
393+ adjustment_alpha : adjustment_alpha. into ( ) ,
394+ difficulty : difficulty. into ( ) ,
395+ commit_reveal_period : commit_reveal_period. into ( ) ,
396+ commit_reveal_weights_enabled,
397+ alpha_high : alpha_high. into ( ) ,
398+ alpha_low : alpha_low. into ( ) ,
399+ liquid_alpha_enabled,
400+ alpha_sigmoid_steepness,
401+ yuma_version : yuma_version. into ( ) ,
402+ subnet_is_active : subnet_token_enabled,
403+ transfers_enabled,
404+ bonds_reset_enabled : bonds_reset,
291405 user_liquidity_enabled,
292406 } )
293407 }
0 commit comments