From e27220117a056aea10f048528074a0f271d1aa2a Mon Sep 17 00:00:00 2001 From: Roman Date: Tue, 4 Feb 2025 19:17:45 -0800 Subject: [PATCH 01/10] update based on `https://github.com/opentensor/subtensor/pull/1205` --- bittensor/core/chain_data/chain_identity.py | 20 +++++++++++++++---- .../core/chain_data/subnet_hyperparameters.py | 6 +++--- bittensor/core/chain_data/subnet_info.py | 3 ++- .../core/extrinsics/asyncex/commit_reveal.py | 4 +--- bittensor/core/extrinsics/commit_reveal.py | 4 +--- tests/e2e_tests/test_commit_weights.py | 10 ++-------- .../extrinsics/asyncex/test_commit_reveal.py | 4 ++-- .../extrinsics/test_commit_reveal.py | 4 ++-- 8 files changed, 29 insertions(+), 26 deletions(-) diff --git a/bittensor/core/chain_data/chain_identity.py b/bittensor/core/chain_data/chain_identity.py index f66de75410..4f080fa58a 100644 --- a/bittensor/core/chain_data/chain_identity.py +++ b/bittensor/core/chain_data/chain_identity.py @@ -1,15 +1,27 @@ from dataclasses import dataclass +from bittensor.core.chain_data.info_base import InfoBase @dataclass -class ChainIdentity: +class ChainIdentity(InfoBase): """Dataclass for chain identity information.""" - # In `bittensor.core.chain_data.utils.custom_rpc_type_registry` represents as `ChainIdentityOf` structure. - name: str + github: str + contact: str url: str - image: str discord: str description: str additional: str + + @classmethod + def _from_dict(cls, decoded: dict) -> "ChainIdentity": + return cls( + name=decoded["subnet_name"], + github=decoded["github_repo"], + contact=decoded["subnet_contact"], + url=decoded["subnet_url"], + discord=decoded["discord"], + description=decoded["description"], + additional=decoded["additional"], + ) diff --git a/bittensor/core/chain_data/subnet_hyperparameters.py b/bittensor/core/chain_data/subnet_hyperparameters.py index ddcbe53b24..479ab78f14 100644 --- a/bittensor/core/chain_data/subnet_hyperparameters.py +++ b/bittensor/core/chain_data/subnet_hyperparameters.py @@ -31,7 +31,7 @@ class SubnetHyperparameters(InfoBase): max_validators (int): Maximum number of validators. adjustment_alpha (int): Alpha value for adjustments. difficulty (int): Difficulty level. - commit_reveal_weights_interval (int): Interval for commit-reveal weights. + commit_reveal_period (int): Interval for commit-reveal weights. commit_reveal_weights_enabled (bool): Flag indicating if commit-reveal weights are enabled. alpha_high (int): High value of alpha. alpha_low (int): Low value of alpha. @@ -60,7 +60,7 @@ class SubnetHyperparameters(InfoBase): max_validators: int adjustment_alpha: int difficulty: int - commit_reveal_weights_interval: int + commit_reveal_period: int commit_reveal_weights_enabled: bool alpha_high: int alpha_low: int @@ -89,7 +89,7 @@ def _from_dict(cls, decoded: dict) -> "SubnetHyperparameters": alpha_low=decoded["alpha_low"], bonds_moving_avg=decoded["bonds_moving_avg"], commit_reveal_weights_enabled=decoded["commit_reveal_weights_enabled"], - commit_reveal_weights_interval=decoded["commit_reveal_weights_interval"], + commit_reveal_period=decoded["commit_reveal_period"], difficulty=decoded["difficulty"], immunity_period=decoded["immunity_period"], kappa=decoded["kappa"], diff --git a/bittensor/core/chain_data/subnet_info.py b/bittensor/core/chain_data/subnet_info.py index b4ae0237aa..ae3e0333f8 100644 --- a/bittensor/core/chain_data/subnet_info.py +++ b/bittensor/core/chain_data/subnet_info.py @@ -32,6 +32,7 @@ class SubnetInfo(InfoBase): @classmethod def _from_dict(cls, decoded: Any) -> "SubnetInfo": + print(decoded) return SubnetInfo( blocks_since_epoch=decoded["blocks_since_last_step"], burn=Balance.from_rao(decoded["burn"]), @@ -40,7 +41,7 @@ def _from_dict(cls, decoded: Any) -> "SubnetInfo": for (netuid, req) in decoded["network_connect"] }, difficulty=decoded["difficulty"], - emission_value=decoded["emission_values"], + emission_value=decoded["emission_value"], immunity_period=decoded["immunity_period"], kappa=decoded["kappa"], max_allowed_validators=decoded["max_allowed_validators"], diff --git a/bittensor/core/extrinsics/asyncex/commit_reveal.py b/bittensor/core/extrinsics/asyncex/commit_reveal.py index 7804a131f2..2a5212b569 100644 --- a/bittensor/core/extrinsics/asyncex/commit_reveal.py +++ b/bittensor/core/extrinsics/asyncex/commit_reveal.py @@ -103,9 +103,7 @@ async def commit_reveal_v3_extrinsic( netuid, block_hash=current_block["header"]["hash"] ) tempo = subnet_hyperparameters.tempo - subnet_reveal_period_epochs = ( - subnet_hyperparameters.commit_reveal_weights_interval - ) + subnet_reveal_period_epochs = subnet_hyperparameters.commit_reveal_period # Encrypt `commit_hash` with t-lock and `get reveal_round` commit_for_reveal, reveal_round = get_encrypted_commit( diff --git a/bittensor/core/extrinsics/commit_reveal.py b/bittensor/core/extrinsics/commit_reveal.py index 4e21fa2c9e..f71fae5581 100644 --- a/bittensor/core/extrinsics/commit_reveal.py +++ b/bittensor/core/extrinsics/commit_reveal.py @@ -103,9 +103,7 @@ def commit_reveal_v3_extrinsic( netuid, block=current_block ) tempo = subnet_hyperparameters.tempo - subnet_reveal_period_epochs = ( - subnet_hyperparameters.commit_reveal_weights_interval - ) + subnet_reveal_period_epochs = subnet_hyperparameters.commit_reveal_period # Encrypt `commit_hash` with t-lock and `get reveal_round` commit_for_reveal, reveal_round = get_encrypted_commit( diff --git a/tests/e2e_tests/test_commit_weights.py b/tests/e2e_tests/test_commit_weights.py index 90ab7a9303..5cb2bea121 100644 --- a/tests/e2e_tests/test_commit_weights.py +++ b/tests/e2e_tests/test_commit_weights.py @@ -77,10 +77,7 @@ async def test_commit_and_reveal_weights_legacy(local_chain): ) assert ( - subtensor.get_subnet_hyperparameters( - netuid=netuid - ).commit_reveal_weights_interval - == 1 + subtensor.get_subnet_hyperparameters(netuid=netuid).commit_reveal_period == 1 ), "Failed to set commit/reveal periods" assert ( @@ -233,10 +230,7 @@ async def test_commit_weights_uses_next_nonce(local_chain): ) assert ( - subtensor.get_subnet_hyperparameters( - netuid=netuid - ).commit_reveal_weights_interval - == 1 + subtensor.get_subnet_hyperparameters(netuid=netuid).commit_reveal_period == 1 ), "Failed to set commit/reveal periods" assert ( diff --git a/tests/unit_tests/extrinsics/asyncex/test_commit_reveal.py b/tests/unit_tests/extrinsics/asyncex/test_commit_reveal.py index 24ba13c707..5df1225b18 100644 --- a/tests/unit_tests/extrinsics/asyncex/test_commit_reveal.py +++ b/tests/unit_tests/extrinsics/asyncex/test_commit_reveal.py @@ -43,7 +43,7 @@ def hyperparams(): max_validators=0, adjustment_alpha=0, difficulty=0, - commit_reveal_weights_interval=0, + commit_reveal_period=0, commit_reveal_weights_enabled=True, alpha_high=0, alpha_low=0, @@ -223,7 +223,7 @@ async def test_commit_reveal_v3_extrinsic_success_with_torch( mocked_get_encrypted_commit.assert_called_once_with( uids=mocked_uids, weights=mocked_weights, - subnet_reveal_period_epochs=mock_hyperparams.return_value.commit_reveal_weights_interval, + subnet_reveal_period_epochs=mock_hyperparams.return_value.commit_reveal_period, version_key=async_commit_reveal.version_as_int, tempo=mock_hyperparams.return_value.tempo, netuid=fake_netuid, diff --git a/tests/unit_tests/extrinsics/test_commit_reveal.py b/tests/unit_tests/extrinsics/test_commit_reveal.py index f3e3266d64..d91dde2673 100644 --- a/tests/unit_tests/extrinsics/test_commit_reveal.py +++ b/tests/unit_tests/extrinsics/test_commit_reveal.py @@ -44,7 +44,7 @@ def hyperparams(): max_validators=0, adjustment_alpha=0, difficulty=0, - commit_reveal_weights_interval=0, + commit_reveal_period=0, commit_reveal_weights_enabled=True, alpha_high=0, alpha_low=0, @@ -209,7 +209,7 @@ def test_commit_reveal_v3_extrinsic_success_with_torch(mocker, subtensor, hyperp mocked_get_encrypted_commit.assert_called_once_with( uids=mocked_uids, weights=mocked_weights, - subnet_reveal_period_epochs=mock_hyperparams.return_value.commit_reveal_weights_interval, + subnet_reveal_period_epochs=mock_hyperparams.return_value.commit_reveal_period, version_key=commit_reveal.version_as_int, tempo=mock_hyperparams.return_value.tempo, netuid=fake_netuid, From 5255e7ceffb9740174929022361630e1b680560b Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 5 Feb 2025 10:53:44 -0800 Subject: [PATCH 02/10] update `Async/Subtensor.query_identity` argument and docstring --- bittensor/core/async_subtensor.py | 7 ++++--- bittensor/core/subtensor.py | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/bittensor/core/async_subtensor.py b/bittensor/core/async_subtensor.py index 6714f5f324..e17eb927b0 100644 --- a/bittensor/core/async_subtensor.py +++ b/bittensor/core/async_subtensor.py @@ -2456,7 +2456,7 @@ async def neurons_lite( async def query_identity( self, - key: str, + coldkey_ss58: str, block: Optional[int] = None, block_hash: Optional[str] = None, reuse_block: bool = False, @@ -2467,7 +2467,8 @@ async def query_identity( decentralized identity and governance system. Arguments: - key (str): The key used to query the neuron's identity, typically the neuron's SS58 address. + coldkey_ss58 (str): The coldkey used to query the neuron's identity (technically the neuron's coldkey SS58 + address). block (Optional[int]): The blockchain block number for the query. block_hash (str): The hash of the blockchain block number at which to perform the query. reuse_block (bool): Whether to reuse the last-used blockchain block hash. @@ -2486,7 +2487,7 @@ async def query_identity( identity_info = await self.substrate.query( module="Registry", storage_function="IdentityOf", - params=[key], + params=[coldkey_ss58], block_hash=block_hash, reuse_block_hash=reuse_block, ) diff --git a/bittensor/core/subtensor.py b/bittensor/core/subtensor.py index d266853199..9f5bd43df5 100644 --- a/bittensor/core/subtensor.py +++ b/bittensor/core/subtensor.py @@ -1883,14 +1883,15 @@ def neurons_lite( return NeuronInfoLite.list_from_dicts(result) - def query_identity(self, key: str, block: Optional[int] = None) -> dict: + def query_identity(self, coldkey_ss58: str, block: Optional[int] = None) -> dict: """ Queries the identity of a neuron on the Bittensor blockchain using the given key. This function retrieves detailed identity information about a specific neuron, which is a crucial aspect of the network's decentralized identity and governance system. Arguments: - key (str): The key used to query the neuron's identity, typically the neuron's SS58 address. + coldkey_ss58 (str): The coldkey used to query the neuron's identity (technically the neuron's coldkey SS58 + address). block (Optional[int]): The blockchain block number for the query. Returns: @@ -1906,7 +1907,7 @@ def query_identity(self, key: str, block: Optional[int] = None) -> dict: identity_info = self.substrate.query( module="Registry", storage_function="IdentityOf", - params=[key], + params=[coldkey_ss58], block_hash=self.determine_block_hash(block), ) try: From 124740718a71b0d05fae8fab5c99705a91865ddc Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 5 Feb 2025 11:29:27 -0800 Subject: [PATCH 03/10] remove debug print --- bittensor/core/chain_data/subnet_info.py | 1 - 1 file changed, 1 deletion(-) diff --git a/bittensor/core/chain_data/subnet_info.py b/bittensor/core/chain_data/subnet_info.py index ae3e0333f8..c8919d0c8b 100644 --- a/bittensor/core/chain_data/subnet_info.py +++ b/bittensor/core/chain_data/subnet_info.py @@ -32,7 +32,6 @@ class SubnetInfo(InfoBase): @classmethod def _from_dict(cls, decoded: Any) -> "SubnetInfo": - print(decoded) return SubnetInfo( blocks_since_epoch=decoded["blocks_since_last_step"], burn=Balance.from_rao(decoded["burn"]), From 5872b134a86c17717c0d7fd93a5a55aeb3fb1414 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 5 Feb 2025 13:12:06 -0800 Subject: [PATCH 04/10] chain identity fix + tests --- bittensor/core/chain_data/chain_identity.py | 10 +++++----- tests/unit_tests/test_async_subtensor.py | 20 +++++++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/bittensor/core/chain_data/chain_identity.py b/bittensor/core/chain_data/chain_identity.py index 4f080fa58a..14655c221f 100644 --- a/bittensor/core/chain_data/chain_identity.py +++ b/bittensor/core/chain_data/chain_identity.py @@ -7,9 +7,9 @@ class ChainIdentity(InfoBase): """Dataclass for chain identity information.""" name: str - github: str - contact: str url: str + github: str + image: str discord: str description: str additional: str @@ -17,10 +17,10 @@ class ChainIdentity(InfoBase): @classmethod def _from_dict(cls, decoded: dict) -> "ChainIdentity": return cls( - name=decoded["subnet_name"], + name=decoded["name"], + url=decoded["url"], github=decoded["github_repo"], - contact=decoded["subnet_contact"], - url=decoded["subnet_url"], + image=decoded["image"], discord=decoded["discord"], description=decoded["description"], additional=decoded["additional"], diff --git a/tests/unit_tests/test_async_subtensor.py b/tests/unit_tests/test_async_subtensor.py index a8a7d9a12f..cf79cf6527 100644 --- a/tests/unit_tests/test_async_subtensor.py +++ b/tests/unit_tests/test_async_subtensor.py @@ -1430,7 +1430,7 @@ async def test_get_delegated_with_empty_result(subtensor, mocker): async def test_query_identity_successful(subtensor, mocker): """Tests query_identity method with successful identity query.""" # Preps - fake_key = "test_key" + fake_coldkey_ss58 = "test_key" fake_block_hash = "block_hash" fake_identity_info = {"info": {"stake": (b"\x01\x02",)}} @@ -1444,13 +1444,15 @@ async def test_query_identity_successful(subtensor, mocker): ) # Call - result = await subtensor.query_identity(key=fake_key, block_hash=fake_block_hash) + result = await subtensor.query_identity( + coldkey_ss58=fake_coldkey_ss58, block_hash=fake_block_hash + ) # Asserts mocked_query.assert_called_once_with( module="Registry", storage_function="IdentityOf", - params=[fake_key], + params=[fake_coldkey_ss58], block_hash=fake_block_hash, reuse_block_hash=False, ) @@ -1461,19 +1463,19 @@ async def test_query_identity_successful(subtensor, mocker): async def test_query_identity_no_info(subtensor, mocker): """Tests query_identity method when no identity info is returned.""" # Preps - fake_key = "test_key" + fake_coldkey_ss58 = "test_key" mocked_query = mocker.AsyncMock(return_value=None) subtensor.substrate.query = mocked_query # Call - result = await subtensor.query_identity(key=fake_key) + result = await subtensor.query_identity(coldkey_ss58=fake_coldkey_ss58) # Asserts mocked_query.assert_called_once_with( module="Registry", storage_function="IdentityOf", - params=[fake_key], + params=[fake_coldkey_ss58], block_hash=None, reuse_block_hash=False, ) @@ -1484,7 +1486,7 @@ async def test_query_identity_no_info(subtensor, mocker): async def test_query_identity_type_error(subtensor, mocker): """Tests query_identity method when a TypeError occurs during decoding.""" # Preps - fake_key = "test_key" + fake_coldkey_ss58 = "test_key" fake_identity_info = {"info": {"rank": (b"\xff\xfe",)}} mocked_query = mocker.AsyncMock(return_value=fake_identity_info) @@ -1497,13 +1499,13 @@ async def test_query_identity_type_error(subtensor, mocker): ) # Call - result = await subtensor.query_identity(key=fake_key) + result = await subtensor.query_identity(coldkey_ss58=fake_coldkey_ss58) # Asserts mocked_query.assert_called_once_with( module="Registry", storage_function="IdentityOf", - params=[fake_key], + params=[fake_coldkey_ss58], block_hash=None, reuse_block_hash=False, ) From c7a4fc1ec1fa89876e69263d986870edae6835f5 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 5 Feb 2025 13:51:55 -0800 Subject: [PATCH 05/10] update registry --- tests/helpers/registry | Bin 216782 -> 221261 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/tests/helpers/registry b/tests/helpers/registry index dd70e716c26df10fc12f1fb6e0ef600a2bc86ba8..4844ee5de57b57a84d77df140139f126c3237d70 100644 GIT binary patch delta 14421 zcmeHudsvj$o&UMa%sbo^6m+=ha8pn*fS{mgL`5MH@dgGXAtSuNRAvU|qEJK7Zb)Jp ztL(&_&}bVPO*DyV*wjpI!!~r+ZEb5?)5kXM)+T0SyS8x~o6yE??X#bA-a#R>zui8& z`~3cCo{8`0bFSZW&i8vR-*fo>k(hID#6;2by)ne4`yG?73`YIp`9;=JUtqh>?{)a~ zhGu7{-jumo{#%(}P;81_?R7NLUPeqbcDvK>JHcqI6A^^;2J?^GX6$3874#S*RvPW{ zZQsYJsfN(#HsAJRfGdLYkK0pj#qR$^EFt@48A*NP%IF)DDtP#KCOsA$K0ei|$|K~E z%F#bANB`IylTKu&42;Ti8!DR)%DfbMk}K=Yt1dObTvz;j_U5FD3_n_d*)I7)*SzfL&ywZxPEA zd)BZi^b!*J=w+33#!HXVD-umDUD@hzx+|M>x8LdSsx2TSC3we6>B0A3vWX}g-OR{U zq)QHd^QC%vP3DMSzA3QXt^3Di5tT{w?r53~r9f0ez}qI`Y;;{Ixo(Jzwv0$wZ!m%% zF~t_z(2AQ9S`XU@<%lzLf}d<)1h?V;+oH1=9_)KDF)DVYqpi(k+DzzIgWo)vF@1

