-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove nonce verification from miner axon.
- Loading branch information
acer-king
committed
Oct 15, 2024
1 parent
ce7bb34
commit afbd923
Showing
2 changed files
with
29 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import bittensor | ||
import bittensor as bt | ||
from substrateinterface import Keypair | ||
from bittensor.errors import SynapseDendriteNoneException | ||
|
||
|
||
class CortexAxon(bt.axon): | ||
def default_verify(self, synapse: bittensor.Synapse): | ||
if synapse.dendrite is not None: | ||
keypair = Keypair(ss58_address=synapse.dendrite.hotkey) | ||
|
||
# Build the signature messages. | ||
message = f"{synapse.dendrite.nonce}.{synapse.dendrite.hotkey}.{self.wallet.hotkey.ss58_address}.{synapse.dendrite.uuid}.{synapse.computed_body_hash}" | ||
|
||
# Build the unique endpoint key. | ||
endpoint_key = f"{synapse.dendrite.hotkey}:{synapse.dendrite.uuid}" | ||
|
||
if not keypair.verify(message, synapse.dendrite.signature): | ||
raise Exception( | ||
f"Signature mismatch with {message} and {synapse.dendrite.signature}" | ||
) | ||
|
||
# Success | ||
self.nonces[endpoint_key] = synapse.dendrite.nonce # type: ignore | ||
else: | ||
raise SynapseDendriteNoneException() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters