Skip to content

Commit f2b8ac4

Browse files
committed
commit suggestions
1 parent 7627c0c commit f2b8ac4

File tree

2 files changed

+13
-289
lines changed

2 files changed

+13
-289
lines changed

pallets/subtensor/src/macros/dispatches.rs

Lines changed: 0 additions & 284 deletions
Original file line numberDiff line numberDiff line change
@@ -2070,289 +2070,5 @@ mod dispatches {
20702070
PendingChildKeyCooldown::<T>::put(cooldown);
20712071
Ok(())
20722072
}
2073-
2074-
// /// --- Adds stake to a hotkey on a subnet with a price limit.
2075-
// /// This extrinsic allows to specify the limit price for alpha token
2076-
// /// at which or better (lower) the staking should execute.
2077-
// ///
2078-
// /// In case if slippage occurs and the price shall move beyond the limit
2079-
// /// price, the staking order may execute only partially or not execute
2080-
// /// at all.
2081-
// ///
2082-
// /// The operation will be delayed.
2083-
// ///
2084-
// /// # Args:
2085-
// /// * 'origin': (<T as frame_system::Config>Origin):
2086-
// /// - The signature of the caller's coldkey.
2087-
// ///
2088-
// /// * 'hotkey' (T::AccountId):
2089-
// /// - The associated hotkey account.
2090-
// ///
2091-
// /// * 'netuid' (u16):
2092-
// /// - Subnetwork UID
2093-
// ///
2094-
// /// * 'amount_staked' (u64):
2095-
// /// - The amount of stake to be added to the hotkey staking account.
2096-
// ///
2097-
// /// # Event:
2098-
// /// * StakeAdded;
2099-
// /// - On the successfully adding stake to a global account.
2100-
// ///
2101-
// /// # Raises:
2102-
// /// * 'NotEnoughBalanceToStake':
2103-
// /// - Not enough balance on the coldkey to add onto the global account.
2104-
// ///
2105-
// /// * 'NonAssociatedColdKey':
2106-
// /// - The calling coldkey is not associated with this hotkey.
2107-
// ///
2108-
// /// * 'BalanceWithdrawalError':
2109-
// /// - Errors stemming from transaction pallet.
2110-
// ///
2111-
// #[pallet::call_index(103)]
2112-
// #[pallet::weight((Weight::from_parts(162_000_000, 5127)
2113-
// .saturating_add(T::DbWeight::get().reads(15_u64))
2114-
// .saturating_add(T::DbWeight::get().writes(12_u64)), DispatchClass::Normal, Pays::No))]
2115-
// pub fn add_stake_aggregate(
2116-
// origin: OriginFor<T>,
2117-
// hotkey: T::AccountId,
2118-
// netuid: u16,
2119-
// amount_staked: u64,
2120-
// ) -> DispatchResult {
2121-
// Self::do_add_stake_aggregate(origin, hotkey, netuid, amount_staked)
2122-
// }
2123-
2124-
// /// --- Removes stake from a hotkey on a subnet with a price limit.
2125-
// /// This extrinsic allows to specify the limit price for alpha token
2126-
// /// at which or better (higher) the staking should execute.
2127-
// ///
2128-
// /// In case if slippage occurs and the price shall move beyond the limit
2129-
// /// price, the staking order may execute only partially or not execute
2130-
// /// at all.
2131-
// ///
2132-
// /// The operation will be delayed.
2133-
// ///
2134-
// /// # Args:
2135-
// /// * 'origin': (<T as frame_system::Config>Origin):
2136-
// /// - The signature of the caller's coldkey.
2137-
// ///
2138-
// /// * 'hotkey' (T::AccountId):
2139-
// /// - The associated hotkey account.
2140-
// ///
2141-
// /// * 'netuid' (u16):
2142-
// /// - Subnetwork UID
2143-
// ///
2144-
// /// * 'amount_unstaked' (u64):
2145-
// /// - The amount of stake to be added to the hotkey staking account.
2146-
// ///
2147-
// /// # Event:
2148-
// /// * StakeRemoved;
2149-
// /// - On the successfully removing stake from the hotkey account.
2150-
// ///
2151-
// /// # Raises:
2152-
// /// * 'NotRegistered':
2153-
// /// - Thrown if the account we are attempting to unstake from is non existent.
2154-
// ///
2155-
// /// * 'NonAssociatedColdKey':
2156-
// /// - Thrown if the coldkey does not own the hotkey we are unstaking from.
2157-
// ///
2158-
// /// * 'NotEnoughStakeToWithdraw':
2159-
// /// - Thrown if there is not enough stake on the hotkey to withdwraw this amount.
2160-
// ///
2161-
// #[pallet::call_index(104)]
2162-
// #[pallet::weight((Weight::from_parts(213_300_000, 10163)
2163-
// .saturating_add(T::DbWeight::get().reads(20_u64))
2164-
// .saturating_add(T::DbWeight::get().writes(12_u64)), DispatchClass::Normal, Pays::No))]
2165-
// pub fn remove_stake_aggregate(
2166-
// origin: OriginFor<T>,
2167-
// hotkey: T::AccountId,
2168-
// netuid: u16,
2169-
// amount_unstaked: u64,
2170-
// ) -> DispatchResult {
2171-
// Self::do_remove_stake_aggregate(origin, hotkey, netuid, amount_unstaked)
2172-
// }
2173-
2174-
// /// --- Adds stake to a hotkey on a subnet with a price limit.
2175-
// /// This extrinsic allows to specify the limit price for alpha token
2176-
// /// at which or better (lower) the staking should execute.
2177-
// ///
2178-
// /// In case if slippage occurs and the price shall move beyond the limit
2179-
// /// price, the staking order may execute only partially or not execute
2180-
// /// at all.
2181-
// ///
2182-
// /// The operation will be delayed.
2183-
// ///
2184-
// /// # Args:
2185-
// /// * 'origin': (<T as frame_system::Config>Origin):
2186-
// /// - The signature of the caller's coldkey.
2187-
// ///
2188-
// /// * 'hotkey' (T::AccountId):
2189-
// /// - The associated hotkey account.
2190-
// ///
2191-
// /// * 'netuid' (u16):
2192-
// /// - Subnetwork UID
2193-
// ///
2194-
// /// * 'amount_staked' (u64):
2195-
// /// - The amount of stake to be added to the hotkey staking account.
2196-
// ///
2197-
// /// * 'limit_price' (u64):
2198-
// /// - The limit price expressed in units of RAO per one Alpha.
2199-
// ///
2200-
// /// * 'allow_partial' (bool):
2201-
// /// - Allows partial execution of the amount. If set to false, this becomes
2202-
// /// fill or kill type or order.
2203-
// ///
2204-
// /// # Event:
2205-
// /// * StakeAdded;
2206-
// /// - On the successfully adding stake to a global account.
2207-
// ///
2208-
// /// # Raises:
2209-
// /// * 'NotEnoughBalanceToStake':
2210-
// /// - Not enough balance on the coldkey to add onto the global account.
2211-
// ///
2212-
// /// * 'NonAssociatedColdKey':
2213-
// /// - The calling coldkey is not associated with this hotkey.
2214-
// ///
2215-
// /// * 'BalanceWithdrawalError':
2216-
// /// - Errors stemming from transaction pallet.
2217-
// ///
2218-
// #[pallet::call_index(105)]
2219-
// #[pallet::weight((Weight::from_parts(169_200_000, 5127)
2220-
// .saturating_add(T::DbWeight::get().reads(14_u64))
2221-
// .saturating_add(T::DbWeight::get().writes(12_u64)), DispatchClass::Normal, Pays::No))]
2222-
// pub fn add_stake_limit_aggregate(
2223-
// origin: OriginFor<T>,
2224-
// hotkey: T::AccountId,
2225-
// netuid: u16,
2226-
// amount_staked: u64,
2227-
// limit_price: u64,
2228-
// allow_partial: bool,
2229-
// ) -> DispatchResult {
2230-
// Self::do_add_stake_limit_aggregate(
2231-
// origin,
2232-
// hotkey,
2233-
// netuid,
2234-
// amount_staked,
2235-
// limit_price,
2236-
// allow_partial,
2237-
// )
2238-
// }
2239-
2240-
// /// --- Removes stake from a hotkey on a subnet with a price limit.
2241-
// /// This extrinsic allows to specify the limit price for alpha token
2242-
// /// at which or better (higher) the staking should execute.
2243-
// ///
2244-
// /// In case if slippage occurs and the price shall move beyond the limit
2245-
// /// price, the staking order may execute only partially or not execute
2246-
// /// at all.
2247-
// ///
2248-
// /// The operation will be delayed.
2249-
// ///
2250-
// /// # Args:
2251-
// /// * 'origin': (<T as frame_system::Config>Origin):
2252-
// /// - The signature of the caller's coldkey.
2253-
// ///
2254-
// /// * 'hotkey' (T::AccountId):
2255-
// /// - The associated hotkey account.
2256-
// ///
2257-
// /// * 'netuid' (u16):
2258-
// /// - Subnetwork UID
2259-
// ///
2260-
// /// * 'amount_unstaked' (u64):
2261-
// /// - The amount of stake to be added to the hotkey staking account.
2262-
// ///
2263-
// /// * 'limit_price' (u64):
2264-
// /// - The limit price expressed in units of RAO per one Alpha.
2265-
// ///
2266-
// /// * 'allow_partial' (bool):
2267-
// /// - Allows partial execution of the amount. If set to false, this becomes
2268-
// /// fill or kill type or order.
2269-
// ///
2270-
// /// # Event:
2271-
// /// * StakeRemoved;
2272-
// /// - On the successfully removing stake from the hotkey account.
2273-
// ///
2274-
// /// # Raises:
2275-
// /// * 'NotRegistered':
2276-
// /// - Thrown if the account we are attempting to unstake from is non existent.
2277-
// ///
2278-
// /// * 'NonAssociatedColdKey':
2279-
// /// - Thrown if the coldkey does not own the hotkey we are unstaking from.
2280-
// ///
2281-
// /// * 'NotEnoughStakeToWithdraw':
2282-
// /// - Thrown if there is not enough stake on the hotkey to withdwraw this amount.
2283-
// ///
2284-
// #[pallet::call_index(106)]
2285-
// #[pallet::weight((Weight::from_parts(211_700_000, 10163)
2286-
// .saturating_add(T::DbWeight::get().reads(19_u64))
2287-
// .saturating_add(T::DbWeight::get().writes(12_u64)), DispatchClass::Normal, Pays::No))]
2288-
// pub fn remove_stake_limit_aggregate(
2289-
// origin: OriginFor<T>,
2290-
// hotkey: T::AccountId,
2291-
// netuid: u16,
2292-
// amount_unstaked: u64,
2293-
// limit_price: u64,
2294-
// allow_partial: bool,
2295-
// ) -> DispatchResult {
2296-
// Self::do_remove_stake_limit_aggregate(
2297-
// origin,
2298-
// hotkey,
2299-
// netuid,
2300-
// amount_unstaked,
2301-
// limit_price,
2302-
// allow_partial,
2303-
// )
2304-
// }
2305-
2306-
// /// ---- The implementation for the extrinsic unstake_all_aggregate: Removes all stake from a hotkey account across all subnets and adds it onto a coldkey.
2307-
// ///
2308-
// /// The operation will be delayed.
2309-
// ///
2310-
// /// # Args:
2311-
// /// * `origin` - (<T as frame_system::Config>::Origin):
2312-
// /// - The signature of the caller's coldkey.
2313-
// ///
2314-
// /// * `hotkey` (T::AccountId):
2315-
// /// - The associated hotkey account.
2316-
// ///
2317-
// /// # Event:
2318-
// /// * StakeRemoved;
2319-
// /// - On the successfully removing stake from the hotkey account.
2320-
// ///
2321-
// /// # Raises:
2322-
// /// * `NotRegistered`:
2323-
// /// - Thrown if the account we are attempting to unstake from is non existent.
2324-
// ///
2325-
// /// * `NonAssociatedColdKey`:
2326-
// /// - Thrown if the coldkey does not own the hotkey we are unstaking from.
2327-
// ///
2328-
// /// * `NotEnoughStakeToWithdraw`:
2329-
// /// - Thrown if there is not enough stake on the hotkey to withdraw this amount.
2330-
// ///
2331-
// /// * `TxRateLimitExceeded`:
2332-
// /// - Thrown if key has hit transaction rate limit
2333-
// #[pallet::call_index(107)]
2334-
// #[pallet::weight((Weight::from_parts(3_000_000, 0).saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Operational, Pays::No))]
2335-
// pub fn unstake_all_aggregate(origin: OriginFor<T>, hotkey: T::AccountId) -> DispatchResult {
2336-
// Self::do_unstake_all_aggregate(origin, hotkey)
2337-
// }
2338-
2339-
// /// ---- The implementation for the extrinsic unstake_all_alpha_aggregate: Removes all stake from a hotkey account across all subnets and adds it onto a coldkey.
2340-
// ///
2341-
// /// The operation will be delayed.
2342-
// ///
2343-
// /// # Args:
2344-
// /// * `origin` - (<T as frame_system::Config>::Origin):
2345-
// /// - The signature of the caller's coldkey.
2346-
// ///
2347-
// /// * `hotkey` (T::AccountId):
2348-
// /// - The associated hotkey account.
2349-
// #[pallet::call_index(108)]
2350-
// #[pallet::weight((Weight::from_parts(3_000_000, 0).saturating_add(T::DbWeight::get().writes(1)), DispatchClass::Operational, Pays::No))]
2351-
// pub fn unstake_all_alpha_aggregate(
2352-
// origin: OriginFor<T>,
2353-
// hotkey: T::AccountId,
2354-
// ) -> DispatchResult {
2355-
// Self::do_unstake_all_alpha_aggregate(origin, hotkey)
2356-
// }
23572073
}
23582074
}