eH{Sx8{t`V%zCx z3+TS_fw4YEo8Ks;@EgD9EP}t9_YePMqG`e3eQUmRD4#&lnI+~gqe169c9iq6L{&+EvLKDTz2s%0V{Ld2R(|Ibm zq223j)NM36u&|KOLiDI-S3|qQ>vuZZGGVYDPaC=C@V^DW@w22fyT@&J*o{H8?{fNE z!Blp;Dr!Cz2d+|EkH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D^U+y+Ep_(W?4(7lbY~sBfzRhveM#Ct9 zVZ3_I3Oi<( zd3-qkt&@RCN{XmeQS$PQDn>afkswiy>>y5^#3}M~;alg#3%NXspYEZoj{-rAC~L?R4TR>@P~10>?z=L zd6n)JR}1)QZLh99D?Xc#sd;lg>@p}mozJf#n)$s2{3Gtx4~b_M@(x&CQXyZ!+jNhp zD&&t$sMMomys=I16hnplQ`%+rF5>?}dAHtU{@D_~nIrK1n`JQ2m_FSRIN;W2s_;N{ zJ#@+KH}@9vB``qoot4}}&zcD((uRA?lv17yTQZlf;%>%=^o!=V*6_6qv+(POd9%&o z)*~7WU(~Q@+Q?mZ7`|QG$eSIpJd_q*!TopG74xYI%&Gl`uANF=FOF>HaVC^IMp>Ut z6vZ)DSfA}q96qa(Ptiv7o4WY%7C!%vWN?n?VGfd86Ks}uJQ=E~*+XywuNSYBV71%v z4zr7vN`AkF({__3`}0aZow*$1|*Lx zz8!1Fqg(k8xkpbI%eV1G@YN@`@ixj^ZEi8CiqAqUVo?=O#k%3H;?ofCe5#5+m{{x} zGZBTa_8GzEMxVopB{b-%JsBbYl!>7#o`6{8FRL)fm15!!o-?@$n#clvwcJ|gV_efW z@8DBidmUuWAEs6B%ONe|xgBWvkm%dNolYG1N@OmC2&-ijx~|#XRPQHvhq8ma@cQJ7 z9cZ*wIIDR=Tpu>?H5=r4N1n_>-!m6Ac^vhkubNL1?rJzbw)O^#wxbN(QQOIvA=tR_ Hf`j}Q``y53 From f28f15eb191e11cee5a4cb5e5515477d3be354e1 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 5 Feb 2025 13:52:29 -0800 Subject: [PATCH 06/10] update query_runtime_api method --- bittensor/core/subtensor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bittensor/core/subtensor.py b/bittensor/core/subtensor.py index 9f5bd43df5..12c21a1e05 100644 --- a/bittensor/core/subtensor.py +++ b/bittensor/core/subtensor.py @@ -515,7 +515,7 @@ def get_all_subnets_info(self, block: Optional[int] = None) -> list["SubnetInfo" """ result = self.query_runtime_api( runtime_api="SubnetInfoRuntimeApi", - method="get_subnets_info", + method="get_subnets_info_v2", params=[], block=block, ) From 02c605432c20f5d12a93f456dcdb41c4e1cd3c4e Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 5 Feb 2025 13:52:56 -0800 Subject: [PATCH 07/10] update SubnetIdentity --- bittensor/core/chain_data/dynamic_info.py | 4 ++++ bittensor/core/chain_data/subnet_identity.py | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/bittensor/core/chain_data/dynamic_info.py b/bittensor/core/chain_data/dynamic_info.py index 4d1be86e05..09de89cde0 100644 --- a/bittensor/core/chain_data/dynamic_info.py +++ b/bittensor/core/chain_data/dynamic_info.py @@ -88,6 +88,10 @@ def _from_dict(cls, decoded: dict) -> "DynamicInfo": subnet_contact=bytes( decoded["subnet_identity"]["subnet_contact"] ).decode(), + subnet_url=bytes(decoded["subnet_identity"]["subnet_url"]).decode(), + discord=bytes(decoded["subnet_identity"]["discord"]).decode(), + description=bytes(decoded["subnet_identity"]["description"]).decode(), + additional=bytes(decoded["subnet_identity"]["additional"]).decode(), ) else: subnet_identity = None diff --git a/bittensor/core/chain_data/subnet_identity.py b/bittensor/core/chain_data/subnet_identity.py index e011dde31c..487122bfb4 100644 --- a/bittensor/core/chain_data/subnet_identity.py +++ b/bittensor/core/chain_data/subnet_identity.py @@ -8,5 +8,19 @@ class SubnetIdentity: subnet_name: str github_repo: str subnet_contact: str + subnet_url: str + discord: str + description: str + additional: str - # TODO: Add other methods when fetching from chain + @classmethod + def _from_dict(cls, decoded: dict) -> "SubnetIdentity": + return cls( + subnet_name=decoded["subnet_name"], + github_repo=decoded["github_repo"], + subnet_contact=decoded["subnet_contact"], + subnet_url=decoded["subnet_url"], + discord=decoded["discord"], + description=decoded["description"], + additional=decoded["additional"], + ) From 840b79509c40ad59dc74134f80c5bdc68fbc669b Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 5 Feb 2025 13:53:12 -0800 Subject: [PATCH 08/10] update tests --- tests/helpers/integration_websocket_data.py | 4 ++-- tests/integration_tests/test_subtensor_integration.py | 2 +- tests/unit_tests/test_subtensor.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/helpers/integration_websocket_data.py b/tests/helpers/integration_websocket_data.py index 90b2b0a05f..b4cf5bfc75 100644 --- a/tests/helpers/integration_websocket_data.py +++ b/tests/helpers/integration_websocket_data.py @@ -923,9 +923,9 @@ } }, "state_call": { - '["SubnetInfoRuntimeApi_get_subnets_info", "", null]': { + '["SubnetInfoRuntimeApi_get_subnets_info_v2", "", null]': { "jsonrpc": "2.0", - "result": "0x08010028feff0100025a62020140010100feff0300c80001017501910100000002286bee0000000000000000000000000000000000000000000000000000000000000000010428feff0100025a62020140010100feff0300c804010479019101000002286bee02286bee0000000000000000000000000000000000000000000000000000000000000000", + "result": "0x08010028feff0100025a62020140010100feff0300c80001015d01910100000002286bee000000000000000000000000000000000000000000000000000000000000000000010428feff0100025a62020140010100feff0300c804010461019101000002286bee02286bee000000000000000000000000000000000000000000000000000000000000000000", } }, "state_getRuntimeVersion": { diff --git a/tests/integration_tests/test_subtensor_integration.py b/tests/integration_tests/test_subtensor_integration.py index 6da0a831fd..fac094b26e 100644 --- a/tests/integration_tests/test_subtensor_integration.py +++ b/tests/integration_tests/test_subtensor_integration.py @@ -47,7 +47,7 @@ async def test_get_all_subnets_info(mocker): assert result[0].owner_ss58 == "5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM" assert result[1].kappa == 32767 assert result[1].max_weight_limit == 65535 - assert result[1].blocks_since_epoch == 94 + assert result[1].blocks_since_epoch == 88 @pytest.mark.asyncio diff --git a/tests/unit_tests/test_subtensor.py b/tests/unit_tests/test_subtensor.py index 65b4cffa29..ac4f716a06 100644 --- a/tests/unit_tests/test_subtensor.py +++ b/tests/unit_tests/test_subtensor.py @@ -2094,7 +2094,7 @@ def test_get_all_subnets_info_success(mocker, subtensor): # Asserts subtensor.query_runtime_api.assert_called_once_with( runtime_api="SubnetInfoRuntimeApi", - method="get_subnets_info", + method="get_subnets_info_v2", params=[], block=block, ) @@ -2122,7 +2122,7 @@ def test_get_all_subnets_info_no_data(mocker, subtensor, result_): assert result == [] subtensor.query_runtime_api.assert_called_once_with( runtime_api="SubnetInfoRuntimeApi", - method="get_subnets_info", + method="get_subnets_info_v2", params=[], block=block, ) From 61468841cde06cab5a22f64f3d5c65f623f83bac Mon Sep 17 00:00:00 2001 From: ibraheem-opentensor Date: Wed, 5 Feb 2025 14:11:34 -0800 Subject: [PATCH 09/10] Updates query_identity --- bittensor/core/async_subtensor.py | 8 +++++--- bittensor/core/subtensor.py | 6 +++--- bittensor/utils/__init__.py | 25 +++++++++---------------- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/bittensor/core/async_subtensor.py b/bittensor/core/async_subtensor.py index e17eb927b0..17ffa29a4a 100644 --- a/bittensor/core/async_subtensor.py +++ b/bittensor/core/async_subtensor.py @@ -2485,14 +2485,16 @@ async def query_identity( """ block_hash = await self.determine_block_hash(block, block_hash, reuse_block) identity_info = await self.substrate.query( - module="Registry", - storage_function="IdentityOf", + module="SubtensorModule", + storage_function="IdentitiesV2", params=[coldkey_ss58], block_hash=block_hash, reuse_block_hash=reuse_block, ) + if not identity_info: + return {} try: - return _decode_hex_identity_dict(identity_info["info"]) + return _decode_hex_identity_dict(identity_info) except TypeError: return {} diff --git a/bittensor/core/subtensor.py b/bittensor/core/subtensor.py index 12c21a1e05..e9704e142f 100644 --- a/bittensor/core/subtensor.py +++ b/bittensor/core/subtensor.py @@ -1905,13 +1905,13 @@ def query_identity(self, coldkey_ss58: str, block: Optional[int] = None) -> dict parameters. """ identity_info = self.substrate.query( - module="Registry", - storage_function="IdentityOf", + module="SubtensorModule", + storage_function="IdentitiesV2", params=[coldkey_ss58], block_hash=self.determine_block_hash(block), ) try: - return _decode_hex_identity_dict(identity_info["info"]) + return _decode_hex_identity_dict(identity_info) except TypeError: return {} diff --git a/bittensor/utils/__init__.py b/bittensor/utils/__init__.py index da0ed2c448..a84f6d6a81 100644 --- a/bittensor/utils/__init__.py +++ b/bittensor/utils/__init__.py @@ -52,28 +52,21 @@ def __new__(cls, data: Union[str, dict]): def _decode_hex_identity_dict(info_dictionary: dict[str, Any]) -> dict[str, Any]: # TODO why does this exist alongside `decode_hex_identity_dict`? """Decodes a dictionary of hexadecimal identities.""" + decoded_info = {} for k, v in info_dictionary.items(): if isinstance(v, dict): item = next(iter(v.values())) else: item = v - if isinstance(item, tuple) and item: - if len(item) > 1: - try: - info_dictionary[k] = ( - bytes(item).hex(sep=" ", bytes_per_sep=2).upper() - ) - except UnicodeDecodeError: - logging.error(f"Could not decode: {k}: {item}.") - else: - try: - info_dictionary[k] = bytes(item[0]).decode("utf-8") - except UnicodeDecodeError: - logging.error(f"Could not decode: {k}: {item}.") - else: - info_dictionary[k] = item - return info_dictionary + if isinstance(item, tuple): + try: + decoded_info[k] = bytes(item).decode() + except UnicodeDecodeError: + print(f"Could not decode: {k}: {item}") + else: + decoded_info[k] = item + return decoded_info def ss58_to_vec_u8(ss58_address: str) -> list[int]: From 5cb49e0d832d2fa8092a77aaa071c642e5ac5961 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 5 Feb 2025 14:26:13 -0800 Subject: [PATCH 10/10] remove obsoleted tests --- tests/unit_tests/test_async_subtensor.py | 33 +++++------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/tests/unit_tests/test_async_subtensor.py b/tests/unit_tests/test_async_subtensor.py index cf79cf6527..248ab8a9a2 100644 --- a/tests/unit_tests/test_async_subtensor.py +++ b/tests/unit_tests/test_async_subtensor.py @@ -51,20 +51,6 @@ def test_decode_ss58_tuples_in_proposal_vote_data(mocker): ] -def test_decode_hex_identity_dict_with_single_byte_utf8(): - """Tests _decode_hex_identity_dict when value is a single utf-8 decodable byte.""" - info_dict = {"name": (b"Neuron",)} - result = async_subtensor._decode_hex_identity_dict(info_dict) - assert result["name"] == "Neuron" - - -def test_decode_hex_identity_dict_with_non_utf8_data(): - """Tests _decode_hex_identity_dict when value cannot be decoded as utf-8.""" - info_dict = {"data": (b"\xff\xfe",)} - result = async_subtensor._decode_hex_identity_dict(info_dict) - assert result["data"] == (b"\xff\xfe",) - - def test_decode_hex_identity_dict_with_non_tuple_value(): """Tests _decode_hex_identity_dict when value is not a tuple.""" info_dict = {"info": "regular_string"} @@ -72,13 +58,6 @@ def test_decode_hex_identity_dict_with_non_tuple_value(): assert result["info"] == "regular_string" -def test_decode_hex_identity_dict_with_nested_dict(): - """Tests _decode_hex_identity_dict with a nested dictionary.""" - info_dict = {"identity": {"rank": (65, 66, 67)}} - result = async_subtensor._decode_hex_identity_dict(info_dict) - assert result["identity"] == "41 4243" - - @pytest.mark.asyncio async def test_init_if_unknown_network_is_valid(mocker): """Tests __init__ if passed network unknown and is valid.""" @@ -1450,8 +1429,8 @@ async def test_query_identity_successful(subtensor, mocker): # Asserts mocked_query.assert_called_once_with( - module="Registry", - storage_function="IdentityOf", + module="SubtensorModule", + storage_function="IdentitiesV2", params=[fake_coldkey_ss58], block_hash=fake_block_hash, reuse_block_hash=False, @@ -1473,8 +1452,8 @@ async def test_query_identity_no_info(subtensor, mocker): # Asserts mocked_query.assert_called_once_with( - module="Registry", - storage_function="IdentityOf", + module="SubtensorModule", + storage_function="IdentitiesV2", params=[fake_coldkey_ss58], block_hash=None, reuse_block_hash=False, @@ -1503,8 +1482,8 @@ async def test_query_identity_type_error(subtensor, mocker): # Asserts mocked_query.assert_called_once_with( - module="Registry", - storage_function="IdentityOf", + module="SubtensorModule", + storage_function="IdentitiesV2", params=[fake_coldkey_ss58], block_hash=None, reuse_block_hash=False,