Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
7cb256f
fix: update pull request template links to properly reload appropriat…
AgSpades May 18, 2025
7310523
fix: update PR template links to use full paths
AgSpades May 18, 2025
0e463b8
fix: template rendering with required 'expand' query parameter
AgSpades May 18, 2025
8b19348
Merge branch 'staging' into fix-pr-template
basfroman May 20, 2025
7e4b02a
Merge branch 'staging' into fix-pr-template
basfroman May 21, 2025
e301a3b
Merge branch 'staging' into fix-pr-template
AgSpades May 23, 2025
4b8fef8
add `get_subnet_info` to subtensors
May 23, 2025
50fc0aa
add unit tests for `get_subnet_info` to subtensors
May 23, 2025
2ab8a71
update SubtensorApi
May 23, 2025
b0d159e
ruff
May 23, 2025
c8d3d59
Merge pull request #2894 from opentensor/feat/roman/add-get_subnet_info
basfroman May 27, 2025
332fc21
improve skipping logic (no error when skip the job)
May 28, 2025
d6393f9
is `blocks_since_last_step==0` then `get_next_epoch_start_block` retu…
May 28, 2025
9b30583
add unit test for 3 scenarios
May 28, 2025
155ca25
Merge pull request #2899 from opentensor/fix/roman/get_next_epoch_sta…
basfroman May 28, 2025
c95b7cb
Merge branch 'staging' into fix/roman/improve-skipping-job
basfroman May 28, 2025
6219525
Merge pull request #2898 from opentensor/fix/roman/improve-skipping-job
basfroman May 29, 2025
9bfdae4
replace `transfer_allow_death` with `transfer_keep_alive`
May 29, 2025
e12b20f
update tests
May 29, 2025
23f25a3
Merge branch 'staging' into fix-pr-template
basfroman May 29, 2025
f4abe88
Merge pull request #2900 from opentensor/feat/roman/replace-transfer_…
basfroman May 29, 2025
aaa3c22
bumps version and changelog
ibraheem-abe May 29, 2025
e52602e
Merge pull request #2901 from opentensor/changelog/9.6.2
ibraheem-abe May 29, 2025
1bed73f
Merge branch 'staging' into fix-pr-template
thewhaleking May 29, 2025
6bf7d42
Merge pull request #2883 from AgSpades/fix-pr-template
basfroman May 29, 2025
35212f7
Update PR templates so users acknowledge they are opening against the…
thewhaleking May 29, 2025
2ee7164
Merge pull request #2903 from opentensor/feat/thewhaleking/update-pr-…
basfroman May 29, 2025
0414d4e
bumps version & changelog
ibraheem-abe May 29, 2025
7b25284
remove old ref
ibraheem-abe May 29, 2025
5e32c05
Merge pull request #2904 from opentensor/changelog/970
ibraheem-abe May 29, 2025
5dcf51b
Merge branch 'master' into release/9.7.0
ibraheem-abe May 29, 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
6 changes: 5 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE/bug_fix.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,8 @@ Examples:
- Fixed an issue where multiple cursors did not work in a file with a single line.
- Increased the performance of searching and replacing across a whole project.

-->
-->


### Branch Acknowledgement
[ ] I am acknowledging that I am opening this branch against `staging`
6 changes: 5 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE/feature_change.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@ Examples:
- Fixed an issue where multiple cursors did not work in a file with a single line.
- Increased the performance of searching and replacing across a whole project.

-->
-->


### Branch Acknowledgement
[ ] I am acknowledging that I am opening this branch against `staging`
6 changes: 5 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE/performance_improvement.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ Examples:
- Fixed an issue where multiple cursors did not work in a file with a single line.
- Increased the performance of searching and replacing across a whole project.

-->
-->


### Branch Acknowledgement
[ ] I am acknowledging that I am opening this branch against `staging`
6 changes: 3 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ please switch to **Preview** for links to render properly.

Please choose the right template for your pull request:

