Skip to content

Commit 9fc15c4

Browse files
authored
Merge pull request #1326 from opentensor/fix/add-dest-hotkey-check
Add dest hotkey check and test
2 parents b76d155 + 1216bd3 commit 9fc15c4

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

pallets/subtensor/src/staking/stake_utils.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,12 @@ impl<T: Config> Pallet<T> {
987987
Error::<T>::HotKeyAccountNotExists
988988
);
989989

990+
// Ensure that the destination hotkey account exists
991+
ensure!(
992+
Self::hotkey_account_exists(destination_hotkey),
993+
Error::<T>::HotKeyAccountNotExists
994+
);
995+
990996
// Ensure there is enough stake in the origin subnet.
991997
let origin_alpha = Self::get_stake_for_hotkey_and_coldkey_on_subnet(
992998
origin_hotkey,

pallets/subtensor/src/tests/move_stake.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,9 @@ fn test_do_move_nonexistent_destination_hotkey() {
245245
let fee = 0;
246246

247247
// Set up initial stake
248-
SubtensorModule::stake_into_subnet(&origin_hotkey, &coldkey, netuid, stake_amount, fee);
248+
SubtensorModule::create_account_if_non_existent(&coldkey, &origin_hotkey);
249+
let alpha =
250+
SubtensorModule::stake_into_subnet(&origin_hotkey, &coldkey, netuid, stake_amount, fee);
249251

250252
// Attempt to move stake from a non-existent origin hotkey
251253
add_network(netuid, 1, 0);
@@ -256,12 +258,12 @@ fn test_do_move_nonexistent_destination_hotkey() {
256258
nonexistent_destination_hotkey,
257259
netuid,
258260
netuid,
259-
1234
261+
alpha
260262
),
261263
Error::<Test>::HotKeyAccountNotExists
262264
);
263265

264-
// Check that the stake was moved successfully
266+
// Check that the stake was not moved
265267
assert_eq!(
266268
SubtensorModule::get_stake_for_hotkey_and_coldkey_on_subnet(
267269
&origin_hotkey,

runtime/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
229229
// `spec_version`, and `authoring_version` are the same between Wasm and native.
230230
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
231231
// the compatible custom types.
232-
spec_version: 241,
232+
spec_version: 242,
233233
impl_version: 1,
234234
apis: RUNTIME_API_VERSIONS,
235235
transaction_version: 1,

0 commit comments

Comments
 (0)