Skip to content

Commit 922b9b3

Browse files
authored
Merge branch 'staging' into feat--silent-aiohttp.ClientOSError
2 parents 70b0704 + 53762f7 commit 922b9b3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1666
-783
lines changed

.circleci/config.yml

Lines changed: 6 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
python -m venv .venv
4040
. .venv/bin/activate
4141
python -m pip install --upgrade uv
42-
uv pip install ruff -c requirements/dev.txt
42+
uv pip install ruff==0.11.5
4343
4444
- save_cache:
4545
name: Save cached ruff venv
@@ -68,9 +68,7 @@ jobs:
6868
name: Install dependencies and Check compatibility
6969
command: |
7070
if [ "$REQUIREMENTS_CHANGED" == "true" ]; then
71-
sudo apt-get update
72-
sudo apt-get install -y jq curl
73-
./scripts/check_compatibility.sh << parameters.python_version >>
71+
python -m pip install ".[dev,cli]" --dry-run --python-version << parameters.python_version >> --no-deps
7472
else
7573
echo "Skipping compatibility checks..."
7674
fi
@@ -87,31 +85,19 @@ jobs:
8785
steps:
8886
- checkout
8987

90-
- restore_cache:
91-
name: Restore cached venv
92-
keys:
93-
- v2-pypi-py<< parameters.python-version >>-{{ checksum "requirements/prod.txt" }}+{{ checksum "requirements/dev.txt" }}
94-
- v2-pypi-py<< parameters.python-version >>
95-
9688
- run:
9789
name: Update & Activate venv
9890
command: |
9991
python -m venv .venv
10092
. .venv/bin/activate
10193
python -m pip install --upgrade uv
102-
uv sync --all-extras --dev
103-
104-
- save_cache:
105-
name: Save cached venv
106-
paths:
107-
- "venv/"
108-
key: v2-pypi-py<< parameters.python-version >>-{{ checksum "requirements/prod.txt" }}+{{ checksum "requirements/dev.txt" }}
94+
uv sync --extra dev --dev
10995
11096
- run:
11197
name: Install Bittensor
11298
command: |
11399
. .venv/bin/activate
114-
uv sync --all-extras --dev
100+
uv sync --extra dev --dev
115101
116102
- run:
117103
name: Instantiate Mock Wallet
@@ -178,32 +164,20 @@ jobs:
178164
steps:
179165
- checkout
180166

181-
- restore_cache:
182-
name: Restore cached venv
183-
keys:
184-
- v2-pypi-py<< parameters.python-version >>-{{ checksum "requirements/prod.txt" }}+{{ checksum "requirements/dev.txt" }}
185-
- v2-pypi-py<< parameters.python-version >>
186-
187167
- run:
188168
name: Update & Activate venv
189169
command: |
190170
python -m venv .venv
191171
. .venv/bin/activate
192172
python -m pip install --upgrade uv
193-
uv sync --all-extras --dev
173+
uv sync --extra dev --dev
194174
uv pip install flake8
195175
196-
- save_cache:
197-
name: Save cached venv
198-
paths:
199-
- "env/"
200-
key: v2-pypi-py<< parameters.python-version >>-{{ checksum "requirements/prod.txt" }}+{{ checksum "requirements/dev.txt" }}
201-
202176
- run:
203177
name: Install Bittensor
204178
command: |
205179
. .venv/bin/activate
206-
uv sync --all-extras --dev
180+
uv sync --extra dev --dev
207181
208182
- run:
209183
name: Lint with flake8
@@ -235,18 +209,6 @@ jobs:
235209
uv pip install --upgrade coveralls
236210
coveralls --finish --rcfile .coveragerc || echo "Failed to upload coverage"
237211
238-
check-version-updated:
239-
docker:
240-
- image: cimg/python:3.10
241-
steps:
242-
- checkout
243-
244-
- run:
245-
name: Version is updated
246-
command: |
247-
[[ $(git diff-tree --no-commit-id --name-only -r HEAD..master | grep bittensor/__init__.py | wc -l) == 1 ]] && echo "bittensor/__init__.py has changed"
248-
[[ $(git diff-tree --no-commit-id --name-only -r HEAD..master | grep VERSION | wc -l) == 1 ]] && echo "VERSION has changed"
249-
250212
check-changelog-updated:
251213
docker:
252214
- image: cimg/python:3.10
@@ -323,11 +285,6 @@ workflows:
323285

