From 64c0bbe153265b0320a22a331768c2cd46fdc827 Mon Sep 17 00:00:00 2001 From: Serge Nedashkovsky Date: Fri, 17 May 2024 15:08:51 +1000 Subject: [PATCH 1/6] - add setting a subnet particle - update docs --- cybertensor/commands/network.py | 5 +++-- cybertensor/cwtensor.py | 6 +++--- cybertensor/messages/network.py | 3 ++- cybertensor/metagraph.py | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/cybertensor/commands/network.py b/cybertensor/commands/network.py index ddca43b..2ab13c1 100644 --- a/cybertensor/commands/network.py +++ b/cybertensor/commands/network.py @@ -323,6 +323,7 @@ def add_args(parser: argparse.ArgumentParser): "min_burn": "sudo_set_min_burn", "max_burn": "sudo_set_max_burn", "max_allowed_validators": "sudo_set_max_allowed_validators", + "particle": "sudo_set_subnet_metadata", } @@ -420,7 +421,7 @@ class SubnetHyperparamsCommand: Example usage: >>> ctcli subnets hyperparameters --netuid 1 - Subnet Hyperparameters - NETUID: 1 - finney + Subnet Hyperparameters - NETUID: 1 - space-pussy HYPERPARAMETER VALUE rho 10 kappa 32767 @@ -518,7 +519,7 @@ class SubnetGetHyperparamsCommand: Example usage: >>> ctcli sudo get --netuid 1 - Subnet Hyperparameters - NETUID: 1 - finney + Subnet Hyperparameters - NETUID: 1 - space-pussy HYPERPARAMETER VALUE rho 10 kappa 32767 diff --git a/cybertensor/cwtensor.py b/cybertensor/cwtensor.py index d83e14f..56b94e1 100644 --- a/cybertensor/cwtensor.py +++ b/cybertensor/cwtensor.py @@ -82,7 +82,7 @@ class cwtensor: """Factory Class for cybertensor.cwtensor The cwtensor class handles interactions with the substrate cwtensor chain. - By default, the cwtensor class connects to the Finney which serves as the main cybertensor network. + By default, the cwtensor class connects to the Space-pussy which serves as the main cybertensor network. The cwtensor class in cybertensor serves as a crucial interface for interacting with the cybertensor blockchain, facilitating a range of operations essential for the decentralized machine learning network. @@ -95,7 +95,7 @@ class cwtensor: the ranking and incentive mechanisms within the network. Higher-ranked neurons, as determined by their contributions and trust within the network, receive more incentives. - The cwtensor class connects to various cybertensor networks like the main ``finney`` network or local test + The cwtensor class connects to various cybertensor networks like the main ``space-pussy`` network or local test networks, providing a gateway to the blockchain layer of cybertensor. It leverages a staked weighted trust system and consensus to ensure fair and distributed incentive mechanisms, where incentives (I) are primarily allocated to neurons that are trusted by the majority of the network. @@ -2347,7 +2347,7 @@ def metagraph( netuid: int, lite: bool = True, block: Optional[int] = None, - ) -> "cybertensor.Metagraph": + ) -> "cybertensor.metagraph": """ Returns a synced metagraph for a specified subnet within the cybertensor network. The metagraph represents the network's structure, including neuron connections and interactions. diff --git a/cybertensor/messages/network.py b/cybertensor/messages/network.py index b79ea89..1044c95 100644 --- a/cybertensor/messages/network.py +++ b/cybertensor/messages/network.py @@ -173,8 +173,9 @@ def set_hyperparameter_message( with console.status( f":satellite: Setting hyperparameter {parameter} to {value} on subnet: {netuid} ..." ): + _value = int(value) if parameter != 'particle' else str(value) sudo_msg = { - str(message): {"netuid": netuid, str(parameter): int(value)}, + str(message): {"netuid": netuid, str(parameter): _value}, } signer_wallet = LocalWallet( PrivateKey(wallet.coldkey.private_key), cwtensor.address_prefix diff --git a/cybertensor/metagraph.py b/cybertensor/metagraph.py index 7368264..497f718 100644 --- a/cybertensor/metagraph.py +++ b/cybertensor/metagraph.py @@ -265,7 +265,7 @@ def metadata(self) -> dict: } def __init__( - self, netuid: int, network: str = "finney", lite: bool = True, sync: bool = True + self, netuid: int, network: str = "space-pussy", lite: bool = True, sync: bool = True ) -> "metagraph": """ Initialize the metagraph object. From 15d645cc9131fab368b59a471cf271ee51475714 Mon Sep 17 00:00:00 2001 From: Serge Nedashkovsky Date: Sat, 18 May 2024 14:09:56 +1000 Subject: [PATCH 2/6] - update requirements --- requirements/dev.txt | 3 ++- requirements/prod.txt | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/requirements/dev.txt b/requirements/dev.txt index bc5d785..24302ca 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -9,4 +9,5 @@ ddt==1.6.0 hypothesis==6.81.1 flake8==7.0.0 mypy==1.8.0 -types-retry==0.9.9.4 \ No newline at end of file +types-retry==0.9.9.4 +jupyter>=1.0.0 \ No newline at end of file diff --git a/requirements/prod.txt b/requirements/prod.txt index e3a3173..1b2e003 100644 --- a/requirements/prod.txt +++ b/requirements/prod.txt @@ -29,7 +29,8 @@ rich setuptools<=65.6.3 shtab==1.6.5 termcolor -torch>=1.13.1 +torch>=1.13.1+cpu +torchvision>=0.13.1+cpu tqdm uvicorn==0.22.0 wheel From 84e45e6ee2789390a2456c93c6d95235c531d0ce Mon Sep 17 00:00:00 2001 From: Serge Nedashkovsky Date: Mon, 20 May 2024 15:09:11 +1000 Subject: [PATCH 3/6] - update requirements --- requirements/prod.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements/prod.txt b/requirements/prod.txt index 1b2e003..00adece 100644 --- a/requirements/prod.txt +++ b/requirements/prod.txt @@ -29,8 +29,8 @@ rich setuptools<=65.6.3 shtab==1.6.5 termcolor -torch>=1.13.1+cpu -torchvision>=0.13.1+cpu +torch==1.13.1+cpu +torchvision==0.14.1+cpu tqdm uvicorn==0.22.0 wheel From 7bfbb4d708e3c388e82fb3b4ee2e477c48f906ba Mon Sep 17 00:00:00 2001 From: Serge Nedashkovsky Date: Wed, 29 May 2024 21:01:26 +1000 Subject: [PATCH 4/6] - update contract address - add graph verse/contract for space-pussy network - update delegate info to new cybernet version - update requirements --- cybertensor/__init__.py | 19 +++++++++++++++++-- cybertensor/chain_data.py | 6 +++--- cybertensor/cwtensor.py | 7 ++++++- cybertensor/mock/cwtensor_mock.py | 2 +- requirements/prod.txt | 3 +-- 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/cybertensor/__init__.py b/cybertensor/__init__.py index bfcc985..839e364 100644 --- a/cybertensor/__init__.py +++ b/cybertensor/__init__.py @@ -112,7 +112,7 @@ def __init__( __boot_symbol__: str = "PUSSY" __giga_boot_symbol__: str = "GPUSSY" -__networks__ = ["local", "bostrom", "space-pussy"] +__networks__ = ["local", "bostrom", "space-pussy", "space-pussy-graph"] __default_network__ = "space-pussy" @@ -158,7 +158,22 @@ def __init__( giga_token_symbol="GPUSSY", network_explorer="https://cyb.ai", address_prefix="pussy", - contract_address="pussy1ddwq8rxgdsm27pvpxqdy2ep9enuen6t2yhrqujvj9qwl4dtukx0s8hpka9", + contract_address="pussy1guj27rm0uj2mhwnnsr8j7cz6uvsz2d759kpalgqs60jahfzwgjcs4l28cw", +) + +__space_pussy_graph_network__ = NetworkConfigCwTensor( + chain_id="space-pussy", + url="grpc+https://grpc.space-pussy.cybernode.ai:1443", + fee_minimum_gas_price=0.01, + fee_denomination="pussy", + staking_denomination="pussy", + faucet_url="", + token="pussy", + token_symbol="PUSSY", + giga_token_symbol="GPUSSY", + network_explorer="https://cyb.ai", + address_prefix="pussy", + contract_address="pussy1j9qku20ssfjdzgl3y5hl0vfxzsjwzwn7d7us2t2n4ejgc6pesqcqhnxsz0", ) __contract_path__ = None diff --git a/cybertensor/chain_data.py b/cybertensor/chain_data.py index 91777de..4aa242d 100644 --- a/cybertensor/chain_data.py +++ b/cybertensor/chain_data.py @@ -446,7 +446,7 @@ class DelegateInfo: int ] # List of subnets that the delegate is allowed to validate on registrations: List[int] # List of subnets that the delegate is registered on - return_per_1000: Balance # Return per 1000 gboot of the delegate over a day + return_per_giga: Balance # Return per 1 gboot of the delegate over a day total_daily_return: Balance # Total daily return of the delegate @classmethod @@ -469,8 +469,8 @@ def fix_decoded_values(cls, decoded: Any) -> "DelegateInfo": ), validator_permits=decoded["validator_permits"], registrations=decoded["registrations"], - return_per_1000=Balance.from_boot(decoded["return_per_1000"]), - total_daily_return=Balance.from_boot(decoded["total_daily_return"]), + return_per_giga=Balance.from_boot(int(decoded["return_per_giga"]["amount"])), + total_daily_return=Balance.from_boot(int(decoded["total_daily_return"]["amount"])), ) @classmethod diff --git a/cybertensor/cwtensor.py b/cybertensor/cwtensor.py index 56b94e1..db08bda 100644 --- a/cybertensor/cwtensor.py +++ b/cybertensor/cwtensor.py @@ -184,7 +184,7 @@ def determine_chain_endpoint_and_network( """ if network is None: return None, None - if network in ["local", "bostrom", "space-pussy"]: + if network in ["local", "bostrom", "space-pussy", "space-pussy-graph"]: if network == "bostrom": return ( network, @@ -195,6 +195,11 @@ def determine_chain_endpoint_and_network( network, cybertensor.__space_pussy_network__, ) + elif network == "space-pussy-graph": + return ( + network, + cybertensor.__space_pussy_graph_network__, + ) elif network == "local": return ( network, diff --git a/cybertensor/mock/cwtensor_mock.py b/cybertensor/mock/cwtensor_mock.py index 47e1d19..52018b6 100644 --- a/cybertensor/mock/cwtensor_mock.py +++ b/cybertensor/mock/cwtensor_mock.py @@ -1322,7 +1322,7 @@ def get_delegate_by_hotkey( if self.neuron_has_validator_permit(uid=uid, netuid=subnet, block=block) ], registrations=[subnet for subnet, _ in registered_subnets], - return_per_1000=Balance.from_gboot(1234567), # Doesn't matter for mock? + return_per_giga=Balance.from_gboot(1234567), # Doesn't matter for mock? total_daily_return=Balance.from_gboot(1234567), # Doesn't matter for mock? ) diff --git a/requirements/prod.txt b/requirements/prod.txt index 00adece..6f7b6e0 100644 --- a/requirements/prod.txt +++ b/requirements/prod.txt @@ -29,8 +29,7 @@ rich setuptools<=65.6.3 shtab==1.6.5 termcolor -torch==1.13.1+cpu -torchvision==0.14.1+cpu +torch==1.13.1 tqdm uvicorn==0.22.0 wheel From 982078c75c170678c3c2e68140023717672ece8d Mon Sep 17 00:00:00 2001 From: Serge Nedashkovsky Date: Wed, 12 Jun 2024 19:37:45 +1000 Subject: [PATCH 5/6] - bump version - update contract schema (cybernet v0.3.0) - change metadata type from string to dictionary (cybernet v0.3.0) --- cybertensor/__init__.py | 2 +- cybertensor/commands/network.py | 2 +- cybertensor/contract/schema/execute.json | 173 ++++++++++++++++++++++- cybertensor/contract/schema/query.json | 116 ++++++++++++--- cybertensor/messages/network.py | 5 +- 5 files changed, 269 insertions(+), 29 deletions(-) diff --git a/cybertensor/__init__.py b/cybertensor/__init__.py index 839e364..c06e648 100644 --- a/cybertensor/__init__.py +++ b/cybertensor/__init__.py @@ -30,7 +30,7 @@ nest_asyncio.apply() # Cybertensor code and protocol version. -__version__ = "0.2.2" +__version__ = "0.2.3" version_split = __version__.split(".") __version_as_int__ = ( (100 * int(version_split[0])) diff --git a/cybertensor/commands/network.py b/cybertensor/commands/network.py index 2ab13c1..00465cb 100644 --- a/cybertensor/commands/network.py +++ b/cybertensor/commands/network.py @@ -323,7 +323,7 @@ def add_args(parser: argparse.ArgumentParser): "min_burn": "sudo_set_min_burn", "max_burn": "sudo_set_max_burn", "max_allowed_validators": "sudo_set_max_allowed_validators", - "particle": "sudo_set_subnet_metadata", + "metadata": "sudo_set_subnet_metadata", } diff --git a/cybertensor/contract/schema/execute.json b/cybertensor/contract/schema/execute.json index 1070417..384914b 100644 --- a/cybertensor/contract/schema/execute.json +++ b/cybertensor/contract/schema/execute.json @@ -157,6 +157,31 @@ }, "additionalProperties": false }, + { + "type": "object", + "required": [ + "set_delegate_commission" + ], + "properties": { + "set_delegate_commission": { + "type": "object", + "required": [ + "commission", + "hotkey" + ], + "properties": { + "commission": { + "type": "string" + }, + "hotkey": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, { "type": "object", "required": [ @@ -1425,10 +1450,37 @@ ], "properties": { "sudo_set_subnet_metadata": { + "type": "object", + "required": [ + "metadata", + "netuid" + ], + "properties": { + "metadata": { + "$ref": "#/definitions/Metadata" + }, + "netuid": { + "type": "integer", + "format": "uint16", + "minimum": 0.0 + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "sudo_set_subnet_owner" + ], + "properties": { + "sudo_set_subnet_owner": { "type": "object", "required": [ "netuid", - "particle" + "new_owner" ], "properties": { "netuid": { @@ -1436,7 +1488,7 @@ "format": "uint16", "minimum": 0.0 }, - "particle": { + "new_owner": { "type": "string" } }, @@ -1444,9 +1496,126 @@ } }, "additionalProperties": false + }, + { + "type": "object", + "required": [ + "sudo_set_root" + ], + "properties": { + "sudo_set_root": { + "type": "object", + "required": [ + "new_root" + ], + "properties": { + "new_root": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "sudo_set_verse_metadata" + ], + "properties": { + "sudo_set_verse_metadata": { + "type": "object", + "required": [ + "metadata" + ], + "properties": { + "metadata": { + "$ref": "#/definitions/Metadata" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "sudo_unstake_all" + ], + "properties": { + "sudo_unstake_all": { + "type": "object", + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "sudo_set_commission_change" + ], + "properties": { + "sudo_set_commission_change": { + "type": "object", + "required": [ + "change" + ], + "properties": { + "change": { + "type": "boolean" + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false } ], "definitions": { + "Metadata": { + "type": "object", + "required": [ + "description", + "extra", + "logo", + "name", + "particle", + "types" + ], + "properties": { + "description": { + "type": "string" + }, + "extra": { + "type": "string" + }, + "logo": { + "type": "string" + }, + "name": { + "type": "string" + }, + "particle": { + "type": "string" + }, + "types": { + "type": "string" + } + } + }, "Uint128": { "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", "type": "string" diff --git a/cybertensor/contract/schema/query.json b/cybertensor/contract/schema/query.json index 3904130..11b2002 100644 --- a/cybertensor/contract/schema/query.json +++ b/cybertensor/contract/schema/query.json @@ -648,29 +648,6 @@ }, "additionalProperties": false }, - { - "type": "object", - "required": [ - "get_subnetwork_n" - ], - "properties": { - "get_subnetwork_n": { - "type": "object", - "required": [ - "netuid" - ], - "properties": { - "netuid": { - "type": "integer", - "format": "uint16", - "minimum": 0.0 - } - }, - "additionalProperties": false - } - }, - "additionalProperties": false - }, { "type": "object", "required": [ @@ -862,6 +839,99 @@ }, "additionalProperties": false }, + { + "type": "object", + "required": [ + "get_block_rewards" + ], + "properties": { + "get_block_rewards": { + "type": "object", + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "get_subnet_metadata" + ], + "properties": { + "get_subnet_metadata": { + "type": "object", + "required": [ + "netuid" + ], + "properties": { + "netuid": { + "type": "integer", + "format": "uint16", + "minimum": 0.0 + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "get_subnets_metadata" + ], + "properties": { + "get_subnets_metadata": { + "type": "object", + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint16", + "minimum": 0.0 + }, + "start_after": { + "type": [ + "integer", + "null" + ], + "format": "uint16", + "minimum": 0.0 + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "get_verse_metadata" + ], + "properties": { + "get_verse_metadata": { + "type": "object", + "additionalProperties": false + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "get_economy" + ], + "properties": { + "get_economy": { + "type": "object", + "additionalProperties": false + } + }, + "additionalProperties": false + }, { "type": "object", "required": [ diff --git a/cybertensor/messages/network.py b/cybertensor/messages/network.py index 1044c95..765be05 100644 --- a/cybertensor/messages/network.py +++ b/cybertensor/messages/network.py @@ -16,6 +16,7 @@ # DEALINGS IN THE SOFTWARE. import time +import json from cosmpy.aerial.wallet import LocalWallet from cosmpy.crypto.keypairs import PrivateKey @@ -173,7 +174,7 @@ def set_hyperparameter_message( with console.status( f":satellite: Setting hyperparameter {parameter} to {value} on subnet: {netuid} ..." ): - _value = int(value) if parameter != 'particle' else str(value) + _value = int(value) if parameter != 'metadata' else json.loads(value) sudo_msg = { str(message): {"netuid": netuid, str(parameter): _value}, } @@ -188,7 +189,7 @@ def set_hyperparameter_message( f":exclamation_mark: [yellow]Warning[/yellow]: TX {tx.tx_hash} broadcasted without confirmation..." ) else: - tx = cwtensor.contract.execute(sudo_msg, signer_wallet, gas) + tx = cwtensor.contract.execute(sudo_msg, sender=signer_wallet, gas_limit=gas) console.print( f":satellite: [green]Processing..[/green]: TX {tx.tx_hash} waiting to complete..." ) From 140c27f8e4a48841b9a638f1342256546bda1643 Mon Sep 17 00:00:00 2001 From: Serge Nedashkovsky Date: Thu, 13 Jun 2024 15:42:28 +1000 Subject: [PATCH 6/6] - update requirements --- requirements/prod.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements/prod.txt b/requirements/prod.txt index 6f7b6e0..e3a3173 100644 --- a/requirements/prod.txt +++ b/requirements/prod.txt @@ -29,7 +29,7 @@ rich setuptools<=65.6.3 shtab==1.6.5 termcolor -torch==1.13.1 +torch>=1.13.1 tqdm uvicorn==0.22.0 wheel