Skip to content

Commit

Permalink
Merge pull request #413 from backend-developers-ltd/upgrade-bittensor
Browse files Browse the repository at this point in the history
Upgrade bittensor to v9
  • Loading branch information
emnoor-reef authored Feb 13, 2025
2 parents 13ce663 + d44dab2 commit 06c35fb
Show file tree
Hide file tree
Showing 20 changed files with 736 additions and 1,064 deletions.
2 changes: 1 addition & 1 deletion compute_horde/compute_horde/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import bittensor
import pydantic
from substrateinterface.exceptions import SubstrateRequestException
from bittensor.core.errors import SubstrateRequestException

BAC_VALIDATOR_SS58_ADDRESS = "5HBVrFGy6oYhhh71m9fFGYD7zbKyAeHnWN8i8s9fJTBMCtEE"
MIN_STAKE = 1000
Expand Down
1 change: 0 additions & 1 deletion compute_horde/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def test(session):
session.run(
"pytest",
"-s",
"-x",
"-vv",
"--junitxml",
"test-report.xml",
Expand Down
2 changes: 1 addition & 1 deletion compute_horde/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ readme = "README.md"
requires-python = "==3.11.*"
dependencies = [
"pydantic<3,>=2.3",
"bittensor<9.0.0,>=8.3.1",
"bittensor>=9.0.0,<9.1",
"websockets>=14.0,<15.0",
"more-itertools>=10.2.0",
"phx-class-registry>=4.1.0",
Expand Down
4 changes: 2 additions & 2 deletions compute_horde/tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import random
from uuid import uuid4

from bittensor_wallet import Keypair
from bittensor import Keypair
from django.utils import timezone

from compute_horde.executor_class import ExecutorClass
Expand Down Expand Up @@ -41,4 +41,4 @@ def random_receipt(


def random_keypair() -> Keypair:
return Keypair.create_from_seed("".join(random.sample("0123456789abcdef" * 10, 64)))
return Keypair.create_from_seed(bytes(random.randint(0, 255) for _ in range(32)))
345 changes: 137 additions & 208 deletions compute_horde/uv.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion executor/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ def test(session):
session.run(
"pytest",
"-s",
"-x",
"-vv",
"-n",
"1",
Expand Down
332 changes: 132 additions & 200 deletions executor/uv.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import asgiref.sync
import bittensor
import substrateinterface.exceptions
from bittensor.core.errors import SubstrateRequestException
from compute_horde.subtensor import get_cycle_containing_block
from django.conf import settings

Expand Down Expand Up @@ -55,7 +55,7 @@ def fetch_current_block(self) -> int:
def fetch_neurons(self, netuid: int, block: int) -> list[bittensor.NeuronInfoLite]:
try:
return self.subtensor.neurons_lite(netuid, block) # type: ignore
except substrateinterface.exceptions.SubstrateRequestException as e:
except SubstrateRequestException as e:
if e.args[0]["code"] != UNKNOWN_BLOCK_ERROR:
raise

Expand Down
41 changes: 22 additions & 19 deletions miner/app/src/compute_horde_miner/miner/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,32 @@
@pytest.fixture(scope="session")
def validator_wallet():
wallet = bittensor.wallet(name="test_validator")
# workaround the overwrite flag
wallet.regenerate_coldkey(seed="a" * 64, use_password=False, overwrite=True)
wallet.regenerate_hotkey(seed="b" * 64, use_password=False, overwrite=True)
wallet.regenerate_coldkey(
mnemonic="local ghost evil lizard decade own lecture absurd vote despair predict cage",
use_password=False,
overwrite=True,
)
wallet.regenerate_hotkey(
mnemonic="position chicken ugly key sugar expect another require cinnamon rubber rich veteran",
use_password=False,
overwrite=True,
)
return wallet


@pytest.fixture(scope="function")
def miner_wallet(settings):
@pytest.fixture(scope="session", autouse=True)
def miner_wallet():
wallet = bittensor.wallet(name="test_miner")
# workaround the overwrite flag
wallet.regenerate_coldkey(seed="c" * 64, use_password=False, overwrite=True)
wallet.regenerate_hotkey(seed="d" * 64, use_password=False, overwrite=True)
wallet.regenerate_coldkey(
mnemonic="marine oyster umbrella sail over speak emerge rude matrix glue argue learn",
use_password=False,
overwrite=True,
)
wallet.regenerate_hotkey(
mnemonic="radio busy purpose chicken nose soccer private bridge nephew float ten media",
use_password=False,
overwrite=True,
)
return wallet


Expand All @@ -30,14 +44,3 @@ def some() -> Generator[int, None, None]:
# setup code
yield 1
# teardown code


@pytest.fixture(scope="session", autouse=True)
def wallet():
wallet = bittensor.wallet(name="test_miner")
try:
# workaround the overwrite flag
wallet.regenerate_coldkey(seed="e" * 64, use_password=False, overwrite=True)
wallet.regenerate_hotkey(seed="f" * 64, use_password=False, overwrite=True)
except Exception as e:
logger.error(f"Failed to create wallet: {e}")
1 change: 0 additions & 1 deletion miner/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ def test(session):
session.run(
"pytest",
"-s",
"-x",
"-vv",
"-n",
"auto",
Expand Down
332 changes: 132 additions & 200 deletions miner/uv.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def test(session):
session.run(
"pytest",
"-s",
"-x",
"-vv",
"--junitxml",
"test-report.xml",
Expand Down
32 changes: 20 additions & 12 deletions tests/integration_tests/test_miner_on_dev_executor_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,31 @@

def get_miner_wallet():
wallet = bittensor.wallet(name="test_miner")
try:
# workaround the overwrite flag
wallet.regenerate_coldkey(seed="c" * 64, use_password=False, overwrite=True)
wallet.regenerate_hotkey(seed="d" * 64, use_password=False, overwrite=True)
except Exception as e:
logger.error(f"Failed to create wallet: {e}")
wallet.regenerate_coldkey(
mnemonic="marine oyster umbrella sail over speak emerge rude matrix glue argue learn",
use_password=False,
overwrite=True,
)
wallet.regenerate_hotkey(
mnemonic="radio busy purpose chicken nose soccer private bridge nephew float ten media",
use_password=False,
overwrite=True,
)
return wallet


def get_validator_wallet():
wallet = bittensor.wallet(name="test_validator")
try:
# workaround the overwrite flag
wallet.regenerate_coldkey(seed="a" * 64, use_password=False, overwrite=True)
wallet.regenerate_hotkey(seed="b" * 64, use_password=False, overwrite=True)
except Exception as e:
logger.error(f"Failed to create wallet: {e}")
wallet.regenerate_coldkey(
mnemonic="local ghost evil lizard decade own lecture absurd vote despair predict cage",
use_password=False,
overwrite=True,
)
wallet.regenerate_hotkey(
mnemonic="position chicken ugly key sugar expect another require cinnamon rubber rich veteran",
use_password=False,
overwrite=True,
)
return wallet


Expand Down
Loading

0 comments on commit 06c35fb

Please sign in to comment.