Skip to content

Commit

Permalink
Use async_substrate_interface rather than the local version.
Browse files Browse the repository at this point in the history
  • Loading branch information
thewhaleking committed Jan 10, 2025
1 parent 4609355 commit 1107ec7
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 4,618 deletions.
4 changes: 2 additions & 2 deletions bittensor/core/async_subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import Optional, Any, Union, Iterable, TYPE_CHECKING

import aiohttp
from async_substrate_interface.substrate_interface import AsyncSubstrateInterface
import asyncstdlib as a
import numpy as np
import scalecodec
Expand Down Expand Up @@ -72,7 +73,6 @@
execute_coroutine,
)
from bittensor.utils import networking
from bittensor.utils.substrate_interface import AsyncSubstrateInterface
from bittensor.utils.balance import Balance
from bittensor.utils.btlogging import logging
from bittensor.utils.delegates_details import DelegatesDetails
Expand All @@ -84,7 +84,7 @@
from bittensor_wallet import Wallet
from bittensor.core.axon import Axon
from bittensor.utils import Certificate
from bittensor.utils.substrate_interface import QueryMapResult
from async_substrate_interface.substrate_interface import QueryMapResult


def _decode_hex_identity_dict(info_dictionary: dict[str, Any]) -> dict[str, Any]:
Expand Down
29 changes: 12 additions & 17 deletions bittensor/core/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,23 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

from __future__ import annotations

from typing import Optional, TYPE_CHECKING

from async_substrate_interface.errors import (
SubstrateRequestException,
StorageFunctionNotFound,
BlockNotFound,
ExtrinsicNotFound,
)

if TYPE_CHECKING:
from bittensor.core.synapse import Synapse


class SubstrateRequestException(Exception):
pass


class StorageFunctionNotFound(ValueError):
pass


class BlockNotFound(Exception):
pass


class ExtrinsicNotFound(Exception):
pass
# redundant aliases
SubstrateRequestException = SubstrateRequestException
StorageFunctionNotFound = StorageFunctionNotFound
BlockNotFound = BlockNotFound
ExtrinsicNotFound = ExtrinsicNotFound


class ChainError(SubstrateRequestException):
Expand Down
4 changes: 2 additions & 2 deletions bittensor/core/extrinsics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

from bittensor.utils.btlogging import logging
from bittensor.utils import format_error_message
from bittensor.utils.substrate_interface import SubstrateRequestException
from async_substrate_interface.substrate_interface import SubstrateRequestException

if TYPE_CHECKING:
from bittensor.core.subtensor import Subtensor
from bittensor.core.async_subtensor import AsyncSubtensor
from bittensor.utils.substrate_interface import (
from async_substrate_interface.substrate_interface import (
AsyncExtrinsicReceipt,
ExtrinsicReceipt,
)
Expand Down
4 changes: 2 additions & 2 deletions bittensor/core/subtensor.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from functools import lru_cache
from typing import TYPE_CHECKING, Any, Iterable, Optional, Union

from async_substrate_interface.substrate_interface import SubstrateInterface
import numpy as np
from numpy.typing import NDArray

from bittensor.core.async_subtensor import AsyncSubtensor
from bittensor.core.metagraph import Metagraph
from bittensor.core.settings import version_as_int
from bittensor.utils.substrate_interface import SubstrateInterface
from bittensor.utils import execute_coroutine, torch, get_event_loop

if TYPE_CHECKING:
Expand All @@ -23,7 +23,7 @@
from bittensor.core.chain_data.subnet_info import SubnetInfo
from bittensor.utils.balance import Balance
from bittensor.utils import Certificate
from bittensor.utils.substrate_interface import QueryMapResult
from async_substrate_interface.substrate_interface import QueryMapResult
from bittensor.utils.delegates_details import DelegatesDetails
from scalecodec.types import ScaleType

Expand Down
2 changes: 1 addition & 1 deletion bittensor/utils/mock/subtensor_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
PrometheusInfo,
AxonInfo,
)
from bittensor.utils.substrate_interface import SubstrateInterface
from async_substrate_interface.substrate_interface import SubstrateInterface
from bittensor.core.types import AxonServeCallParams, PrometheusServeCallParams
from bittensor.core.errors import ChainQueryError
from bittensor.core.subtensor import Subtensor
Expand Down
Loading

0 comments on commit 1107ec7

Please sign in to comment.