Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions bittensor/core/extrinsics/asyncex/mechanism.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ async def commit_mechanism_weights_extrinsic(
`message` is a string value describing the success or potential error.
"""
try:
unlock = unlock_key(wallet, raise_error=raise_error)
signing_keypair = "hotkey"
unlock = unlock_key(
wallet=wallet, raise_error=raise_error, unlock_type=signing_keypair
)
if not unlock.success:
logging.error(unlock.message)
return False, unlock.message
Expand Down Expand Up @@ -86,8 +89,8 @@ async def commit_mechanism_weights_extrinsic(
wait_for_finalization=wait_for_finalization,
use_nonce=True,
period=period,
sign_with="hotkey",
nonce_key="hotkey",
sign_with=signing_keypair,
nonce_key=signing_keypair,
raise_error=raise_error,
)

Expand Down Expand Up @@ -146,7 +149,10 @@ async def commit_timelocked_mechanism_weights_extrinsic(
`message` is a string value describing the success or potential error.
"""
try:
unlock = unlock_key(wallet, raise_error=raise_error)
signing_keypair = "hotkey"
unlock = unlock_key(
wallet=wallet, raise_error=raise_error, unlock_type=signing_keypair
)
if not unlock.success:
logging.error(unlock.message)
return False, unlock.message
Expand Down Expand Up @@ -193,8 +199,8 @@ async def commit_timelocked_mechanism_weights_extrinsic(
wait_for_finalization=wait_for_finalization,
use_nonce=True,
period=period,
sign_with="hotkey",
nonce_key="hotkey",
sign_with=signing_keypair,
nonce_key=signing_keypair,
raise_error=raise_error,
)

Expand Down Expand Up @@ -252,7 +258,10 @@ async def reveal_mechanism_weights_extrinsic(
`message` is a string value describing the success or potential error.
"""
try:
unlock = unlock_key(wallet, raise_error=raise_error)
signing_keypair = "hotkey"
unlock = unlock_key(
wallet=wallet, raise_error=raise_error, unlock_type=signing_keypair
)
if not unlock.success:
logging.error(unlock.message)
return False, unlock.message
Expand All @@ -278,8 +287,8 @@ async def reveal_mechanism_weights_extrinsic(
wait_for_finalization=wait_for_finalization,
use_nonce=True,
period=period,
sign_with="hotkey",
nonce_key="hotkey",
sign_with=signing_keypair,
nonce_key=signing_keypair,
raise_error=raise_error,
)

Expand Down Expand Up @@ -335,7 +344,10 @@ async def set_mechanism_weights_extrinsic(
`message` is a string value describing the success or potential error.
"""
try:
unlock = unlock_key(wallet, raise_error=raise_error)
signing_keypair = "hotkey"
unlock = unlock_key(
wallet=wallet, raise_error=raise_error, unlock_type=signing_keypair
)
if not unlock.success:
logging.error(unlock.message)
return False, unlock.message
Expand All @@ -361,8 +373,8 @@ async def set_mechanism_weights_extrinsic(
wait_for_finalization=wait_for_finalization,
period=period,
use_nonce=True,
nonce_key="hotkey",
sign_with="hotkey",
nonce_key=signing_keypair,
sign_with=signing_keypair,
raise_error=raise_error,
)

Expand Down
36 changes: 24 additions & 12 deletions bittensor/core/extrinsics/mechanism.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ def commit_mechanism_weights_extrinsic(
`message` is a string value describing the success or potential error.
"""
try:
unlock = unlock_key(wallet, raise_error=raise_error)
signing_keypair = "hotkey"
unlock = unlock_key(
wallet=wallet, raise_error=raise_error, unlock_type=signing_keypair
)
if not unlock.success:
logging.error(unlock.message)
return False, unlock.message
Expand Down Expand Up @@ -86,8 +89,8 @@ def commit_mechanism_weights_extrinsic(
wait_for_finalization=wait_for_finalization,
use_nonce=True,
period=period,
sign_with="hotkey",
nonce_key="hotkey",
sign_with=signing_keypair,
nonce_key=signing_keypair,
raise_error=raise_error,
)

Expand Down Expand Up @@ -146,7 +149,10 @@ def commit_timelocked_mechanism_weights_extrinsic(
`message` is a string value describing the success or potential error.
"""
try:
unlock = unlock_key(wallet, raise_error=raise_error)
signing_keypair = "hotkey"
unlock = unlock_key(
wallet=wallet, raise_error=raise_error, unlock_type=signing_keypair
)
if not unlock.success:
logging.error(unlock.message)
return False, unlock.message
Expand Down Expand Up @@ -193,8 +199,8 @@ def commit_timelocked_mechanism_weights_extrinsic(
wait_for_finalization=wait_for_finalization,
use_nonce=True,
period=period,
sign_with="hotkey",
nonce_key="hotkey",
sign_with=signing_keypair,
nonce_key=signing_keypair,
raise_error=raise_error,
)

Expand Down Expand Up @@ -252,7 +258,10 @@ def reveal_mechanism_weights_extrinsic(
`message` is a string value describing the success or potential error.
"""
try:
unlock = unlock_key(wallet, raise_error=raise_error)
signing_keypair = "hotkey"
unlock = unlock_key(
wallet=wallet, raise_error=raise_error, unlock_type=signing_keypair
)
if not unlock.success:
logging.error(unlock.message)
return False, unlock.message
Expand All @@ -278,8 +287,8 @@ def reveal_mechanism_weights_extrinsic(
wait_for_finalization=wait_for_finalization,
use_nonce=True,
period=period,
sign_with="hotkey",
nonce_key="hotkey",
sign_with=signing_keypair,
nonce_key=signing_keypair,
raise_error=raise_error,
)

Expand Down Expand Up @@ -335,7 +344,10 @@ def set_mechanism_weights_extrinsic(
`message` is a string value describing the success or potential error.
"""
try:
unlock = unlock_key(wallet, raise_error=raise_error)
signing_keypair = "hotkey"
unlock = unlock_key(
wallet=wallet, raise_error=raise_error, unlock_type=signing_keypair
)
if not unlock.success:
logging.error(unlock.message)
return False, unlock.message
Expand All @@ -361,8 +373,8 @@ def set_mechanism_weights_extrinsic(
wait_for_finalization=wait_for_finalization,
period=period,
use_nonce=True,
nonce_key="hotkey",
sign_with="hotkey",
sign_with=signing_keypair,
nonce_key=signing_keypair,
raise_error=raise_error,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ async def test_commit_mechanism_weights_extrinsic(mocker, subtensor, fake_wallet
weights = []
salt = []

mocked_unlock_key = mocker.patch.object(
mechanism, "unlock_key", return_value=mocker.Mock(success=True)
)
mocked_get_mechanism_storage_index = mocker.patch.object(
mechanism, "get_mechid_storage_index"
)
Expand All @@ -35,6 +38,9 @@ async def test_commit_mechanism_weights_extrinsic(mocker, subtensor, fake_wallet
)

# Asserts
mocked_unlock_key.assert_called_once_with(
wallet=fake_wallet, raise_error=False, unlock_type="hotkey"
)
mocked_get_mechanism_storage_index.assert_called_once_with(
netuid=netuid, mechid=mechid
)
Expand Down Expand Up @@ -83,6 +89,9 @@ async def test_commit_timelocked_mechanism_weights_extrinsic(
weights = []
block_time = mocker.Mock()

mocked_unlock_key = mocker.patch.object(
mechanism, "unlock_key", return_value=mocker.Mock(success=True)
)
mocked_convert_and_normalize_weights_and_uids = mocker.patch.object(
mechanism,
"convert_and_normalize_weights_and_uids",
Expand Down Expand Up @@ -122,6 +131,9 @@ async def test_commit_timelocked_mechanism_weights_extrinsic(
)

# Asserts
mocked_unlock_key.assert_called_once_with(
wallet=fake_wallet, raise_error=False, unlock_type="hotkey"
)
mocked_convert_and_normalize_weights_and_uids.assert_called_once_with(uids, weights)
mocked_get_mechanism_storage_index.assert_called_once_with(
netuid=netuid, mechid=mechid
Expand Down Expand Up @@ -174,6 +186,9 @@ async def test_reveal_mechanism_weights_extrinsic(mocker, subtensor, fake_wallet
weights = []
salt = []

mocked_unlock_key = mocker.patch.object(
mechanism, "unlock_key", return_value=mocker.Mock(success=True)
)
mocked_convert_and_normalize_weights_and_uids = mocker.patch.object(
mechanism,
"convert_and_normalize_weights_and_uids",
Expand All @@ -197,6 +212,9 @@ async def test_reveal_mechanism_weights_extrinsic(mocker, subtensor, fake_wallet
)

# Asserts
mocked_unlock_key.assert_called_once_with(
wallet=fake_wallet, raise_error=False, unlock_type="hotkey"
)
mocked_convert_and_normalize_weights_and_uids.assert_called_once_with(uids, weights)
mocked_compose_call.assert_awaited_once_with(
call_module="SubtensorModule",
Expand Down Expand Up @@ -235,6 +253,9 @@ async def test_mechanism_sub_weights_extrinsic(mocker, subtensor, fake_wallet):
uids = []
weights = []

mocked_unlock_key = mocker.patch.object(
mechanism, "unlock_key", return_value=mocker.Mock(success=True)
)
mocked_convert_and_normalize_weights_and_uids = mocker.patch.object(
mechanism,
"convert_and_normalize_weights_and_uids",
Expand Down Expand Up @@ -262,6 +283,9 @@ async def test_mechanism_sub_weights_extrinsic(mocker, subtensor, fake_wallet):
)

# Asserts
mocked_unlock_key.assert_called_once_with(
wallet=fake_wallet, raise_error=False, unlock_type="hotkey"
)
mocked_convert_and_normalize_weights_and_uids.assert_called_once_with(uids, weights)
mocked_compose_call.assert_awaited_once_with(
call_module="SubtensorModule",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ def test_commit_mechanism_weights_extrinsic(mocker, subtensor, fake_wallet):
weights = []
salt = []

mocked_unlock_key = mocker.patch.object(
mechanism, "unlock_key", return_value=mocker.Mock(success=True)
)
mocked_get_sub_subnet_storage_index = mocker.patch.object(
mechanism, "get_mechid_storage_index"
)
Expand All @@ -34,6 +37,9 @@ def test_commit_mechanism_weights_extrinsic(mocker, subtensor, fake_wallet):
)

# Asserts
mocked_unlock_key.assert_called_once_with(
wallet=fake_wallet, raise_error=False, unlock_type="hotkey"
)
mocked_get_sub_subnet_storage_index.assert_called_once_with(
netuid=netuid, mechid=mechid
)
Expand Down Expand Up @@ -79,6 +85,9 @@ def test_commit_timelocked_mechanism_weights_extrinsic(mocker, subtensor, fake_w
weights = []
block_time = mocker.Mock()

mocked_unlock_key = mocker.patch.object(
mechanism, "unlock_key", return_value=mocker.Mock(success=True)
)
mocked_convert_and_normalize_weights_and_uids = mocker.patch.object(
mechanism,
"convert_and_normalize_weights_and_uids",
Expand Down Expand Up @@ -118,6 +127,9 @@ def test_commit_timelocked_mechanism_weights_extrinsic(mocker, subtensor, fake_w
)

# Asserts
mocked_unlock_key.assert_called_once_with(
wallet=fake_wallet, raise_error=False, unlock_type="hotkey"
)
mocked_convert_and_normalize_weights_and_uids.assert_called_once_with(uids, weights)
mocked_get_sub_subnet_storage_index.assert_called_once_with(
netuid=netuid, mechid=mechid
Expand Down Expand Up @@ -169,6 +181,9 @@ def test_reveal_mechanism_weights_extrinsic(mocker, subtensor, fake_wallet):
weights = []
salt = []

mocked_unlock_key = mocker.patch.object(
mechanism, "unlock_key", return_value=mocker.Mock(success=True)
)
mocked_convert_and_normalize_weights_and_uids = mocker.patch.object(
mechanism,
"convert_and_normalize_weights_and_uids",
Expand All @@ -192,6 +207,9 @@ def test_reveal_mechanism_weights_extrinsic(mocker, subtensor, fake_wallet):
)

# Asserts
mocked_unlock_key.assert_called_once_with(
wallet=fake_wallet, raise_error=False, unlock_type="hotkey"
)
mocked_convert_and_normalize_weights_and_uids.assert_called_once_with(uids, weights)
mocked_compose_call.assert_called_once_with(
call_module="SubtensorModule",
Expand Down Expand Up @@ -229,6 +247,9 @@ def test_mechanism_sub_weights_extrinsic(mocker, subtensor, fake_wallet):
uids = []
weights = []

mocked_unlock_key = mocker.patch.object(
mechanism, "unlock_key", return_value=mocker.Mock(success=True)
)
mocked_convert_and_normalize_weights_and_uids = mocker.patch.object(
mechanism,
"convert_and_normalize_weights_and_uids",
Expand Down Expand Up @@ -256,6 +277,9 @@ def test_mechanism_sub_weights_extrinsic(mocker, subtensor, fake_wallet):
)

# Asserts
mocked_unlock_key.assert_called_once_with(
wallet=fake_wallet, raise_error=False, unlock_type="hotkey"
)
mocked_convert_and_normalize_weights_and_uids.assert_called_once_with(uids, weights)
mocked_compose_call.assert_called_once_with(
call_module="SubtensorModule",
Expand Down
Loading