Skip to content

Commit c40da87

Browse files
authored
Merge pull request #2996 from opentensor/fix/roman/remove-ownership-check
Remove ownership check in `transfer_stake_extrinsic` and `swap_stake_extrinsic`
2 parents 79e6639 + 9a8c06b commit c40da87

File tree

3 files changed

+0
-57
lines changed

3 files changed

+0
-57
lines changed

bittensor/core/extrinsics/asyncex/move_stake.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,6 @@ async def transfer_stake_extrinsic(
7171
"""
7272

7373
amount.set_unit(netuid=origin_netuid)
74-
# Verify ownership
75-
hotkey_owner = await subtensor.get_hotkey_owner(hotkey_ss58)
76-
if hotkey_owner != wallet.coldkeypub.ss58_address:
77-
logging.error(
78-
f":cross_mark: [red]Failed[/red]: Hotkey: {hotkey_ss58} does not belong to the origin coldkey owner: "
79-
f"{wallet.coldkeypub.ss58_address}"
80-
)
81-
return False
8274

8375
# Check sufficient stake
8476
stake_in_origin, stake_in_destination = await _get_stake_in_origin_and_dest(
@@ -194,14 +186,6 @@ async def swap_stake_extrinsic(
194186
bool: True if the swap was successful, False otherwise.
195187
"""
196188
amount.set_unit(netuid=origin_netuid)
197-
# Verify ownership
198-
hotkey_owner = await subtensor.get_hotkey_owner(hotkey_ss58)
199-
if hotkey_owner != wallet.coldkeypub.ss58_address:
200-
logging.error(
201-
f":cross_mark: [red]Failed[/red]: Hotkey: {hotkey_ss58} does not belong to the origin coldkey owner: "
202-
f"{wallet.coldkeypub.ss58_address}"
203-
)
204-
return False
205189

206190
# Check sufficient stake
207191
stake_in_origin, stake_in_destination = await _get_stake_in_origin_and_dest(

bittensor/core/extrinsics/move_stake.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,6 @@ def transfer_stake_extrinsic(
6868
"""
6969

7070
amount.set_unit(netuid=origin_netuid)
71-
# Verify ownership
72-
hotkey_owner = subtensor.get_hotkey_owner(hotkey_ss58)
73-
if hotkey_owner != wallet.coldkeypub.ss58_address:
74-
logging.error(
75-
f":cross_mark: [red]Failed[/red]: Hotkey: {hotkey_ss58} does not belong to the origin coldkey owner: "
76-
f"{wallet.coldkeypub.ss58_address}"
77-
)
78-
return False
7971

8072
# Check sufficient stake
8173
stake_in_origin, stake_in_destination = _get_stake_in_origin_and_dest(
@@ -192,14 +184,6 @@ def swap_stake_extrinsic(
192184
"""
193185

194186
amount.set_unit(netuid=origin_netuid)
195-
# Verify ownership
196-
hotkey_owner = subtensor.get_hotkey_owner(hotkey_ss58)
197-
if hotkey_owner != wallet.coldkeypub.ss58_address:
198-
logging.error(
199-
f":cross_mark: [red]Failed[/red]: Hotkey: {hotkey_ss58} does not belong to the origin coldkey owner: "
200-
f"{wallet.coldkeypub.ss58_address}"
201-
)
202-
return False
203187

204188
# Check sufficient stake
205189
stake_in_origin, stake_in_destination = _get_stake_in_origin_and_dest(

tests/unit_tests/test_subtensor_extended.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,31 +1484,6 @@ def test_transfer_stake_error(
14841484
)
14851485

14861486

1487-
def test_transfer_stake_non_owner(mock_substrate, subtensor, fake_wallet, mocker):
1488-
mocker.patch.object(
1489-
subtensor,
1490-
"get_hotkey_owner",
1491-
autospec=True,
1492-
return_value="owner2_ss58",
1493-
)
1494-
1495-
success = subtensor.transfer_stake(
1496-
fake_wallet,
1497-
"dest",
1498-
"hotkey_ss58",
1499-
origin_netuid=1,
1500-
destination_netuid=1,
1501-
amount=Balance(1),
1502-
)
1503-
1504-
assert success is False
1505-
1506-
subtensor.get_hotkey_owner.assert_called_once_with(
1507-
"hotkey_ss58",
1508-
)
1509-
mock_substrate.submit_extrinsic.assert_not_called()
1510-
1511-
15121487
def test_transfer_stake_insufficient_stake(
15131488
mock_substrate, subtensor, fake_wallet, mocker
15141489
):

0 commit comments

Comments
 (0)