@@ -105,6 +105,8 @@ pub mod pallet {
105105 MaxAllowedUIdsLessThanCurrentUIds ,
106106 /// The maximum value for bonds moving average is reached
107107 BondsMovingAverageMaxReached ,
108+ /// Only root can set negative sigmoid steepness values
109+ NegativeSigmoidSteepness ,
108110 }
109111 /// Enum for specifying the type of precompile operation.
110112 #[ derive( Encode , Decode , TypeInfo , Clone , PartialEq , Eq , Debug , Copy ) ]
@@ -1560,20 +1562,36 @@ pub mod pallet {
15601562 /// # Arguments
15611563 /// * `origin` - The origin of the call, which must be the root account.
15621564 /// * `netuid` - The unique identifier for the subnet.
1563- /// * `steepness` - The new steepness for the alpha sigmoid function.
1565+ /// * `steepness` - The Steepness for the alpha sigmoid function. (range is 0-int16::MAX,
1566+ /// negative values are reserved for future use)
15641567 ///
15651568 /// # Errors
15661569 /// * `BadOrigin` - If the caller is not the root account.
1570+ /// * `SubnetDoesNotExist` - If the specified subnet does not exist.
1571+ /// * `NegativeSigmoidSteepness` - If the steepness is negative and the caller is
1572+ /// root.
15671573 /// # Weight
15681574 /// Weight is handled by the `#[pallet::weight]` attribute.
15691575 #[ pallet:: call_index( 68 ) ]
15701576 #[ pallet:: weight( ( 0 , DispatchClass :: Operational , Pays :: No ) ) ]
15711577 pub fn sudo_set_alpha_sigmoid_steepness (
15721578 origin : OriginFor < T > ,
15731579 netuid : NetUid ,
1574- steepness : u16 ,
1580+ steepness : i16 ,
15751581 ) -> DispatchResult {
1576- ensure_root ( origin) ?;
1582+ pallet_subtensor:: Pallet :: < T > :: ensure_subnet_owner_or_root ( origin. clone ( ) , netuid) ?;
1583+
1584+ ensure ! (
1585+ pallet_subtensor:: Pallet :: <T >:: if_subnet_exist( netuid) ,
1586+ Error :: <T >:: SubnetDoesNotExist
1587+ ) ;
1588+
1589+ let is_root = ensure_root ( origin) . is_ok ( ) ;
1590+ ensure ! (
1591+ is_root || steepness >= 0 ,
1592+ Error :: <T >:: NegativeSigmoidSteepness
1593+ ) ;
1594+
15771595 pallet_subtensor:: Pallet :: < T > :: set_alpha_sigmoid_steepness ( netuid, steepness) ;
15781596
15791597 log:: debug!(
0 commit comments