Skip to content

Commit 35029c1

Browse files
authored
Merge pull request #2759 from opentensor/release/9.2.0
Release/9.2.0
2 parents d6ad9f8 + 31b0718 commit 35029c1

File tree

12 files changed

+688
-91
lines changed

12 files changed

+688
-91
lines changed

.github/workflows/e2e-subtensor-tests.yaml

Lines changed: 34 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ env:
2525

2626
# job to run tests in parallel
2727
jobs:
28-
# Job to find all test files
28+
2929
find-tests:
3030
runs-on: ubuntu-latest
3131
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }}
@@ -42,68 +42,55 @@ jobs:
4242
echo "::set-output name=test-files::$test_files"
4343
shell: bash
4444

45+
pull-docker-image:
46+
runs-on: ubuntu-latest
47+
steps:
48+
- name: Log in to GitHub Container Registry
49+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
50+
51+
- name: Pull Docker Image
52+
run: docker pull ghcr.io/opentensor/subtensor-localnet:latest
53+
54+
- name: Save Docker Image to Cache
55+
run: docker save -o subtensor-localnet.tar ghcr.io/opentensor/subtensor-localnet:latest
56+
57+
- name: Upload Docker Image as Artifact
58+
uses: actions/upload-artifact@v4
59+
with:
60+
name: subtensor-localnet
61+
path: subtensor-localnet.tar
62+
4563
# Job to run tests in parallel
4664
run:
47-
needs: find-tests
48-
runs-on: SubtensorCI
65+
needs:
66+
- find-tests
67+
- pull-docker-image
68+
runs-on: ubuntu-latest
4969
timeout-minutes: 45
5070
strategy:
5171
fail-fast: false # Allow other matrix jobs to run even if this job fails
52-
max-parallel: 8 # Set the maximum number of parallel jobs
72+
max-parallel: 32 # Set the maximum number of parallel jobs (same as we have cores in SubtensorCI runner)
5373
matrix:
54-
rust-branch:
55-
- stable
56-
rust-target:
57-
- x86_64-unknown-linux-gnu
5874
os:
5975
- ubuntu-latest
6076
test-file: ${{ fromJson(needs.find-tests.outputs.test-files) }}
61-
env:
62-
RELEASE_NAME: development
63-
RUSTV: ${{ matrix.rust-branch }}
64-
RUST_BACKTRACE: full
65-
RUST_BIN_DIR: target/${{ matrix.rust-target }}
66-
TARGET: ${{ matrix.rust-target }}
6777
steps:
68-
- name: Check-out repository under $GITHUB_WORKSPACE
78+
- name: Check-out repository
6979
uses: actions/checkout@v4
7080

71-
- name: Install dependencies
72-
run: |
73-
sudo apt-get update &&
74-
sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler
75-
76-
- name: Install Rust ${{ matrix.rust-branch }}
77-
uses: actions-rs/[email protected]
78-
with:
79-
toolchain: ${{ matrix.rust-branch }}
80-
components: rustfmt
81-
profile: minimal
82-
83-
- name: Add wasm32-unknown-unknown target
84-
run: |
85-
rustup target add wasm32-unknown-unknown --toolchain stable-x86_64-unknown-linux-gnu
86-
rustup component add rust-src --toolchain stable-x86_64-unknown-linux-gnu
87-
88-
- name: Clone subtensor repo
89-
run: git clone https://github.com/opentensor/subtensor.git
90-
91-
- name: Setup subtensor repo
92-
working-directory: ${{ github.workspace }}/subtensor
93-
run: git checkout devnet-ready
94-
9581
- name: Install uv
9682
uses: astral-sh/setup-uv@v4
9783

9884
- name: install dependencies
9985
run: uv sync --all-extras --dev
10086

101-
- name: Run tests
102-
run: |
103-
LOCALNET_SH_PATH="${{ github.workspace }}/subtensor/scripts/localnet.sh" uv run pytest ${{ matrix.test-file }} -s
87+
- name: Download Cached Docker Image
88+
uses: actions/download-artifact@v4
89+
with:
90+
name: subtensor-localnet
10491

