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 Space Pussy network #14

Closed
wants to merge 4 commits into from
Closed
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
33 changes: 29 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@

## Install

From source:
1. From source:
```bash
git clone https://github.com/cybercongress/cybertensor.git
python3 -m pip install -e cybertensor/
```

To test your installation, type:
2. To test your installation, type:
```bash
ctcli --help
```
Expand All @@ -21,6 +20,32 @@ or using python
import cybertensor
```

## Space Pussy setup

1. Clone:
```bash
git clone https://github.com/cybercongress/cybertensor.git
cd cybertensor
git checkout add-space-pussy-network
```
2. [Optional] Create and activate a virtual environment:
```bash
python3 -m venv venv
. venv/bin/activate
```
3. Install from the source
```bash
python3 -m pip install -e .
```

4. To test your installation, type:
```bash
ctcli --help
```
or using python
```python
import cybertensor
```

## Dev setup
1. Use localbostrom:
Expand Down Expand Up @@ -64,4 +89,4 @@ tree ~/.cybertensor/contract
7. Register network:
```bash
ctcli s create
```
```
32 changes: 21 additions & 11 deletions cybertensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,15 @@ def debug(on: bool = True):
__delegates_details_url__: str = "https://raw.githubusercontent.com/cybercongress/cybertensor/main/public/delegates.json"

# Bostrom network address prefix
__chain_address_prefix__ = "bostrom"
__chain_address_prefix__ = "pussy"

__networks__ = ["local", "bostrom"]
__networks__ = ["local", "space-pussy", "bostrom"]

__contracts__ = [
"bostrom14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sww4mxt",
"bostrom14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sww4mxt"
]
__contracts__ = {
"space-pussy": "pussy13xxjfq8p3kht26fn4s9jg8c5407xpphhle2744gwe4rgh2y47n4q7f7x63",
"local": "bostrom14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sww4mxt",
"bostrom": "bostrom14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sww4mxt"
}

