@@ -4,7 +4,7 @@ use frame_support::storage::IterableStorageMap;
44extern crate alloc;
55use codec:: Compact ;
66
7- #[ freeze_struct( "ccca539640c3f631 " ) ]
7+ #[ freeze_struct( "fe79d58173da662a " ) ]
88#[ derive( Decode , Encode , PartialEq , Eq , Clone , Debug ) ]
99pub struct SubnetInfo < T : Config > {
1010 netuid : Compact < u16 > ,
@@ -25,6 +25,29 @@ pub struct SubnetInfo<T: Config> {
2525 emission_values : Compact < u64 > ,
2626 burn : Compact < u64 > ,
2727 owner : T :: AccountId ,
28+ }
29+
30+ #[ freeze_struct( "65f931972fa13222" ) ]
31+ #[ derive( Decode , Encode , PartialEq , Eq , Clone , Debug ) ]
32+ pub struct SubnetInfov2 < T : Config > {
33+ netuid : Compact < u16 > ,
34+ rho : Compact < u16 > ,
35+ kappa : Compact < u16 > ,
36+ difficulty : Compact < u64 > ,
37+ immunity_period : Compact < u16 > ,
38+ max_allowed_validators : Compact < u16 > ,
39+ min_allowed_weights : Compact < u16 > ,
40+ max_weights_limit : Compact < u16 > ,
41+ scaling_law_power : Compact < u16 > ,
42+ subnetwork_n : Compact < u16 > ,
43+ max_allowed_uids : Compact < u16 > ,
44+ blocks_since_last_step : Compact < u64 > ,
45+ tempo : Compact < u16 > ,
46+ network_modality : Compact < u16 > ,
47+ network_connect : Vec < [ u16 ; 2 ] > ,
48+ emission_values : Compact < u64 > ,
49+ burn : Compact < u64 > ,
50+ owner : T :: AccountId ,
2851 identity : Option < SubnetIdentity > ,
2952}
3053
@@ -81,8 +104,6 @@ impl<T: Config> Pallet<T> {
81104 let network_modality = <NetworkModality < T > >:: get ( netuid) ;
82105 let emission_values = Self :: get_emission_value ( netuid) ;
83106 let burn: Compact < u64 > = Self :: get_burn_as_u64 ( netuid) . into ( ) ;
84- let identity: Option < SubnetIdentity > = SubnetIdentities :: < T > :: get ( netuid) ;
85-
86107 // DEPRECATED
87108 let network_connect: Vec < [ u16 ; 2 ] > = Vec :: < [ u16 ; 2 ] > :: new ( ) ;
88109 // DEPRECATED for ( _netuid_, con_req) in < NetworkConnect<T> as IterableStorageDoubleMap<u16, u16, u16> >::iter_prefix(netuid) {
@@ -108,7 +129,6 @@ impl<T: Config> Pallet<T> {
108129 emission_values : emission_values. into ( ) ,
109130 burn,
110131 owner : Self :: get_subnet_owner ( netuid) ,
111- identity,
112132 } )
113133 }
114134
@@ -134,6 +154,77 @@ impl<T: Config> Pallet<T> {
134154 subnets_info
135155 }
136156
157+ pub fn get_subnet_info_v2 ( netuid : u16 ) -> Option < SubnetInfov2 < T > > {
158+ if !Self :: if_subnet_exist ( netuid) {
159+ return None ;
160+ }
161+
162+ let rho = Self :: get_rho ( netuid) ;
163+ let kappa = Self :: get_kappa ( netuid) ;
164+ let difficulty: Compact < u64 > = Self :: get_difficulty_as_u64 ( netuid) . into ( ) ;
165+ let immunity_period = Self :: get_immunity_period ( netuid) ;
166+ let max_allowed_validators = Self :: get_max_allowed_validators ( netuid) ;
167+ let min_allowed_weights = Self :: get_min_allowed_weights ( netuid) ;
168+ let max_weights_limit = Self :: get_max_weight_limit ( netuid) ;
169+ let scaling_law_power = Self :: get_scaling_law_power ( netuid) ;
170+ let subnetwork_n = Self :: get_subnetwork_n ( netuid) ;
171+ let max_allowed_uids = Self :: get_max_allowed_uids ( netuid) ;
172+ let blocks_since_last_step = Self :: get_blocks_since_last_step ( netuid) ;
173+ let tempo = Self :: get_tempo ( netuid) ;
174+ let network_modality = <NetworkModality < T > >:: get ( netuid) ;
175+ let emission_values = Self :: get_emission_value ( netuid) ;
176+ let burn: Compact < u64 > = Self :: get_burn_as_u64 ( netuid) . into ( ) ;
177+ let identity: Option < SubnetIdentity > = SubnetIdentities :: < T > :: get ( netuid) ;
178+
179+ // DEPRECATED
180+ let network_connect: Vec < [ u16 ; 2 ] > = Vec :: < [ u16 ; 2 ] > :: new ( ) ;
181+ // DEPRECATED for ( _netuid_, con_req) in < NetworkConnect<T> as IterableStorageDoubleMap<u16, u16, u16> >::iter_prefix(netuid) {
182+ // network_connect.push([_netuid_, con_req]);
183+ // }
184+
185+ Some ( SubnetInfov2 {
186+ rho : rho. into ( ) ,
187+ kappa : kappa. into ( ) ,
188+ difficulty,
189+ immunity_period : immunity_period. into ( ) ,
190+ netuid : netuid. into ( ) ,
191+ max_allowed_validators : max_allowed_validators. into ( ) ,
192+ min_allowed_weights : min_allowed_weights. into ( ) ,
193+ max_weights_limit : max_weights_limit. into ( ) ,
194+ scaling_law_power : scaling_law_power. into ( ) ,
195+ subnetwork_n : subnetwork_n. into ( ) ,
196+ max_allowed_uids : max_allowed_uids. into ( ) ,
197+ blocks_since_last_step : blocks_since_last_step. into ( ) ,
198+ tempo : tempo. into ( ) ,
199+ network_modality : network_modality. into ( ) ,
200+ network_connect,
201+ emission_values : emission_values. into ( ) ,
202+ burn,
203+ owner : Self :: get_subnet_owner ( netuid) ,
204+ identity,
205+ } )
206+ }
207+ pub fn get_subnets_info_v2 ( ) -> Vec < Option < SubnetInfo < T > > > {
208+ let mut subnet_netuids = Vec :: < u16 > :: new ( ) ;
209+ let mut max_netuid: u16 = 0 ;
210+ for ( netuid, added) in <NetworksAdded < T > as IterableStorageMap < u16 , bool > >:: iter ( ) {
211+ if added {
212+ subnet_netuids. push ( netuid) ;
213+ if netuid > max_netuid {
214+ max_netuid = netuid;
215+ }
216+ }
217+ }
218+
219+ let mut subnets_info = Vec :: < Option < SubnetInfo < T > > > :: new ( ) ;
220+ for netuid_ in 0 ..=max_netuid {
221+ if subnet_netuids. contains ( & netuid_) {
222+ subnets_info. push ( Self :: get_subnet_info ( netuid_) ) ;
223+ }
224+ }
225+
226+ subnets_info
227+ }
137228 pub fn get_subnet_hyperparams ( netuid : u16 ) -> Option < SubnetHyperparams > {
138229 if !Self :: if_subnet_exist ( netuid) {
139230 return None ;
0 commit comments