Skip to content

Commit dcd1740

Browse files
author
acer-king
committed
cursor support
1 parent ad5d951 commit dcd1740

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

Diff for: validators/core/axon.py

+24
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
InternalServerError,
3535
)
3636
from bittensor.threadpool import PriorityThreadPoolExecutor
37+
import bittensor
38+
import bittensor as bt
39+
from substrateinterface import Keypair
40+
from bittensor.errors import SynapseDendriteNoneException
3741

3842

3943
class CortexAxon(bt.axon):
@@ -49,6 +53,26 @@ def __init__(self,
4953
super().__init__(wallet, config, port, ip, external_ip, external_port, max_workers)
5054
self.app.add_middleware(CortexAxonMiddleware, axon=self)
5155

56+
def default_verify(self, synapse: bittensor.Synapse):
57+
if synapse.dendrite is not None:
58+
keypair = Keypair(ss58_address=synapse.dendrite.hotkey)
59+
60+
# Build the signature messages.
61+
message = f"{synapse.dendrite.nonce}.{synapse.dendrite.hotkey}.{self.wallet.hotkey.ss58_address}.{synapse.dendrite.uuid}.{synapse.computed_body_hash}"
62+
63+
# Build the unique endpoint key.
64+
endpoint_key = f"{synapse.dendrite.hotkey}:{synapse.dendrite.uuid}"
65+
66+
if not keypair.verify(message, synapse.dendrite.signature):
67+
raise Exception(
68+
f"Signature mismatch with {message} and {synapse.dendrite.signature}"
69+
)
70+
71+
# Success
72+
self.nonces[endpoint_key] = synapse.dendrite.nonce # type: ignore
73+
else:
74+
raise SynapseDendriteNoneException()
75+
5276

5377
class CortexAxonMiddleware(BaseHTTPMiddleware):
5478
"""

Diff for: validators/weight_setter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
from validators.services.cache import QueryResponseCache
2525
from validators.utils import error_handler, setup_max_capacity, load_entire_questions
2626
from validators.task_manager import TaskMgr
27+
from validators.core.axon import CortexAxon
2728
from cortext.dendrite import CortexDendrite
28-
from cortext.axon import CortexAxon
2929
from cursor.app.endpoints.text import chat
3030
from cursor.app.endpoints.generic import models
3131
from cursor.app.core.middleware import APIKeyMiddleware

0 commit comments

Comments
 (0)