Skip to content

Commit 47dacb6

Browse files
authored
Merge pull request #1313 from opentensor/staking-amount-priority
Staking amount in TX priority
2 parents 88df14e + 776d886 commit 47dacb6

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

pallets/subtensor/src/lib.rs

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,15 +1566,21 @@ pub mod pallet {
15661566
}
15671567

15681568
/// Returns the transaction priority for stake operations.
1569-
pub fn get_priority_staking(coldkey: &T::AccountId, hotkey: &T::AccountId) -> u64 {
1569+
pub fn get_priority_staking(
1570+
coldkey: &T::AccountId,
1571+
hotkey: &T::AccountId,
1572+
stake_amount: u64,
1573+
) -> u64 {
15701574
match LastColdkeyHotkeyStakeBlock::<T>::get(coldkey, hotkey) {
15711575
Some(last_stake_block) => {
15721576
let current_block_number = Self::get_current_block_as_u64();
15731577
let default_priority = current_block_number.saturating_sub(last_stake_block);
15741578

1575-
default_priority.saturating_add(u32::MAX as u64)
1579+
default_priority
1580+
.saturating_add(u32::MAX as u64)
1581+
.saturating_add(stake_amount)
15761582
}
1577-
None => 0,
1583+
None => stake_amount,
15781584
}
15791585
}
15801586

@@ -1703,8 +1709,12 @@ where
17031709
Pallet::<T>::get_priority_set_weights(who, netuid)
17041710
}
17051711

1706-
pub fn get_priority_staking(coldkey: &T::AccountId, hotkey: &T::AccountId) -> u64 {
1707-
Pallet::<T>::get_priority_staking(coldkey, hotkey)
1712+
pub fn get_priority_staking(
1713+
coldkey: &T::AccountId,
1714+
hotkey: &T::AccountId,
1715+
stake_amount: u64,
1716+
) -> u64 {
1717+
Pallet::<T>::get_priority_staking(coldkey, hotkey, stake_amount)
17081718
}
17091719

17101720
pub fn check_weights_min_stake(who: &T::AccountId, netuid: u16) -> bool {
@@ -1919,7 +1929,7 @@ where
19191929
*amount_staked,
19201930
false,
19211931
),
1922-
Self::get_priority_staking(who, hotkey),
1932+
Self::get_priority_staking(who, hotkey, *amount_staked),
19231933
)
19241934
}
19251935
Some(Call::add_stake_limit {
@@ -1949,7 +1959,7 @@ where
19491959
max_amount,
19501960
*allow_partial,
19511961
),
1952-
Self::get_priority_staking(who, hotkey),
1962+
Self::get_priority_staking(who, hotkey, *amount_staked),
19531963
)
19541964
}
19551965
Some(Call::remove_stake {
@@ -1967,7 +1977,7 @@ where
19671977
*amount_unstaked,
19681978
false,
19691979
),
1970-
Self::get_priority_staking(who, hotkey),
1980+
Self::get_priority_staking(who, hotkey, *amount_unstaked),
19711981
)
19721982
}
19731983
Some(Call::remove_stake_limit {
@@ -1990,7 +2000,7 @@ where
19902000
max_amount,
19912001
*allow_partial,
19922002
),
1993-
Self::get_priority_staking(who, hotkey),
2003+
Self::get_priority_staking(who, hotkey, *amount_unstaked),
19942004
)
19952005
}
19962006
Some(Call::move_stake {
@@ -2021,7 +2031,7 @@ where
20212031
None,
20222032
false,
20232033
),
2024-
Self::get_priority_staking(who, origin_hotkey),
2034+
Self::get_priority_staking(who, origin_hotkey, *alpha_amount),
20252035
)
20262036
}
20272037
Some(Call::transfer_stake {
@@ -2052,7 +2062,7 @@ where
20522062
None,
20532063
true,
20542064
),
2055-
Self::get_priority_staking(who, hotkey),
2065+
Self::get_priority_staking(who, hotkey, *alpha_amount),
20562066
)
20572067
}
20582068
Some(Call::swap_stake {
@@ -2082,7 +2092,7 @@ where
20822092
None,
20832093
false,
20842094
),
2085-
Self::get_priority_staking(who, hotkey),
2095+
Self::get_priority_staking(who, hotkey, *alpha_amount),
20862096
)
20872097
}
20882098
Some(Call::swap_stake_limit {
@@ -2121,7 +2131,7 @@ where
21212131
Some(*allow_partial),
21222132
false,
21232133
),
2124-
Self::get_priority_staking(who, hotkey),
2134+
Self::get_priority_staking(who, hotkey, *alpha_amount),
21252135
)
21262136
}
21272137
Some(Call::register { netuid, .. } | Call::burned_register { netuid, .. }) => {

0 commit comments

Comments
 (0)