- 🐛 Are you fixing a bug? [Bug fix](?template=bug_fix.md)
- 📈 Are you improving performance? [Performance improvement](?template=performance_improvement.md)
- 💻 Are you changing functionality? [Feature change](?template=feature_change.md)
- 🐛 Are you fixing a bug? [Bug fix](?expand=1&template=bug_fix.md)
- 📈 Are you improving performance? [Performance improvement](?expand=1&template=performance_improvement.md)
- 💻 Are you changing functionality? [Feature change](?expand=1&template=feature_change.md)
30 changes: 21 additions & 9 deletions .github/workflows/e2e-subtensor-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,75 +128,87 @@
fi
done

# run non-fast-blocks only on Saturday and by cron schedule
check-if-saturday:
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
outputs:
is-saturday: ${{ steps.check.outputs.is-saturday }}
steps:
- id: check
run: |
day=$(date -u +%u)
echo "Today is weekday $day"
if [ "$day" -ne 6 ]; then
echo "⏭️ Skipping: not Saturday"
echo "is-saturday=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "is-saturday=true"
echo "is-saturday=true" >> "$GITHUB_OUTPUT"


cron-run-non-fast-blocks-e2e-test:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
if: github.event_name == 'schedule'
if: github.event_name == 'schedule' && needs.check-if-saturday.outputs.is-saturday == 'true'
name: "NFB: ${{ matrix.test-file }} / Python ${{ matrix.python-version }}"
needs:
- check-if-saturday
- find-tests
- pull-docker-image
runs-on: ubuntu-latest
timeout-minutes: 1440

strategy:
fail-fast: false # Allow other matrix jobs to run even if this job fails
max-parallel: 32 # Set the maximum number of parallel jobs (same as we have cores in ubuntu-latest runner)
matrix:
os:
- ubuntu-latest
test-file: ${{ fromJson(needs.find-tests.outputs.test-files) }}
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- name: Check if today is Saturday
run: |
day=$(date -u +%u)
echo "Today is weekday $day"
if [ "$day" -ne 6 ]; then
echo "⏭️ Skipping: not Saturday"
exit 78
fi
- name: Check-out repository
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

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

- name: install dependencies
run: uv sync --extra dev --dev

- name: Download Cached Docker Image
uses: actions/download-artifact@v4
with:
name: subtensor-localnet

- name: Load Docker Image
run: docker load -i subtensor-localnet.tar

- name: Run patched E2E tests
env:
FAST_BLOCKS: "0"
run: |
set +e
for i in 1 2 3; do
echo "🔁 Attempt $i: Running tests"
uv run pytest ${{ matrix.test-file }} -s
status=$?
if [ $status -eq 0 ]; then
echo "✅ Tests passed on attempt $i"
break
else
echo "❌ Tests failed on attempt $i"
if [ $i -eq 3 ]; then
echo "Tests failed after 3 attempts"
exit 1
fi
echo "Retrying..."
sleep 5
fi
done

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 9.7.0 /2025-05-29

