Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
ca261c0
add BUILD_BINARY=0
Mar 13, 2025
0074c9b
replace devnet-ready to devnet-ready-with-nodes
Mar 13, 2025
0511b9f
Merge branch 'staging' into feat/roman/test-run-tests-without-building
basfroman Mar 13, 2025
a810aae
trigger actions
Mar 13, 2025
de812b9
add debug
Mar 13, 2025
e66c9ed
return proper runner
Mar 13, 2025
99390ba
get-latest-artifact-id
Mar 13, 2025
83ef99f
try tests with compatible architecture
Mar 13, 2025
a04018c
use the same runner
Mar 13, 2025
3210071
debug
Mar 13, 2025
1ce9578
debug file
Mar 13, 2025
b671655
sudo
Mar 13, 2025
f1f0898
more debug info
Mar 13, 2025
d044f89
more debug info
Mar 13, 2025
3007f67
more debug info
Mar 13, 2025
336af8e
more debug info
Mar 13, 2025
ffe6a41
wait till start of the new epoch
zyzniewski-reef Mar 13, 2025
faf1ef7
Merge branch 'staging' into fix/zyzniewski/test_incentive
zyzniewski-reef Mar 14, 2025
6caa770
Merge branch 'staging' into feat/roman/test-run-tests-without-building
Mar 14, 2025
bb2d795
ruff
Mar 15, 2025
1538152
update e2e tests workflow
Mar 15, 2025
99aab1b
fix
Mar 15, 2025
8841166
add reqs
Mar 15, 2025
f42de89
try improvement
Mar 15, 2025
c3595ea
add needs
Mar 15, 2025
93d8b1c
remove venv job
Mar 15, 2025
096a312
fix
Mar 15, 2025
85067d2
test time with uv
Mar 15, 2025
049aeb8
test time with uv
Mar 15, 2025
a594e73
remove debug file
Mar 15, 2025
c117432
clean up
Mar 15, 2025
0ac6ffc
fix comments + new logic
Mar 17, 2025
9a2c531
update README.md
Mar 17, 2025
ef87986
refactor
Mar 17, 2025
5022a5f
ruff
Mar 17, 2025
a23f2cd
fix except
Mar 17, 2025
f859a0a
Added to subtensor
ibraheem-abe Mar 17, 2025
d32dc2c
Added to async subtensor
ibraheem-abe Mar 17, 2025
03cd1db
adds unit test
ibraheem-abe Mar 17, 2025
09ed453
added e2es
ibraheem-abe Mar 17, 2025
23c5976
Merge pull request #2746 from opentensor/fix/zyzniewski/test_incentive
ibraheem-abe Mar 17, 2025
e3d836a
Merge branch 'staging' into feat/roman/test-run-tests-without-building
ibraheem-abe Mar 17, 2025
d4c3a16
Bumps async substrate
ibraheem-abe Mar 17, 2025
3a58d4a
Merge branch 'master' into feat/dynamic-stake-prices
ibraheem-abe Mar 17, 2025
3d648df
Merge pull request #2743 from opentensor/feat/roman/test-run-tests-wi…
basfroman Mar 17, 2025
8016b02
Allows installation on 3.13
thewhaleking Mar 17, 2025
d5a632f
Merge branch 'staging' into feat/dynamic-stake-prices
ibraheem-abe Mar 17, 2025
a5d391d
improve e2e
ibraheem-abe Mar 17, 2025
957649d
Merge pull request #2756 from opentensor/feat/thewhaleking/add-3-13-s…
thewhaleking Mar 17, 2025
f7c2273
Improves all apis
ibraheem-abe Mar 17, 2025
ab4de41
Merge branch 'staging' into feat/dynamic-stake-prices
ibraheem-abe Mar 17, 2025
7b0c1ea
Update test
ibraheem-abe Mar 17, 2025
64bd56b
Make rao -> tao
ibraheem-abe Mar 17, 2025
acc66f8
Revert unneeded change
ibraheem-abe Mar 17, 2025
efbf98c
Merge pull request #2755 from opentensor/feat/dynamic-stake-prices
ibraheem-abe Mar 18, 2025
8d704eb
Bumps version and changelog
ibraheem-abe Mar 18, 2025
31b0718
Merge pull request #2758 from opentensor/changelog/902
ibraheem-abe Mar 18, 2025
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
81 changes: 34 additions & 47 deletions .github/workflows/e2e-subtensor-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ env:

