From 7e4849a55f2152b924d50d1042270b8135a81736 Mon Sep 17 00:00:00 2001 From: Roman <167799377+roman-opentensor@users.noreply.github.com> Date: Wed, 6 Nov 2024 12:25:36 -0800 Subject: [PATCH] Add `subvortex` subnet and tests (#2395) * add `subvortex` subnet and tests * ruff --- bittensor/core/settings.py | 14 ++++++++++++++ bittensor/core/subtensor.py | 13 ++----------- tests/unit_tests/test_subtensor.py | 13 +++++++++++++ 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/bittensor/core/settings.py b/bittensor/core/settings.py index 8413b5329..7f0c24af2 100644 --- a/bittensor/core/settings.py +++ b/bittensor/core/settings.py @@ -40,12 +40,26 @@ WALLETS_DIR.mkdir(parents=True, exist_ok=True) MINERS_DIR.mkdir(parents=True, exist_ok=True) +# Bittensor networks name +NETWORKS = ["finney", "test", "archive", "local", "subvortex"] + +DEFAULT_ENDPOINT = "wss://entrypoint-finney.opentensor.ai:443" +DEFAULT_NETWORK = NETWORKS[0] # Bittensor endpoints (Needs to use wss://) FINNEY_ENTRYPOINT = "wss://entrypoint-finney.opentensor.ai:443" FINNEY_TEST_ENTRYPOINT = "wss://test.finney.opentensor.ai:443/" ARCHIVE_ENTRYPOINT = "wss://archive.chain.opentensor.ai:443/" LOCAL_ENTRYPOINT = os.getenv("BT_SUBTENSOR_CHAIN_ENDPOINT") or "ws://127.0.0.1:9944" +SUBVORTEX_ENTRYPOINT = "ws://subvortex.info:9944" + +NETWORK_MAP = { + NETWORKS[0]: FINNEY_ENTRYPOINT, + NETWORKS[1]: FINNEY_TEST_ENTRYPOINT, + NETWORKS[2]: ARCHIVE_ENTRYPOINT, + NETWORKS[3]: LOCAL_ENTRYPOINT, + NETWORKS[4]: SUBVORTEX_ENTRYPOINT, +} # Currency Symbols Bittensor TAO_SYMBOL: str = chr(0x03C4) diff --git a/bittensor/core/subtensor.py b/bittensor/core/subtensor.py index 76e95a677..70da83f63 100644 --- a/bittensor/core/subtensor.py +++ b/bittensor/core/subtensor.py @@ -715,16 +715,8 @@ def determine_chain_endpoint_and_network( if network is None: return None, None - if network in ["finney", "local", "test", "archive"]: - if network == "finney": - # Kiru Finney staging network. - return network, settings.FINNEY_ENTRYPOINT - elif network == "local": - return network, settings.LOCAL_ENTRYPOINT - elif network == "test": - return network, settings.FINNEY_TEST_ENTRYPOINT - elif network == "archive": - return network, settings.ARCHIVE_ENTRYPOINT + if network in settings.NETWORKS: + return network, settings.NETWORK_MAP[network] else: if ( network == settings.FINNEY_ENTRYPOINT @@ -745,7 +737,6 @@ def determine_chain_endpoint_and_network( return "local", network else: return "unknown", network - return None, None def get_netuids_for_hotkey( self, hotkey_ss58: str, block: Optional[int] = None diff --git a/tests/unit_tests/test_subtensor.py b/tests/unit_tests/test_subtensor.py index c88990368..765e093dd 100644 --- a/tests/unit_tests/test_subtensor.py +++ b/tests/unit_tests/test_subtensor.py @@ -2138,3 +2138,16 @@ def test_get_delegate_take_none(subtensor, mocker): subtensor_module.u16_normalized_float.assert_not_called() assert result is None + + +def test_networks_during_connection(mocker): + """Test networks during_connection.""" + # Preps + subtensor_module.SubstrateInterface = mocker.Mock() + # Call + for network in list(settings.NETWORK_MAP.keys()) + ["undefined"]: + sub = Subtensor(network) + + # Assertions + sub.network = network + sub.chain_endpoint = settings.NETWORK_MAP.get(network)