Skip to content

Commit

Permalink
Merge branch 'release/6.11.0' of github.com:opentensor/bittensor into…
Browse files Browse the repository at this point in the history
… release/6.11.0
  • Loading branch information
gus-opentensor committed Apr 11, 2024
2 parents ce8e8dc + c31bc4b commit 1040635
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 22 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@
* @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
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.11.0
6.11.0
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 1040635

Please sign in to comment.