324286
release-branches-requirements:
325287
jobs:
326-
- check-version-updated:
327-
filters:
328-
branches:
329-
only:
330-
- /^(release|hotfix)/.*/
331288
- check-changelog-updated:
332289
filters:
333290
branches:

.github/dependabot.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
version: 2
22
updates:
33
- package-ecosystem: "pip"
4-
directory: ""
5-
file: "requirements/prod.txt"
4+
directory: "/"
65
schedule:
76
interval: "daily"
87
open-pull-requests-limit: 0 # Only security updates will be opened as PRs

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

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
test_files=$(find tests/e2e_tests -name "test*.py" | jq -R -s -c 'split("\n") | map(select(. != ""))')
4242
# keep it here for future debug
4343
# test_files=$(find tests/e2e_tests -type f -name "test*.py" | grep -E 'test_(incentive|commit_weights|set_weights)\.py$' | jq -R -s -c 'split("\n") | map(select(. != ""))')
44-
echo "::set-output name=test-files::$test_files"
44+
echo "test-files=$test_files" >> "$GITHUB_OUTPUT"
4545
shell: bash
4646

4747
pull-docker-image:
@@ -91,7 +91,7 @@ jobs:
9191
uses: astral-sh/setup-uv@v4
9292

9393
- name: install dependencies
94-
run: uv sync --all-extras --dev
94+
run: uv sync --extra dev --dev
9595

9696
- name: Download Cached Docker Image
9797
uses: actions/download-artifact@v4
@@ -101,5 +101,26 @@ jobs:
101101
- name: Load Docker Image
102102
run: docker load -i subtensor-localnet.tar
103103

104-
- name: Run tests
105-
run: uv run pytest ${{ matrix.test-file }} -s
104+
# - name: Run tests
105+
# run: uv run pytest ${{ matrix.test-file }} -s
106+
107+
- name: Run tests with retry
108+
run: |
109+
set +e
110+
for i in 1 2; do
111+
echo "🔁 Attempt $i: Running tests"
112+
uv run pytest ${{ matrix.test-file }} -s
113+
status=$?
114+
if [ $status -eq 0 ]; then
115+
echo "✅ Tests passed on attempt $i"
116+
break
117+
else
118+
echo "❌ Tests failed on attempt $i"
119+
if [ $i -eq 2 ]; then
120+
echo "Tests failed after 2 attempts"
121+
exit 1
122+
fi
123+
echo "Retrying..."
124+
sleep 5
125+
fi
126+
done

CHANGELOG.md

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

