File tree Expand file tree Collapse file tree 3 files changed +36
-2
lines changed Expand file tree Collapse file tree 3 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -2186,6 +2186,20 @@ pub mod pallet {
21862186 log:: debug!( "set_tao_flow_smoothing_factor( {smoothing_factor:?} ) " ) ;
21872187 Ok ( ( ) )
21882188 }
2189+
2190+ /// Sets the global maximum number of mechanisms in a subnet
2191+ #[ pallet:: call_index( 84 ) ]
2192+ #[ pallet:: weight( Weight :: from_parts( 15_000_000 , 0 )
2193+ . saturating_add( <T as frame_system:: Config >:: DbWeight :: get( ) . reads( 1_u64 ) )
2194+ . saturating_add( <T as frame_system:: Config >:: DbWeight :: get( ) . writes( 1_u64 ) ) ) ]
2195+ pub fn sudo_set_max_mechanism_count (
2196+ origin : OriginFor < T > ,
2197+ max_mechanism_count : MechId ,
2198+ ) -> DispatchResult {
2199+ ensure_root ( origin) ?;
2200+ pallet_subtensor:: Pallet :: < T > :: do_set_max_mechanism_count ( max_mechanism_count) ?;
2201+ Ok ( ( ) )
2202+ }
21892203 }
21902204}
21912205
Original file line number Diff line number Diff line change @@ -2041,9 +2041,13 @@ pub mod pallet {
20412041 }
20422042 #[ pallet:: type_value]
20432043 /// -- ITEM (Maximum number of sub-subnets)
2044- pub fn MaxMechanismCount < T : Config > ( ) -> MechId {
2044+ pub fn DefaultMaxMechanismCount < T : Config > ( ) -> MechId {
20452045 MechId :: from ( 2 )
20462046 }
2047+ #[ pallet:: storage]
2048+ /// ITEM( max_mechanism_count )
2049+ pub type MaxMechanismCount < T > =
2050+ StorageValue < _ , MechId , ValueQuery , DefaultMaxMechanismCount < T > > ;
20472051 #[ pallet:: type_value]
20482052 /// -- ITEM (Rate limit for mechanism count updates)
20492053 pub fn MechanismCountSetRateLimit < T : Config > ( ) -> u64 {
Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ impl<T: Config> Pallet<T> {
9595 Ok ( ( ) )
9696 }
9797
98- /// Set the desired valus of sub-subnet count for a subnet identified
98+ /// Set the desired value of sub-subnet count for a subnet identified
9999 /// by netuid
100100 pub fn do_set_mechanism_count ( netuid : NetUid , mechanism_count : MechId ) -> DispatchResult {
101101 // Make sure the subnet exists
@@ -124,6 +124,22 @@ impl<T: Config> Pallet<T> {
124124 Ok ( ( ) )
125125 }
126126
127+ /// Set the global maximum number of mechanisms per subnet
128+ pub fn do_set_max_mechanism_count ( max_mechanism_count : MechId ) -> DispatchResult {
129+ // Max count cannot be zero
130+ ensure ! ( max_mechanism_count > 0 . into( ) , Error :: <T >:: InvalidValue ) ;
131+
132+ // Make sure we are not allowing numbers that will break the math
133+ ensure ! (
134+ max_mechanism_count <= MechId :: from( MAX_MECHANISM_COUNT_PER_SUBNET ) ,
135+ Error :: <T >:: InvalidValue
136+ ) ;
137+
138+ MaxMechanismCount :: < T > :: set ( max_mechanism_count) ;
139+
140+ Ok ( ( ) )
141+ }
142+
127143 /// Update current count for a subnet identified by netuid
128144 /// - Cleans up all sub-subnet maps if count is reduced
129145 ///
You can’t perform that action at this time.
0 commit comments