pallets/subtensor/src/tests/swap_hotkey_with_subnet.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ fn test_swap_delegates() {
155155
let old_hotkey = U256::from(1);
156156
let new_hotkey = U256::from(2);
157157
let coldkey = U256::from(3);
158+
158159
let netuid = add_dynamic_network(&old_hotkey, &coldkey);
159160
SubtensorModule::add_balance_to_coldkey_account(&coldkey, u64::MAX);
160161

@@ -179,6 +180,7 @@ fn test_swap_subnet_membership() {
179180
let old_hotkey = U256::from(1);
180181
let new_hotkey = U256::from(2);
181182
let coldkey = U256::from(3);
183+
182184
let netuid = add_dynamic_network(&old_hotkey, &coldkey);
183185
SubtensorModule::add_balance_to_coldkey_account(&coldkey, u64::MAX);
184186

@@ -204,6 +206,7 @@ fn test_swap_uids_and_keys() {
204206
let old_hotkey = U256::from(1);
205207
let new_hotkey = U256::from(2);
206208
let coldkey = U256::from(3);
209+
207210
let netuid = add_dynamic_network(&old_hotkey, &coldkey);
208211
SubtensorModule::add_balance_to_coldkey_account(&coldkey, u64::MAX);
209212

@@ -235,6 +238,7 @@ fn test_swap_prometheus() {
235238
let coldkey = U256::from(3);
236239

237240
let prometheus_info = PrometheusInfo::default();
241+
238242
let netuid = add_dynamic_network(&old_hotkey, &coldkey);
239243
SubtensorModule::add_balance_to_coldkey_account(&coldkey, u64::MAX);
240244

@@ -267,6 +271,7 @@ fn test_swap_axons() {
267271
let coldkey = U256::from(3);
268272

269273
let axon_info = AxonInfo::default();
274+
270275
let netuid = add_dynamic_network(&old_hotkey, &coldkey);
271276
SubtensorModule::add_balance_to_coldkey_account(&coldkey, u64::MAX);
272277

@@ -296,6 +301,7 @@ fn test_swap_certificates() {
296301
let coldkey = U256::from(3);
297302

298303
let certificate = NeuronCertificate::try_from(vec![1, 2, 3]).unwrap();
304+
299305
let netuid = add_dynamic_network(&old_hotkey, &coldkey);
300306
SubtensorModule::add_balance_to_coldkey_account(&coldkey, u64::MAX);
301307

@@ -331,6 +337,7 @@ fn test_swap_weight_commits() {
331337

332338
let mut weight_commits: VecDeque<(H256, u64, u64, u64)> = VecDeque::new();
333339
weight_commits.push_back((H256::from_low_u64_be(100), 200, 1, 1));
340+
334341
let netuid = add_dynamic_network(&old_hotkey, &coldkey);
335342
SubtensorModule::add_balance_to_coldkey_account(&coldkey, u64::MAX);
336343

@@ -364,6 +371,7 @@ fn test_swap_loaded_emission() {
364371

365372
let server_emission = 1000u64;
366373
let validator_emission = 1000u64;
374+
367375
let netuid = add_dynamic_network(&old_hotkey, &coldkey);
368376
SubtensorModule::add_balance_to_coldkey_account(&coldkey, u64::MAX);
369377

@@ -764,7 +772,7 @@ fn test_swap_hotkey_with_multiple_coldkeys_and_subnets() {
764772
fn test_swap_hotkey_tx_rate_limit_exceeded() {
765773
new_test_ext(1).execute_with(|| {
766774
let netuid = NetUid::from(1);
767-
let tempo = 13;
775+
let tempo: u16 = 13;
768776
let old_hotkey = U256::from(1);
769777
let new_hotkey_1 = U256::from(2);
770778
let new_hotkey_2 = U256::from(4);
@@ -824,7 +832,7 @@ fn test_swap_hotkey_tx_rate_limit_exceeded() {
824832
fn test_do_swap_hotkey_err_not_owner() {
825833
new_test_ext(1).execute_with(|| {
826834
let netuid = NetUid::from(1);
827-
let tempo = 13;
835+
let tempo: u16 = 13;
828836
let old_hotkey = U256::from(1);
829837
let new_hotkey = U256::from(2);
830838
let coldkey = U256::from(3);
@@ -1443,6 +1451,7 @@ fn test_swap_owner_failed_interval_not_passed() {
14431451
let old_hotkey = U256::from(1);
14441452
let new_hotkey = U256::from(2);
14451453
let coldkey = U256::from(3);
1454+
14461455
let netuid = add_dynamic_network(&old_hotkey, &coldkey);
14471456
SubtensorModule::add_balance_to_coldkey_account(&coldkey, u64::MAX);
14481457
Owner::<Test>::insert(old_hotkey, coldkey);
@@ -1464,6 +1473,7 @@ fn test_swap_owner_check_swap_block_set() {
14641473
let old_hotkey = U256::from(1);
14651474
let new_hotkey = U256::from(2);
14661475
let coldkey = U256::from(3);
1476+
14671477
let netuid = add_dynamic_network(&old_hotkey, &coldkey);
14681478
SubtensorModule::add_balance_to_coldkey_account(&coldkey, u64::MAX);
14691479
Owner::<Test>::insert(old_hotkey, coldkey);
@@ -1506,9 +1516,7 @@ fn test_swap_owner_check_swap_record_clean_up() {
15061516
new_block_number
15071517
);
15081518

1509-
let netuid_u16: u16 = netuid.into();
1510-
1511-
step_block((HotkeySwapOnSubnetInterval::get() as u16 + netuid_u16) * 2u16);
1519+
step_block((HotkeySwapOnSubnetInterval::get() as u16 + u16::from(netuid)) * 2);
15121520
assert!(!LastHotkeySwapOnNetuid::<Test>::contains_key(
15131521
netuid, coldkey
15141522
));

0 commit comments

Comments
 (0)