File tree Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Expand file tree Collapse file tree 2 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ pub mod pallet {
28
28
use frame_support:: { dispatch:: DispatchResult , pallet_prelude:: StorageMap } ;
29
29
use frame_system:: pallet_prelude:: * ;
30
30
use pallet_evm_chain_id:: { self , ChainId } ;
31
+ use substrate_fixed:: types:: I96F32 ;
31
32
use sp_runtime:: BoundedVec ;
32
33
33
34
/// The main data structure of the module.
@@ -1376,6 +1377,32 @@ pub mod pallet {
1376
1377
} ) ;
1377
1378
}
1378
1379
Ok ( ( ) )
1380
+ }
1381
+
1382
+ ///
1383
+ ///
1384
+ /// # Arguments
1385
+ /// * `origin` - The origin of the call, which must be the root account.
1386
+ /// * `precompile_id` - The identifier of the EVM precompile to toggle.
1387
+ /// * `enabled` - The new enablement state of the precompile.
1388
+ ///
1389
+ /// # Errors
1390
+ /// * `BadOrigin` - If the caller is not the root account.
1391
+ ///
1392
+ /// # Weight
1393
+ /// Weight is handled by the `#[pallet::weight]` attribute.
1394
+ #[ pallet:: call_index( 63 ) ]
1395
+ #[ pallet:: weight( ( 0 , DispatchClass :: Operational , Pays :: No ) ) ]
1396
+ pub fn sudo_set_subnet_moving_alpha (
1397
+ origin : OriginFor < T > ,
1398
+ alpha : I96F32 ,
1399
+ ) -> DispatchResult {
1400
+ ensure_root ( origin) ?;
1401
+ let alpha: I96F32 = I96F32 :: saturating_from_num ( alpha) ;
1402
+ pallet_subtensor:: SubnetMovingAlpha :: < T > :: set ( alpha) ;
1403
+
1404
+ log:: debug!( "SubnetMovingAlphaSet( alpha: {:?} )" , alpha) ;
1405
+ Ok ( ( ) )
1379
1406
}
1380
1407
}
1381
1408
}
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ use pallet_subtensor::Error as SubtensorError;
10
10
use pallet_subtensor:: Event ;
11
11
use sp_consensus_grandpa:: AuthorityId as GrandpaId ;
12
12
use sp_core:: { Pair , U256 , ed25519} ;
13
+ use substrate_fixed:: types:: I96F32 ;
13
14
14
15
use crate :: Error ;
15
16
use crate :: pallet:: PrecompileEnable ;
@@ -1449,3 +1450,18 @@ fn test_sudo_toggle_evm_precompile() {
1449
1450
assert ! ( final_enabled) ;
1450
1451
} ) ;
1451
1452
}
1453
+
1454
+ #[ test]
1455
+ fn test_sudo_root_sets_subnet_moving_alpha ( ) {
1456
+ new_test_ext ( ) . execute_with ( || {
1457
+ let alpha: I96F32 = I96F32 :: saturating_from_num ( 0.5 ) ;
1458
+ assert_eq ! ( pallet_subtensor:: SubnetMovingAlpha :: <Test >:: get( ) , 0 ) ;
1459
+
1460
+ assert_ok ! ( AdminUtils :: sudo_set_subnet_moving_alpha(
1461
+ <<Test as Config >:: RuntimeOrigin >:: root( ) ,
1462
+ alpha
1463
+ ) ) ;
1464
+
1465
+ assert_eq ! ( pallet_subtensor:: SubnetMovingAlpha :: <Test >:: get( ) , alpha) ;
1466
+ } ) ;
1467
+ }
You can’t perform that action at this time.
0 commit comments