# job to run tests in parallel
jobs:
# Job to find all test files

find-tests:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.draft == false }}
Expand All @@ -42,68 +42,55 @@ jobs:
echo "::set-output name=test-files::$test_files"
shell: bash

pull-docker-image:
runs-on: ubuntu-latest
steps:
- name: Log in to GitHub Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin

- name: Pull Docker Image
run: docker pull ghcr.io/opentensor/subtensor-localnet:latest

- name: Save Docker Image to Cache
run: docker save -o subtensor-localnet.tar ghcr.io/opentensor/subtensor-localnet:latest

- name: Upload Docker Image as Artifact
uses: actions/upload-artifact@v4
with:
name: subtensor-localnet
path: subtensor-localnet.tar

# Job to run tests in parallel
run:
needs: find-tests
runs-on: SubtensorCI
needs:
- find-tests
- pull-docker-image
runs-on: ubuntu-latest
timeout-minutes: 45
strategy:
fail-fast: false # Allow other matrix jobs to run even if this job fails
max-parallel: 8 # Set the maximum number of parallel jobs
max-parallel: 32 # Set the maximum number of parallel jobs (same as we have cores in SubtensorCI runner)
matrix:
rust-branch:
- stable
rust-target:
- x86_64-unknown-linux-gnu
os:
- ubuntu-latest
test-file: ${{ fromJson(needs.find-tests.outputs.test-files) }}
env:
RELEASE_NAME: development
RUSTV: ${{ matrix.rust-branch }}
RUST_BACKTRACE: full
RUST_BIN_DIR: target/${{ matrix.rust-target }}
TARGET: ${{ matrix.rust-target }}
steps:
- name: Check-out repository under $GITHUB_WORKSPACE
- name: Check-out repository
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update &&
sudo apt-get install -y clang curl libssl-dev llvm libudev-dev protobuf-compiler

- name: Install Rust ${{ matrix.rust-branch }}
uses: actions-rs/[email protected]
with:
toolchain: ${{ matrix.rust-branch }}
components: rustfmt
profile: minimal

- name: Add wasm32-unknown-unknown target
run: |
rustup target add wasm32-unknown-unknown --toolchain stable-x86_64-unknown-linux-gnu
rustup component add rust-src --toolchain stable-x86_64-unknown-linux-gnu

- name: Clone subtensor repo
run: git clone https://github.com/opentensor/subtensor.git

- name: Setup subtensor repo
working-directory: ${{ github.workspace }}/subtensor
run: git checkout devnet-ready

- name: Install uv
uses: astral-sh/setup-uv@v4

- name: install dependencies
run: uv sync --all-extras --dev

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

- name: Retry failed tests
if: failure()
run: |
sleep 10
LOCALNET_SH_PATH="${{ github.workspace }}/subtensor/scripts/localnet.sh" uv run pytest ${{ matrix.test-file }} -s
- name: Load Docker Image
run: docker load -i subtensor-localnet.tar

- name: Run tests
run: uv run pytest ${{ matrix.test-file }} -s
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 9.2.0 /2025-03-18

## What's Changed
* Fix E2E test_incentive by waiting till start of the very next epoch by @zyzniewski-reef in https://github.com/opentensor/bittensor/pull/2746
* New era of e2e Tests Bittensor by @roman-opentensor in https://github.com/opentensor/bittensor/pull/2743
* Allow installation on Py 3.13 by @thewhaleking in https://github.com/opentensor/bittensor/pull/2756
* Feat/dynamic stake prices by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/2755

**Full Changelog**: https://github.com/opentensor/bittensor/compare/v9.1.0...v9.2.0

## 9.1.0 /2025-03-12