3+
## 9.3.1a1 /2025-04-14
4+
5+
## What's Changed
6+
* Release/9.3.0 by @ibraheem-abe in https://github.com/opentensor/bittensor/pull/2805
7+
* Fix for flaky behavior of `test_incentive`, `test_commit_weights` and `test_set_weights` by @basfroman in https://github.com/opentensor/bittensor/pull/2795
8+
* Add `get_next_epoch_start_block` method to Async/Subtensor by @basfroman in https://github.com/opentensor/bittensor/pull/2808
9+
* Adds compatibility for torch 2.6.0+ by @thewhaleking in https://github.com/opentensor/bittensor/pull/2811
10+
* f Update CONTRIBUTING.md by @Hack666r in https://github.com/opentensor/bittensor/pull/2813
11+
* docs: replaced discord link with documentation by @sashaphmn in https://github.com/opentensor/bittensor/pull/2809
12+
* sometimes it's still flaky because the chain returns data with time offset by @basfroman in https://github.com/opentensor/bittensor/pull/2816
13+
* Remove requirements directory by @thewhaleking in https://github.com/opentensor/bittensor/pull/2812
14+
* version in one place by @thewhaleking in https://github.com/opentensor/bittensor/pull/2806
15+
* Update CONTRIBUTING hyperlinks by @thewhaleking in https://github.com/opentensor/bittensor/pull/2820
16+
17+
## New Contributors
18+
* @Hack666r made their first contribution in https://github.com/opentensor/bittensor/pull/2813
19+
20+
**Full Changelog**: https://github.com/opentensor/bittensor/compare/v9.3.0...v9.3.1a1
21+
322
## 9.3.0 /2025-04-09
423

524
## What's Changed

Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,3 @@ install:
2121

2222
install-dev:
2323
python3 -m pip install '.[dev]'
24-
25-
install-cubit:
26-
python3 -m pip install '.[cubit]'

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
## Internet-scale Neural Networks <!-- omit in toc -->
1212

