Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add subvortex subnet and tests #2395

Merged
merged 2 commits into from
Nov 6, 2024
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
11 changes: 3 additions & 8 deletions bittensor/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
MINERS_DIR.mkdir(parents=True, exist_ok=True)

# Bittensor networks name
NETWORKS = ["finney", "test", "archive", "local"]
NETWORKS = ["finney", "test", "archive", "local", "subvortex"]

DEFAULT_ENDPOINT = "wss://entrypoint-finney.opentensor.ai:443"
DEFAULT_NETWORK = NETWORKS[0]
Expand All @@ -46,19 +46,14 @@
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,
Comment on lines 51 to 55
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
NETWORK_MAP = {
NETWORKS[0]: FINNEY_ENTRYPOINT,
NETWORKS[1]: FINNEY_TEST_ENTRYPOINT,
NETWORKS[2]: ARCHIVE_ENTRYPOINT,
NETWORKS[3]: LOCAL_ENTRYPOINT,
NETWORK_MAP = {
"finney": FINNEY_ENTRYPOINT,
"test": FINNEY_TEST_ENTRYPOINT,
"archive": ARCHIVE_ENTRYPOINT,
"local": LOCAL_ENTRYPOINT,
"subvortex": SUBVORTEX_ENTRYPOINT,
}

and later

NETWORKS = NETWORK_MAP.keys()

Normally I'd refactor the module to not use NETWORKS at all, but someone might be using it in subnet code, so lets leave it. One day when the interface is documented we can clean it up.

}

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
Expand Down
13 changes: 2 additions & 11 deletions bittensor/core/subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,16 +685,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]
Comment on lines +688 to +689
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if network in settings.NETWORKS:
return network, settings.NETWORK_MAP[network]
if chain_endpoint := settings.NETWORK_MAP.get(network):
return network, chain_endpoint

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we check the network argument before chain_endpoint if defined

else:
if (
network == settings.FINNEY_ENTRYPOINT
Expand All @@ -715,7 +707,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 @@ -2110,3 +2110,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)
Loading