From 913083a2d515e1341b9723328c0fcd1bbb6b919b Mon Sep 17 00:00:00 2001 From: ifrit98 Date: Mon, 25 Mar 2024 20:57:33 +0000 Subject: [PATCH 1/4] add version --- VERSION | 2 +- bittensor/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 6020dfc232..11946a9fd7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.9.3 \ No newline at end of file +6.10.0 \ No newline at end of file diff --git a/bittensor/__init__.py b/bittensor/__init__.py index 63fd4b60b8..3a50f14358 100644 --- a/bittensor/__init__.py +++ b/bittensor/__init__.py @@ -27,7 +27,7 @@ nest_asyncio.apply() # Bittensor code and protocol version. -__version__ = "6.9.3" +__version__ = "6.10.0" version_split = __version__.split(".") __version_as_int__: int = ( From 4fed84442dee7fb424a58507e0533e615908fb17 Mon Sep 17 00:00:00 2001 From: ifrit98 Date: Mon, 25 Mar 2024 20:58:40 +0000 Subject: [PATCH 2/4] add changelog --- CHANGELOG.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b61cbdff07..afbdb10e3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # Changelog +## 6.10.0 / 2024-03-25 + +## What's Changed +* handle req args by parsing and raising by @ifrit98 in https://github.com/opentensor/bittensor/pull/1733 +* Replace wildcard imports with specific imports by @brueningf in https://github.com/opentensor/bittensor/pull/1724 +* Logging Refactor by @sepehr-opentensor in https://github.com/opentensor/bittensor/pull/1751 +* Update DEBUGGING.md by @e-gons in https://github.com/opentensor/bittensor/pull/1755 +* fix: nonce implementation by @GentikSolm in https://github.com/opentensor/bittensor/pull/1754 + +## New Contributors +* @sepehr-opentensor made their first contribution in https://github.com/opentensor/bittensor/pull/1751 +* @e-gons made their first contribution in https://github.com/opentensor/bittensor/pull/1755 +* @GentikSolm made their first contribution in https://github.com/opentensor/bittensor/pull/1754 + +**Full Changelog**: https://github.com/opentensor/bittensor/compare/v6.9.3...v6.10.0 + + ## 6.9.3 / 2024-03-12 ## What's Changed From ee41131c139312c688beae9bbf36760fc7846b2d Mon Sep 17 00:00:00 2001 From: ifrit98 Date: Fri, 5 Apr 2024 17:16:05 +0000 Subject: [PATCH 3/4] Revert "fix: nonce implementation". Must branded as a breaking change. All validators need to update simultaneously. This reverts commit d5348b9fac5facf3fc2ee03c8ecc668d349f4f1c. --- bittensor/axon.py | 23 ++++++----------------- bittensor/dendrite.py | 2 +- bittensor/synapse.py | 6 +++--- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/bittensor/axon.py b/bittensor/axon.py index 34ce9e51f1..1301b32c8d 100644 --- a/bittensor/axon.py +++ b/bittensor/axon.py @@ -914,25 +914,14 @@ async def default_verify(self, synapse: bittensor.Synapse): # Build the unique endpoint key. endpoint_key = f"{synapse.dendrite.hotkey}:{synapse.dendrite.uuid}" - # Check the nonce from the endpoint key with 4 second delta - allowedDelta = 4000000000 - - # Requests must have nonces to be safe from replays - if synapse.dendrite.nonce is None: - raise Exception("Missing Nonce") - - # If we don't have a nonce stored, ensure that the nonce falls within - # a reasonable delta. - if ( - self.nonces.get(endpoint_key) is None - and synapse.dendrite.nonce <= time.time_ns() - allowedDelta - ): - raise Exception("Nonce is too old") + # Check the nonce from the endpoint key. if ( - self.nonces.get(endpoint_key) is not None + endpoint_key in self.nonces.keys() + and self.nonces[endpoint_key] is not None + and synapse.dendrite.nonce is not None and synapse.dendrite.nonce <= self.nonces[endpoint_key] ): - raise Exception("Nonce is too old") + raise Exception("Nonce is too small") if not keypair.verify(message, synapse.dendrite.signature): raise Exception( @@ -1201,7 +1190,7 @@ async def preprocess(self, request: Request) -> bittensor.Synapse: { "version": str(bittensor.__version_as_int__), "uuid": str(self.axon.uuid), - "nonce": f"{time.time_ns()}", + "nonce": f"{time.monotonic_ns()}", "status_message": "Success", "status_code": "100", } diff --git a/bittensor/dendrite.py b/bittensor/dendrite.py index b5e8df9a28..2b7afee5ef 100644 --- a/bittensor/dendrite.py +++ b/bittensor/dendrite.py @@ -658,7 +658,7 @@ def preprocess_synapse_for_request( synapse.dendrite = bittensor.TerminalInfo( ip=self.external_ip, version=bittensor.__version_as_int__, - nonce=time.time_ns(), + nonce=time.monotonic_ns(), uuid=self.uuid, hotkey=self.keypair.ss58_address, ) diff --git a/bittensor/synapse.py b/bittensor/synapse.py index 6b7af3d765..d4f210670e 100644 --- a/bittensor/synapse.py +++ b/bittensor/synapse.py @@ -114,7 +114,7 @@ class TerminalInfo(pydantic.BaseModel): ip (str): IP address of the terminal, crucial for network routing and data transmission. port (int): Network port used by the terminal, key for establishing network connections. version (int): Bittensor version running on the terminal, ensuring compatibility between different nodes in the network. - nonce (int): Unix timestamp that linearly increases for each request, ensuring requests cannot be duplicated or repeated + nonce (int): Unique, monotonically increasing number for each terminal, aiding in identifying and ordering network interactions. uuid (str): Unique identifier for the terminal, fundamental for network security and identification. hotkey (str): Encoded hotkey string of the terminal wallet, important for transaction and identity verification in the network. signature (str): Digital signature verifying the tuple of nonce, axon_hotkey, dendrite_hotkey, and uuid, critical for ensuring data authenticity and security. @@ -211,10 +211,10 @@ class Config: cast_int ) - # A Unix timestamp to associate with the terminal + # A unique monotonically increasing integer nonce associate with the terminal nonce: Optional[int] = pydantic.Field( title="nonce", - description="A Unix timestamp that prevents replay attacks", + description="A unique monotonically increasing integer nonce associate with the terminal generated from time.monotonic_ns()", examples=111111, default=None, allow_mutation=True, From 5bf1b3f0e2437503a869c13f6439a837b658ef02 Mon Sep 17 00:00:00 2001 From: ifrit98 Date: Fri, 5 Apr 2024 17:26:59 +0000 Subject: [PATCH 4/4] prerelease --- CHANGELOG.md | 4 ++++ VERSION | 2 +- bittensor/__init__.py | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index afbdb10e3d..3a99636d6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 6.10.1 / 2024-04-05 +## What's Changed +* Revert nonce implementation fix #1774: Breaking change needs to telegraphed in next release. + ## 6.10.0 / 2024-03-25 ## What's Changed diff --git a/VERSION b/VERSION index 11946a9fd7..83c2b6325b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.10.0 \ No newline at end of file +6.10.1 \ No newline at end of file diff --git a/bittensor/__init__.py b/bittensor/__init__.py index 3a50f14358..948f8cd15d 100644 --- a/bittensor/__init__.py +++ b/bittensor/__init__.py @@ -27,7 +27,7 @@ nest_asyncio.apply() # Bittensor code and protocol version. -__version__ = "6.10.0" +__version__ = "6.10.1" version_split = __version__.split(".") __version_as_int__: int = (