@@ -6,11 +6,10 @@ use frame_support::pallet_macros::pallet_section;
66#[ pallet_section]
77mod dispatches {
88 use crate :: subnets:: leasing:: SubnetLeasingWeightInfo ;
9- use frame_support:: traits:: schedule:: DispatchTime ;
109 use frame_support:: traits:: schedule:: v3:: Anon as ScheduleAnon ;
1110 use frame_system:: pallet_prelude:: BlockNumberFor ;
1211 use sp_core:: ecdsa:: Signature ;
13- use sp_runtime:: { Percent , traits :: Saturating } ;
12+ use sp_runtime:: Percent ;
1413
1514 use crate :: MAX_CRV3_COMMIT_SIZE_BYTES ;
1615 use crate :: MAX_NUM_ROOT_CLAIMS ;
@@ -1068,34 +1067,17 @@ mod dispatches {
10681067
10691068 /// The extrinsic for user to change the coldkey associated with their account.
10701069 ///
1071- /// # Arguments
1072- ///
1073- /// * `origin` - The origin of the call, must be signed by the old coldkey.
1074- /// * `old_coldkey` - The current coldkey associated with the account.
1075- /// * `new_coldkey` - The new coldkey to be associated with the account.
1076- ///
1077- /// # Returns
1078- ///
1079- /// Returns a `DispatchResultWithPostInfo` indicating success or failure of the operation.
1080- ///
1081- /// # Weight
1082- ///
1083- /// Weight is calculated based on the number of database reads and writes.
1070+ /// WARNING: This is deprecated in favor of `announce_coldkey_swap`/`coldkey_swap`
10841071 #[ pallet:: call_index( 71 ) ]
1085- #[ pallet:: weight( ( Weight :: from_parts( 161_700_000 , 0 )
1086- . saturating_add( T :: DbWeight :: get( ) . reads( 16_u64 ) )
1087- . saturating_add( T :: DbWeight :: get( ) . writes( 9 ) ) , DispatchClass :: Operational , Pays :: Yes ) ) ]
1072+ #[ pallet:: weight( Weight :: zero( ) ) ]
1073+ #[ deprecated( note = "Deprecated, please migrate to `announce_coldkey_swap`/`coldkey_swap`" ) ]
10881074 pub fn swap_coldkey (
1089- origin : OriginFor < T > ,
1090- old_coldkey : T :: AccountId ,
1091- new_coldkey : T :: AccountId ,
1092- swap_cost : TaoCurrency ,
1075+ _origin : OriginFor < T > ,
1076+ _old_coldkey : T :: AccountId ,
1077+ _new_coldkey : T :: AccountId ,
1078+ _swap_cost : TaoCurrency ,
10931079 ) -> DispatchResult {
1094- // Ensure it's called with root privileges (scheduler has root privileges)
1095- ensure_root ( origin) ?;
1096- log:: debug!( "swap_coldkey: {:?} -> {:?}" , old_coldkey, new_coldkey) ;
1097-
1098- Self :: do_swap_coldkey ( & old_coldkey, & new_coldkey, swap_cost)
1080+ Err ( Error :: < T > :: Deprecated . into ( ) )
10991081 }
11001082
11011083 /// Sets the childkey take for a given hotkey.
@@ -1332,94 +1314,15 @@ mod dispatches {
13321314
13331315 /// Schedules a coldkey swap operation to be executed at a future block.
13341316 ///
1335- /// This function allows a user to schedule the swapping of their coldkey to a new one
1336- /// at a specified future block. The swap is not executed immediately but is scheduled
1337- /// to occur at the specified block number.
1338- ///
1339- /// # Arguments
1340- ///
1341- /// * `origin` - The origin of the call, which should be signed by the current coldkey owner.
1342- /// * `new_coldkey` - The account ID of the new coldkey that will replace the current one.
1343- /// * `when` - The block number at which the coldkey swap should be executed.
1344- ///
1345- /// # Returns
1346- ///
1347- /// Returns a `DispatchResultWithPostInfo` indicating whether the scheduling was successful.
1348- ///
1349- /// # Errors
1350- ///
1351- /// This function may return an error if:
1352- /// * The origin is not signed.
1353- /// * The scheduling fails due to conflicts or system constraints.
1354- ///
1355- /// # Notes
1356- ///
1357- /// - The actual swap is not performed by this function. It merely schedules the swap operation.
1358- /// - The weight of this call is set to a fixed value and may need adjustment based on benchmarking.
1359- ///
1360- /// # TODO
1361- ///
1362- /// - Implement proper weight calculation based on the complexity of the operation.
1363- /// - Consider adding checks to prevent scheduling too far into the future.
1364- /// TODO: Benchmark this call
1317+ /// WARNING: This function is deprecated, please migrate to `announce_coldkey_swap`/`coldkey_swap`
13651318 #[ pallet:: call_index( 73 ) ]
1366- #[ pallet:: weight( ( Weight :: from_parts( 37_830_000 , 0 )
1367- . saturating_add( T :: DbWeight :: get( ) . reads( 4 ) )
1368- . saturating_add( T :: DbWeight :: get( ) . writes( 2 ) ) , DispatchClass :: Normal , Pays :: Yes ) ) ]
1319+ #[ pallet:: weight( Weight :: zero( ) ) ]
1320+ #[ deprecated( note = "Deprecated, please migrate to `announce_coldkey_swap`/`coldkey_swap`" ) ]
13691321 pub fn schedule_swap_coldkey (
1370- origin : OriginFor < T > ,
1371- new_coldkey : T :: AccountId ,
1372- ) -> DispatchResultWithPostInfo {
1373- let who = ensure_signed ( origin) ?;
1374- let current_block = <frame_system:: Pallet < T > >:: block_number ( ) ;
1375-
1376- // If the coldkey has a scheduled swap, check if we can reschedule it
1377- if ColdkeySwapScheduled :: < T > :: contains_key ( & who) {
1378- let ( scheduled_block, _scheduled_coldkey) = ColdkeySwapScheduled :: < T > :: get ( & who) ;
1379- let reschedule_duration = ColdkeySwapRescheduleDuration :: < T > :: get ( ) ;
1380- let redo_when = scheduled_block. saturating_add ( reschedule_duration) ;
1381- ensure ! ( redo_when <= current_block, Error :: <T >:: SwapAlreadyScheduled ) ;
1382- }
1383-
1384- // Calculate the swap cost and ensure sufficient balance
1385- let swap_cost = Self :: get_key_swap_cost ( ) ;
1386- ensure ! (
1387- Self :: can_remove_balance_from_coldkey_account( & who, swap_cost. into( ) ) ,
1388- Error :: <T >:: NotEnoughBalanceToPaySwapColdKey
1389- ) ;
1390-
1391- let current_block: BlockNumberFor < T > = <frame_system:: Pallet < T > >:: block_number ( ) ;
1392- let duration: BlockNumberFor < T > = ColdkeySwapScheduleDuration :: < T > :: get ( ) ;
1393- let when: BlockNumberFor < T > = current_block. saturating_add ( duration) ;
1394-
1395- let call = Call :: < T > :: swap_coldkey {
1396- old_coldkey : who. clone ( ) ,
1397- new_coldkey : new_coldkey. clone ( ) ,
1398- swap_cost,
1399- } ;
1400-
1401- let bound_call = <T as Config >:: Preimages :: bound ( LocalCallOf :: < T > :: from ( call. clone ( ) ) )
1402- . map_err ( |_| Error :: < T > :: FailedToSchedule ) ?;
1403-
1404- T :: Scheduler :: schedule (
1405- DispatchTime :: At ( when) ,
1406- None ,
1407- 63 ,
1408- frame_system:: RawOrigin :: Root . into ( ) ,
1409- bound_call,
1410- )
1411- . map_err ( |_| Error :: < T > :: FailedToSchedule ) ?;
1412-
1413- ColdkeySwapScheduled :: < T > :: insert ( & who, ( when, new_coldkey. clone ( ) ) ) ;
1414- // Emit the SwapScheduled event
1415- Self :: deposit_event ( Event :: ColdkeySwapScheduled {
1416- old_coldkey : who. clone ( ) ,
1417- new_coldkey : new_coldkey. clone ( ) ,
1418- execution_block : when,
1419- swap_cost,
1420- } ) ;
1421-
1422- Ok ( ( ) . into ( ) )
1322+ _origin : OriginFor < T > ,
1323+ _new_coldkey : T :: AccountId ,
1324+ ) -> DispatchResult {
1325+ Err ( Error :: < T > :: Deprecated . into ( ) )
14231326 }
14241327
14251328 /// ---- Set prometheus information for the neuron.
0 commit comments