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

Chore: Backmerge 7.2 #2020

Merged
merged 97 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
913083a
add version
ifrit98 Mar 25, 2024
4fed844
add changelog
ifrit98 Mar 25, 2024
c5dabe0
Merge pull request #1757 from opentensor/release/6.10.0
ifrit98 Apr 4, 2024
ee41131
Revert "fix: nonce implementation". Must branded as a breaking chang…
ifrit98 Apr 5, 2024
5bf1b3f
prerelease
ifrit98 Apr 5, 2024
bfc7877
Merge pull request #1774 from opentensor/hotfix/6.10.1
ifrit98 Apr 5, 2024
65b3a31
chore: bump release version
gus-opentensor Apr 11, 2024
c31bc4b
Merge branch 'master' into release/6.11.0
gus-opentensor Apr 11, 2024
ce8e8dc
chore: changelog
gus-opentensor Apr 11, 2024
1040635
Merge branch 'release/6.11.0' of github.com:opentensor/bittensor into…
gus-opentensor Apr 11, 2024
c74fb15
Merge pull request #1782 from opentensor/release/6.11.0
gus-opentensor Apr 24, 2024
a83aa0c
chore: bump version
gus-opentensor Apr 29, 2024
ccaf6c7
doc: changelog
gus-opentensor Apr 29, 2024
4cec121
Merge branch 'master' into release/6.12.0
gus-opentensor Apr 29, 2024
6a20260
chore: fmt
gus-opentensor Apr 29, 2024
bfb5de7
Merge pull request #1824 from opentensor/release/6.12.0
gus-opentensor May 2, 2024
799a909
chore: update changelog
gus-opentensor May 17, 2024
167c99c
Merge branch 'master' into release/7.0.0
gus-opentensor May 17, 2024
f04e2c3
Updated version to 6.12.1
roman-opentensor May 17, 2024
c3bbc92
Hotfix if the subnet UID is not in the Subnets.
roman-opentensor May 17, 2024
fd2442d
Hotfix 6.12.1: Fixed typo
ibraheem-opentensor May 17, 2024
f71f797
chore: update changelog
gus-opentensor May 17, 2024
16f2604
Merge pull request #1902 from opentensor/release/6.12.1
garrett-opentensor May 17, 2024
b4919ec
feat: Add setting delegate take
gus-opentensor May 20, 2024
3e2ec71
chore: bump version
gus-opentensor May 20, 2024
d1d7653
chore: update changelog
gus-opentensor May 20, 2024
9ea370d
fmt
gus-opentensor May 20, 2024
54eee60
Improve: Introduced _do_set_root_weights
ibraheem-opentensor May 3, 2024
1790410
Update CHANGELOG.md
gus-opentensor May 20, 2024
10e4312
chore: update changelog
gus-opentensor May 17, 2024
c3b8d99
chore: backmerge pydantic
gus-opentensor May 21, 2024
ebcc8a3
chore: rm _do_set_root_weights
gus-opentensor May 22, 2024
bea05d6
fix: deprecated transfer method usage
orriin May 15, 2024
6f5bb73
Update CHANGELOG.md
gus-opentensor May 22, 2024
41412c2
Merge pull request #1910 from opentensor/release/6.12.2
gus-opentensor May 22, 2024
238d87b
Merge branch 'master' into release/7.0.0
gus-opentensor May 23, 2024
ec153c3
chore: fmt black
gus-opentensor May 23, 2024
06c5053
fix: import
gus-opentensor May 23, 2024
be4cb15
Update Pydantic Requirement to at least version 2.3 or greater.
opendansor May 23, 2024
3eb7eed
fix: logging import
gus-opentensor May 23, 2024
f376f02
Merge pull request #1917 from backend-developers-ltd/improve_no_torch
thewhaleking May 22, 2024
cd8a4df
Merge pull request #1919 from opentensor/thewhaleking/further-legacy-…
thewhaleking May 22, 2024
bba8118
Merge pull request #1937 from opentensor/thewhaleking/torch-compatibi…
thewhaleking May 24, 2024
7ad61ab
Merge pull request #1940 from opentensor/chore/abe/fix-take-msg
ibraheem-opentensor May 24, 2024
1904ebe
Removed delegates_lite functionality
ibraheem-opentensor May 28, 2024
45d41f2
Created a mock logger fixture so that object mutations don't break ot…
thewhaleking May 28, 2024
0a601d3
Chore: Updated dev requirements
ibraheem-opentensor May 28, 2024
75d21a4
Merge pull request #1946 from opentensor/chore/abe/update-dev-req
ibraheem-opentensor May 28, 2024
1c1f57c
7.0.0: Changelog updated
ibraheem-opentensor May 29, 2024
116cb8a
Merge pull request #1899 from opentensor/release/7.0.0
garrett-opentensor May 29, 2024
150c34c
Fix return of ip version.
opendansor May 31, 2024
39f0645
Fix return of ip version.
opendansor May 31, 2024
8633cb4
Merge remote-tracking branch 'origin/bugfix/opendansor/fix_ip_version…
opendansor May 31, 2024
a5a527a
Black
opendansor May 31, 2024
c38da2b
Merge pull request #1961 from opentensor/bugfix/opendansor/fix_ip_ver…
gus-opentensor May 31, 2024
d3d3dc5
chore: release notes + version
gus-opentensor May 31, 2024
e630210
Update CHANGELOG.md
gus-opentensor Jun 3, 2024
cf5c3e5
Merge pull request #1963 from opentensor/release/7.0.1
gus-opentensor Jun 3, 2024
f352f71
Improve: Introduced _do_set_root_weights
ibraheem-opentensor May 3, 2024
2b2c039
Merge pull request #1938 from opentensor/feature/opendansor/commit_we…
opendansor May 28, 2024
c07cc46
Chore: updated version
ibraheem-opentensor May 28, 2024
0331090
Root weights: Updated tests and logger
ibraheem-opentensor May 29, 2024
515ee09
chore: black formatting
ibraheem-opentensor May 29, 2024
536b23c
Merge pull request #1952 from opentensor/chore/opendansor/fix-commit-…
opendansor May 29, 2024
4f4d30d
chore: bump verion
gus-opentensor Jun 1, 2024
7c087ae
chore: Updates CHANGELOG
gus-opentensor Jun 1, 2024
9f7d4b4
chore: correct version
gus-opentensor Jun 4, 2024
5657e80
Merge pull request #1962 from dgagn/ovior/fix-networking-ipv6
gus-opentensor Jun 3, 2024
cda3eda
revert #1962 (ab36b85)
camfairchild Jun 5, 2024
87ebaba
chore: changelog
gus-opentensor Jun 5, 2024
08bb08d
Merge pull request #1975 from opentensor/release/7.1.0
gus-opentensor Jun 11, 2024
8346c21
fix commit_reveal_weights_enabled argument parsing
camfairchild Jun 11, 2024
32f1872
bump version
camfairchild Jun 11, 2024
d6b0550
add changelog entry
camfairchild Jun 11, 2024
066b9a9
bump version in-code also
camfairchild Jun 11, 2024
a8eca40
add test for hotfix bug
camfairchild Jun 11, 2024
c3696aa
add tests for other params
camfairchild Jun 11, 2024
0b475d5
run black
camfairchild Jun 11, 2024
0405867
Add 1 and 0 as booleans.
opendansor Jun 11, 2024
7ee133b
Add 1 and 0 as booleans.
opendansor Jun 11, 2024
bf1a27b
Merge remote-tracking branch 'origin/hotfix/7.1.1' into hotfix/7.1.1
opendansor Jun 11, 2024
ed3c69c
black
opendansor Jun 11, 2024
637c9ca
Merge pull request #2010 from opentensor/release/7.1.1
ibraheem-opentensor Jun 12, 2024
0c8449f
chore: changelog
gus-opentensor Jun 12, 2024
6d39b12
chore: bump version
gus-opentensor Jun 12, 2024
53c943c
Merge branch 'master' into release/7.2.0
gus-opentensor Jun 12, 2024
5db7b4c
chore: ruff
gus-opentensor Jun 12, 2024
365e4d7
fix: import
gus-opentensor Jun 12, 2024
6e27dc6
fix: adds _do_set_root_weights
gus-opentensor Jun 12, 2024
913c04e
chore: ruff
gus-opentensor Jun 12, 2024
ae1a5d0
Added missing nonce implementation
ibraheem-opentensor Jun 12, 2024
60bd367
chore: update changelog
gus-opentensor Jun 12, 2024
51afab8
chore: update changelog
gus-opentensor Jun 12, 2024
ea83f43
Merge pull request #2016 from opentensor/fix/allow-unstake-below-netw…
gus-opentensor Jun 12, 2024
f25fa40
Merge pull request #2018 from opentensor/release/7.2.0
garrett-opentensor Jun 12, 2024
c944079
Merge branch 'master' into staging
gus-opentensor Jun 13, 2024
949eac1
Merge branch 'staging' into chores/gus/backmerge-7.2
gus-opentensor Jun 13, 2024
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
202 changes: 190 additions & 12 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.0.0
7.2.0
3 changes: 1 addition & 2 deletions bittensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@