13-
[Discord](https://discord.gg/qasY3HA9F9)[Network](https://taostats.io/)[Research](https://bittensor.com/whitepaper)
13+
[Discord](https://discord.gg/qasY3HA9F9)[Network](https://taostats.io/)[Research](https://bittensor.com/whitepaper)[Documentation](https://docs.bittensor.com)
1414

1515
</div>
1616

VERSION

Lines changed: 0 additions & 1 deletion
This file was deleted.

bittensor/core/async_subtensor.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
publish_metadata,
5858
get_metadata,
5959
)
60+
from bittensor.core.extrinsics.asyncex.start_call import start_call_extrinsic
6061
from bittensor.core.extrinsics.asyncex.serving import serve_axon_extrinsic
6162
from bittensor.core.extrinsics.asyncex.staking import (
6263
add_stake_extrinsic,
@@ -752,6 +753,7 @@ async def does_hotkey_exist(
752753
return_val = (
753754
False
754755
if result is None
756+
# not the default key (0x0)
755757
else result != "5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM"
756758
)
757759
return return_val
@@ -3004,7 +3006,7 @@ async def wait_for_block(self, block: Optional[int] = None):
30043006

30053007
async def handler(block_data: dict):
30063008
logging.debug(
3007-
f'reached block {block_data["header"]["number"]}. Waiting for block {target_block}'
3009+
f"reached block {block_data['header']['number']}. Waiting for block {target_block}"
30083010
)
30093011
if block_data["header"]["number"] >= target_block:
30103012
return True
@@ -3181,7 +3183,7 @@ async def sign_and_send_extrinsic(
31813183
return True, ""
31823184

31833185
if raise_error:
3184-
raise ChainError.from_error(response.error_message)
3186+
raise ChainError.from_error(await response.error_message)
31853187

31863188
return False, format_error_message(await response.error_message)
31873189

@@ -3986,6 +3988,36 @@ async def serve_axon(
39863988
certificate=certificate,
39873989
)
39883990

3991+
async def start_call(
3992+
self,
3993+
wallet: "Wallet",
3994+
netuid: int,
3995+
wait_for_inclusion: bool = True,
3996+
wait_for_finalization: bool = False,
3997+
) -> tuple[bool, str]:
3998+
"""
3999+
Submits a start_call extrinsic to the blockchain, to trigger the start call process for a subnet (used to start a
4000+
new subnet's emission mechanism).
4001+
4002+
Args:
4003+
wallet (Wallet): The wallet used to sign the extrinsic (must be unlocked).
4004+
netuid (int): The UID of the target subnet for which the call is being initiated.
4005+
wait_for_inclusion (bool, optional): Whether to wait for the extrinsic to be included in a block. Defaults to True.
4006+
wait_for_finalization (bool, optional): Whether to wait for finalization of the extrinsic. Defaults to False.
4007+
4008+
Returns:
4009+
Tuple[bool, str]:
4010+
- True and a success message if the extrinsic is successfully submitted or processed.
4011+
- False and an error message if the submission fails or the wallet cannot be unlocked.
4012+
"""
4013+
return await start_call_extrinsic(
4014+
subtensor=self,
4015+
wallet=wallet,
4016+
netuid=netuid,
4017+
wait_for_inclusion=wait_for_inclusion,
4018+
wait_for_finalization=wait_for_finalization,
4019+
)
4020+
39894021
async def swap_stake(
39904022
self,
39914023
wallet: "Wallet",

bittensor/core/axon.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,9 @@ def verify_custom(synapse: MyCustomSynapse):
504504
)
505505

506506
param_class = first_param.annotation
507-
assert issubclass(
508-
param_class, Synapse
509-
), "The first argument of forward_fn must inherit from bittensor.Synapse"
507+
assert issubclass(param_class, Synapse), (
508+
"The first argument of forward_fn must inherit from bittensor.Synapse"
509+
)
510510
request_name = param_class.__name__
511511

512512
async def endpoint(*args, **kwargs):
@@ -580,19 +580,19 @@ async def endpoint(*args, **kwargs):
580580
blacklist_sig = Signature(
581581
expected_params, return_annotation=Tuple[bool, str]
582582
)
583-
assert (
584-
signature(blacklist_fn) == blacklist_sig
585-
), f"The blacklist_fn function must have the signature: blacklist( synapse: {request_name} ) -> tuple[bool, str]"
583+
assert signature(blacklist_fn) == blacklist_sig, (
584+
f"The blacklist_fn function must have the signature: blacklist( synapse: {request_name} ) -> tuple[bool, str]"
585+
)
586586
if priority_fn:
587587
priority_sig = Signature(expected_params, return_annotation=float)
588-
assert (
589-
signature(priority_fn) == priority_sig
590-
), f"The priority_fn function must have the signature: priority( synapse: {request_name} ) -> float"
588+
assert signature(priority_fn) == priority_sig, (
589+
f"The priority_fn function must have the signature: priority( synapse: {request_name} ) -> float"
590+
)
591591
if verify_fn:
592592
verify_sig = Signature(expected_params, return_annotation=None)
593-
assert (
594-
signature(verify_fn) == verify_sig
595-
), f"The verify_fn function must have the signature: verify( synapse: {request_name} ) -> None"
593+
assert signature(verify_fn) == verify_sig, (
594+
f"The verify_fn function must have the signature: verify( synapse: {request_name} ) -> None"
595+
)
596596

597597
# Store functions in appropriate attribute dictionaries
598598
self.forward_class_types[request_name] = param_class
@@ -747,9 +747,9 @@ def check_config(cls, config: "Config"):
747747
Raises:
748748
AssertionError: If the axon or external ports are not in range [1024, 65535]
749749
"""
750-
assert (
751-
1024 < config.axon.port < 65535
752-
), "Axon port must be in range [1024, 65535]"
750+
assert 1024 < config.axon.port < 65535, (
751+
"Axon port must be in range [1024, 65535]"
752+
)
753753

754754
assert config.axon.external_port is None or (
755755
1024 < config.axon.external_port < 65535

bittensor/core/chain_data/metagraph_info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def _chr_str(codes: tuple[int]) -> str:
2525
def process_nested(data: Union[tuple, dict], chr_transform):
2626
"""Processes nested data structures by applying a transformation function to their elements."""
2727
if isinstance(data, (list, tuple)):
28-
if len(data) > 0 and isinstance(data[0], dict):
28+
if len(data) > 0:
2929
return [
3030
{k: chr_transform(v) for k, v in item.items()}
3131
if item is not None

0 commit comments

Comments
 (0)