@@ -44,7 +44,7 @@ type IdentityCheckResult struct {
4444 SeqNumber uint64 `json:"seqNumber"`
4545 Attnets string `json:"attnets"`
4646 Syncnets string `json:"syncnets"`
47- CGC int `json:"cgc"`
47+ CGC uint64 `json:"cgc"`
4848 ENRFields map [string ]interface {} `json:"enrFields"`
4949 ChecksPassed bool `json:"checksPassed"`
5050 FailureReasons []string `json:"failureReasons"`
@@ -118,6 +118,7 @@ func (t *Task) processCheck() {
118118 }
119119
120120 totalClientCount ++
121+
121122 t .logger .Infof ("Checking identity for client: %s" , client .Config .Name )
122123
123124 result := t .checkClientIdentity (client )
@@ -131,12 +132,14 @@ func (t *Task) processCheck() {
131132 t .logger .Infof (" Discovery Addresses: %v" , result .DiscoveryAddresses )
132133 t .logger .Infof (" Sequence Number: %d" , result .SeqNumber )
133134 t .logger .Infof (" Checks Passed: %v" , result .ChecksPassed )
135+
134136 if len (result .FailureReasons ) > 0 {
135137 t .logger .Infof (" Failure Reasons: %v" , result .FailureReasons )
136138 }
137139
138140 if result .ChecksPassed {
139141 passResultCount ++
142+
140143 matchingClients = append (matchingClients , result )
141144 t .logger .Infof ("✅ Client %s passed all checks" , result .ClientName )
142145 } else {
@@ -221,8 +224,10 @@ func (t *Task) checkClientIdentity(client *clients.PoolClient) *IdentityCheckRes
221224 identity , err := client .ConsensusClient .GetRPCClient ().GetNodeIdentity (ctx )
222225 if err != nil {
223226 t .logger .Errorf ("Failed to get node identity for client %s: %v" , client .Config .Name , err )
227+
224228 result .ChecksPassed = false
225229 result .FailureReasons = append (result .FailureReasons , fmt .Sprintf ("Failed to get node identity: %v" , err ))
230+
226231 return result
227232 }
228233
@@ -239,11 +244,14 @@ func (t *Task) checkClientIdentity(client *clients.PoolClient) *IdentityCheckRes
239244
240245 // Extract CGC from ENR
241246 t .logger .Debugf ("Extracting CGC from ENR for client %s" , client .Config .Name )
247+
242248 cgc , enrFields , err := t .extractCGCFromENR (identity .ENR )
243249 if err != nil {
244250 t .logger .Errorf ("Failed to parse ENR for client %s: %v" , client .Config .Name , err )
251+
245252 result .ChecksPassed = false
246253 result .FailureReasons = append (result .FailureReasons , fmt .Sprintf ("Failed to parse ENR: %v" , err ))
254+
247255 return result
248256 }
249257
@@ -303,12 +311,14 @@ func (t *Task) performChecks(result *IdentityCheckResult) {
303311 // Check P2P address match
304312 if t .config .ExpectP2PAddressMatch != "" {
305313 found := false
314+
306315 for _ , addr := range result .P2PAddresses {
307316 if matched , _ := regexp .MatchString (t .config .ExpectP2PAddressMatch , addr ); matched {
308317 found = true
309318 break
310319 }
311320 }
321+
312322 if ! found {
313323 result .ChecksPassed = false
314324 result .FailureReasons = append (result .FailureReasons ,
@@ -344,7 +354,7 @@ func (t *Task) performChecks(result *IdentityCheckResult) {
344354}
345355
346356// extractCGCFromENR extracts the Custody Group Count from ENR using proper ENR parsing
347- func (t * Task ) extractCGCFromENR (enrStr string ) (int , map [string ]interface {}, error ) {
357+ func (t * Task ) extractCGCFromENR (enrStr string ) (cgc uint64 , enrFields map [string ]interface {}, err error ) {
348358 if enrStr == "" {
349359 t .logger .Debugf ("Empty ENR provided" )
350360 return 0 , nil , fmt .Errorf ("empty ENR" )
@@ -360,10 +370,8 @@ func (t *Task) extractCGCFromENR(enrStr string) (int, map[string]interface{}, er
360370 }
361371
362372 // Get all key-value pairs from ENR
363- enrFields : = t .getKeyValuesFromENR (record )
373+ enrFields = t .getKeyValuesFromENR (record )
364374
365- // Extract CGC from the fields
366- cgc := 0
367375 if cgcHex , ok := enrFields ["cgc" ]; ok {
368376 // CGC is stored as hex string, parse it
369377 cgcStr , ok := cgcHex .(string )
@@ -372,11 +380,12 @@ func (t *Task) extractCGCFromENR(enrStr string) (int, map[string]interface{}, er
372380 } else {
373381 // Remove "0x" prefix if present
374382 cgcStr = strings .TrimPrefix (cgcStr , "0x" )
383+
375384 val , err := strconv .ParseUint (cgcStr , 16 , 64 )
376385 if err != nil {
377386 t .logger .Errorf ("Failed to parse CGC value %s: %v" , cgcStr , err )
378387 } else {
379- cgc = int ( val )
388+ cgc = val
380389 t .logger .Debugf ("Found CGC in ENR: %d" , cgc )
381390 }
382391 }
@@ -397,13 +406,15 @@ func (t *Task) decodeENR(raw string) (*enr.Record, error) {
397406 }
398407
399408 dec := make ([]byte , base64 .RawURLEncoding .DecodedLen (len (b )))
409+
400410 n , err := base64 .RawURLEncoding .Decode (dec , b )
401411 if err != nil {
402412 return nil , err
403413 }
404414
405415 var r enr.Record
406416 err = rlp .DecodeBytes (dec [:n ], & r )
417+
407418 return & r , err
408419}
409420
@@ -417,8 +428,17 @@ func (t *Task) getKeyValuesFromENR(r *enr.Record) map[string]interface{} {
417428 // Get all key-value pairs from the record
418429 kv := r .AppendElements (nil )[1 :] // Skip the sequence number
419430 for i := 0 ; i < len (kv ); i += 2 {
420- key := kv [i ].(string )
421- val := kv [i + 1 ].(rlp.RawValue )
431+ key , ok := kv [i ].(string )
432+ if ! ok {
433+ t .logger .Warnf ("Invalid ENR key type: %T" , kv [i ])
434+ continue
435+ }
436+
437+ val , ok := kv [i + 1 ].(rlp.RawValue )
438+ if ! ok {
439+ t .logger .Warnf ("Invalid ENR value type for key %s: %T" , key , kv [i + 1 ])
440+ continue
441+ }
422442
423443 // Format the value based on the key
424444 fmtval := t .formatENRValue (key , val )
0 commit comments