Skip to content

Commit

Permalink
Add subvortex subnet and tests (#2395)
Browse files Browse the repository at this point in the history
* add `subvortex` subnet and tests

* ruff
  • Loading branch information
roman-opentensor authored and ibraheem-opentensor committed Nov 6, 2024
1 parent 1a5a243 commit 7e4849a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
14 changes: 14 additions & 0 deletions bittensor/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 2 additions & 11 deletions bittensor/core/subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
13 changes: 13 additions & 0 deletions tests/unit_tests/test_subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 7e4849a

Please sign in to comment.