# Bittensor code and protocol version.
__version__ = "7.0.0"
__version__ = "7.2.0"

_version_split = __version__.split(".")
__version_info__ = tuple(int(part) for part in _version_split)
Expand Down Expand Up @@ -304,7 +304,6 @@ def debug(on: bool = True):
NeuronInfoLite,
PrometheusInfo,
DelegateInfo,
DelegateInfoLite,
StakeInfo,
SubnetInfo,
SubnetHyperparameters,
Expand Down
1 change: 0 additions & 1 deletion bittensor/axon.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,6 @@ async def default_verify(self, synapse: bittensor.Synapse):
# If we don't have a nonce stored, ensure that the nonce falls within
# a reasonable delta.

# Updated nonce using NTP implementated at v7.2
if (
synapse.dendrite.version is not None
and synapse.dendrite.version >= V_7_2_0
Expand Down
2 changes: 0 additions & 2 deletions bittensor/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
InspectCommand,
ListCommand,
ListDelegatesCommand,
ListDelegatesLiteCommand,
MetagraphCommand,
MyDelegatesCommand,
NewColdkeyCommand,
Expand Down Expand Up @@ -133,7 +132,6 @@
"undelegate": DelegateUnstakeCommand,
"my_delegates": MyDelegatesCommand,
"list_delegates": ListDelegatesCommand,
"list_delegates_lite": ListDelegatesLiteCommand,
"nominate": NominateCommand,
},
},
Expand Down
1 change: 0 additions & 1 deletion bittensor/commands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
from .delegates import (
NominateCommand,
ListDelegatesCommand,
ListDelegatesLiteCommand,
DelegateStakeCommand,
DelegateUnstakeCommand,
MyDelegatesCommand,
Expand Down
77 changes: 1 addition & 76 deletions bittensor/commands/delegates.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,84 +604,9 @@ def check_config(config: "bittensor.config"):
config.unstake_all = True


class ListDelegatesLiteCommand:
"""
Displays a formatted table of Bittensor network delegates, providing a lite overview of delegate statistics and information. For a more detailed view, use the :func:`ListDelegatesCommand` class.

This table helps users make informed decisions on which delegates to allocate their TAO stake.

Optional Arguments:
- ``wallet.name``: The name of the wallet to use for the command.
- ``subtensor.network``: The name of the network to use for the command.

The table columns include:

- INDEX: The delegate's index in the sorted list.
- DELEGATE: The name of the delegate.
- SS58: The delegate's unique SS58 address (truncated for display).
- NOMINATORS: The count of nominators backing the delegate.
- VPERMIT: Indicates the subnets for which the delegate has validator permits.
- TAKE: The percentage of the delegate's earnings taken by the network.
- DELEGATE/(24h): The total earnings of the delegate in the last 24 hours.
- DESCRIPTION: A brief description of the delegate's purpose and operations.

Sorting is done based on the ``TOTAL STAKE`` column in descending order. Changes in stake are highlighted as follows: Increases are indicated in green and decreases are indicated in red. Entries with no previous data are marked with ``NA``. Each delegate's name is a hyperlink to their respective URL, if available.

Example usage::

btcli root list_delegates_lite
btcli root list_delegates_lite --wallet.name my_wallet
btcli root list_delegates_lite --subtensor.network finney # can also be `test` or `local`

Note:
This function is part of the Bittensor CLI tools and is intended for use within a console application. It prints directly to the console and does not return any value.
"""

@staticmethod
def run(cli: "bittensor.cli"):
r"""
List all delegates on the network.
"""
try:
cli.config.subtensor.network = "archive"
cli.config.subtensor.chain_endpoint = (
"wss://archive.chain.opentensor.ai:443"
)
subtensor: "bittensor.subtensor" = bittensor.subtensor(
config=cli.config, log_verbose=False
)
ListDelegatesLiteCommand._run(cli, subtensor)
finally:
if "subtensor" in locals():
subtensor.close()
bittensor.logging.debug("closing subtensor connection")

@staticmethod
def _run(cli: "bittensor.cli", subtensor: "bittensor.subtensor"):
r"""
List all delegates on the network.
"""
with bittensor.__console__.status(":satellite: Loading delegates..."):
delegates: list[bittensor.DelegateInfoLite] = subtensor.get_delegates_lite()

show_delegates_lite(delegates, width=cli.config.get("width", None))

@staticmethod
def add_args(parser: argparse.ArgumentParser):
list_delegates_parser = parser.add_parser(
"list_delegates_lite",
help="""List all delegates on the network (lite version).""",
)
bittensor.subtensor.add_args(list_delegates_parser)

@staticmethod
def check_config(config: "bittensor.config"):
pass


class ListDelegatesCommand:
"""
Displays a formatted table of Bittensor network delegates, providing a comprehensive overview of delegate statistics and information. Use the :func:`ListDelegatesLiteCommand` class for a lighter version of this class.
Displays a formatted table of Bittensor network delegates, providing a comprehensive overview of delegate statistics and information.

This table helps users make informed decisions on which delegates to allocate their TAO stake.

Expand Down
7 changes: 6 additions & 1 deletion bittensor/commands/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,13 @@ def _run(
if (
cli.config.param == "network_registration_allowed"
or cli.config.param == "network_pow_registration_allowed"
or cli.config.param == "commit_reveal_weights_enabled"
):
cli.config.value = True if cli.config.value.lower() == "true" else False
cli.config.value = (
True
if (cli.config.value.lower() == "true" or cli.config.value == "1")
else False
)

subtensor.set_hyperparameter(
wallet,
Expand Down
1 change: 1 addition & 0 deletions bittensor/extrinsics/commit_weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from rich.prompt import Confirm

import bittensor

from bittensor.utils import format_error_message


Expand Down
1 change: 1 addition & 0 deletions bittensor/extrinsics/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import bittensor
from bittensor.utils import format_error_message

from bittensor.utils.registration import (
POWSolution,
create_pow,
Expand Down
9 changes: 6 additions & 3 deletions bittensor/extrinsics/root.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ def root_register_extrinsic(
)
if is_registered:
bittensor.__console__.print(
f":white_heavy_check_mark: [green]Already registered on root network.[/green]"
":white_heavy_check_mark: [green]Already registered on root network.[/green]"
)
return True

if prompt:
# Prompt user for confirmation.
if not Confirm.ask(f"Register to root network?"):
if not Confirm.ask("Register to root network?"):
return False

with bittensor.__console__.status(":satellite: Registering to root network..."):
Expand Down Expand Up @@ -130,6 +130,9 @@ def set_root_weights_extrinsic(
success (bool):
Flag is ``true`` if extrinsic was finalized or uncluded in the block. If we did not wait for finalization / inclusion, the response is ``true``.
"""

wallet.coldkey # unlock coldkey

# First convert types.
if isinstance(netuids, list):
netuids = np.array(netuids, dtype=np.int64)
Expand Down Expand Up @@ -177,7 +180,7 @@ def set_root_weights_extrinsic(
weight_uids, weight_vals = weight_utils.convert_weights_and_uids_for_emit(
netuids, weights
)
success, error_message = subtensor._do_set_weights(
success, error_message = subtensor._do_set_root_weights(
roman-opentensor marked this conversation as resolved.
Show resolved Hide resolved
wallet=wallet,
netuid=0,
uids=weight_uids,
Expand Down
73 changes: 69 additions & 4 deletions bittensor/subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
from bittensor.btlogging import logging as _logger
from bittensor.utils import torch, weight_utils, format_error_message
from .chain_data import (
DelegateInfoLite,
NeuronInfo,
DelegateInfo,
DelegateInfoLite,
PrometheusInfo,
SubnetInfo,
SubnetHyperparameters,
Expand Down Expand Up @@ -614,7 +614,6 @@ def set_take(
) -> bool:
"""
Set delegate hotkey take

Args:
wallet (bittensor.wallet): The wallet containing the hotkey to be nominated.
delegate_ss58 (str, optional): Hotkey
Expand Down Expand Up @@ -1082,6 +1081,7 @@ def reveal_weights(
This function allows neurons to reveal their previously committed weight distribution, ensuring transparency
and accountability within the Bittensor network.
"""

retries = 0
success = False
message = "No attempt made. Perhaps it is too soon to reveal weights!"
Expand Down Expand Up @@ -2659,6 +2659,73 @@ def root_set_weights(
prompt=prompt,
)

def _do_set_root_weights(
self,
wallet: "bittensor.wallet",
uids: List[int],
vals: List[int],
netuid: int = 0,
version_key: int = bittensor.__version_as_int__,
wait_for_inclusion: bool = False,
wait_for_finalization: bool = False,
) -> Tuple[bool, Optional[str]]: # (success, error_message)
"""
Internal method to send a transaction to the Bittensor blockchain, setting weights
for specified neurons on root. This method constructs and submits the transaction, handling
retries and blockchain communication.

Args:
wallet (bittensor.wallet): The wallet associated with the neuron setting the weights.
uids (List[int]): List of neuron UIDs for which weights are being set.
vals (List[int]): List of weight values corresponding to each UID.
netuid (int): Unique identifier for the network.
version_key (int, optional): Version key for compatibility with the network.
wait_for_inclusion (bool, optional): Waits for the transaction to be included in a block.
wait_for_finalization (bool, optional): Waits for the transaction to be finalized on the blockchain.

Returns:
Tuple[bool, Optional[str]]: A tuple containing a success flag and an optional error message.

This method is vital for the dynamic weighting mechanism in Bittensor, where neurons adjust their
trust in other neurons based on observed performance and contributions on the root network.
"""

@retry(delay=2, tries=3, backoff=2, max_delay=4, logger=_logger)
def make_substrate_call_with_retry():
call = self.substrate.compose_call(
call_module="SubtensorModule",
call_function="set_root_weights",
call_params={
"dests": uids,
"weights": vals,
"netuid": netuid,
"version_key": version_key,
"hotkey": wallet.hotkey.ss58_address,
},
)
# Period dictates how long the extrinsic will stay as part of waiting pool
extrinsic = self.substrate.create_signed_extrinsic(
call=call,
keypair=wallet.coldkey,
era={"period": 5},
)
response = self.substrate.submit_extrinsic(
extrinsic,
wait_for_inclusion=wait_for_inclusion,
wait_for_finalization=wait_for_finalization,
)
# We only wait here if we expect finalization.
if not wait_for_finalization and not wait_for_inclusion:
return True, "Not waiting for finalziation or inclusion."

response.process_events()
if response.is_success:
return True, "Successfully set weights."
else:
return False, response.error_message

return make_substrate_call_with_retry()

##################
# Registry Calls #
##################
Expand Down Expand Up @@ -4325,8 +4392,6 @@ def get_delegates(self, block: Optional[int] = None) -> List[DelegateInfo]:
Analyzing the delegate population offers insights into the network's governance dynamics and the distribution of
trust and responsibility among participating neurons.

For a lighter version of this function, see :func:`get_delegates_lite`.

Args:
block (Optional[int], optional): The blockchain block number for the query.

Expand Down
2 changes: 1 addition & 1 deletion bittensor/synapse.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class TerminalInfo(BaseModel):
ip (str): IP address of the terminal, crucial for network routing and data transmission.
port (int): Network port used by the terminal, key for establishing network connections.
version (int): Bittensor version running on the terminal, ensuring compatibility between different nodes in the network.
nonce (int): Unix timestamp that linearly increases for each request, ensuring requests cannot be duplicated or repeated
nonce (int): Unique, monotonically increasing number for each terminal, aiding in identifying and ordering network interactions.
uuid (str): Unique identifier for the terminal, fundamental for network security and identification.
hotkey (str): Encoded hotkey string of the terminal wallet, important for transaction and identity verification in the network.
signature (str): Digital signature verifying the tuple of nonce, axon_hotkey, dendrite_hotkey, and uuid, critical for ensuring data authenticity and security.
Expand Down
14 changes: 9 additions & 5 deletions bittensor/utils/weight_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# DEALINGS IN THE SOFTWARE.

import hashlib
import logging
roman-opentensor marked this conversation as resolved.
Show resolved Hide resolved
from typing import Tuple, List, Union

import numpy as np
Expand Down Expand Up @@ -140,11 +141,14 @@ def convert_root_weight_uids_and_vals_to_tensor(
for uid_j, wij in list(zip(uids, weights)):
if uid_j in subnets:
index_s = subnets.index(uid_j)
row_weights[index_s] = float(
wij
) # assumes max-upscaled values (w_max = U16_MAX).
else:
raise Exception("Incorrect Subnet {uid_j} in {subnets}")
row_weights[index_s] = float(
wij
) # assumes max-upscaled values (w_max = U16_MAX).
logging.warning(
f"Incorrect Subnet uid {uid_j} in Subnets {subnets}. The subnet is unavailable at the moment."
)
continue
row_sum = row_weights.sum()
if row_sum > 0:
row_weights /= row_sum # normalize
Expand Down Expand Up @@ -252,7 +256,7 @@ def process_weights_for_netuid(
metagraph = subtensor.metagraph(netuid)

# Cast weights to floats.
if not use_torch():
if use_torch():
if not isinstance(weights, torch.FloatTensor):
weights = weights.type(torch.float32)
else:
Expand Down
Empty file.
2 changes: 2 additions & 0 deletions tests/e2e_tests/subcommands/weights/test_commit_weights.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
)
from tests.e2e_tests.utils import setup_wallet


"""
Test the Commit/Reveal weights mechanism.

Expand All @@ -30,6 +31,7 @@
def test_commit_and_reveal_weights(local_chain):
# Register root as Alice
keypair, exec_command, wallet_path = setup_wallet("//Alice", True)

exec_command(RegisterSubnetworkCommand, ["s", "create"])

# define values
Expand Down
Loading
Loading