@@ -90,6 +90,20 @@ pub mod pallet {
9090 /// Indicates if the Bonds Reset was enabled or disabled.
9191 enabled : bool ,
9292 } ,
93+ /// Event emitted when the burn half-life parameter is set for a subnet.
94+ BurnHalfLifeSet {
95+ /// The network identifier.
96+ netuid : NetUid ,
97+ /// The new burn half-life value.
98+ burn_half_life : u16 ,
99+ } ,
100+ /// Event emitted when the burn increase multiplier is set for a subnet.
101+ BurnIncreaseMultSet {
102+ /// The network identifier.
103+ netuid : NetUid ,
104+ /// The new burn increase multiplier.
105+ burn_increase_mult : U64F64 ,
106+ } ,
93107 }
94108
95109 // Errors inform users that something went wrong.
@@ -117,6 +131,10 @@ pub mod pallet {
117131 MaxAllowedUidsGreaterThanDefaultMaxAllowedUids ,
118132 /// Bad parameter value
119133 InvalidValue ,
134+ /// Operation is not permitted on the root network.
135+ NotPermittedOnRootSubnet ,
136+ /// POW Registration has been deprecated
137+ POWRegistrationDisabled ,
120138 }
121139 /// Enum for specifying the type of precompile operation.
122140 #[ derive(
@@ -674,30 +692,11 @@ pub mod pallet {
674692 . saturating_add( <T as frame_system:: Config >:: DbWeight :: get( ) . writes( 1 ) )
675693 ) ]
676694 pub fn sudo_set_network_pow_registration_allowed (
677- origin : OriginFor < T > ,
678- netuid : NetUid ,
679- registration_allowed : bool ,
695+ _origin : OriginFor < T > ,
696+ _netuid : NetUid ,
697+ _registration_allowed : bool ,
680698 ) -> DispatchResult {
681- let maybe_owner = pallet_subtensor:: Pallet :: < T > :: ensure_sn_owner_or_root_with_limits (
682- origin,
683- netuid,
684- & [ Hyperparameter :: PowRegistrationAllowed . into ( ) ] ,
685- ) ?;
686- pallet_subtensor:: Pallet :: < T > :: ensure_admin_window_open ( netuid) ?;
687-
688- pallet_subtensor:: Pallet :: < T > :: set_network_pow_registration_allowed (
689- netuid,
690- registration_allowed,
691- ) ;
692- log:: debug!(
693- "NetworkPowRegistrationAllowed( registration_allowed: {registration_allowed:?} ) "
694- ) ;
695- pallet_subtensor:: Pallet :: < T > :: record_owner_rl (
696- maybe_owner,
697- netuid,
698- & [ Hyperparameter :: PowRegistrationAllowed . into ( ) ] ,
699- ) ;
700- Ok ( ( ) )
699+ Err ( Error :: < T > :: POWRegistrationDisabled . into ( ) )
701700 }
702701
703702 /// The extrinsic sets the target registrations per interval for a subnet.
@@ -2134,6 +2133,104 @@ pub mod pallet {
21342133 log:: trace!( "ColdkeySwapReannouncementDelaySet( duration: {duration:?} )" ) ;
21352134 Ok ( ( ) )
21362135 }
2136+
2137+ /// Set BurnHalfLife for a subnet.
2138+ /// It is only callable by root and subnet owner.
2139+ #[ pallet:: call_index( 89 ) ]
2140+ #[ pallet:: weight( (
2141+ Weight :: from_parts( 25_000_000 , 0 )
2142+ . saturating_add( T :: DbWeight :: get( ) . reads( 4 ) )
2143+ . saturating_add( T :: DbWeight :: get( ) . writes( 1 ) ) ,
2144+ DispatchClass :: Operational ,
2145+ Pays :: Yes ,
2146+ ) ) ]
2147+ pub fn sudo_set_burn_half_life (
2148+ origin : OriginFor < T > ,
2149+ netuid : NetUid ,
2150+ burn_half_life : u16 ,
2151+ ) -> DispatchResult {
2152+ let maybe_owner = pallet_subtensor:: Pallet :: < T > :: ensure_sn_owner_or_root_with_limits (
2153+ origin,
2154+ netuid,
2155+ & [ Hyperparameter :: BurnHalfLife . into ( ) ] ,
2156+ ) ?;
2157+ pallet_subtensor:: Pallet :: < T > :: ensure_admin_window_open ( netuid) ?;
2158+
2159+ ensure ! (
2160+ pallet_subtensor:: Pallet :: <T >:: if_subnet_exist( netuid) ,
2161+ Error :: <T >:: SubnetDoesNotExist
2162+ ) ;
2163+ ensure ! ( !netuid. is_root( ) , Error :: <T >:: NotPermittedOnRootSubnet ) ;
2164+ ensure ! (
2165+ burn_half_life > 0
2166+ && burn_half_life <= pallet_subtensor:: MaxBurnHalfLife :: <T >:: get( ) ,
2167+ Error :: <T >:: InvalidValue
2168+ ) ;
2169+
2170+ pallet_subtensor:: BurnHalfLife :: < T > :: insert ( netuid, burn_half_life) ;
2171+ Self :: deposit_event ( Event :: BurnHalfLifeSet {
2172+ netuid,
2173+ burn_half_life,
2174+ } ) ;
2175+
2176+ pallet_subtensor:: Pallet :: < T > :: record_owner_rl (
2177+ maybe_owner,
2178+ netuid,
2179+ & [ Hyperparameter :: BurnHalfLife . into ( ) ] ,
2180+ ) ;
2181+
2182+ Ok ( ( ) )
2183+ }
2184+
2185+ /// Set BurnIncreaseMult for a subnet.
2186+ /// It is only callable by root and subnet owner.
2187+ #[ pallet:: call_index( 90 ) ]
2188+ #[ pallet:: weight( (
2189+ Weight :: from_parts( 25_000_000 , 0 )
2190+ . saturating_add( T :: DbWeight :: get( ) . reads( 4 ) )
2191+ . saturating_add( T :: DbWeight :: get( ) . writes( 1 ) ) ,
2192+ DispatchClass :: Operational ,
2193+ Pays :: Yes ,
2194+ ) ) ]
2195+ pub fn sudo_set_burn_increase_mult (
2196+ origin : OriginFor < T > ,
2197+ netuid : NetUid ,
2198+ burn_increase_mult : U64F64 ,
2199+ ) -> DispatchResult {
2200+ let maybe_owner = pallet_subtensor:: Pallet :: < T > :: ensure_sn_owner_or_root_with_limits (
2201+ origin,
2202+ netuid,
2203+ & [ Hyperparameter :: BurnIncreaseMult . into ( ) ] ,
2204+ ) ?;
2205+ pallet_subtensor:: Pallet :: < T > :: ensure_admin_window_open ( netuid) ?;
2206+
2207+ ensure ! (
2208+ pallet_subtensor:: Pallet :: <T >:: if_subnet_exist( netuid) ,
2209+ Error :: <T >:: SubnetDoesNotExist
2210+ ) ;
2211+ ensure ! ( !netuid. is_root( ) , Error :: <T >:: NotPermittedOnRootSubnet ) ;
2212+ ensure ! (
2213+ ( 1 ..=3 ) . contains( & burn_increase_mult) ,
2214+ Error :: <T >:: InvalidValue
2215+ ) ;
2216+
2217+ pallet_subtensor:: BurnIncreaseMult :: < T > :: insert (
2218+ netuid,
2219+ U64F64 :: from_num ( burn_increase_mult) ,
2220+ ) ;
2221+ Self :: deposit_event ( Event :: BurnIncreaseMultSet {
2222+ netuid,
2223+ burn_increase_mult,
2224+ } ) ;
2225+
2226+ pallet_subtensor:: Pallet :: < T > :: record_owner_rl (
2227+ maybe_owner,
2228+ netuid,
2229+ & [ Hyperparameter :: BurnIncreaseMult . into ( ) ] ,
2230+ ) ;
2231+
2232+ Ok ( ( ) )
2233+ }
21372234 }
21382235}
21392236
0 commit comments