Skip to content

Commit

Permalink
Merge pull request #20 from cybercongress/flow-feedback
Browse files Browse the repository at this point in the history
Updates based on flow guide feedback
  • Loading branch information
cyborgshead authored Feb 9, 2024
2 parents b73b609 + 4720643 commit 94a041f
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 55 deletions.
2 changes: 2 additions & 0 deletions cybertensor/chain_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ class SubnetInfo:
emission_value: float
burn: Balance
owner: str
metadata: str

@classmethod
def from_list_any(cls, list_any: List[Any]) -> Optional["SubnetInfo"]:
Expand Down Expand Up @@ -613,6 +614,7 @@ def fix_decoded_values(cls, decoded: Dict) -> "SubnetInfo":
emission_value=decoded["emission_values"],
burn=Balance.from_boot(decoded["burn"]),
owner=decoded["owner"],
metadata=decoded["metadata"],
)

def to_parameter_dict(self) -> "torch.nn.ParameterDict":
Expand Down
59 changes: 24 additions & 35 deletions cybertensor/commands/delegates.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ def show_delegates(
table.add_row(
str(i),
Text(delegate_name, style=f"link {delegate_url}"),
f"{delegate.hotkey:16.16}...",
f"{delegate.hotkey[:16]}...{delegate.hotkey[-8:]}",
# f"{delegate.hotkey}",
str(len([nom for nom in delegate.nominators if nom[1].boot > 0])),
f"{owner_stake!s:13.13}",
f"{delegate.total_stake!s:13.13}",
Expand Down Expand Up @@ -328,21 +329,15 @@ def check_config(config: "cybertensor.config"):

# Get amount.
if not config.get("amount") and not config.get("stake_all"):
if not Confirm.ask(
f"Stake all {cwtensor.giga_token_symbol} "
f"from account: [bold]'{config.wallet.get('name', defaults.wallet.name)}'[/bold]?"
):
amount = Prompt.ask(f"Enter {cwtensor.giga_token_symbol} amount to stake")
try:
config.amount = float(amount)
except ValueError:
console.print(
f":cross_mark: [red]Invalid {cwtensor.giga_token_symbol} amount[/red] "
f"[bold white]{amount}[/bold white]"
)
sys.exit()
else:
config.stake_all = True
amount = Prompt.ask(f"Enter {cwtensor.giga_token_symbol} amount to stake")
try:
config.amount = float(amount)
except ValueError:
console.print(
f":cross_mark: [red]Invalid {cwtensor.giga_token_symbol} amount[/red] "
f"[bold white]{amount}[/bold white]"
)
sys.exit()


class DelegateUnstakeCommand:
Expand Down Expand Up @@ -450,21 +445,15 @@ def check_config(config: "cybertensor.config"):

# Get amount.
if not config.get("amount") and not config.get("unstake_all"):
if not Confirm.ask(
f"Unstake all {cwtensor.giga_token_symbol} "
f"to account: [bold]'{config.wallet.get('name', defaults.wallet.name)}'[/bold]?"
):
amount = Prompt.ask(f"Enter {cwtensor.giga_token_symbol} amount to unstake")
try:
config.amount = float(amount)
except ValueError:
console.print(
f":cross_mark: [red]Invalid {cwtensor.giga_token_symbol} amount[/red] "
f"[bold white]{amount}[/bold white]"
)
sys.exit()
else:
config.unstake_all = True
amount = Prompt.ask(f"Enter {cwtensor.giga_token_symbol} amount to unstake")
try:
config.amount = float(amount)
except ValueError:
console.print(
f":cross_mark: [red]Invalid {cwtensor.giga_token_symbol} amount[/red] "
f"[bold white]{amount}[/bold white]"
)
sys.exit()


class ListDelegatesCommand:
Expand Down Expand Up @@ -671,9 +660,9 @@ class MyDelegatesCommand:
--all flag can be specified to aggregate information across all wallets.
Example usage:
>>> ctcli my_delegates
>>> ctcli my_delegates --all
>>> ctcli my_delegates --wallet.name my_wallet
>>> ctcli root my_delegates
>>> ctcli root my_delegates --all
>>> ctcli root my_delegates --wallet.name my_wallet
Note:
This function is typically called by the CLI parser and is not intended to be used
Expand Down Expand Up @@ -795,7 +784,7 @@ def run(cli):
table.add_row(
wallet.name,
Text(delegate_name, style=f"link {delegate_url}"),
f"{delegate[0].hotkey:16.16}...",
f"{delegate[0].hotkey[:16]}...{delegate[0].hotkey[-8:]}",
f"{my_delegates[delegate[0].hotkey]!s:16.16}",
f"{delegate[0].total_daily_return.gboot * (my_delegates[delegate[0].hotkey] / delegate[0].total_stake.gboot)!s:6.6}",
str(len(delegate[0].nominators)),
Expand Down
4 changes: 2 additions & 2 deletions cybertensor/commands/metagraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ def run(cli):
ep.ip + ":" + str(ep.port)
if ep.is_serving
else "[yellow]none[/yellow]",
ep.hotkey[:16],
ep.coldkey[:16]
f"{ep.hotkey[:14]}...{ep.hotkey[-6:]}",
f"{ep.coldkey[:14]}...{ep.coldkey[-6:]}"
]
total_stake += metagraph.total_stake[uid]
total_rank += metagraph.ranks[uid]
Expand Down
2 changes: 2 additions & 0 deletions cybertensor/commands/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ def run(cli):
# TODO revisit
# f"{delegate_info[subnet.owner_ss58].name if subnet.owner_ss58 in delegate_info else subnet.owner_ss58}",
f"{delegate_info[subnet.owner].owner if subnet.owner in delegate_info else subnet.owner}",
f"{subnet.metadata}",
)
)
table = Table(
Expand Down Expand Up @@ -242,6 +243,7 @@ def run(cli):
table.add_column("[overline white]BURN", style="white", justify="center")
table.add_column("[overline white]POW", style="white", justify="center")
table.add_column("[overline white]SUDO", style="white")
table.add_column("[overline white]METADATA", style="white")
for row in rows:
table.add_row(*row)
cybertensor.__console__.print(table)
Expand Down
24 changes: 9 additions & 15 deletions cybertensor/commands/stake.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,21 +220,15 @@ def check_config(cls, config: "cybertensor.config"):
and not config.get("stake_all")
and not config.get("max_stake")
):
if not Confirm.ask(
f"Stake all {cybertensor.__giga_boot_symbol__} "
f"from account: [bold]'{config.wallet.get('name', defaults.wallet.name)}'[/bold]?"
):
amount = Prompt.ask(f"Enter {cybertensor.__giga_boot_symbol__} amount to stake")
try:
config.amount = float(amount)
except ValueError:
console.print(
f":cross_mark:[red]Invalid {cybertensor.__giga_boot_symbol__} amount[/red] "
f"[bold white]{amount}[/bold white]"
)
sys.exit()
else:
config.stake_all = True
amount = Prompt.ask(f"Enter {cybertensor.__giga_boot_symbol__} amount to stake")
try:
config.amount = float(amount)
except ValueError:
console.print(
f":cross_mark:[red]Invalid {cybertensor.__giga_boot_symbol__} amount[/red] "
f"[bold white]{amount}[/bold white]"
)
sys.exit()

