Skip to content

Commit bba291c

Browse files
Merge branch 'staging' into tests/zyzniewski/more_e2e_tests
2 parents d6f747f + f2a963b commit bba291c

23 files changed

+316
-130
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Changelog
22

3+
## 9.0.2 /2025-02-24
4+
5+
## What's Changed
6+
* CI: Upgrade rust compiler for E2E tests by @zyzniewski-reef in https://github.com/opentensor/bittensor/pull/2690
7+
* Break away cli reqs by @thewhaleking in https://github.com/opentensor/bittensor/pull/2692
8+
* Updates DelegateInfo chain data by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/2683
9+
* Backmerge main to staging 901 by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/2689
10+
* fix: typos in documentation files by @zeevick10 in https://github.com/opentensor/bittensor/pull/2687
11+
* Removes tx limit in stake_multiple by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/2694
12+
13+
## New Contributors
14+
* @zeevick10 made their first contribution in https://github.com/opentensor/bittensor/pull/2687
15+
16+
**Full Changelog**: https://github.com/opentensor/bittensor/compare/v9.0.1...v9.0.2
17+
318
## 9.0.1 /2025-02-20
419

520
## What's Changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9.0.1
1+
9.0.2

bittensor/core/async_subtensor.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import asyncio
22
import copy
3+
from datetime import datetime, timezone
34
import ssl
45
from functools import partial
56
from typing import Optional, Any, Union, Iterable, TYPE_CHECKING
@@ -27,6 +28,7 @@
2728
decode_account_id,
2829
DynamicInfo,
2930
)
31+
from bittensor.core.chain_data.delegate_info import DelegatedInfo
3032
from bittensor.core.chain_data.utils import decode_metadata
3133
from bittensor.core.config import Config
3234
from bittensor.core.errors import SubstrateRequestException
@@ -999,7 +1001,7 @@ async def get_all_commitments(
9991001
)
10001002
result = {}
10011003
async for id_, value in query:
1002-
result[decode_account_id(id_[0])] = decode_account_id(value)
1004+
result[decode_account_id(id_[0])] = decode_metadata(value)
10031005
return result
10041006

