Skip to content

Commit 827933f

Browse files
committed
cargo fmt
1 parent ed8ea3f commit 827933f

File tree

2 files changed

+40
-33
lines changed

2 files changed

+40
-33
lines changed

pallets/subtensor/src/staking/stake_utils.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -862,9 +862,13 @@ impl<T: Config> Pallet<T> {
862862
netuid,
863863
alpha,
864864
);
865-
if netuid == NetUid::ROOT {
866-
Self::remove_stake_adjust_root_claimed_for_hotkey_and_coldkey(origin_hotkey, origin_coldkey, alpha);
867-
}
865+
if netuid == NetUid::ROOT {
866+
Self::remove_stake_adjust_root_claimed_for_hotkey_and_coldkey(
867+
origin_hotkey,
868+
origin_coldkey,
869+
alpha,
870+
);
871+
}
868872

869873
// Increase alpha on destination keys
870874
let actual_alpha_moved = Self::increase_stake_for_hotkey_and_coldkey_on_subnet(
@@ -873,9 +877,13 @@ impl<T: Config> Pallet<T> {
873877
netuid,
874878
actual_alpha_decrease,
875879
);
876-
if netuid == NetUid::ROOT {
877-
Self::add_stake_adjust_root_claimed_for_hotkey_and_coldkey(destination_hotkey, destination_coldkey, actual_alpha_decrease.into());
878-
}
880+
if netuid == NetUid::ROOT {
881+
Self::add_stake_adjust_root_claimed_for_hotkey_and_coldkey(
882+
destination_hotkey,
883+
destination_coldkey,
884+
actual_alpha_decrease.into(),
885+
);
886+
}
879887

880888
// Calculate TAO equivalent based on current price (it is accurate because
881889
// there's no slippage in this move)

pallets/subtensor/src/tests/claim_root.rs

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,7 +1833,7 @@ fn test_claim_root_with_moved_stake() {
18331833
let hotkey = U256::from(1002);
18341834
let alice_coldkey = U256::from(1003);
18351835
let bob_coldkey = U256::from(1004);
1836-
let eve_coldkey = U256::from(1005);
1836+
let eve_coldkey = U256::from(1005);
18371837
let netuid = add_dynamic_network(&hotkey, &owner_coldkey);
18381838

18391839
SubtensorModule::set_tao_weight(u64::MAX); // Set TAO weight to 1.0
@@ -1873,10 +1873,10 @@ fn test_claim_root_with_moved_stake() {
18731873
RootClaimTypeEnum::Keep
18741874
),);
18751875

1876-
assert_ok!(SubtensorModule::set_root_claim_type(
1877-
RuntimeOrigin::signed(eve_coldkey),
1878-
RootClaimTypeEnum::Keep
1879-
),);
1876+
assert_ok!(SubtensorModule::set_root_claim_type(
1877+
RuntimeOrigin::signed(eve_coldkey),
1878+
RootClaimTypeEnum::Keep
1879+
),);
18801880

18811881
// Distribute pending root alpha
18821882

@@ -1921,7 +1921,6 @@ fn test_claim_root_with_moved_stake() {
19211921

19221922
assert_abs_diff_eq!(alice_stake, estimated_stake as u64, epsilon = 100u64,);
19231923

1924-
19251924
// Distribute pending root alpha
19261925

19271926
let pending_root_alpha = 10_000_000u64;
@@ -1938,19 +1937,19 @@ fn test_claim_root_with_moved_stake() {
19381937

19391938
assert_ok!(SubtensorModule::transfer_stake(
19401939
RuntimeOrigin::signed(bob_coldkey,),
1941-
eve_coldkey,
1940+
eve_coldkey,
19421941
hotkey,
19431942
NetUid::ROOT,
19441943
NetUid::ROOT,
19451944
stake_decrement.into(),
19461945
));
19471946

1948-
let eve_stake: u64 = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(
1949-
&hotkey,
1950-
&eve_coldkey,
1951-
netuid,
1952-
)
1953-
.into();
1947+
let eve_stake: u64 = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(
1948+
&hotkey,
1949+
&eve_coldkey,
1950+
netuid,
1951+
)
1952+
.into();
19541953

19551954
assert_ok!(SubtensorModule::claim_root(
19561955
RuntimeOrigin::signed(alice_coldkey),
@@ -1961,10 +1960,10 @@ fn test_claim_root_with_moved_stake() {
19611960
BTreeSet::from([netuid])
19621961
));
19631962

1964-
assert_ok!(SubtensorModule::claim_root(
1965-
RuntimeOrigin::signed(eve_coldkey),
1966-
BTreeSet::from([netuid])
1967-
));
1963+
assert_ok!(SubtensorModule::claim_root(
1964+
RuntimeOrigin::signed(eve_coldkey),
1965+
BTreeSet::from([netuid])
1966+
));
19681967

19691968
// Check new stakes
19701969

@@ -1982,16 +1981,16 @@ fn test_claim_root_with_moved_stake() {
19821981
)
19831982
.into();
19841983

1985-
let eve_stake2: u64 = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(
1986-
&hotkey,
1987-
&eve_coldkey,
1988-
netuid,
1989-
)
1990-
.into();
1984+
let eve_stake2: u64 = SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(
1985+
&hotkey,
1986+
&eve_coldkey,
1987+
netuid,
1988+
)
1989+
.into();
19911990

1992-
// Eve should not have gotten any root claim
1993-
let eve_stake_diff = eve_stake2 - eve_stake;
1994-
assert_abs_diff_eq!(eve_stake_diff, 0, epsilon = 100u64,);
1991+
// Eve should not have gotten any root claim
1992+
let eve_stake_diff = eve_stake2 - eve_stake;
1993+
assert_abs_diff_eq!(eve_stake_diff, 0, epsilon = 100u64,);
19951994

19961995
let estimated_stake = (pending_root_alpha as f64) * (1f64 - validator_take_percent) / 2f64;
19971996

@@ -2005,7 +2004,7 @@ fn test_claim_root_with_moved_stake() {
20052004
let stake_increment = stake_decrement;
20062005

20072006
assert_ok!(SubtensorModule::transfer_stake(
2008-
RuntimeOrigin::signed(eve_coldkey,),
2007+
RuntimeOrigin::signed(eve_coldkey,),
20092008
bob_coldkey,
20102009
hotkey,
20112010
NetUid::ROOT,

0 commit comments

Comments
 (0)