@@ -50,18 +50,22 @@ class ValidatorSignature:
5050 voting_power : int
5151 proposer_priority : int
5252
53- def load_validator_mappings (mappings_file = 'validators.yaml' ):
53+ def load_validator_mappings (mappings_file = None ):
5454 """Load validator address to name mappings from YAML file"""
5555 validator_names = {}
5656
5757 if not mappings_file :
58- print ("\n WARNING: No validator mappings file specified" )
59- return validator_names
60-
61- # If only directory is specified, append default filename
62- if mappings_file == '.' :
63- mappings_file = './validators.yaml'
58+ default_path = '/app/validators.yaml'
59+ config_path = '/app/config/validators.yaml'
6460
61+ # Check for custom config first
62+ if os .path .exists (config_path ):
63+ print (f"\n Using custom validator mappings from: { config_path } " )
64+ mappings_file = config_path
65+ else :
66+ print (f"\n Using default validator mappings from: { default_path } " )
67+ mappings_file = default_path
68+
6569 if not os .path .exists (mappings_file ):
6670 print (f"\n WARNING: Validator mappings file not found at: { mappings_file } " )
6771 return validator_names
@@ -82,31 +86,36 @@ def load_validator_mappings(mappings_file='validators.yaml'):
8286 print (f"Warning: Expected list under 'validators' key, got: { type (mappings )} " )
8387 return validator_names
8488
85- # Process mappings
89+ # Process mappings with case preservation
8690 for mapping in mappings :
8791 if isinstance (mapping , str ):
8892 try :
8993 address , name = mapping .split (':' , 1 )
90- address = address .strip ().upper ()
94+ # Store original address for lookups, but use uppercase for storage
95+ original_address = address .strip ()
96+ uppercase_address = original_address .upper ()
9197 name = name .strip ()
9298
93- if not address or not name :
99+ if not original_address or not name :
94100 print (f"Warning: Empty address or name in mapping: { mapping } " )
95101 continue
96102
97- validator_names [address ] = name
98- print (f"Loaded mapping: { address } -> { name } " )
103+ validator_names [uppercase_address ] = {
104+ 'name' : name ,
105+ 'original_address' : original_address
106+ }
107+ print (f"Loaded mapping: { original_address } -> { name } " )
99108 except ValueError as e :
100109 print (f"Warning: Invalid format in mapping: { mapping } " )
101110 continue
102111
103112 print (f"\n Successfully loaded { len (validator_names )} validator mappings" )
104113 if validator_names :
105114 print ("\n All loaded mappings:" )
106- for addr , name in sorted (validator_names .items ()):
107- print (f" { addr } -> { name } " )
115+ for addr , info in sorted (validator_names .items ()):
116+ print (f" { info [ 'original_address' ] } -> { info [ ' name' ] } " )
108117 print ("\n Available addresses for matching:" )
109- print (", " .join (sorted (validator_names .keys ())))
118+ print (", " .join (sorted (addr for addr in validator_names .keys ())))
110119
111120 except yaml .YAMLError as e :
112121 print (f"\n ERROR parsing YAML file: { str (e )} " )
@@ -601,8 +610,24 @@ def setup_tables(self):
601610 self .db_pool .return_connection (conn )
602611
603612 def _get_validator_name (self , address ):
604- """Get validator name from mapping"""
605- return self .validator_names .get (address , '' )
613+ """Get validator name from mapping with case-insensitive matching and original address preservation"""
614+ if not address :
615+ return ''
616+
617+ # Convert address to uppercase for lookup
618+ address_upper = address .upper ()
619+
620+ # Get validator info
621+ validator_info = self .validator_names .get (address_upper )
622+
623+ if validator_info :
624+ name = validator_info ['name' ]
625+ original_address = validator_info ['original_address' ]
626+ print (f"Found mapping for { original_address } -> { name } " )
627+ return name
628+ else :
629+ print (f"No mapping found for { address } " )
630+ return ''
606631
607632 def _store_validator_set (self , cursor , height : int , validators : List [Dict ]):
608633 """Store validator set data with names"""
0 commit comments