105-
- name: Retry failed tests
106-
if: failure()
107-
run: |
108-
sleep 10
109-
LOCALNET_SH_PATH="${{ github.workspace }}/subtensor/scripts/localnet.sh" uv run pytest ${{ matrix.test-file }} -s
92+
- name: Load Docker Image
93+
run: docker load -i subtensor-localnet.tar
94+
95+
- name: Run tests
96+
run: uv run pytest ${{ matrix.test-file }} -s

CHANGELOG.md

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

3+
## 9.2.0 /2025-03-18
4+
5+
## What's Changed
6+
* Fix E2E test_incentive by waiting till start of the very next epoch by @zyzniewski-reef in https://github.com/opentensor/bittensor/pull/2746
7+
* New era of e2e Tests Bittensor by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2743
8+
* Allow installation on Py 3.13 by @thewhaleking in https://github.com/opentensor/bittensor/pull/2756
9+
* Feat/dynamic stake prices by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/2755
10+
11+
**Full Changelog**: https://github.com/opentensor/bittensor/compare/v9.1.0...v9.2.0
12+
313
## 9.1.0 /2025-03-12
414

515
## What's Changed

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,49 @@ The Python interpreter output will look like below.
221221
>>>
222222
```
223223

224+
### Testing
225+
You can run integration and unit tests in interactive mode of IDE or in terminal mode using the command:
226+
```bash
227+
pytest tests/integration_tests
228+
pytest tests/unit_tests
229+
```
230+
231+
#### E2E tests have 2 options for launching (legacy runner):
232+
- using a compiler based on the substrait code
233+
- using an already built docker image (docker runner)
234+
235+
#### Using `docker runner` (default for now):
236+
- E2E tests with docker image do not require preliminary compilation
237+
- are executed very quickly
238+
- require docker installed in OS
239+
240+
Ho to use:
241+
```bash
242+
pytest tests/e2e_tests
243+
```
244+
245+
#### TUsing `legacy runner`:
246+
- Will start compilation of the collected code in your subtensor repository
247+
- you must provide the `LOCALNET_SH_PATH` variable in the local environment with the path to the file `/scripts/localnet.sh` in the cloned repository within your OS
248+
- you can use the `BUILD_BINARY=0` variable, this will skip the copy step for each test.
249+
- you can use the `USE_DOCKER=0` variable, this will run tests using the "legacy runner", even if docker is installed in your OS
250+
251+
#### Ho to use:
252+
Regular e2e tests run
253+
```bash
254+
LOCALNET_SH_PATH=/path/to/your/localnet.sh pytest tests/e2e_tests
255+
```
256+
257+
If you want to skip re-build process for each e2e test
258+
```bash
259+
BUILD_BINARY=0 LOCALNET_SH_PATH=/path/to/your/localnet.sh pytest tests/e2e_tests
260+
```
261+
262+
If you want to use legacy runner even with installed Docker in your OS
263+
```bash
264+
USE_DOCKER=0 BUILD_BINARY=0 LOCALNET_SH_PATH=/path/to/your/localnet.sh pytest tests/e2e_tests
265+
```
266+
224267
---
225268

226269
## Release Guidelines

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9.1.0
1+
9.2.0

bittensor/core/async_subtensor.py

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,6 +1575,117 @@ async def get_stake(
15751575

15761576
return Balance.from_rao(int(stake)).set_unit(netuid=netuid)
15771577

1578+
async def get_stake_add_fee(
1579+
self,
1580+
amount: Balance,
1581+
netuid: int,
1582+
coldkey_ss58: str,
1583+
hotkey_ss58: str,
1584+
block: Optional[int] = None,
1585+
) -> Balance:
1586+
"""
1587+
Calculates the fee for adding new stake to a hotkey.
1588+
1589+
Args:
1590+
amount: Amount of stake to add in TAO
1591+
netuid: Netuid of subnet
1592+
coldkey_ss58: SS58 address of source coldkey
1593+
hotkey_ss58: SS58 address of destination hotkey
1594+
block: Block number at which to perform the calculation
1595+
1596+
Returns:
1597+
The calculated stake fee as a Balance object
1598+
"""
1599+
result = await self.query_runtime_api(
1600+
runtime_api="StakeInfoRuntimeApi",
1601+
method="get_stake_fee",
1602+
params=[
1603+
None,
1604+
coldkey_ss58,
1605+
(hotkey_ss58, netuid),
1606+
coldkey_ss58,
1607+
amount.rao,
1608+
],
1609+
block=block,
1610+
)
1611+
return Balance.from_rao(result)
1612+
1613+
async def get_unstake_fee(
1614+
self,
1615+
amount: Balance,
1616+
netuid: int,
1617+
coldkey_ss58: str,
1618+
hotkey_ss58: str,
1619+
block: Optional[int] = None,
1620+
) -> Balance:
1621+
"""
1622+
Calculates the fee for unstaking from a hotkey.
1623+
1624+
Args:
1625+
amount: Amount of stake to unstake in TAO
1626+
netuid: Netuid of subnet
1627+
coldkey_ss58: SS58 address of source coldkey
1628+
hotkey_ss58: SS58 address of destination hotkey
1629+
block: Block number at which to perform the calculation
1630+
1631+
Returns:
1632+
The calculated stake fee as a Balance object
1633+
"""
1634+
result = await self.query_runtime_api(
1635+
runtime_api="StakeInfoRuntimeApi",
1636+
method="get_stake_fee",
1637+
params=[
1638+
None,
1639+
coldkey_ss58,
1640+
(hotkey_ss58, netuid),
1641+
coldkey_ss58,
1642+
amount.rao,
1643+
],
1644+
block=block,
1645+
)
1646+
return Balance.from_rao(result)
1647+
1648+
async def get_stake_movement_fee(
1649+
self,
1650+
amount: Balance,
1651+
origin_netuid: int,
1652+
origin_hotkey_ss58: str,
1653+
origin_coldkey_ss58: str,
1654+
destination_netuid: int,
1655+
destination_hotkey_ss58: str,
1656+
destination_coldkey_ss58: str,
1657+
block: Optional[int] = None,
1658+
) -> Balance:
1659+
"""
1660+
Calculates the fee for moving stake between hotkeys/subnets/coldkeys.
1661+
1662+
Args:
1663+
amount: Amount of stake to move in TAO
1664+
origin_netuid: Netuid of source subnet
1665+
origin_hotkey_ss58: SS58 address of source hotkey
1666+
origin_coldkey_ss58: SS58 address of source coldkey
1667+
destination_netuid: Netuid of destination subnet
1668+
destination_hotkey_ss58: SS58 address of destination hotkey
1669+
destination_coldkey_ss58: SS58 address of destination coldkey
1670+
block: Block number at which to perform the calculation
1671+
1672+
Returns:
1673+
The calculated stake fee as a Balance object
1674+
"""
1675+
result = await self.query_runtime_api(
1676+
runtime_api="StakeInfoRuntimeApi",
1677+
method="get_stake_fee",
1678+
params=[
1679+
(origin_hotkey_ss58, origin_netuid),
1680+
origin_coldkey_ss58,
1681+
(destination_hotkey_ss58, destination_netuid),
1682+
destination_coldkey_ss58,
1683+
amount.rao,
1684+
],
1685+
block=block,
1686+
)
1687+
return Balance.from_rao(result)
1688+
15781689
async def get_stake_for_coldkey_and_hotkey(
15791690
self,
15801691
coldkey_ss58: str,

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.1.0"
1+
__version__ = "9.2.0"
22

33
import os
44
import re

0 commit comments

Comments
 (0)