File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 7
7
import json
8
8
import os
9
9
import enum
10
+ import cli_parser
10
11
from utils .gc_logging import gc_log_competition_metrics
11
12
12
13
@@ -69,6 +70,7 @@ def __init__(self, config_dir: str):
69
70
self .config_file = os .path .join (config_dir , "competition_config.json" )
70
71
self .current_competition : Optional [CompetitionConfig ] = None
71
72
self .state = CompetitionState ()
73
+ self .wallet = bt .wallet (config = cli_parser .config )
72
74
73
75
self ._load_state ()
74
76
self ._load_config ()
@@ -188,7 +190,7 @@ def log_metrics(self, metrics: dict):
188
190
** metrics ,
189
191
}
190
192
191
- gc_log_competition_metrics (comp_metrics )
193
+ gc_log_competition_metrics (comp_metrics , self . wallet . hotkey )
192
194
except Exception as e :
193
195
bt .logging .error (f"Error logging metrics: { e } " )
194
196
Original file line number Diff line number Diff line change @@ -69,16 +69,27 @@ def log_responses(
69
69
return None
70
70
71
71
72
- def gc_log_competition_metrics (metrics : dict ) -> Optional [requests .Response ]:
72
+ def gc_log_competition_metrics (
73
+ metrics : dict , hotkey : bt .Keypair
74
+ ) -> Optional [requests .Response ]:
73
75
"""
74
76
Log competition metrics to the centralized logging server.
75
77
"""
76
78
try :
79
+ metrics ["validator_key" ] = hotkey .ss58_address
77
80
input_bytes = json .dumps (metrics ).encode ("utf-8" )
81
+ # sign the inputs with your hotkey
82
+ signature = hotkey .sign (input_bytes )
83
+ # encode the inputs and signature as base64
84
+ signature_str = base64 .b64encode (signature ).decode ("utf-8" )
85
+
78
86
return session .post (
79
87
COMPETITION_LOGGING_URL ,
80
88
data = input_bytes ,
81
- headers = {"Content-Type" : "application/json" },
89
+ headers = {
90
+ "Content-Type" : "application/json" ,
91
+ "X-Request-Signature" : signature_str ,
92
+ },
82
93
timeout = 5 ,
83
94
)
84
95
except requests .exceptions .RequestException as e :
You can’t perform that action at this time.
0 commit comments