Skip to content

Commit 5dc537f

Browse files
authored
Merge branch 'staging' into feat/roman/wait_for_node_start-to-20-mins
2 parents 2a6f62a + ed700b2 commit 5dc537f

File tree

12 files changed

+222
-74
lines changed

12 files changed

+222
-74
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: 33 additions & 1 deletion
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
@@ -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/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: 15 additions & 0 deletions
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

@@ -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

requirements/prod.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ scalecodec==1.2.11
2222
uvicorn
2323
websockets>=14.1
2424
bittensor-commit-reveal>=0.2.0
25-
bittensor-wallet>=3.0.3
26-
async-substrate-interface>=1.0.0
25+
bittensor-wallet>=3.0.4
26+
async-substrate-interface>=1.0.3

scripts/install.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ linux_install_bittensor() {
105105
git clone https://github.com/opentensor/bittensor.git ~/.bittensor/bittensor/ 2> /dev/null || (cd ~/.bittensor/bittensor/ ; git fetch origin master ; git checkout master ; git pull --ff-only ; git reset --hard ; git clean -xdf)
106106
ohai "Installing bittensor"
107107
$python -m pip install -e ~/.bittensor/bittensor/
108+
$python -m pip install -U bittensor-cli
108109
exit_on_error $?
109110
}
110111

@@ -163,10 +164,11 @@ mac_update_pip() {
163164
}
164165

165166
mac_install_bittensor() {
166-
ohai "Cloning bittensor@text_prompting into ~/.bittensor/bittensor"
167+
ohai "Cloning bittensor into ~/.bittensor/bittensor"
167168
git clone https://github.com/opentensor/bittensor.git ~/.bittensor/bittensor/ 2> /dev/null || (cd ~/.bittensor/bittensor/ ; git fetch origin master ; git checkout master ; git pull --ff-only ; git reset --hard; git clean -xdf)
168169
ohai "Installing bittensor"
169170
$python -m pip install -e ~/.bittensor/bittensor/
171+
$python -m pip install -U bittensor-cli
170172
exit_on_error $?
171173
deactivate
172174
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from datetime import datetime
2+
import pytest
3+
4+
5+
@pytest.mark.asyncio
6+
async def test_get_timestamp(subtensor, async_subtensor, local_chain):
7+
with subtensor:
8+
block_number = subtensor.get_current_block()
9+
assert isinstance(
10+
subtensor.get_timestamp(), datetime
11+
) # verify it works with no block number specified
12+
sync_result = subtensor.get_timestamp(
13+
block=block_number
14+
) # verify it works with block number specified
15+
async with async_subtensor:
16+
assert isinstance(await async_subtensor.get_timestamp(), datetime)
17+
async_result = await async_subtensor.get_timestamp(block=block_number)
18+
assert sync_result == async_result

tests/e2e_tests/test_incentive.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import asyncio
2-
import time
32

43
import pytest
54

@@ -23,9 +22,6 @@ async def test_incentive(local_chain, subtensor, templates, alice_wallet, bob_wa
2322
AssertionError: If any of the checks or verifications fail
2423
"""
2524

26-
# Wait for 2 tempos to spin up chain properly
27-
subtensor.wait_for_block(20)
28-
2925
print("Testing test_incentive")
3026
netuid = 2
3127

@@ -51,15 +47,13 @@ async def test_incentive(local_chain, subtensor, templates, alice_wallet, bob_wa
5147
# Get current miner/validator stats
5248
alice_neuron = metagraph.neurons[0]
5349

54-
time.sleep(30)
5550
assert alice_neuron.validator_permit is True
5651
assert alice_neuron.dividends == 0
5752
assert alice_neuron.stake.tao > 0
5853
assert alice_neuron.validator_trust == 0
5954

6055
bob_neuron = metagraph.neurons[1]
6156

62-
time.sleep(30)
6357
assert bob_neuron.incentive == 0
6458
assert bob_neuron.consensus == 0
6559
assert bob_neuron.rank == 0
@@ -79,15 +73,14 @@ async def test_incentive(local_chain, subtensor, templates, alice_wallet, bob_wa
7973
# wait for the Validator to process and set_weights
8074
await asyncio.sleep(5)
8175

82-
# Wait until next epoch
83-
await wait_epoch(subtensor, netuid)
76+
# Wait few epochs
77+
await wait_epoch(subtensor, netuid, times=4)
8478

8579
# Refresh metagraph
8680
metagraph = subtensor.metagraph(netuid)
8781

8882
# Get current emissions and validate that Alice has gotten tao
8983
alice_neuron = metagraph.neurons[0]
90-
time.sleep(5)
9184

9285
assert alice_neuron.validator_permit is True
9386
assert alice_neuron.dividends == 1.0

0 commit comments

Comments
 (0)