@@ -17,17 +17,23 @@ async def get_whitelisted_relays(config):
1717 relays = await contract .functions .get_relays ().call ()
1818 return relays
1919
20- async def check_validator_registration (session , relay_url , pubkey ):
21- """Check if a validator is registered with a specific relay"""
20+ async def check_validator_registration (session , relay_url , pubkey , config ):
21+ """Check if a validator is registered with a specific relay and verify fee recipient """
2222 url = f"{ relay_url } /relay/v1/data/validator_registration"
23+
2324 try :
2425 async with session .get (url , params = {'pubkey' : pubkey }, timeout = 5 ) as response :
2526 if response .status == 200 :
26- return True
27- return False
27+ data = await response .json ()
28+ if 'message' in data and 'fee_recipient' in data ['message' ]:
29+ fee_recipient = data ['message' ]['fee_recipient' ]
30+ # Return tuple of (registration status, fee recipient)
31+ return (True , fee_recipient .lower () == config ['fee_recipient' ].lower (), fee_recipient )
32+ return (False , False , None )
33+ return (False , False , None )
2834 except Exception as e :
2935 print (f"Warning: Could not check registration status for { relay_url } : { str (e )} " )
30- return None # Return None to indicate unknown status
36+ return None
3137
3238async def get_validator_keys_from_csm (config ):
3339 csm = CSM (config )
@@ -77,25 +83,31 @@ async def check_relays(config, args):
7783 'optional_total' : 0 ,
7884 'mandatory_relays' : [],
7985 'optional_relays' : [],
80- 'unknown' : []
86+ 'unknown' : [],
87+ 'fee_mismatches' : [] # Add this field to track fee mismatches
8188 }
8289 for relay_url in relay_urls :
83- tasks .append (check_validator_registration (session , relay_url , validator ))
90+ tasks .append (check_validator_registration (session , relay_url , validator , config ))
8491
8592 chunk_results = await asyncio .gather (* tasks )
8693
8794 for validator_idx , validator in enumerate (validator_chunk ):
88- for relay_idx , is_registered in enumerate (chunk_results [validator_idx * len (relay_urls ):(validator_idx + 1 ) * len (relay_urls )]):
95+ for relay_idx , result in enumerate (chunk_results [validator_idx * len (relay_urls ):(validator_idx + 1 ) * len (relay_urls )]):
8996 relay_url = relay_urls [relay_idx ]
90- if is_registered is True :
91- if relay_url in mandatory_relays :
92- results [validator ]['mandatory_total' ] += 1
93- results [validator ]['mandatory_relays' ].append (relay_url )
94- else :
95- results [validator ]['optional_total' ] += 1
96- results [validator ]['optional_relays' ].append (relay_url )
97- elif is_registered is None :
97+ if result is None :
9898 results [validator ]['unknown' ].append (relay_url )
99+ else :
100+ is_registered , fee_matches , fee_recipient = result
101+ if is_registered :
102+ if not fee_matches :
103+ results [validator ]['fee_mismatches' ].append ((relay_url , fee_recipient ))
104+
105+ if relay_url in mandatory_relays :
106+ results [validator ]['mandatory_total' ] += 1
107+ results [validator ]['mandatory_relays' ].append (relay_url )
108+ else :
109+ results [validator ]['optional_total' ] += 1
110+ results [validator ]['optional_relays' ].append (relay_url )
99111
100112 if not args .pubkey : # Only show progress for bulk checks
101113 print (f"Processed { min (i + chunk_size , len (validator_keys ))} /{ len (validator_keys )} validators..." )
@@ -113,12 +125,18 @@ def print_summary_report(results, mandatory_relays, optional_relays):
113125
114126 ok_count = 0
115127 not_ok_count = 0
128+ fee_mismatch_count = 0
116129
117130 for validator , data in results .items ():
118- is_ok = data ['mandatory_total' ] >= 2 # At least 2 mandatory relays required
131+ has_fee_mismatch = len (data .get ('fee_mismatches' , [])) > 0
132+ is_ok = data ['mandatory_total' ] >= 2 and not has_fee_mismatch # At least 2 mandatory relays required and no fee mismatches
133+
119134 status = "OK" if is_ok else "NOT OK"
135+ if has_fee_mismatch :
136+ status += " (⚠️ Fee mismatch)"
137+ fee_mismatch_count += 1
120138
121- if is_ok :
139+ if is_ok and not has_fee_mismatch :
122140 ok_count += 1
123141 else :
124142 not_ok_count += 1
@@ -129,36 +147,33 @@ def print_summary_report(results, mandatory_relays, optional_relays):
129147 print (f"Validator { validator } : { status :6} (Mandatory: { mandatory_coverage } , Optional: { optional_coverage } )" )
130148
131149 print (f"\n Summary: { ok_count } validators OK, { not_ok_count } validators NOT OK" )
150+ if fee_mismatch_count > 0 :
151+ print (f"Warning: { fee_mismatch_count } validators have fee recipient mismatches" )
152+ else :
153+ print ("All validators have correct fee recipient set" )
132154
133155def print_detailed_report (results , relay_tuples , mandatory_relays , optional_relays ):
134156 """Print detailed report of validator relay registration status"""
135157 print ("\n Detailed Relay Coverage Report:" )
136158 print ("-" * 50 )
137159
138160 for validator , data in results .items ():
139- is_ok = data ['mandatory_total' ] >= 2
161+ has_fee_mismatch = len (data .get ('fee_mismatches' , [])) > 0
162+ is_ok = data ['mandatory_total' ] >= 2 and not has_fee_mismatch
163+
140164 status = "OK" if is_ok else "NOT OK"
165+ if has_fee_mismatch :
166+ status += " (⚠️ Fee mismatch)"
141167
142168 print (f"\n Validator { validator } : { status } " )
143169 print (f"Registered with { data ['mandatory_total' ]} /{ len (mandatory_relays )} mandatory relays" )
144170 print (f"Registered with { data ['optional_total' ]} /{ len (optional_relays )} optional relays" )
145171
146- if data [ 'unknown' ] :
147- print (f"Could not check status for { len ( data [ 'unknown' ]) } relay(s) :" )
148- for relay in data ['unknown ' ]:
172+ if data . get ( 'fee_mismatches' ) :
173+ print (" \n Fee recipient mismatches :" )
174+ for relay , incorrect_fee in data ['fee_mismatches ' ]:
149175 relay_info = next (r for r in relay_tuples if r [0 ] == relay )
150- print (f" ? { relay } ({ relay_info [1 ]} - { relay_info [3 ]} )" )
151-
152- missing_mandatory = set (mandatory_relays ) - set (data ['mandatory_relays' ])
153- if missing_mandatory :
154- print ("Missing mandatory registrations:" )
155- for relay in missing_mandatory :
156- relay_info = next (r for r in relay_tuples if r [0 ] == relay )
157- print (f" - { relay } ({ relay_info [1 ]} - { relay_info [3 ]} )" )
176+ print (f" ! { relay } ({ relay_info [1 ]} - { relay_info [3 ]} ) - Incorrect fee recipient: { incorrect_fee } " )
177+ else :
178+ print ("Fee recipient is correctly set for all relays" )
158179
159- missing_optional = set (optional_relays ) - set (data ['optional_relays' ])
160- if missing_optional :
161- print ("Missing optional registrations:" )
162- for relay in missing_optional :
163- relay_info = next (r for r in relay_tuples if r [0 ] == relay )
164- print (f" - { relay } ({ relay_info [1 ]} - { relay_info [3 ]} )" )
0 commit comments