## What's Changed
* Add `get_subnet_info` by @basfroman in https://github.com/opentensor/bittensor/pull/2894
* Fix bug in `get_next_epoch_start_block` by @basfroman in https://github.com/opentensor/bittensor/pull/2899
* e2e workflow: improve skipping logic (no error when skip the job) by @basfroman in https://github.com/opentensor/bittensor/pull/2898
* Replace `transfer_allow_death` with `transfer_keep_alive` by @basfroman in https://github.com/opentensor/bittensor/pull/2900
* Fix broken pull request template links (#2867) by @AgSpades in https://github.com/opentensor/bittensor/pull/2883
* update pr templates with branch ack by @thewhaleking in https://github.com/opentensor/bittensor/pull/2903

## New Contributors
* @AgSpades made their first contribution in https://github.com/opentensor/bittensor/pull/2883

**Full Changelog**: https://github.com/opentensor/bittensor/compare/v9.6.1...v9.7.0

## 9.6.1 /2025-05-22

## What's Changed
Expand Down
40 changes: 38 additions & 2 deletions bittensor/core/async_subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1796,7 +1796,7 @@ async def get_next_epoch_start_block(
netuid=netuid, block=block, block_hash=block_hash, reuse_block=reuse_block
)

if block and blocks_since_last_step and tempo:
if block and blocks_since_last_step is not None and tempo:
return block - blocks_since_last_step + tempo + 1
return None

Expand Down Expand Up @@ -1921,6 +1921,42 @@ async def get_stake_add_fee(
)
return Balance.from_rao(result)

async def get_subnet_info(
self,
netuid: int,
block: Optional[int] = None,
block_hash: Optional[str] = None,
reuse_block: bool = False,
) -> Optional["SubnetInfo"]:
"""
Retrieves detailed information about subnet within the Bittensor network.
This function provides comprehensive data on subnet, including its characteristics and operational parameters.

Arguments:
netuid: The unique identifier of the subnet.
block: The blockchain block number for the query.
block_hash (Optional[str]): The hash of the block to retrieve the stake from. Do not specify if using block
or reuse_block
reuse_block (bool): Whether to use the last-used block. Do not set if using block_hash or block.

Returns:
SubnetInfo: A SubnetInfo objects, each containing detailed information about a subnet.

Gaining insights into the subnet's details assists in understanding the network's composition, the roles of
different subnets, and their unique features.
"""
result = await self.query_runtime_api(
runtime_api="SubnetInfoRuntimeApi",
method="get_subnet_info_v2",
params=[netuid],
block=block,
block_hash=block_hash,
reuse_block=reuse_block,
)
if not result:
return None
return SubnetInfo.from_dict(result)

async def get_unstake_fee(
self,
amount: Balance,
Expand Down Expand Up @@ -2286,7 +2322,7 @@ async def get_transfer_fee(

call = await self.substrate.compose_call(
call_module="Balances",
call_function="transfer_allow_death",
call_function="transfer_keep_alive",
call_params={"dest": dest, "value": value.rao},
)

Expand Down
2 changes: 1 addition & 1 deletion bittensor/core/extrinsics/asyncex/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async def _do_transfer(
"""
call = await subtensor.substrate.compose_call(
call_module="Balances",
call_function="transfer_allow_death",
call_function="transfer_keep_alive",
call_params={"dest": destination, "value": amount.rao},
)

Expand Down
2 changes: 1 addition & 1 deletion bittensor/core/extrinsics/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def _do_transfer(
"""
call = subtensor.substrate.compose_call(
call_module="Balances",
call_function="transfer_allow_death",
call_function="transfer_keep_alive",
call_params={"dest": destination, "value": amount.rao},
)

Expand Down
31 changes: 29 additions & 2 deletions bittensor/core/subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,7 @@ def get_next_epoch_start_block(
blocks_since_last_step = self.blocks_since_last_step(netuid=netuid, block=block)
tempo = self.tempo(netuid=netuid, block=block)

if block and blocks_since_last_step and tempo:
if block and blocks_since_last_step is not None and tempo:
return block - blocks_since_last_step + tempo + 1
return None

Expand Down Expand Up @@ -1507,6 +1507,33 @@ def get_stake_add_fee(
)
return Balance.from_rao(result)

def get_subnet_info(
self, netuid: int, block: Optional[int] = None
) -> Optional["SubnetInfo"]:
"""
Retrieves detailed information about subnet within the Bittensor network.
This function provides comprehensive data on subnet, including its characteristics and operational parameters.

Arguments:
netuid: The unique identifier of the subnet.
block: The blockchain block number for the query.

Returns:
SubnetInfo: A SubnetInfo objects, each containing detailed information about a subnet.

Gaining insights into the subnet's details assists in understanding the network's composition, the roles of
different subnets, and their unique features.
"""
result = self.query_runtime_api(
runtime_api="SubnetInfoRuntimeApi",
method="get_subnet_info_v2",
params=[netuid],
block=block,
)
if not result:
return None
return SubnetInfo.from_dict(result)

def get_unstake_fee(
self,
amount: Balance,
Expand Down Expand Up @@ -1804,7 +1831,7 @@ def get_transfer_fee(self, wallet: "Wallet", dest: str, value: Balance) -> Balan
value = check_and_convert_to_balance(value)
call = self.substrate.compose_call(
call_module="Balances",
call_function="transfer_allow_death",
call_function="transfer_keep_alive",
call_params={"dest": dest, "value": value.rao},
)

Expand Down
1 change: 1 addition & 0 deletions bittensor/core/subtensor_api/subnets.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(self, subtensor: Union["_Subtensor", "_AsyncSubtensor"]):
self.get_next_epoch_start_block = subtensor.get_next_epoch_start_block
self.get_subnet_burn_cost = subtensor.get_subnet_burn_cost
self.get_subnet_hyperparameters = subtensor.get_subnet_hyperparameters
self.get_subnet_info = subtensor.get_subnet_info
self.get_subnet_owner_hotkey = subtensor.get_subnet_owner_hotkey
self.get_subnet_reveal_period_epochs = subtensor.get_subnet_reveal_period_epochs
self.get_subnet_validator_permits = subtensor.get_subnet_validator_permits
Expand Down
1 change: 1 addition & 0 deletions bittensor/core/subtensor_api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def add_legacy_methods(subtensor: "SubtensorApi"):
subtensor.get_subnet_hyperparameters = (
subtensor._subtensor.get_subnet_hyperparameters
)
subtensor.get_subnet_info = subtensor._subtensor.get_subnet_info
subtensor.get_subnet_owner_hotkey = subtensor._subtensor.get_subnet_owner_hotkey
subtensor.get_subnet_reveal_period_epochs = (
subtensor._subtensor.get_subnet_reveal_period_epochs
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "bittensor"
version = "9.6.1"
version = "9.7.0"
description = "Bittensor"
readme = "README.md"
authors = [
Expand Down
6 changes: 3 additions & 3 deletions tests/unit_tests/extrinsics/asyncex/test_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async def test_do_transfer_success(subtensor, fake_wallet, mocker):
# Asserts
subtensor.substrate.compose_call.assert_awaited_once_with(
call_module="Balances",
call_function="transfer_allow_death",
call_function="transfer_keep_alive",
call_params={"dest": fake_destination, "value": fake_amount.rao},
)

Expand Down Expand Up @@ -77,7 +77,7 @@ async def test_do_transfer_failure(subtensor, fake_wallet, mocker):
# Asserts
subtensor.substrate.compose_call.assert_awaited_once_with(
call_module="Balances",
call_function="transfer_allow_death",
call_function="transfer_keep_alive",
call_params={"dest": fake_destination, "value": fake_amount.rao},
)

Expand Down Expand Up @@ -124,7 +124,7 @@ async def test_do_transfer_no_waiting(subtensor, fake_wallet, mocker):
# Asserts
subtensor.substrate.compose_call.assert_awaited_once_with(
call_module="Balances",
call_function="transfer_allow_death",
call_function="transfer_keep_alive",
call_params={"dest": fake_destination, "value": fake_amount.rao},
)

Expand Down
6 changes: 3 additions & 3 deletions tests/unit_tests/extrinsics/test_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_do_transfer_is_success_true(subtensor, fake_wallet, mocker):
# Asserts
subtensor.substrate.compose_call.assert_called_once_with(
call_module="Balances",
call_function="transfer_allow_death",
call_function="transfer_keep_alive",
call_params={"dest": fake_dest, "value": fake_transfer_balance.rao},
)
subtensor.sign_and_send_extrinsic.assert_called_once_with(
Expand Down Expand Up @@ -64,7 +64,7 @@ def test_do_transfer_is_success_false(subtensor, fake_wallet, mocker):
# Asserts
subtensor.substrate.compose_call.assert_called_once_with(
call_module="Balances",
call_function="transfer_allow_death",
call_function="transfer_keep_alive",
call_params={"dest": fake_dest, "value": fake_transfer_balance.rao},
)
subtensor.sign_and_send_extrinsic.assert_called_once_with(
Expand Down Expand Up @@ -103,7 +103,7 @@ def test_do_transfer_no_waits(subtensor, fake_wallet, mocker):
# Asserts
subtensor.substrate.compose_call.assert_called_once_with(
call_module="Balances",
call_function="transfer_allow_death",
call_function="transfer_keep_alive",
call_params={"dest": fake_dest, "value": fake_transfer_balance.rao},
)
subtensor.sign_and_send_extrinsic.assert_called_once_with(
Expand Down
Loading
Loading