Skip to content

Commit

Permalink
Merge branch 'master' into release/6.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gus-opentensor committed Apr 29, 2024
2 parents ccaf6c7 + c74fb15 commit 4cec121
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 21 deletions.
38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Changelog


## 6.12.0 / 2024-04-29

## What's Changed
Expand All @@ -15,6 +16,43 @@

**Full Changelog**: https://github.com/opentensor/bittensor/compare/v6.11.0...v6.12.0

## 6.11.0 / 2024-04-11

## What's Changed
* Tests: Adds coverage to subtensor help method & determine_chain_endpoint_and_network by @gus-opentensor in https://github.com/opentensor/bittensor/pull/1761
* [bug fix] Fix import json by @camfairchild in https://github.com/opentensor/bittensor/pull/1759
* Remove context management for substrate in subtensor by @sepehr-opentensor in https://github.com/opentensor/bittensor/pull/1766
* Tests: Extends coverage on axon methods by @gus-opentensor in https://github.com/opentensor/bittensor/pull/1769
* Revert nonce implementation fix by @ifrit98 in https://github.com/opentensor/bittensor/pull/1774
* remove tests from package distribution by @mjurbanski-reef in https://github.com/opentensor/bittensor/pull/1779
* Tests: Extends test coverage on Senate methods by @ibraheem-opentensor in https://github.com/opentensor/bittensor/pull/1781

## New Contributors
* @mjurbanski-reef made their first contribution in https://github.com/opentensor/bittensor/pull/1779
* @ibraheem-opentensor made their first contribution in https://github.com/opentensor/bittensor/pull/1781

**Full Changelog**: https://github.com/opentensor/bittensor/compare/v6.10.1...v6.11.0
## 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
* 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

Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@

6.12.0
1 change: 1 addition & 0 deletions bittensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
nest_asyncio.apply()

# Bittensor code and protocol version.

__version__ = "6.12.0"

version_split = __version__.split(".")
Expand Down
23 changes: 6 additions & 17 deletions bittensor/axon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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",
}
Expand Down
2 changes: 1 addition & 1 deletion bittensor/dendrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
6 changes: 3 additions & 3 deletions bittensor/synapse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 4cec121

Please sign in to comment.