__local_network__ = NetworkConfig(
chain_id="localbostrom",
Expand All @@ -106,23 +107,32 @@ def debug(on: bool = True):

__bostrom_network__ = NetworkConfig(
chain_id="bostrom",
url="grpc+http://localhost:9090",
fee_minimum_gas_price=0.1,
url="grpc+http://grpc.bostrom.cybernode.ai:1443",
fee_minimum_gas_price=0.01,
fee_denomination="boot",
staking_denomination="boot",
faucet_url="",
)

__space_pussy_network__ = NetworkConfig(
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="",
)

__contract_path__ = Path(__file__).home() / ".cybertensor/contract/cybernet.wasm"
__contract_schema_path__ = Path(__file__).home() / ".cybertensor/contract/schema"

__token__ = "boot"
__token__ = "pussy"

__default_gas__ = 1_000_000
__default_transfer_gas__ = 100_000

__boot_symbol__: str = "BOOT"
__giga_boot_symbol__: str = "GBOOT"
__boot_symbol__: str = "PUSSY"
__giga_boot_symbol__: str = "GPUSSY"

# change to emoji here
# __boot_symbol__: str = chr(0x03C4)
Expand Down
2 changes: 1 addition & 1 deletion cybertensor/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def __init__(
cli.check_config(self.config)

# If no_version_checking is not set or set as False in the config, version checking is done.
if not self.config.get("no_version_checking", d=True):
if self.config.get("no_version_checking", d=True):
try:
cybertensor.utils.version_checking()
except:
Expand Down
2 changes: 1 addition & 1 deletion cybertensor/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
defaults: Munch = munchify(
{
"netuid": 1,
"cwtensor": {"network": "local", "_mock": False},
"cwtensor": {"network": "space-pussy", "_mock": False},
"pow_register": {
"num_processes": None,
"update_interval": 50000,
Expand Down
34 changes: 13 additions & 21 deletions cybertensor/commands/delegates.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,18 +332,16 @@ def check_config(config: "cybertensor.config"):
# Get amount.
if not config.get("amount") and not config.get("stake_all"):
if not Confirm.ask(
"Stake all GBOOT from account: [bold]'{}'[/bold]?".format(
config.wallet.get("name", defaults.wallet.name)
)
f"Stake all {cybertensor.__giga_boot_symbol__} "
f"from account: [bold]'{config.wallet.get('name', defaults.wallet.name)}'[/bold]?"
):
amount = Prompt.ask("Enter GBOOT amount to stake")
amount = Prompt.ask(f"Enter {cybertensor.__giga_boot_symbol__} amount to stake")
try:
config.amount = float(amount)
except ValueError:
console.print(
":cross_mark: [red]Invalid GBOOT amount[/red] [bold white]{}[/bold white]".format(
amount
)
f":cross_mark: [red]Invalid {cybertensor.__giga_boot_symbol__} amount[/red] "
f"[bold white]{amount}[/bold white]"
)
sys.exit()
else:
Expand Down Expand Up @@ -443,35 +441,29 @@ def check_config(config: "cybertensor.config"):

if len(delegates) == 0:
console.print(
":cross_mark: [red]There are no delegates on {}[/red]".format(
cwtensor.network
)
f":cross_mark: [red]There are no delegates on {cwtensor.network}[/red]"
)
sys.exit(1)

delegates.sort(key=lambda delegate: delegate.total_stake, reverse=True)
show_delegates(config, delegates, prev_delegates=prev_delegates)
delegate_index = Prompt.ask("Enter delegate index")
config.delegatekey = str(delegates[int(delegate_index)].hotkey)
console.print(
"Selected: [yellow]{}[/yellow]".format(config.delegatekey)
)
console.print(f"Selected: [yellow]{config.delegatekey}[/yellow]")

# Get amount.
if not config.get("amount") and not config.get("unstake_all"):
if not Confirm.ask(
"Unstake all GBOOT to account: [bold]'{}'[/bold]?".format(
config.wallet.get("name", defaults.wallet.name)
)
f"Unstake all {cybertensor.__giga_boot_symbol__} "
f"to account: [bold]'{config.wallet.get('name', defaults.wallet.name)}'[/bold]?"
):
amount = Prompt.ask("Enter GBOOT amount to unstake")
amount = Prompt.ask(f"Enter {cybertensor.__giga_boot_symbol__} amount to unstake")
try:
config.amount = float(amount)
except ValueError:
console.print(
":cross_mark: [red]Invalid GBOOT amount[/red] [bold white]{}[/bold white]".format(
amount
)
f":cross_mark: [red]Invalid {cybertensor.__giga_boot_symbol__} amount[/red] "
f"[bold white]{amount}[/bold white]"
)
sys.exit()
else:
Expand Down Expand Up @@ -826,7 +818,7 @@ def run(cli):
)

cybertensor.__console__.print(table)
cybertensor.__console__.print("Total delegated GBOOT: {}".format(total_delegated))
cybertensor.__console__.print(f"Total delegated {cybertensor.__giga_boot_symbol__}: {total_delegated}")

@staticmethod
def add_args(parser: argparse.ArgumentParser):
Expand Down
4 changes: 1 addition & 3 deletions cybertensor/commands/overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,7 @@ def overview_sort_function(row):

console.clear()

caption = "[italic][dim][white]Wallet balance: [green]GBOOT" + str(
total_balance.gboot
)
caption = f"[italic][dim][white]Wallet balance: [green]{cybertensor.__giga_boot_symbol__}{total_balance.gboot}"
grid.add_row(Align(caption, vertical="middle", align="center"))

# Print the entire table/grid
Expand Down
14 changes: 6 additions & 8 deletions cybertensor/commands/stake.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,18 +219,16 @@ def check_config(cls, config: "cybertensor.config"):
and not config.get("max_stake")
):
if not Confirm.ask(
"Stake all GBOOT from account: [bold]'{}'[/bold]?".format(
config.wallet.get("name", defaults.wallet.name)
)
f"Stake all {cybertensor.__giga_boot_symbol__} "
f"from account: [bold]'{config.wallet.get('name', defaults.wallet.name)}'[/bold]?"
):
amount = Prompt.ask("Enter GBOOT amount to stake")
amount = Prompt.ask(f"Enter {cybertensor.__giga_boot_symbol__} amount to stake")
try:
config.amount = float(amount)
except ValueError:
console.print(
":cross_mark:[red]Invalid GBOOT amount[/red] [bold white]{}[/bold white]".format(
amount
)
f":cross_mark:[red]Invalid {cybertensor.__giga_boot_symbol__} amount[/red] "
f"[bold white]{amount}[/bold white]"
)
sys.exit()
else:
Expand All @@ -251,7 +249,7 @@ def add_args(cls, parser: argparse.ArgumentParser):
required=False,
action="store",
default=None,
help="""Specify the maximum amount of GBOOT to have staked in each hotkey.""",
help=f"""Specify the maximum amount of {cybertensor.__giga_boot_symbol__} to have staked in each hotkey.""",
)
stake_parser.add_argument(
"--hotkeys",
Expand Down
27 changes: 18 additions & 9 deletions cybertensor/cwtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def help(cls):
def add_args(cls, parser: argparse.ArgumentParser, prefix: str = None):
prefix_str = "" if prefix is None else prefix + "."
try:
default_network = os.getenv("CT_CYBER_NETWORK") or "local"
default_network = os.getenv("CT_CYBER_NETWORK") or "space-pussy"
# default_contract_address = os.getenv("CT_CONTRACT_ADDRESS") or "bostrom1"

parser.add_argument(
Expand All @@ -113,6 +113,7 @@ def add_args(cls, parser: argparse.ArgumentParser, prefix: str = None):
help="""The cwtensor network flag. The likely choices are:
-- bostrom (main network)
-- local (local running network)
-- space-pussy (space-pussy network)
""",
)

Expand All @@ -137,25 +138,32 @@ def determine_chain_endpoint_and_network(
network (str): The network flag. The likely choices are:
-- bostrom (main network)
-- local (local running network)
chain_endpoint (str): The chain endpoint flag. If set, overrides the network argument.
-- space-pussy (space-pussy network)
Returns:
network (str): The network flag. The likely choices are:
chain_endpoint (str): The chain endpoint flag. If set, overrides the network argument.
network (str): The network flag.
network_config (NetworkConfig): The chain network config.
contract_address (str): Cybernet contract address
"""
if network is None:
return None, None, None
if network in ["local", "bostrom"]:
if network in ["local", "bostrom", "space-pussy"]:
if network == "bostrom":
return (
network,
cybertensor.__bostrom_network__,
cybertensor.__contracts__[1],
cybertensor.__contracts__[network],
)
elif network == "space-pussy":
return (
network,
cybertensor.__space_pussy_network__,
cybertensor.__contracts__[network],
)
elif network == "local":
return (
network,
cybertensor.__local_network__,
cybertensor.__contracts__[0],
cybertensor.__contracts__[network],
)
else:
return "unknown", {}, "unknown"
Expand Down Expand Up @@ -192,7 +200,7 @@ def setup_config(network: str, config: cybertensor.config):
evaluated_contract_address,
) = cwtensor.determine_chain_endpoint_and_network(
# TODO set default
"local"
"space-pussy"
)

return (
Expand All @@ -213,8 +221,9 @@ def __init__(
cybertensor.cwtensor.config()
network (default='local or ws://127.0.0.1:9946', type=str)
The cwtensor network flag. The likely choices are:
-- bostrom (main network)
-- local (local running network)
-- finney (main network)
-- space-pussy (space-pussy network)
or cwtensor endpoint flag. If set, overrides the network argument.
"""

Expand Down
7 changes: 3 additions & 4 deletions cybertensor/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ def version_checking(timeout: int = 15):

if latest_version_as_int > cybertensor.__version_as_int__:
print(
"\u001b[33mCybertensor Version: Current {}/Latest {}\nPlease update to the latest version at your earliest convenience. "
"Run the following command to upgrade:\n\n\u001b[0mpython -m pip install --upgrade cybertensor".format(
cybertensor.__version__, latest_version
)
f"\u001b[33mCybertensor Version: Current {cybertensor.__version__}/Latest {latest_version}\n"
f"Please update to the latest version at your earliest convenience. "
f"Run the following command to upgrade:\n\n\u001b[0mpython -m pip install --upgrade cybertensor"
)

except requests.exceptions.Timeout:
Expand Down
1 change: 1 addition & 0 deletions cybertensor/utils/networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
""" Utils for handling local network with ip and ports.
"""


def int_to_ip(int_val: int) -> str:
r"""Maps an integer to a unique ip-string
Args:
Expand Down