Skip to content

Commit 90844df

Browse files
authored
Merge branch 'staging' into master
2 parents 979e3d9 + f3af414 commit 90844df

File tree

10 files changed

+47
-28
lines changed

10 files changed

+47
-28
lines changed

bittensor/core/async_subtensor.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import numpy as np
1010
import scalecodec
1111
from async_substrate_interface import AsyncSubstrateInterface
12-
from bittensor_commit_reveal import get_encrypted_commitment
12+
from bittensor_drand import get_encrypted_commitment
1313
from bittensor_wallet.utils import SS58_FORMAT
1414
from numpy.typing import NDArray
1515
from scalecodec import GenericCall
@@ -1480,9 +1480,9 @@ async def get_metagraph_info(
14801480
Retrieves full or partial metagraph information for the specified subnet (netuid).
14811481
14821482
Arguments:
1483-
netuid (int): The NetUID of the subnet to query.
1484-
field_indices (Optional[list[SelectiveMetagraphIndex]]): An optional list of SelectiveMetagraphIndex values
1485-
specifying which fields to retrieve. If not provided, all available fields will be returned.
1483+
netuid: The NetUID of the subnet to query.
1484+
field_indices: An optional list of SelectiveMetagraphIndex values specifying which fields to retrieve. If
1485+
not provided, all available fields will be returned.
14861486
block: the block number at which to retrieve the hyperparameter. Do not specify if using block_hash or
14871487
reuse_block
14881488
block_hash: The hash of blockchain block number for the query. Do not specify if using
@@ -1505,9 +1505,12 @@ async def get_metagraph_info(
15051505

15061506
if field_indices:
15071507
if isinstance(field_indices, list) and all(
1508-
isinstance(f, SelectiveMetagraphIndex) for f in field_indices
1508+
isinstance(f, (SelectiveMetagraphIndex, int)) for f in field_indices
15091509
):
1510-
indexes = [f.value for f in field_indices]
1510+
indexes = [
1511+
f.value if isinstance(f, SelectiveMetagraphIndex) else f
1512+
for f in field_indices
1513+
]
15111514
else:
15121515
raise ValueError(
15131516
"`field_indices` must be a list of SelectiveMetagraphIndex items."

bittensor/core/extrinsics/asyncex/commit_reveal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import Optional, Union, TYPE_CHECKING
44

55
import numpy as np
6-
from bittensor_commit_reveal import get_encrypted_commit
6+
from bittensor_drand import get_encrypted_commit
77
from numpy.typing import NDArray
88

99
from bittensor.core.settings import version_as_int

bittensor/core/extrinsics/commit_reveal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from typing import Union, TYPE_CHECKING, Optional
44

5-
from bittensor_commit_reveal import get_encrypted_commit
5+
from bittensor_drand import get_encrypted_commit
66
import numpy as np
77
from numpy.typing import NDArray
88

bittensor/core/subtensor.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from async_substrate_interface.errors import SubstrateRequestException
99
from async_substrate_interface.sync_substrate import SubstrateInterface
1010
from async_substrate_interface.types import ScaleObj
11-
from bittensor_commit_reveal import get_encrypted_commitment
11+
from bittensor_drand import get_encrypted_commitment
1212
from numpy.typing import NDArray
1313

1414
from bittensor.core.async_subtensor import ProposalVoteData
@@ -1133,18 +1133,18 @@ def get_minimum_required_stake(self) -> Balance:
11331133
def get_metagraph_info(
11341134
self,
11351135
netuid: int,
1136-
field_indices: Optional[list["SelectiveMetagraphIndex"]] = None,
1136+
field_indices: Optional[list[Union["SelectiveMetagraphIndex", int]]] = None,
11371137
block: Optional[int] = None,
11381138
) -> Optional[MetagraphInfo]:
11391139
"""
11401140
Retrieves full or partial metagraph information for the specified subnet (netuid).
11411141
11421142
Arguments:
1143-
netuid (int): The NetUID of the subnet to query.
1144-
field_indices (Optional[list[SelectiveMetagraphIndex]]): An optional list of SelectiveMetagraphIndex values
1145-
specifying which fields to retrieve. If not provided, all available fields will be returned.
1146-
block (Optional[int]):The block number at which to query the data. If not specified, the current block or
1147-
one determined via reuse_block or block_hash will be used.
1143+
netuid: The NetUID of the subnet to query.
1144+
field_indices: An optional list of SelectiveMetagraphIndex values specifying which fields to retrieve. If
1145+
not provided, all available fields will be returned.
1146+
block: The block number at which to query the data. If not specified, the current block or one determined
1147+
via reuse_block or block_hash will be used.
11481148
11491149
Returns:
11501150
Optional[MetagraphInfo]: A MetagraphInfo object containing the requested subnet data, or None if the subnet
@@ -1162,9 +1162,12 @@ def get_metagraph_info(
11621162

11631163
if field_indices:
11641164
if isinstance(field_indices, list) and all(
1165-
isinstance(f, SelectiveMetagraphIndex) for f in field_indices
1165+
isinstance(f, (SelectiveMetagraphIndex, int)) for f in field_indices
11661166
):
1167-
indexes = [f.value for f in field_indices]
1167+
indexes = [
1168+
f.value if isinstance(f, SelectiveMetagraphIndex) else f
1169+
for f in field_indices
1170+
]
11681171
else:
11691172
raise ValueError(
11701173
"`field_indices` must be a list of SelectiveMetagraphIndex items."

bittensor/core/timelock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class Person:
5757
import time
5858
from typing import Optional, Union
5959

60-
from bittensor_commit_reveal import (
60+
from bittensor_drand import (
6161
encrypt as _btr_encrypt,
6262
decrypt as _btr_decrypt,
6363
get_latest_round,

bittensor/utils/easy_imports.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
ProposalCallData,
4848
ProposalVoteData,
4949
ScheduledColdkeySwapInfo,
50+
SelectiveMetagraphIndex,
5051
StakeInfo,
5152
SubnetHyperparameters,
5253
SubnetIdentity,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ dependencies = [
3434
"pydantic>=2.3, <3",
3535
"scalecodec==1.2.11",
3636
"uvicorn",
37-
"bittensor-commit-reveal>=0.4.0",
37+
"bittensor-drand>=0.5.0",
3838
"bittensor-wallet>=3.0.8",
3939
"async-substrate-interface>=1.1.0"
4040
]

scripts/check_requirements_changes.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
# Check if requirements files have changed in the last commit
4-
if git diff --name-only HEAD~1 | grep -E 'pyproject.toml'; then
4+
if git diff --name-only HEAD | grep -E 'pyproject.toml'; then
55
echo "Requirements files may have changed. Running compatibility checks..."
66
echo 'export REQUIREMENTS_CHANGED="true"' >> $BASH_ENV
77
else

tests/unit_tests/test_async_subtensor.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3100,7 +3100,7 @@ async def test_get_metagraph_info_specific_fields(subtensor, mocker):
31003100
# Preps
31013101
netuid = 1
31023102
mock_value = {"mock": "data"}
3103-
fields = [SelectiveMetagraphIndex.Name, SelectiveMetagraphIndex.OwnerHotkey]
3103+
fields = [SelectiveMetagraphIndex.Name, 5]
31043104

31053105
mock_runtime_call = mocker.patch.object(
31063106
subtensor.substrate,
@@ -3119,7 +3119,13 @@ async def test_get_metagraph_info_specific_fields(subtensor, mocker):
31193119
mock_runtime_call.assert_awaited_once_with(
31203120
"SubnetInfoRuntimeApi",
31213121
"get_selective_metagraph",
3122-
params=[netuid, [0] + [f.value for f in fields]],
3122+
params=[
3123+
netuid,
3124+
[0]
3125+
+ [
3126+
f.value if isinstance(f, SelectiveMetagraphIndex) else f for f in fields
3127+
],
3128+
],
31233129
block_hash=await subtensor.determine_block_hash(None),
31243130
)
31253131
mock_from_dict.assert_called_once_with(mock_value)
@@ -3131,8 +3137,8 @@ async def test_get_metagraph_info_specific_fields(subtensor, mocker):
31313137
[
31323138
"invalid",
31333139
],
3134-
[SelectiveMetagraphIndex.Active, 1],
3135-
[1, 2, 3],
3140+
[SelectiveMetagraphIndex.Active, 1, "f"],
3141+
[1, 2, 3, "f"],
31363142
],
31373143
)
31383144
@pytest.mark.asyncio

tests/unit_tests/test_subtensor.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3428,7 +3428,7 @@ def test_get_metagraph_info_specific_fields(subtensor, mocker):
34283428
# Preps
34293429
netuid = 1
34303430
mock_value = {"mock": "data"}
3431-
fields = [SelectiveMetagraphIndex.Name, SelectiveMetagraphIndex.OwnerHotkey]
3431+
fields = [SelectiveMetagraphIndex.Name, 5]
34323432

34333433
mock_runtime_call = mocker.patch.object(
34343434
subtensor.substrate,
@@ -3447,7 +3447,13 @@ def test_get_metagraph_info_specific_fields(subtensor, mocker):
34473447
mock_runtime_call.assert_called_once_with(
34483448
"SubnetInfoRuntimeApi",
34493449
"get_selective_metagraph",
3450-
params=[netuid, [0] + [f.value for f in fields]],
3450+
params=[
3451+
netuid,
3452+
[0]
3453+
+ [
3454+
f.value if isinstance(f, SelectiveMetagraphIndex) else f for f in fields
3455+
],
3456+
],
34513457
block_hash=subtensor.determine_block_hash(None),
34523458
)
34533459
mock_from_dict.assert_called_once_with(mock_value)
@@ -3459,8 +3465,8 @@ def test_get_metagraph_info_specific_fields(subtensor, mocker):
34593465
[
34603466
"invalid",
34613467
],
3462-
[SelectiveMetagraphIndex.Active, 1],
3463-
[1, 2, 3],
3468+
[SelectiveMetagraphIndex.Active, 1, "f"],
3469+
[1, 2, 3, "f"],
34643470
],
34653471
)
34663472
def test_get_metagraph_info_invalid_field_indices(subtensor, wrong_fields):

0 commit comments

Comments
 (0)