Skip to content

Commit 4263d84

Browse files
authored
Merge pull request #1185 from opentensor/fix/fix-clippy-on-stake-into-subnet
Fix/fix clippy on stake into subnet
2 parents b42641f + 438b678 commit 4263d84

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

pallets/subtensor/src/staking/move_stake.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,9 @@ impl<T: Config> Pallet<T> {
288288
);
289289

290290
// 6. Unstake from the origin subnet, returning TAO (or a 1:1 equivalent).
291+
let fee = DefaultMinStake::<T>::get().saturating_div(2);
291292
let tao_unstaked =
292-
Self::unstake_from_subnet(&hotkey, &coldkey, origin_netuid, alpha_amount);
293+
Self::unstake_from_subnet(&hotkey, &coldkey, origin_netuid, alpha_amount, fee);
293294

294295
// 7. Check that the unstaked amount is above the minimum stake threshold.
295296
ensure!(
@@ -298,7 +299,7 @@ impl<T: Config> Pallet<T> {
298299
);
299300

300301
// 8. Stake the unstaked amount into the destination subnet, using the same coldkey/hotkey.
301-
Self::stake_into_subnet(&hotkey, &coldkey, destination_netuid, tao_unstaked);
302+
Self::stake_into_subnet(&hotkey, &coldkey, destination_netuid, tao_unstaked, fee);
302303

303304
// 9. Emit an event for logging.
304305
log::info!(

pallets/subtensor/src/tests/move_stake.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,7 +1085,7 @@ fn test_do_swap_success() {
10851085
let stake_amount = DefaultMinStake::<Test>::get() * 10;
10861086

10871087
SubtensorModule::create_account_if_non_existent(&coldkey, &hotkey);
1088-
SubtensorModule::stake_into_subnet(&hotkey, &coldkey, origin_netuid, stake_amount);
1088+
SubtensorModule::stake_into_subnet(&hotkey, &coldkey, origin_netuid, stake_amount, 0);
10891089
let alpha_before = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(
10901090
&hotkey,
10911091
&coldkey,
@@ -1180,7 +1180,7 @@ fn test_do_swap_insufficient_stake() {
11801180
let attempted_swap = stake_amount * 2;
11811181

11821182
SubtensorModule::create_account_if_non_existent(&coldkey, &hotkey);
1183-
SubtensorModule::stake_into_subnet(&hotkey, &coldkey, netuid1, stake_amount);
1183+
SubtensorModule::stake_into_subnet(&hotkey, &coldkey, netuid1, stake_amount, 0);
11841184

11851185
assert_noop!(
11861186
SubtensorModule::do_swap_stake(
@@ -1209,7 +1209,7 @@ fn test_do_swap_wrong_origin() {
12091209
let stake_amount = 100_000;
12101210

12111211
SubtensorModule::create_account_if_non_existent(&real_coldkey, &hotkey);
1212-
SubtensorModule::stake_into_subnet(&hotkey, &real_coldkey, netuid1, stake_amount);
1212+
SubtensorModule::stake_into_subnet(&hotkey, &real_coldkey, netuid1, stake_amount, 0);
12131213

12141214
assert_noop!(
12151215
SubtensorModule::do_swap_stake(
@@ -1237,7 +1237,7 @@ fn test_do_swap_minimum_stake_check() {
12371237
let swap_amount = 1;
12381238

12391239
SubtensorModule::create_account_if_non_existent(&coldkey, &hotkey);
1240-
SubtensorModule::stake_into_subnet(&hotkey, &coldkey, netuid, total_stake);
1240+
SubtensorModule::stake_into_subnet(&hotkey, &coldkey, netuid, total_stake, 0);
12411241

12421242
assert_err!(
12431243
SubtensorModule::do_swap_stake(
@@ -1264,7 +1264,7 @@ fn test_do_swap_same_subnet() {
12641264
let stake_amount = DefaultMinStake::<Test>::get() * 10;
12651265

12661266
SubtensorModule::create_account_if_non_existent(&coldkey, &hotkey);
1267-
SubtensorModule::stake_into_subnet(&hotkey, &coldkey, netuid, stake_amount);
1267+
SubtensorModule::stake_into_subnet(&hotkey, &coldkey, netuid, stake_amount, 0);
12681268

12691269
let alpha_before =
12701270
SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(&hotkey, &coldkey, netuid);
@@ -1296,7 +1296,7 @@ fn test_do_swap_partial_stake() {
12961296
let total_stake = DefaultMinStake::<Test>::get() * 10;
12971297

12981298
SubtensorModule::create_account_if_non_existent(&coldkey, &hotkey);
1299-
SubtensorModule::stake_into_subnet(&hotkey, &coldkey, origin_netuid, total_stake);
1299+
SubtensorModule::stake_into_subnet(&hotkey, &coldkey, origin_netuid, total_stake, 0);
13001300

13011301
let swap_amount = total_stake / 2;
13021302
assert_ok!(SubtensorModule::do_swap_stake(
@@ -1341,7 +1341,7 @@ fn test_do_swap_storage_updates() {
13411341
let stake_amount = DefaultMinStake::<Test>::get() * 10;
13421342

13431343
SubtensorModule::create_account_if_non_existent(&coldkey, &hotkey);
1344-
SubtensorModule::stake_into_subnet(&hotkey, &coldkey, origin_netuid, stake_amount);
1344+
SubtensorModule::stake_into_subnet(&hotkey, &coldkey, origin_netuid, stake_amount, 0);
13451345

13461346
let alpha = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(
13471347
&hotkey,
@@ -1390,7 +1390,7 @@ fn test_do_swap_multiple_times() {
13901390
let initial_stake = DefaultMinStake::<Test>::get() * 10;
13911391

13921392
SubtensorModule::create_account_if_non_existent(&coldkey, &hotkey);
1393-
SubtensorModule::stake_into_subnet(&hotkey, &coldkey, netuid1, initial_stake);
1393+
SubtensorModule::stake_into_subnet(&hotkey, &coldkey, netuid1, initial_stake, 0);
13941394

13951395
for _ in 0..3 {
13961396
let alpha1 = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(

0 commit comments

Comments
 (0)