@@ -8,6 +8,7 @@ use frame_support::{assert_ok, weights::Weight};
88use frame_system:: RawOrigin ;
99use pallet_contracts:: chain_extension:: RetVal ;
1010use pallet_subtensor:: DefaultMinStake ;
11+ use pallet_subtensor:: weights:: WeightInfo as SubtensorWeightInfo ;
1112use sp_core:: Get ;
1213use sp_core:: U256 ;
1314use sp_runtime:: DispatchError ;
@@ -46,9 +47,7 @@ fn set_coldkey_auto_stake_hotkey_success_sets_destination() {
4647 None
4748 ) ;
4849
49- let expected_weight = Weight :: from_parts ( 29_930_000 , 0 )
50- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . reads ( 4 ) )
51- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . writes ( 2 ) ) ;
50+ let expected_weight = <<mock:: Test as pallet_subtensor:: Config >:: WeightInfo as SubtensorWeightInfo >:: set_coldkey_auto_stake_hotkey ( ) ;
5251
5352 let mut env = MockEnv :: new (
5453 FunctionId :: SetColdkeyAutoStakeHotkeyV1 ,
@@ -103,9 +102,7 @@ fn remove_stake_full_limit_success_with_limit_price() {
103102
104103 mock:: remove_stake_rate_limit_for_tests ( & hotkey, & coldkey, netuid) ;
105104
106- let expected_weight = Weight :: from_parts ( 395_300_000 , 0 )
107- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . reads ( 28 ) )
108- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . writes ( 14 ) ) ;
105+ let expected_weight = <<mock:: Test as pallet_subtensor:: Config >:: WeightInfo as SubtensorWeightInfo >:: remove_stake_full_limit ( ) ;
109106
110107 let balance_before = pallet_subtensor:: Pallet :: < mock:: Test > :: get_coldkey_balance ( & coldkey) ;
111108
@@ -181,9 +178,7 @@ fn swap_stake_limit_with_tight_price_returns_slippage_error() {
181178 let alpha_to_swap: AlphaBalance = ( alpha_origin_before. to_u64 ( ) / 8 ) . into ( ) ;
182179 let limit_price: TaoBalance = 100u64 . into ( ) ;
183180
184- let expected_weight = Weight :: from_parts ( 411_500_000 , 0 )
185- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . reads ( 35 ) )
186- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . writes ( 22 ) ) ;
181+ let expected_weight = <<mock:: Test as pallet_subtensor:: Config >:: WeightInfo as SubtensorWeightInfo >:: swap_stake_limit ( ) ;
187182
188183 let mut env = MockEnv :: new (
189184 FunctionId :: SwapStakeLimitV1 ,
@@ -256,9 +251,7 @@ fn remove_stake_limit_success_respects_price_limit() {
256251
257252 let alpha_to_unstake: AlphaBalance = ( alpha_before. to_u64 ( ) / 2 ) . into ( ) ;
258253
259- let expected_weight = Weight :: from_parts ( 377_400_000 , 0 )
260- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . reads ( 28 ) )
261- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . writes ( 14 ) ) ;
254+ let expected_weight = <<mock:: Test as pallet_subtensor:: Config >:: WeightInfo as SubtensorWeightInfo >:: remove_stake_limit ( ) ;
262255
263256 let balance_before = pallet_subtensor:: Pallet :: < mock:: Test > :: get_coldkey_balance ( & coldkey) ;
264257
@@ -315,9 +308,7 @@ fn add_stake_limit_success_executes_within_price_guard() {
315308 ) ;
316309 let balance_before = pallet_subtensor:: Pallet :: < mock:: Test > :: get_coldkey_balance ( & coldkey) ;
317310
318- let expected_weight = Weight :: from_parts ( 402_900_000 , 0 )
319- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . reads ( 24 ) )
320- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . writes ( 15 ) ) ;
311+ let expected_weight = <<mock:: Test as pallet_subtensor:: Config >:: WeightInfo as SubtensorWeightInfo >:: add_stake_limit ( ) ;
321312
322313 let mut env = MockEnv :: new (
323314 FunctionId :: AddStakeLimitV1 ,
@@ -403,9 +394,7 @@ fn swap_stake_success_moves_between_subnets() {
403394 ) ;
404395 let alpha_to_swap: AlphaBalance = ( alpha_origin_before. to_u64 ( ) / 3 ) . into ( ) ;
405396
406- let expected_weight = Weight :: from_parts ( 351_300_000 , 0 )
407- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . reads ( 35 ) )
408- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . writes ( 22 ) ) ;
397+ let expected_weight = <<mock:: Test as pallet_subtensor:: Config >:: WeightInfo as SubtensorWeightInfo >:: swap_stake ( ) ;
409398
410399 let mut env = MockEnv :: new (
411400 FunctionId :: SwapStakeV1 ,
@@ -478,9 +467,7 @@ fn transfer_stake_success_moves_between_coldkeys() {
478467 ) ;
479468 let alpha_to_transfer: AlphaBalance = ( alpha_before. to_u64 ( ) / 3 ) . into ( ) ;
480469
481- let expected_weight = Weight :: from_parts ( 160_300_000 , 0 )
482- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . reads ( 13 ) )
483- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . writes ( 6 ) ) ;
470+ let expected_weight = <<mock:: Test as pallet_subtensor:: Config >:: WeightInfo as SubtensorWeightInfo >:: transfer_stake ( ) ;
484471
485472 let mut env = MockEnv :: new (
486473 FunctionId :: TransferStakeV1 ,
@@ -562,9 +549,7 @@ fn move_stake_success_moves_alpha_between_hotkeys() {
562549 ) ;
563550 let alpha_to_move: AlphaBalance = ( alpha_before. to_u64 ( ) / 2 ) . into ( ) ;
564551
565- let expected_weight = Weight :: from_parts ( 164_300_000 , 0 )
566- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . reads ( 15 ) )
567- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . writes ( 7 ) ) ;
552+ let expected_weight = <<mock:: Test as pallet_subtensor:: Config >:: WeightInfo as SubtensorWeightInfo >:: move_stake ( ) ;
568553
569554 let mut env = MockEnv :: new (
570555 FunctionId :: MoveStakeV1 ,
@@ -634,9 +619,7 @@ fn unstake_all_alpha_success_moves_stake_to_root() {
634619
635620 mock:: remove_stake_rate_limit_for_tests ( & hotkey, & coldkey, netuid) ;
636621
637- let expected_weight = Weight :: from_parts ( 358_500_000 , 0 )
638- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . reads ( 36 ) )
639- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . writes ( 21 ) ) ;
622+ let expected_weight = <<mock:: Test as pallet_subtensor:: Config >:: WeightInfo as SubtensorWeightInfo >:: unstake_all_alpha ( ) ;
640623
641624 let mut env = MockEnv :: new ( FunctionId :: UnstakeAllAlphaV1 , coldkey, hotkey. encode ( ) )
642625 . with_expected_weight ( expected_weight) ;
@@ -855,9 +838,7 @@ fn add_stake_success_updates_stake_and_returns_success_code() {
855838 pallet_subtensor:: Pallet :: <mock:: Test >:: get_total_stake_for_hotkey( & hotkey) . is_zero( )
856839 ) ;
857840
858- let expected_weight = Weight :: from_parts ( 340_800_000 , 0 )
859- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . reads ( 24 ) )
860- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . writes ( 15 ) ) ;
841+ let expected_weight = <<mock:: Test as pallet_subtensor:: Config >:: WeightInfo as SubtensorWeightInfo >:: add_stake ( ) ;
861842
862843 let mut env = MockEnv :: new (
863844 FunctionId :: AddStakeV1 ,
@@ -890,9 +871,7 @@ fn remove_stake_with_no_stake_returns_amount_too_low() {
890871 let min_stake = DefaultMinStake :: < mock:: Test > :: get ( ) ;
891872 let amount: AlphaBalance = AlphaBalance :: from ( min_stake. to_u64 ( ) ) ;
892873
893- let expected_weight = Weight :: from_parts ( 196_800_000 , 0 )
894- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . reads ( 19 ) )
895- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . writes ( 10 ) ) ;
874+ let expected_weight = <<mock:: Test as pallet_subtensor:: Config >:: WeightInfo as SubtensorWeightInfo >:: remove_stake ( ) ;
896875
897876 let mut env = MockEnv :: new (
898877 FunctionId :: RemoveStakeV1 ,
@@ -948,9 +927,7 @@ fn unstake_all_success_unstakes_balance() {
948927
949928 mock:: remove_stake_rate_limit_for_tests ( & hotkey, & coldkey, netuid) ;
950929
951- let expected_weight = Weight :: from_parts ( 28_830_000 , 0 )
952- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . reads ( 6 ) )
953- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . writes ( 0 ) ) ;
930+ let expected_weight = <<mock:: Test as pallet_subtensor:: Config >:: WeightInfo as SubtensorWeightInfo >:: unstake_all ( ) ;
954931
955932 let pre_balance = pallet_subtensor:: Pallet :: < mock:: Test > :: get_coldkey_balance ( & coldkey) ;
956933
@@ -1040,9 +1017,7 @@ mod caller_dispatch_tests {
10401017 amount_raw. into ( ) ,
10411018 ) ;
10421019
1043- let expected_weight = Weight :: from_parts ( 340_800_000 , 0 )
1044- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . reads ( 24 ) )
1045- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . writes ( 15 ) ) ;
1020+ let expected_weight = <<mock:: Test as pallet_subtensor:: Config >:: WeightInfo as SubtensorWeightInfo >:: add_stake ( ) ;
10461021
10471022 let mut env = MockEnv :: new (
10481023 FunctionId :: CallerAddStakeV1 ,
@@ -1074,9 +1049,7 @@ mod caller_dispatch_tests {
10741049 let min_stake = DefaultMinStake :: < mock:: Test > :: get ( ) ;
10751050 let amount: AlphaBalance = AlphaBalance :: from ( min_stake. to_u64 ( ) ) ;
10761051
1077- let expected_weight = Weight :: from_parts ( 196_800_000 , 0 )
1078- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . reads ( 19 ) )
1079- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . writes ( 10 ) ) ;
1052+ let expected_weight = <<mock:: Test as pallet_subtensor:: Config >:: WeightInfo as SubtensorWeightInfo >:: remove_stake ( ) ;
10801053
10811054 let mut env = MockEnv :: new (
10821055 FunctionId :: CallerRemoveStakeV1 ,
@@ -1128,9 +1101,7 @@ mod caller_dispatch_tests {
11281101
11291102 mock:: remove_stake_rate_limit_for_tests ( & hotkey, & coldkey, netuid) ;
11301103
1131- let expected_weight = Weight :: from_parts ( 28_830_000 , 0 )
1132- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . reads ( 6 ) )
1133- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . writes ( 0 ) ) ;
1104+ let expected_weight = <<mock:: Test as pallet_subtensor:: Config >:: WeightInfo as SubtensorWeightInfo >:: unstake_all ( ) ;
11341105
11351106 let pre_balance = pallet_subtensor:: Pallet :: < mock:: Test > :: get_coldkey_balance ( & coldkey) ;
11361107
@@ -1184,9 +1155,7 @@ mod caller_dispatch_tests {
11841155
11851156 mock:: remove_stake_rate_limit_for_tests ( & hotkey, & coldkey, netuid) ;
11861157
1187- let expected_weight = Weight :: from_parts ( 358_500_000 , 0 )
1188- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . reads ( 36 ) )
1189- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . writes ( 21 ) ) ;
1158+ let expected_weight = <<mock:: Test as pallet_subtensor:: Config >:: WeightInfo as SubtensorWeightInfo >:: unstake_all_alpha ( ) ;
11901159
11911160 let mut env = MockEnv :: new (
11921161 FunctionId :: CallerUnstakeAllAlphaV1 ,
@@ -1258,9 +1227,7 @@ mod caller_dispatch_tests {
12581227 ) ;
12591228 let alpha_to_move: AlphaBalance = ( alpha_before. to_u64 ( ) / 2 ) . into ( ) ;
12601229
1261- let expected_weight = Weight :: from_parts ( 164_300_000 , 0 )
1262- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . reads ( 15 ) )
1263- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . writes ( 7 ) ) ;
1230+ let expected_weight = <<mock:: Test as pallet_subtensor:: Config >:: WeightInfo as SubtensorWeightInfo >:: move_stake ( ) ;
12641231
12651232 let mut env = MockEnv :: new (
12661233 FunctionId :: CallerMoveStakeV1 ,
@@ -1340,9 +1307,7 @@ mod caller_dispatch_tests {
13401307 ) ;
13411308 let alpha_to_transfer: AlphaBalance = ( alpha_before. to_u64 ( ) / 3 ) . into ( ) ;
13421309
1343- let expected_weight = Weight :: from_parts ( 160_300_000 , 0 )
1344- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . reads ( 13 ) )
1345- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . writes ( 6 ) ) ;
1310+ let expected_weight = <<mock:: Test as pallet_subtensor:: Config >:: WeightInfo as SubtensorWeightInfo >:: transfer_stake ( ) ;
13461311
13471312 let mut env = MockEnv :: new (
13481313 FunctionId :: CallerTransferStakeV1 ,
@@ -1433,9 +1398,7 @@ mod caller_dispatch_tests {
14331398 ) ;
14341399 let alpha_to_swap: AlphaBalance = ( alpha_origin_before. to_u64 ( ) / 3 ) . into ( ) ;
14351400
1436- let expected_weight = Weight :: from_parts ( 351_300_000 , 0 )
1437- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . reads ( 35 ) )
1438- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . writes ( 22 ) ) ;
1401+ let expected_weight = <<mock:: Test as pallet_subtensor:: Config >:: WeightInfo as SubtensorWeightInfo >:: swap_stake ( ) ;
14391402
14401403 let mut env = MockEnv :: new (
14411404 FunctionId :: CallerSwapStakeV1 ,
@@ -1493,9 +1456,7 @@ mod caller_dispatch_tests {
14931456 let balance_before =
14941457 pallet_subtensor:: Pallet :: < mock:: Test > :: get_coldkey_balance ( & coldkey) ;
14951458
1496- let expected_weight = Weight :: from_parts ( 402_900_000 , 0 )
1497- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . reads ( 24 ) )
1498- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . writes ( 15 ) ) ;
1459+ let expected_weight = <<mock:: Test as pallet_subtensor:: Config >:: WeightInfo as SubtensorWeightInfo >:: add_stake_limit ( ) ;
14991460
15001461 let mut env = MockEnv :: new (
15011462 FunctionId :: CallerAddStakeLimitV1 ,
@@ -1573,9 +1534,7 @@ mod caller_dispatch_tests {
15731534
15741535 let alpha_to_unstake: AlphaBalance = ( alpha_before. to_u64 ( ) / 2 ) . into ( ) ;
15751536
1576- let expected_weight = Weight :: from_parts ( 377_400_000 , 0 )
1577- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . reads ( 28 ) )
1578- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . writes ( 14 ) ) ;
1537+ let expected_weight = <<mock:: Test as pallet_subtensor:: Config >:: WeightInfo as SubtensorWeightInfo >:: remove_stake_limit ( ) ;
15791538
15801539 let balance_before =
15811540 pallet_subtensor:: Pallet :: < mock:: Test > :: get_coldkey_balance ( & coldkey) ;
@@ -1653,9 +1612,7 @@ mod caller_dispatch_tests {
16531612 let alpha_to_swap: AlphaBalance = ( alpha_origin_before. to_u64 ( ) / 8 ) . into ( ) ;
16541613 let limit_price: TaoBalance = 100u64 . into ( ) ;
16551614
1656- let expected_weight = Weight :: from_parts ( 411_500_000 , 0 )
1657- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . reads ( 35 ) )
1658- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . writes ( 22 ) ) ;
1615+ let expected_weight = <<mock:: Test as pallet_subtensor:: Config >:: WeightInfo as SubtensorWeightInfo >:: swap_stake_limit ( ) ;
16591616
16601617 let mut env = MockEnv :: new (
16611618 FunctionId :: CallerSwapStakeLimitV1 ,
@@ -1713,9 +1670,7 @@ mod caller_dispatch_tests {
17131670
17141671 mock:: remove_stake_rate_limit_for_tests ( & hotkey, & coldkey, netuid) ;
17151672
1716- let expected_weight = Weight :: from_parts ( 395_300_000 , 0 )
1717- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . reads ( 28 ) )
1718- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . writes ( 14 ) ) ;
1673+ let expected_weight = <<mock:: Test as pallet_subtensor:: Config >:: WeightInfo as SubtensorWeightInfo >:: remove_stake_full_limit ( ) ;
17191674
17201675 let balance_before =
17211676 pallet_subtensor:: Pallet :: < mock:: Test > :: get_coldkey_balance ( & coldkey) ;
@@ -1762,9 +1717,7 @@ mod caller_dispatch_tests {
17621717 None
17631718 ) ;
17641719
1765- let expected_weight = Weight :: from_parts ( 29_930_000 , 0 )
1766- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . reads ( 4 ) )
1767- . saturating_add ( <mock:: Test as frame_system:: Config >:: DbWeight :: get ( ) . writes ( 2 ) ) ;
1720+ let expected_weight = <<mock:: Test as pallet_subtensor:: Config >:: WeightInfo as SubtensorWeightInfo >:: set_coldkey_auto_stake_hotkey ( ) ;
17681721
17691722 let mut env = MockEnv :: new (
17701723 FunctionId :: CallerSetColdkeyAutoStakeHotkeyV1 ,
0 commit comments