diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e92566cef..c918823fe0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## 7.0.1 / 2024-05-31 + +## What's Changed +* Release/7.0.0 by @gus-opentensor in https://github.com/opentensor/bittensor/pull/1899 +* Fix return of ip version. by @opendansor in https://github.com/opentensor/bittensor/pull/1961 +* Fix trigger use_torch() by @renesweet24 https://github.com/opentensor/bittensor/pull/1960 + + +**Full Changelog**: https://github.com/opentensor/bittensor/compare/v7.0.0...v7.0.1 + + ## 7.0.0 / 2024-05-29 ## What's Changed diff --git a/VERSION b/VERSION index 66ce77b7ea..73a86b1970 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -7.0.0 +7.0.1 \ No newline at end of file diff --git a/bittensor/__init__.py b/bittensor/__init__.py index b8700daf79..22afe57058 100644 --- a/bittensor/__init__.py +++ b/bittensor/__init__.py @@ -27,7 +27,7 @@ nest_asyncio.apply() # Bittensor code and protocol version. -__version__ = "7.0.0" +__version__ = "7.0.1" version_split = __version__.split(".") __version_as_int__: int = ( diff --git a/bittensor/axon.py b/bittensor/axon.py index 52e6db3a30..b5ec9a4d01 100644 --- a/bittensor/axon.py +++ b/bittensor/axon.py @@ -56,6 +56,7 @@ InternalServerError, ) from bittensor.threadpool import PriorityThreadPoolExecutor +from bittensor.utils import networking class FastAPIThreadedServer(uvicorn.Server): @@ -392,7 +393,7 @@ def info(self) -> "bittensor.AxonInfo": return bittensor.AxonInfo( version=bittensor.__version_as_int__, ip=self.external_ip, - ip_type=4, + ip_type=networking.ip_version(self.external_ip), port=self.external_port, hotkey=self.wallet.hotkey.ss58_address, coldkey=self.wallet.coldkeypub.ss58_address, diff --git a/bittensor/utils/weight_utils.py b/bittensor/utils/weight_utils.py index 7a3d489ca6..0a46e5ea37 100644 --- a/bittensor/utils/weight_utils.py +++ b/bittensor/utils/weight_utils.py @@ -251,7 +251,7 @@ def process_weights_for_netuid( metagraph = subtensor.metagraph(netuid) # Cast weights to floats. - if not use_torch(): + if use_torch(): if not isinstance(weights, torch.FloatTensor): weights = weights.type(torch.float32) else: diff --git a/tests/unit_tests/test_axon.py b/tests/unit_tests/test_axon.py index 33a3724643..5b82148494 100644 --- a/tests/unit_tests/test_axon.py +++ b/tests/unit_tests/test_axon.py @@ -17,14 +17,16 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -# Standard Lib -import pytest import unittest from typing import Any from unittest import IsolatedAsyncioTestCase from unittest.mock import AsyncMock, MagicMock, patch # Third Party +import netaddr + +# Standard Lib +import pytest from starlette.requests import Request # Bittensor @@ -341,6 +343,55 @@ def test_to_string(info_return, expected_output, test_id): assert output == expected_output, f"Test ID: {test_id}" +@pytest.mark.parametrize( + "ip, port, expected_ip_type, test_id", + [ + # Happy path + ( + "127.0.0.1", + 8080, + 4, + "valid_ipv4", + ), + ( + "2001:0db8:85a3:0000:0000:8a2e:0370:7334", + 3030, + 6, + "valid_ipv6", + ), + ], +) +def test_valid_ipv4_and_ipv6_address(ip, port, expected_ip_type, test_id): + # Arrange + axon = Axon() + axon.ip = ip + axon.external_ip = ip + axon.port = port + + # Act + ip_type = axon.info().ip_type + + # Assert + assert ip_type == expected_ip_type, f"Test ID: {test_id}" + + +@pytest.mark.parametrize( + "ip, port, expected_exception", + [ + ( + "This Is not a valid address", + 65534, + netaddr.core.AddrFormatError, + ), + ], + ids=["failed to detect a valid IP " "address from %r"], +) +def test_invalid_ip_address(ip, port, expected_exception): + # Assert + with pytest.raises(expected_exception): + Axon(ip=ip, external_ip=ip, port=port).info() + + @pytest.mark.parametrize( "ip, port, ss58_address, started, forward_fns, expected_str, test_id", [ diff --git a/tests/unit_tests/test_subtensor.py b/tests/unit_tests/test_subtensor.py index b9dee7a110..4024a27f79 100644 --- a/tests/unit_tests/test_subtensor.py +++ b/tests/unit_tests/test_subtensor.py @@ -25,13 +25,13 @@ # Application import bittensor -from bittensor.subtensor import subtensor as Subtensor, _logger from bittensor import subtensor_module +from bittensor.subtensor import subtensor as Subtensor, _logger def test_serve_axon_with_external_ip_set(): - internal_ip: str = "this is an internal ip" - external_ip: str = "this is an external ip" + internal_ip: str = "192.0.2.146" + external_ip: str = "2001:0db8:85a3:0000:0000:8a2e:0370:7334" mock_serve_axon = MagicMock(return_value=True) @@ -72,7 +72,7 @@ def test_serve_axon_with_external_ip_set(): def test_serve_axon_with_external_port_set(): - external_ip: str = "this is an external ip" + external_ip: str = "2001:0db8:85a3:0000:0000:8a2e:0370:7334" internal_port: int = 1234 external_port: int = 5678