## What's Changed
Expand Down
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,49 @@ The Python interpreter output will look like below.
>>>
```

### Testing
You can run integration and unit tests in interactive mode of IDE or in terminal mode using the command:
```bash
pytest tests/integration_tests
pytest tests/unit_tests
```

#### E2E tests have 2 options for launching (legacy runner):
- using a compiler based on the substrait code
- using an already built docker image (docker runner)

#### Using `docker runner` (default for now):
- E2E tests with docker image do not require preliminary compilation
- are executed very quickly
- require docker installed in OS

Ho to use:
```bash
pytest tests/e2e_tests
```

#### TUsing `legacy runner`:
- Will start compilation of the collected code in your subtensor repository
- 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
- you can use the `BUILD_BINARY=0` variable, this will skip the copy step for each test.
- you can use the `USE_DOCKER=0` variable, this will run tests using the "legacy runner", even if docker is installed in your OS

#### Ho to use:
Regular e2e tests run
```bash
LOCALNET_SH_PATH=/path/to/your/localnet.sh pytest tests/e2e_tests
```

If you want to skip re-build process for each e2e test
```bash
BUILD_BINARY=0 LOCALNET_SH_PATH=/path/to/your/localnet.sh pytest tests/e2e_tests
```

If you want to use legacy runner even with installed Docker in your OS
```bash
USE_DOCKER=0 BUILD_BINARY=0 LOCALNET_SH_PATH=/path/to/your/localnet.sh pytest tests/e2e_tests
```

---

## Release Guidelines
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9.1.0
9.2.0
111 changes: 111 additions & 0 deletions bittensor/core/async_subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1575,6 +1575,117 @@ async def get_stake(

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

async def get_stake_add_fee(
self,
amount: Balance,
netuid: int,
coldkey_ss58: str,
hotkey_ss58: str,
block: Optional[int] = None,
) -> Balance:
"""
Calculates the fee for adding new stake to a hotkey.

Args:
amount: Amount of stake to add in TAO
netuid: Netuid of subnet
coldkey_ss58: SS58 address of source coldkey
hotkey_ss58: SS58 address of destination hotkey
block: Block number at which to perform the calculation

Returns:
The calculated stake fee as a Balance object
"""
result = await self.query_runtime_api(
runtime_api="StakeInfoRuntimeApi",
method="get_stake_fee",
params=[
None,
coldkey_ss58,
(hotkey_ss58, netuid),
coldkey_ss58,
amount.rao,
],
block=block,
)
return Balance.from_rao(result)

async def get_unstake_fee(
self,
amount: Balance,
netuid: int,
coldkey_ss58: str,
hotkey_ss58: str,
block: Optional[int] = None,
) -> Balance:
"""
Calculates the fee for unstaking from a hotkey.

Args:
amount: Amount of stake to unstake in TAO
netuid: Netuid of subnet
coldkey_ss58: SS58 address of source coldkey
hotkey_ss58: SS58 address of destination hotkey
block: Block number at which to perform the calculation

Returns:
The calculated stake fee as a Balance object
"""
result = await self.query_runtime_api(
runtime_api="StakeInfoRuntimeApi",
method="get_stake_fee",
params=[
None,
coldkey_ss58,
(hotkey_ss58, netuid),
coldkey_ss58,
amount.rao,
],
block=block,
)
return Balance.from_rao(result)

async def get_stake_movement_fee(
self,
amount: Balance,
origin_netuid: int,
origin_hotkey_ss58: str,
origin_coldkey_ss58: str,
destination_netuid: int,
destination_hotkey_ss58: str,
destination_coldkey_ss58: str,
block: Optional[int] = None,
) -> Balance:
"""
Calculates the fee for moving stake between hotkeys/subnets/coldkeys.

Args:
amount: Amount of stake to move in TAO
origin_netuid: Netuid of source subnet
origin_hotkey_ss58: SS58 address of source hotkey
origin_coldkey_ss58: SS58 address of source coldkey
destination_netuid: Netuid of destination subnet
destination_hotkey_ss58: SS58 address of destination hotkey
destination_coldkey_ss58: SS58 address of destination coldkey
block: Block number at which to perform the calculation

Returns:
The calculated stake fee as a Balance object
"""
result = await self.query_runtime_api(
runtime_api="StakeInfoRuntimeApi",
method="get_stake_fee",
params=[
(origin_hotkey_ss58, origin_netuid),
origin_coldkey_ss58,
(destination_hotkey_ss58, destination_netuid),
destination_coldkey_ss58,
amount.rao,
],
block=block,
)
return Balance.from_rao(result)

async def get_stake_for_coldkey_and_hotkey(
self,
coldkey_ss58: str,
Expand Down
2 changes: 1 addition & 1 deletion bittensor/core/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "9.1.0"
__version__ = "9.2.0"

import os
import re
Expand Down
Loading
Loading