Skip to content

Commit

Permalink
Release/6.4.2 (#1611)
Browse files Browse the repository at this point in the history
* add timeout to websock, resolves hanging issue (#1609)

* add timeout to websock, resolves hanging issue

* add timeout set try/catch

* add ability to turn off verbose logging for btcli cmds (#1608)

* add ability to turn off verbose logging for btcli cmds

* black

* Add taostats explorer to map (#1607)

* add taostats explorer to map and printed list of links for transfers

* update test for explorer

* add polkascan explorer endpoint

* fix endpoint tests

* table set take command

This is intended as a fix for squash+merge issues that arise when
merging master back into staging. Then PRs on github (not git) show
the unsquashed commits when attempting to create a new release branch.

* update changelog, version

* don't log in process pool for stake command

* Sudo/hyperparams pallet update (#1612)

* Update hyperparams set extrinsic to use AdminUtils pallet

* update metadata call

---------

Co-authored-by: Ayden Brewer <dalegribble@riseup.net>
Co-authored-by: philanthrope <ifrit98@gmail.com>

* update changelog 1-sentence info

* fix ful changelog diff

* fix full changelog diff

* fix changelog for 6.4.2

* fix readme typos

* Hyperparams get update (#1614)

* fixes `btcli sudo get`

* black

---------

Co-authored-by: Eugene-hu <85906264+Eugene-hu@users.noreply.github.com>
Co-authored-by: Ayden Brewer <dalegribble@riseup.net>
  • Loading branch information
3 people authored Dec 11, 2023
1 parent 2f7dd30 commit b428dd0
Show file tree
Hide file tree
Showing 13 changed files with 121 additions and 70 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
# Changelog

## 6.4.2 / 2023-12-07

## What's Changed
* Fix broken explorer links https://github.com/opentensor/bittensor/pull/1607
* Fix spamming bittensor subtensor logging https://github.com/opentensor/bittensor/pull/1608
* Fix hanging subtensor websocket https://github.com/opentensor/bittensor/pull/1609
* Hparam update to palette: https://github.com/opentensor/bittensor/pull/1612

**Full Changelog**: https://github.com/opentensor/bittensor/compare/v6.4.1...v6.4.2


## 6.4.1 / 2023-12-01

## What's Changed
* add helpful messages to signal coming changes in https://github.com/opentensor/bittensor/pull/1600/commits/86c0c3ccfcd91d0e3ff87f53bdc3e9c5e68661da
* revert default subtensor network to finney in https://github.com/opentensor/bittensor/pull/1600/commits/8c69a3c15cd556384d0309e951f0a9b164dd36cb

**Full Changelog**: https://github.com/opentensor/bittensor/compare/v6.0.1...v6.4.1
**Full Changelog**: https://github.com/opentensor/bittensor/compare/v6.4.0...v6.4.1


## 6.4.0 / 2023-11-29
Expand Down
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ positional arguments:
lock_cost Return the lock cost to register a subnet.
create Create a new bittensor subnetwork on this chain.
register Register a wallet to a network.
register Register a wallet to a network using PoW.
pow_register Register a wallet to a network using PoW.
hyperparameters View subnet hyperparameters.

options:
Expand Down Expand Up @@ -282,28 +282,28 @@ Axon: Serves Synapse protocols with custom blacklist, priority and verify functi
```python
import bittensor
class MySyanpse( bittensor.Synapse ):
class MySynapse( bittensor.Synapse ):
input: int = 1
output: int = None
# Define a custom request forwarding function
def forward( synapse: MySyanpse ) -> MySyanpse:
def forward( synapse: MySynapse ) -> MySynapse:
# Apply custom logic to synapse and return it
synapse.output = 2
return synapse
# Define a custom request verification function
def verify_my_synapse( synapse: MySyanpse ):
def verify_my_synapse( synapse: MySynapse ):
# Apply custom verification logic to synapse
# Optionally raise Exception
# Define a custom request blacklist function
def blacklist_my_synapse( synapse: MySyanpse ) -> bool:
def blacklist_my_synapse( synapse: MySynapse ) -> bool:
# Apply custom blacklist
# return False ( if non blacklisted ) or True ( if blacklisted )
# Define a custom request priority function
def prioritize_my_synape( synapse: MySyanpse ) -> float:
def prioritize_my_synape( synapse: MySynapse ) -> float:
# Apply custom priority
return 1.0
Expand All @@ -321,6 +321,7 @@ my_axon.attach(

Dendrite: Inheriting from PyTorch's Module class, represents the abstracted implementation of a network client module designed
to send requests to those endpoints to receive inputs.
Example:
```python
dendrite_obj = dendrite( wallet = bittensor.wallet() )
Expand All @@ -340,7 +341,7 @@ Use the `root` subcommand to access setting weights on the network across subnet
```bash
btcli root weights --wallet.name <coldname> --wallet.hotkey <hotname>
Enter netuids (e.g. 0, 1, 2 ...):
# Here enter your selected netuids to wet weights on
# Here enter your selected netuids to set weights on
1, 2
>Enter weights (e.g. 0.09, 0.09, 0.09 ...):
Expand Down Expand Up @@ -377,4 +378,4 @@ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR I
## Acknowledgments
**learning-at-home/hivemind**
**learning-at-home/hivemind**
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.4.1
6.4.2
15 changes: 11 additions & 4 deletions bittensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
nest_asyncio.apply()

# Bittensor code and protocol version.
__version__ = "6.4.1"
__version__ = "6.4.2"
version_split = __version__.split(".")
__version_as_int__ = (
(100 * int(version_split[0]))
Expand Down Expand Up @@ -107,9 +107,16 @@ def debug(on: bool = True):
# Block Explorers map network to explorer url
## Must all be polkadotjs explorer urls
__network_explorer_map__ = {
"local": "https://explorer.finney.opentensor.ai/#/explorer",
"endpoint": "https://explorer.finney.opentensor.ai/#/explorer",
"finney": "https://explorer.finney.opentensor.ai/#/explorer",
"opentensor": {
"local": "https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fentrypoint-finney.opentensor.ai%3A443#/explorer",
"endpoint": "https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fentrypoint-finney.opentensor.ai%3A443#/explorer",
"finney": "https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Fentrypoint-finney.opentensor.ai%3A443#/explorer",
},
"taostats": {
"local": "https://x.taostats.io",
"endpoint": "https://x.taostats.io",
"finney": "https://x.taostats.io",
},
}

# --- Type Registry ---
Expand Down
6 changes: 6 additions & 0 deletions bittensor/chain_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@
["max_burn", "Compact<u64>"],
["bonds_moving_avg", "Compact<u64>"],
["max_regs_per_block", "Compact<u16>"],
["serving_rate_limit", "Compact<u64>"],
["max_validators", "Compact<u16>"],
],
},
}
Expand Down Expand Up @@ -963,6 +965,8 @@ class SubnetHyperparameters:
max_burn: int
bonds_moving_avg: int
max_regs_per_block: int
serving_rate_limit: int
max_validators: int

@classmethod
def from_vec_u8(cls, vec_u8: List[int]) -> Optional["SubnetHyperparameters"]:
Expand Down Expand Up @@ -1013,6 +1017,8 @@ def fix_decoded_values(cls, decoded: Dict) -> "SubnetHyperparameters":
max_burn=decoded["max_burn"],
bonds_moving_avg=decoded["bonds_moving_avg"],
max_regs_per_block=decoded["max_regs_per_block"],
max_validators=decoded["max_validators"],
serving_rate_limit=decoded["serving_rate_limit"],
)

def to_parameter_dict(self) -> "torch.nn.ParameterDict":
Expand Down
1 change: 0 additions & 1 deletion bittensor/commands/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ def add_args(parser: argparse.ArgumentParser):
"immunity_period": "sudo_set_immunity_period",
"min_allowed_weights": "sudo_set_min_allowed_weights",
"activity_cutoff": "sudo_set_activity_cutoff",
"max_validators": "sudo_set_max_allowed_validators",
}


Expand Down
4 changes: 2 additions & 2 deletions bittensor/commands/overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ def _get_neurons_for_netuid(
result: List["bittensor.NeuronInfoLite"] = []

try:
subtensor = bittensor.subtensor(config=subtensor_config)
subtensor = bittensor.subtensor(config=subtensor_config, log_verbose=False)

all_neurons: List["bittensor.NeuronInfoLite"] = subtensor.neurons_lite(
netuid=netuid
Expand Down Expand Up @@ -587,7 +587,7 @@ def _get_de_registered_stake_for_coldkey_wallet(
result: List[Tuple[str, "bittensor.Balance"]] = []

try:
subtensor = bittensor.subtensor(config=subtensor_config)
subtensor = bittensor.subtensor(config=subtensor_config, log_verbose=False)

# Pull all stake for our coldkey
all_stake_info_for_coldkey = subtensor.get_stake_info_for_coldkey(
Expand Down
2 changes: 1 addition & 1 deletion bittensor/commands/stake.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def get_stake_accounts(wallet) -> Dict[str, Dict[str, Union[str, Balance]]]:
Returns:
A dictionary mapping SS58 addresses to their respective stake account details.
"""
subtensor = bittensor.subtensor(config=cli.config)
subtensor = bittensor.subtensor(config=cli.config, log_verbose=False)

wallet_stake_accounts = {}

Expand Down
4 changes: 2 additions & 2 deletions bittensor/extrinsics/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,15 @@ def set_hyperparameter_extrinsic(
):
with subtensor.substrate as substrate:
extrinsic_params = substrate.get_metadata_call_function(
"SubtensorModule", extrinsic
"AdminUtils", extrinsic
)
value_argument = extrinsic_params["fields"][
len(extrinsic_params["fields"]) - 1
]

# create extrinsic call
call = substrate.compose_call(
call_module="SubtensorModule",
call_module="AdminUtils",
call_function=extrinsic,
call_params={"netuid": netuid, str(value_argument["name"]): value},
)
Expand Down
13 changes: 10 additions & 3 deletions bittensor/extrinsics/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,19 @@ def transfer_extrinsic(
"[green]Block Hash: {}[/green]".format(block_hash)
)

explorer_url = bittensor.utils.get_explorer_url_for_network(
explorer_urls = bittensor.utils.get_explorer_url_for_network(
subtensor.network, block_hash, bittensor.__network_explorer_map__
)
if explorer_url is not None:
if explorer_urls != {}:
bittensor.__console__.print(
"[green]Explorer Link: {}[/green]".format(explorer_url)
"[green]Opentensor Explorer Link: {}[/green]".format(
explorer_urls.get("opentensor")
)
)
bittensor.__console__.print(
"[green]Taostats Explorer Link: {}[/green]".format(
explorer_urls.get("taostats")
)
)
else:
bittensor.__console__.print(
Expand Down
8 changes: 7 additions & 1 deletion bittensor/subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ def __init__(
network: str = None,
config: "bittensor.config" = None,
_mock: bool = False,
log_verbose: bool = True,
) -> None:
"""
Initializes a Subtensor interface for interacting with the Bittensor blockchain.
Expand Down Expand Up @@ -333,7 +334,7 @@ def __init__(
if (
self.network == "finney"
or self.chain_endpoint == bittensor.__finney_entrypoint__
):
) and log_verbose:
bittensor.logging.info(
f"You are connecting to {self.network} network with endpoint {self.chain_endpoint}."
)
Expand Down Expand Up @@ -375,6 +376,11 @@ def __init__(
exit(1)
# TODO (edu/phil): Advise to run local subtensor and point to dev docs.

try:
self.substrate.websocket.settimeout(600)
except:
bittensor.logging.warning("Could not set websocket timeout.")

bittensor.logging.info(
f"Connected to {self.network} network and {self.chain_endpoint}."
)
Expand Down
38 changes: 22 additions & 16 deletions bittensor/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ def strtobool(val: str) -> Union[bool, Literal["==SUPRESS=="]]:


def get_explorer_root_url_by_network_from_map(
network: str, network_map: Dict[str, str]
) -> Optional[str]:
network: str, network_map: Dict[str, Dict[str, str]]
) -> Optional[Dict[str, str]]:
r"""
Returns the explorer root url for the given network name from the given network map.
Expand All @@ -136,42 +136,48 @@ def get_explorer_root_url_by_network_from_map(
The explorer url for the given network.
Or None if the network is not in the network map.
"""
explorer_url: Optional[str] = None
if network in network_map:
explorer_url = network_map[network]
explorer_urls: Optional[Dict[str, str]] = {}
for entity_nm, entity_network_map in network_map.items():
if network in entity_network_map:
explorer_urls[entity_nm] = entity_network_map[network]

return explorer_url
return explorer_urls


def get_explorer_url_for_network(
network: str, block_hash: str, network_map: Dict[str, str]
) -> Optional[str]:
) -> Optional[List[str]]:
r"""
Returns the explorer url for the given block hash and network.
Args:
network(str): The network to get the explorer url for.
block_hash(str): The block hash to get the explorer url for.
network_map(Dict[str, str]): The network map to get the explorer url from.
network_map(Dict[str, Dict[str, str]]): The network maps to get the explorer urls from.
Returns:
The explorer url for the given block hash and network.
Or None if the network is not known.
"""

explorer_url: Optional[str] = None
explorer_urls: Optional[Dict[str, str]] = {}
# Will be None if the network is not known. i.e. not in network_map
explorer_root_url: Optional[str] = get_explorer_root_url_by_network_from_map(
network, network_map
)
explorer_root_urls: Optional[
Dict[str, str]
] = get_explorer_root_url_by_network_from_map(network, network_map)

if explorer_root_url is not None:
if explorer_root_urls != {}:
# We are on a known network.
explorer_url = "{root_url}/query/{block_hash}".format(
root_url=explorer_root_url, block_hash=block_hash
explorer_opentensor_url = "{root_url}/query/{block_hash}".format(
root_url=explorer_root_urls.get("opentensor"), block_hash=block_hash
)
explorer_taostats_url = "{root_url}/search?query={block_hash}".format(
root_url=explorer_root_urls.get("taostats"), block_hash=block_hash
)
explorer_urls["opentensor"] = explorer_opentensor_url
explorer_urls["taostats"] = explorer_taostats_url

return explorer_url
return explorer_urls


def ss58_address_to_bytes(ss58_address: str) -> bytes:
Expand Down
Loading

0 comments on commit b428dd0

Please sign in to comment.