From d97a62f5dc101ced4991fede582505cf956799ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20=C5=BBy=C5=BAniewski?= Date: Wed, 12 Mar 2025 10:19:17 +0100 Subject: [PATCH 1/5] increse test_incentive timeout --- tests/e2e_tests/test_incentive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e_tests/test_incentive.py b/tests/e2e_tests/test_incentive.py index 3511271b11..8babb5265e 100644 --- a/tests/e2e_tests/test_incentive.py +++ b/tests/e2e_tests/test_incentive.py @@ -77,7 +77,7 @@ async def test_incentive(local_chain, subtensor, templates, alice_wallet, bob_wa async with templates.miner(bob_wallet, netuid): async with templates.validator(alice_wallet, netuid) as validator: # wait for the Validator to process and set_weights - async with asyncio.timeout(15): + async with asyncio.timeout(60): await validator.set_weights.wait() # Wait few epochs From 88067d98c68c802b652e5f9d236e6439aabe6817 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20=C5=BBy=C5=BAniewski?= Date: Wed, 12 Mar 2025 12:06:53 +0100 Subject: [PATCH 2/5] fix sudo_set_weights_set_rate_limit --- tests/e2e_tests/test_commit_reveal_v3.py | 8 ++++---- tests/e2e_tests/test_commit_weights.py | 13 ++++++++++--- tests/e2e_tests/test_dendrite.py | 6 ++++-- tests/e2e_tests/test_incentive.py | 7 +++++-- tests/e2e_tests/test_set_weights.py | 7 +++++-- 5 files changed, 28 insertions(+), 13 deletions(-) diff --git a/tests/e2e_tests/test_commit_reveal_v3.py b/tests/e2e_tests/test_commit_reveal_v3.py index a31063cd47..1faff6447e 100644 --- a/tests/e2e_tests/test_commit_reveal_v3.py +++ b/tests/e2e_tests/test_commit_reveal_v3.py @@ -1,15 +1,12 @@ import re -import time import numpy as np import pytest from bittensor.utils.btlogging import logging -from bittensor.utils.balance import Balance from bittensor.utils.weight_utils import convert_weights_and_uids_for_emit from tests.e2e_tests.utils.chain_interactions import ( sudo_set_admin_utils, sudo_set_hyperparameter_bool, - sudo_set_hyperparameter_values, wait_interval, next_tempo, ) @@ -57,7 +54,7 @@ async def test_commit_and_reveal_weights_cr3(local_chain, subtensor, alice_walle logging.console.info("Commit reveal enabled") # Change the weights rate limit on the subnet - assert sudo_set_hyperparameter_values( + status, error = sudo_set_admin_utils( local_chain, alice_wallet, call_function="sudo_set_weights_set_rate_limit", @@ -65,6 +62,9 @@ async def test_commit_and_reveal_weights_cr3(local_chain, subtensor, alice_walle return_error_message=True, ) + assert error is None + assert status is True + # Verify weights rate limit was changed assert ( subtensor.get_subnet_hyperparameters(netuid=netuid).weights_rate_limit == 0 diff --git a/tests/e2e_tests/test_commit_weights.py b/tests/e2e_tests/test_commit_weights.py index cb6b7fd885..226b9d8741 100644 --- a/tests/e2e_tests/test_commit_weights.py +++ b/tests/e2e_tests/test_commit_weights.py @@ -7,7 +7,6 @@ from tests.e2e_tests.utils.chain_interactions import ( sudo_set_admin_utils, sudo_set_hyperparameter_bool, - sudo_set_hyperparameter_values, wait_epoch, ) @@ -54,8 +53,9 @@ async def test_commit_and_reveal_weights_legacy(local_chain, subtensor, alice_wa assert ( subtensor.weights_rate_limit(netuid=netuid) > 0 ), "Weights rate limit is below 0" + # Lower the rate limit - assert sudo_set_hyperparameter_values( + status, error = sudo_set_admin_utils( local_chain, alice_wallet, call_function="sudo_set_weights_set_rate_limit", @@ -63,6 +63,9 @@ async def test_commit_and_reveal_weights_legacy(local_chain, subtensor, alice_wa return_error_message=True, ) + assert error is None + assert status is True + assert ( subtensor.get_subnet_hyperparameters(netuid=netuid).weights_rate_limit == 0 ), "Failed to set weights_rate_limit" @@ -192,8 +195,9 @@ async def test_commit_weights_uses_next_nonce(local_chain, subtensor, alice_wall assert ( subtensor.weights_rate_limit(netuid=netuid) > 0 ), "Weights rate limit is below 0" + # Lower the rate limit - assert sudo_set_hyperparameter_values( + status, error = sudo_set_admin_utils( local_chain, alice_wallet, call_function="sudo_set_weights_set_rate_limit", @@ -201,6 +205,9 @@ async def test_commit_weights_uses_next_nonce(local_chain, subtensor, alice_wall return_error_message=True, ) + assert error is None + assert status is True + assert ( subtensor.get_subnet_hyperparameters(netuid=netuid).weights_rate_limit == 0 ), "Failed to set weights_rate_limit" diff --git a/tests/e2e_tests/test_dendrite.py b/tests/e2e_tests/test_dendrite.py index 36a6dfa786..76cbea9a15 100644 --- a/tests/e2e_tests/test_dendrite.py +++ b/tests/e2e_tests/test_dendrite.py @@ -6,7 +6,6 @@ from bittensor.utils.btlogging import logging from tests.e2e_tests.utils.chain_interactions import ( sudo_set_admin_utils, - sudo_set_hyperparameter_values, wait_epoch, ) @@ -48,7 +47,7 @@ async def test_dendrite(local_chain, subtensor, templates, alice_wallet, bob_wal ) # update weights_set_rate_limit for fast-blocks - assert sudo_set_hyperparameter_values( + status, error = sudo_set_admin_utils( local_chain, alice_wallet, call_function="sudo_set_weights_set_rate_limit", @@ -59,6 +58,9 @@ async def test_dendrite(local_chain, subtensor, templates, alice_wallet, bob_wal return_error_message=True, ) + assert error is None + assert status is True + # Register Bob to the network assert subtensor.burned_register( bob_wallet, netuid diff --git a/tests/e2e_tests/test_incentive.py b/tests/e2e_tests/test_incentive.py index 8babb5265e..ce3d740803 100644 --- a/tests/e2e_tests/test_incentive.py +++ b/tests/e2e_tests/test_incentive.py @@ -3,7 +3,7 @@ import pytest from tests.e2e_tests.utils.chain_interactions import ( - sudo_set_hyperparameter_values, + sudo_set_admin_utils, wait_epoch, ) @@ -66,7 +66,7 @@ async def test_incentive(local_chain, subtensor, templates, alice_wallet, bob_wa assert bob_neuron.trust == 0 # update weights_set_rate_limit for fast-blocks - assert sudo_set_hyperparameter_values( + status, error = sudo_set_admin_utils( local_chain, alice_wallet, call_function="sudo_set_weights_set_rate_limit", @@ -74,6 +74,9 @@ async def test_incentive(local_chain, subtensor, templates, alice_wallet, bob_wa return_error_message=True, ) + assert error is None + assert status is True + async with templates.miner(bob_wallet, netuid): async with templates.validator(alice_wallet, netuid) as validator: # wait for the Validator to process and set_weights diff --git a/tests/e2e_tests/test_set_weights.py b/tests/e2e_tests/test_set_weights.py index d124238b5f..baf5ab91a8 100644 --- a/tests/e2e_tests/test_set_weights.py +++ b/tests/e2e_tests/test_set_weights.py @@ -5,7 +5,6 @@ from bittensor.utils.weight_utils import convert_weights_and_uids_for_emit from tests.e2e_tests.utils.chain_interactions import ( sudo_set_hyperparameter_bool, - sudo_set_hyperparameter_values, sudo_set_admin_utils, wait_epoch, ) @@ -84,8 +83,9 @@ async def test_set_weights_uses_next_nonce(local_chain, subtensor, alice_wallet) assert ( subtensor.weights_rate_limit(netuid=netuid) > 0 ), "Weights rate limit is below 0" + # Lower the rate limit - assert sudo_set_hyperparameter_values( + status, error = sudo_set_admin_utils( local_chain, alice_wallet, call_function="sudo_set_weights_set_rate_limit", @@ -93,6 +93,9 @@ async def test_set_weights_uses_next_nonce(local_chain, subtensor, alice_wallet) return_error_message=True, ) + assert error is None + assert status is True + assert ( subtensor.get_subnet_hyperparameters(netuid=netuid).weights_rate_limit == 0 ), "Failed to set weights_rate_limit" From 39fb38ecf441f27ec2801c61bf4b6d6c37119528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20=C5=BBy=C5=BAniewski?= Date: Wed, 12 Mar 2025 15:01:02 +0100 Subject: [PATCH 3/5] refactor: omit return_error_message param in sudo_set_admin_utils --- tests/e2e_tests/test_commit_reveal_v3.py | 2 -- tests/e2e_tests/test_commit_weights.py | 3 --- tests/e2e_tests/test_delegate.py | 1 - tests/e2e_tests/test_dendrite.py | 2 -- tests/e2e_tests/test_incentive.py | 1 - tests/e2e_tests/test_set_weights.py | 3 --- tests/e2e_tests/utils/chain_interactions.py | 11 +++-------- 7 files changed, 3 insertions(+), 20 deletions(-) diff --git a/tests/e2e_tests/test_commit_reveal_v3.py b/tests/e2e_tests/test_commit_reveal_v3.py index 1faff6447e..52d2324c62 100644 --- a/tests/e2e_tests/test_commit_reveal_v3.py +++ b/tests/e2e_tests/test_commit_reveal_v3.py @@ -59,7 +59,6 @@ async def test_commit_and_reveal_weights_cr3(local_chain, subtensor, alice_walle alice_wallet, call_function="sudo_set_weights_set_rate_limit", call_params={"netuid": netuid, "weights_set_rate_limit": "0"}, - return_error_message=True, ) assert error is None @@ -81,7 +80,6 @@ async def test_commit_and_reveal_weights_cr3(local_chain, subtensor, alice_walle alice_wallet, call_function="sudo_set_tempo", call_params={"netuid": netuid, "tempo": tempo_set}, - return_error_message=True, )[0] is True ) diff --git a/tests/e2e_tests/test_commit_weights.py b/tests/e2e_tests/test_commit_weights.py index 226b9d8741..4d966c8c37 100644 --- a/tests/e2e_tests/test_commit_weights.py +++ b/tests/e2e_tests/test_commit_weights.py @@ -60,7 +60,6 @@ async def test_commit_and_reveal_weights_legacy(local_chain, subtensor, alice_wa alice_wallet, call_function="sudo_set_weights_set_rate_limit", call_params={"netuid": netuid, "weights_set_rate_limit": "0"}, - return_error_message=True, ) assert error is None @@ -80,7 +79,6 @@ async def test_commit_and_reveal_weights_legacy(local_chain, subtensor, alice_wa "netuid": netuid, "tempo": 100, }, - return_error_message=True, ) # Commit-reveal values @@ -202,7 +200,6 @@ async def test_commit_weights_uses_next_nonce(local_chain, subtensor, alice_wall alice_wallet, call_function="sudo_set_weights_set_rate_limit", call_params={"netuid": netuid, "weights_set_rate_limit": "0"}, - return_error_message=True, ) assert error is None diff --git a/tests/e2e_tests/test_delegate.py b/tests/e2e_tests/test_delegate.py index ae9c6b9cac..a5a835a98a 100644 --- a/tests/e2e_tests/test_delegate.py +++ b/tests/e2e_tests/test_delegate.py @@ -320,7 +320,6 @@ def test_nominator_min_required_stake(local_chain, subtensor, alice_wallet, bob_ call_params={ "min_stake": "100000000000000", }, - return_error_message=True, ) minimum_required_stake = subtensor.get_minimum_required_stake() diff --git a/tests/e2e_tests/test_dendrite.py b/tests/e2e_tests/test_dendrite.py index 76cbea9a15..b2e891ff73 100644 --- a/tests/e2e_tests/test_dendrite.py +++ b/tests/e2e_tests/test_dendrite.py @@ -43,7 +43,6 @@ async def test_dendrite(local_chain, subtensor, templates, alice_wallet, bob_wal "netuid": netuid, "max_allowed_validators": 1, }, - return_error_message=True, ) # update weights_set_rate_limit for fast-blocks @@ -55,7 +54,6 @@ async def test_dendrite(local_chain, subtensor, templates, alice_wallet, bob_wal "netuid": netuid, "weights_set_rate_limit": 10, }, - return_error_message=True, ) assert error is None diff --git a/tests/e2e_tests/test_incentive.py b/tests/e2e_tests/test_incentive.py index ce3d740803..0467a0cd81 100644 --- a/tests/e2e_tests/test_incentive.py +++ b/tests/e2e_tests/test_incentive.py @@ -71,7 +71,6 @@ async def test_incentive(local_chain, subtensor, templates, alice_wallet, bob_wa alice_wallet, call_function="sudo_set_weights_set_rate_limit", call_params={"netuid": netuid, "weights_set_rate_limit": 10}, - return_error_message=True, ) assert error is None diff --git a/tests/e2e_tests/test_set_weights.py b/tests/e2e_tests/test_set_weights.py index baf5ab91a8..8a279e3ccf 100644 --- a/tests/e2e_tests/test_set_weights.py +++ b/tests/e2e_tests/test_set_weights.py @@ -34,7 +34,6 @@ async def test_set_weights_uses_next_nonce(local_chain, subtensor, alice_wallet) alice_wallet, call_function="sudo_set_network_rate_limit", call_params={"rate_limit": "0"}, # No limit - return_error_message=True, ) # Set lock reduction interval sudo_set_admin_utils( @@ -42,7 +41,6 @@ async def test_set_weights_uses_next_nonce(local_chain, subtensor, alice_wallet) alice_wallet, call_function="sudo_set_lock_reduction_interval", call_params={"interval": "1"}, # 1 block # reduce lock every block - return_error_message=True, ) # Try to register the subnets @@ -90,7 +88,6 @@ async def test_set_weights_uses_next_nonce(local_chain, subtensor, alice_wallet) alice_wallet, call_function="sudo_set_weights_set_rate_limit", call_params={"netuid": netuid, "weights_set_rate_limit": "0"}, - return_error_message=True, ) assert error is None diff --git a/tests/e2e_tests/utils/chain_interactions.py b/tests/e2e_tests/utils/chain_interactions.py index b80548041b..9dc13136b3 100644 --- a/tests/e2e_tests/utils/chain_interactions.py +++ b/tests/e2e_tests/utils/chain_interactions.py @@ -150,8 +150,7 @@ def sudo_set_admin_utils( wallet: "Wallet", call_function: str, call_params: dict, - return_error_message: bool = False, -) -> tuple[bool, str]: +) -> tuple[bool, dict]: """ Wraps the call in sudo to set hyperparameter values using AdminUtils. @@ -160,10 +159,9 @@ def sudo_set_admin_utils( wallet (Wallet): Wallet object with the keypair for signing. call_function (str): The AdminUtils function to call. call_params (dict): Parameters for the AdminUtils function. - return_error_message (bool): If True, returns the error message along with the success status. Returns: - Union[bool, tuple[bool, Optional[str]]]: Success status or (success status, error message). + tuple[bool, dict]: (success status, error details). """ inner_call = substrate.compose_call( call_module="AdminUtils", @@ -185,10 +183,7 @@ def sudo_set_admin_utils( wait_for_finalization=True, ) - if return_error_message: - return response.is_success, response.error_message - - return response.is_success, "" + return response.is_success, response.error_message async def root_set_subtensor_hyperparameter_values( From 438f2b3cfbdb1af6083fd40d5915cefa220ba930 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20=C5=BBy=C5=BAniewski?= Date: Wed, 12 Mar 2025 15:09:44 +0100 Subject: [PATCH 4/5] correct (Optional) return type --- tests/e2e_tests/utils/chain_interactions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/e2e_tests/utils/chain_interactions.py b/tests/e2e_tests/utils/chain_interactions.py index 9dc13136b3..3681bf2b46 100644 --- a/tests/e2e_tests/utils/chain_interactions.py +++ b/tests/e2e_tests/utils/chain_interactions.py @@ -150,7 +150,7 @@ def sudo_set_admin_utils( wallet: "Wallet", call_function: str, call_params: dict, -) -> tuple[bool, dict]: +) -> tuple[bool, Optional[dict]]: """ Wraps the call in sudo to set hyperparameter values using AdminUtils. @@ -161,7 +161,7 @@ def sudo_set_admin_utils( call_params (dict): Parameters for the AdminUtils function. Returns: - tuple[bool, dict]: (success status, error details). + tuple[bool, Optional[dict]]: (success status, error details). """ inner_call = substrate.compose_call( call_module="AdminUtils", From daf0908f08c9c2cbb00dc77919898d84e5819eb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20=C5=BBy=C5=BAniewski?= Date: Wed, 12 Mar 2025 15:42:25 +0100 Subject: [PATCH 5/5] tests: wait cooldown period when clearing child keys --- tests/e2e_tests/test_hotkeys.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/e2e_tests/test_hotkeys.py b/tests/e2e_tests/test_hotkeys.py index 19bc0dc718..126690d46c 100644 --- a/tests/e2e_tests/test_hotkeys.py +++ b/tests/e2e_tests/test_hotkeys.py @@ -151,6 +151,8 @@ async def test_children(subtensor, alice_wallet, bob_wallet): assert error == "" assert success is True + subtensor.wait_for_block(subtensor.block + SET_CHILDREN_COOLDOWN_PERIOD) + await wait_epoch(subtensor, netuid=1) success, children, error = subtensor.get_children(