diff --git a/bittensor/core/extrinsics/asyncex/mechanism.py b/bittensor/core/extrinsics/asyncex/mechanism.py index 41702fe5f2..91cfa81175 100644 --- a/bittensor/core/extrinsics/asyncex/mechanism.py +++ b/bittensor/core/extrinsics/asyncex/mechanism.py @@ -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 @@ -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, ) @@ -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 @@ -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, ) @@ -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 @@ -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, ) @@ -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 @@ -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, ) diff --git a/bittensor/core/extrinsics/mechanism.py b/bittensor/core/extrinsics/mechanism.py index d8e83b6183..05a4f4aaf6 100644 --- a/bittensor/core/extrinsics/mechanism.py +++ b/bittensor/core/extrinsics/mechanism.py @@ -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 @@ -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, ) @@ -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 @@ -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, ) @@ -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 @@ -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, ) @@ -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 @@ -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, ) diff --git a/tests/unit_tests/extrinsics/asyncex/test_sub_subnet.py b/tests/unit_tests/extrinsics/asyncex/test_mechanisms.py similarity index 90% rename from tests/unit_tests/extrinsics/asyncex/test_sub_subnet.py rename to tests/unit_tests/extrinsics/asyncex/test_mechanisms.py index 144807ceb3..e4611d94ae 100644 --- a/tests/unit_tests/extrinsics/asyncex/test_sub_subnet.py +++ b/tests/unit_tests/extrinsics/asyncex/test_mechanisms.py @@ -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" ) @@ -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 ) @@ -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", @@ -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 @@ -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", @@ -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", @@ -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", @@ -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", diff --git a/tests/unit_tests/extrinsics/test_sub_subnet.py b/tests/unit_tests/extrinsics/test_mechanisms.py similarity index 90% rename from tests/unit_tests/extrinsics/test_sub_subnet.py rename to tests/unit_tests/extrinsics/test_mechanisms.py index 624ffedbf3..a162a0f53c 100644 --- a/tests/unit_tests/extrinsics/test_sub_subnet.py +++ b/tests/unit_tests/extrinsics/test_mechanisms.py @@ -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" ) @@ -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 ) @@ -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", @@ -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 @@ -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", @@ -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", @@ -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", @@ -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",