@@ -986,27 +986,29 @@ impl P2PNetwork {
986986 return false ;
987987 }
988988
989- // Verify the hotkey is a registered validator with sufficient stake
990- if !self . validator_set . is_validator ( & announce. validator ) {
991- warn ! (
989+ // Remove from pending auth (signature is valid)
990+ self . pending_auth . write ( ) . remove ( & source) ;
991+
992+ // Check if the hotkey is a registered validator with sufficient stake
993+ let is_validator = self . validator_set . is_validator ( & announce. validator ) ;
994+
995+ // Add to peer mapping (even non-validators for relay purposes)
996+ self . peer_mapping . insert ( source, announce. validator . clone ( ) ) ;
997+
998+ if is_validator {
999+ info ! (
1000+ peer = %source,
1001+ validator = %announce. validator. to_hex( ) ,
1002+ "Validator peer authenticated successfully"
1003+ ) ;
1004+ } else {
1005+ info ! (
9921006 peer = %source,
9931007 hotkey = %announce. validator. to_hex( ) ,
994- "PeerAnnounce from non-validator, rejecting "
1008+ "Relay peer authenticated ( non-validator, can relay but not send consensus messages) "
9951009 ) ;
996- let _ = swarm. disconnect_peer_id ( source) ;
997- return false ;
9981010 }
9991011
1000- // Authentication successful - add to peer mapping and remove from pending
1001- self . peer_mapping . insert ( source, announce. validator . clone ( ) ) ;
1002- self . pending_auth . write ( ) . remove ( & source) ;
1003-
1004- info ! (
1005- peer = %source,
1006- validator = %announce. validator. to_hex( ) ,
1007- "Peer authenticated successfully"
1008- ) ;
1009-
10101012 true
10111013 }
10121014
@@ -1233,7 +1235,9 @@ fn expected_signer(message: &P2PMessage) -> Option<&Hotkey> {
12331235}
12341236
12351237fn requires_validator ( message : & P2PMessage ) -> bool {
1236- !matches ! ( message, P2PMessage :: Submission ( _) )
1238+ // Submissions and PeerAnnounce don't require validator status
1239+ // PeerAnnounce is verified separately in handle_peer_announce
1240+ !matches ! ( message, P2PMessage :: Submission ( _) | P2PMessage :: PeerAnnounce ( _) )
12371241}
12381242
12391243fn validate_weight_vote_hash ( message : & WeightVoteMessage ) -> Result < ( ) , NetworkError > {
0 commit comments