10051007
async def get_current_weight_commit_info(
@@ -1219,7 +1221,7 @@ async def get_delegated(
12191221
if not result:
12201222
return []
12211223

1222-
return DelegateInfo.delegated_list_from_dicts(result)
1224+
return DelegatedInfo.list_from_dicts(result)
12231225

12241226
async def get_delegates(
12251227
self,
@@ -2744,6 +2746,36 @@ async def weights_rate_limit(
27442746
)
27452747
return None if call is None else int(call)
27462748

2749+
async def get_timestamp(
2750+
self,
2751+
block: Optional[int] = None,
2752+
block_hash: Optional[str] = None,
2753+
reuse_block: bool = False,
2754+
) -> datetime:
2755+
"""
2756+
Retrieves the datetime timestamp for a given block
2757+
2758+
Arguments:
2759+
block: The blockchain block number for the query. Do not specify if specifying block_hash or reuse_block.
2760+
block_hash: The blockchain block_hash representation of the block id. Do not specify if specifying block
2761+
or reuse_block.
2762+
reuse_block: Whether to reuse the last-used blockchain block hash. Do not specify if specifying block or
2763+
block_hash.
2764+
2765+
Returns:
2766+
datetime object for the timestamp of the block
2767+
"""
2768+
unix = (
2769+
await self.query_module(
2770+
"Timestamp",
2771+
"Now",
2772+
block=block,
2773+
block_hash=block_hash,
2774+
reuse_block=reuse_block,
2775+
)
2776+
).value
2777+
return datetime.fromtimestamp(unix / 1000, tz=timezone.utc)
2778+
27472779
# Extrinsics helper ================================================================================================
27482780

27492781
async def sign_and_send_extrinsic(

bittensor/core/dendrite.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,14 @@ def __del__(self):
877877
# ... some operations ...
878878
del dendrite # This will implicitly invoke the __del__ method and close the session.
879879
"""
880-
self.close_session()
880+
try:
881+
self.close_session()
882+
except RuntimeError:
883+
if self._session:
884+
logging.debug(
885+
"A Dendrite session was unable to be closed during garbage-collection of the Dendrite object. This "
886+
"usually indicates that you were not using the async context manager."
887+
)
881888

882889

883890
# For back-compatibility with torch

bittensor/core/extrinsics/asyncex/staking.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -314,20 +314,6 @@ async def add_stake_multiple_extrinsic(
314314
if staking_response is True: # If we successfully staked.
315315
# We only wait here if we expect finalization.
316316

317-
if idx < len(hotkey_ss58s) - 1:
318-
# Wait for tx rate limit.
319-
tx_query = await subtensor.substrate.query(
320-
module="SubtensorModule", storage_function="TxRateLimit"
321-
)
322-
tx_rate_limit_blocks: int = getattr(tx_query, "value", 0)
323-
if tx_rate_limit_blocks > 0:
324-
logging.error(
325-
f":hourglass: [yellow]Waiting for tx rate limit: [white]{tx_rate_limit_blocks}[/white] "
326-
f"blocks[/yellow]"
327-
)
328-
# 12 seconds per block
329-
await asyncio.sleep(tx_rate_limit_blocks * 12)
330-
331317
if not wait_for_finalization and not wait_for_inclusion:
332318
old_balance -= staking_balance
333319
successful_stakes += 1

bittensor/core/extrinsics/asyncex/unstaking.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -281,18 +281,6 @@ async def unstake_multiple_extrinsic(
281281
if staking_response is True: # If we successfully unstaked.
282282
# We only wait here if we expect finalization.
283283

284-
if idx < len(hotkey_ss58s) - 1:
285-
# Wait for tx rate limit.
286-
tx_rate_limit_blocks = await subtensor.tx_rate_limit()
287-
if tx_rate_limit_blocks > 0:
288-
logging.info(
289-
f":hourglass: [yellow]Waiting for tx rate limit: "
290-
f"[white]{tx_rate_limit_blocks}[/white] blocks[/yellow]"
291-
)
292-
await asyncio.sleep(
293-
tx_rate_limit_blocks * 12
294-
) # 12 seconds per block
295-
296284
if not wait_for_finalization and not wait_for_inclusion:
297285
successful_unstakes += 1
298286
continue

bittensor/core/extrinsics/unstaking.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import time
21
from typing import Optional, TYPE_CHECKING
32

43
from bittensor.core.errors import StakeError, NotRegisteredError
@@ -266,16 +265,6 @@ def unstake_multiple_extrinsic(
266265
if staking_response is True: # If we successfully unstaked.
267266
# We only wait here if we expect finalization.
268267

269-
if idx < len(hotkey_ss58s) - 1:
270-
# Wait for tx rate limit.
271-
tx_rate_limit_blocks = subtensor.tx_rate_limit()
272-
if tx_rate_limit_blocks > 0:
273-
logging.info(
274-
f":hourglass: [yellow]Waiting for tx rate limit: "
275-
f"[white]{tx_rate_limit_blocks}[/white] blocks[/yellow]"
276-
)
277-
time.sleep(tx_rate_limit_blocks * 12) # 12 seconds per block
278-
279268
if not wait_for_finalization and not wait_for_inclusion:
280269
successful_unstakes += 1
281270
continue

bittensor/core/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "9.0.1"
1+
__version__ = "9.0.2"
22

33
import os
44
import re

bittensor/core/subtensor.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import copy
2+
from datetime import datetime, timezone
3+
24
from functools import lru_cache
35
from typing import TYPE_CHECKING, Any, Iterable, Optional, Union, cast
46

@@ -754,7 +756,7 @@ def get_all_commitments(
754756
)
755757
result = {}
756758
for id_, value in query:
757-
result[decode_account_id(id_[0])] = decode_account_id(value)
759+
result[decode_account_id(id_[0])] = decode_metadata(value)
758760
return result
759761

760762
def get_current_weight_commit_info(
@@ -2070,6 +2072,19 @@ def weights_rate_limit(
20702072
)
20712073
return None if call is None else int(call)
20722074

2075+
def get_timestamp(self, block: Optional[int] = None) -> datetime:
2076+
"""
2077+
Retrieves the datetime timestamp for a given block
2078+
2079+
Arguments:
2080+
block: The blockchain block number for the query.
2081+
2082+
Returns:
2083+
datetime object for the timestamp of the block
2084+
"""
2085+
unix = cast(ScaleObj, self.query_module("Timestamp", "Now", block=block)).value
2086+
return datetime.fromtimestamp(unix / 1000, tz=timezone.utc)
2087+
20732088
# Extrinsics helper ================================================================================================
20742089

20752090
def sign_and_send_extrinsic(

requirements/cli.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
bittensor-cli>=9.0.0
1+
bittensor-cli>=9.0.2

0 commit comments

Comments
 (0)