@classmethod
def add_args(cls, parser: argparse.ArgumentParser):
Expand Down
9 changes: 6 additions & 3 deletions docs/basic-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,20 @@ You can list all the local wallets stored directly with:
```bash
ctcli wallet list
```
You need to fund your wallet's addresses with tokens to perform operations on the network. Ask friends or team to send your some tokens. You can send tokens from your existing account to addresses of your wallets.
You need to fund both of your addresses (hot and cold) of your wallet. Fund your hotkey with some small amount to pay for gas and fund your coldkey with the rest of the tokens to pay for gas and general network operations.

Get a detailed report of your wallet pairs (coldkey, hotkey). This report includes balance and staking information for both the coldkey and hotkey associated with the wallet.
```bash
ctcli wallet inspect
```

### Root network register
Make registration to the root network. Validators on the root network cast weights to subnets, voting to tokens distribution across subnets in the network. Total consensus weighted distribution to subnets calculated based on validators' stake and their assigned weights to subnets. The network continuously distributes tokens to subnets and these tokens are distributed to subnets operators and validators. All operators and validators of root network and subnets should continuously cast weights. Both root network and subnets have operators and validators. Validators are given a subset of the operators of the root network and subnets with a top-k stake. Only weights of validators are used for consensus algorithm calculation. Join the root network to participate in token distribution across subnets.

Register to the root network to participate in the distribution process of tokens across subnets:
```bash
- ctcli root register
ctcli root register
```

### Subnet network register
Expand Down Expand Up @@ -84,12 +87,12 @@ Let's set the weight on the subnet network. This weight represents your subjecti

Get a list of operators and weights assigned to each operator within the root network to each other:
```bash
ctcli subnet weights
ctcli subnet get_weights
```

Set weights to different operators within the subnet:
```bash
- ctcli subnet weights --uids 0,1,2,3 --weights 0.25,0.25,0.25,0.25
ctcli subnet weights --uids 0,1,2,3 --weights 0.25,0.25,0.25,0.25
```

### Delegate stake
Expand Down

0 comments on commit 94a041f

Please sign in to comment.