Skip to content

Commit ddc66e2

Browse files
committed
chore: implement central server
1 parent 765a2b0 commit ddc66e2

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

neurons/validators/genie_validator.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
SeoChallenge,
2929
BalancedChallenge,
3030
)
31+
from webgenie.datasets.central_dataset import (
32+
CentralDataset,
33+
)
3134
from webgenie.helpers.htmls import preprocess_html, is_valid_resources
3235
from webgenie.helpers.images import image_debug_str
3336
from webgenie.helpers.llms import set_seed
@@ -46,7 +49,6 @@
4649
from webgenie.tasks.image_task_generator import ImageTaskGenerator
4750
from webgenie.utils.uids import get_all_available_uids
4851

49-
5052
class GenieValidator:
5153
def __init__(self, neuron: BaseNeuron):
5254
self.neuron = neuron
@@ -58,6 +60,17 @@ def __init__(self, neuron: BaseNeuron):
5860
self.task_generators = [
5961
(ImageTaskGenerator(), 1.0), # currently only image task generator is supported
6062
]
63+
self.init_signature()
64+
65+
def init_signature(self):
66+
"""Get signature for central database authentication using wallet"""
67+
try:
68+
message = b"I am the owner of the wallet"
69+
CentralDataset.SIGNATURE = self.neuron.wallet.hotkey.sign(message).hex()
70+
CentralDataset.HOTKEY = self.neuron.wallet.hotkey.ss58_address
71+
except Exception as e:
72+
bt.logging.error(f"Error initializing signature: {e}")
73+
raise e
6174

6275
async def query_miners(self):
6376
try:

webgenie/datasets/central_dataset.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
from webgenie.datasets.dataset import Dataset, DatasetEntry
99

1010

11-
class CentralDataset(Dataset):
11+
class CentralDataset(Dataset):
12+
HOTKEY = "hotkey"
13+
SIGNATURE = "signature"
14+
1215
def __init__(self):
1316
pass
1417

@@ -33,7 +36,11 @@ async def generate_context(self, session:int, task_number:int)->DatasetEntry:
3336
def get_html(self, session:int, task_number:int)->str:
3437
method = "GET"
3538
url = f"http://209.126.9.130:18000/api/v1/task/generate?session={session}&task_number={task_number}"
36-
response = requests.request(method, url)
39+
headers = {
40+
"Signature": CentralDataset.SIGNATURE,
41+
"Hotkey": CentralDataset.HOTKEY
42+
}
43+
response = requests.request(method, url, headers=headers)
3744
if response.status_code != 200:
3845
raise Exception(f"Failed to get HTML: {response.status_code} {response.text}")
3946
bt.logging.info(f"HTML: {response.json()}")

0 commit comments

Comments
 (0)