@@ -2505,6 +2505,16 @@ impl ClusterInfo {
2505
2505
false
2506
2506
}
2507
2507
} ;
2508
+ let mut verify_node_instance = |value : & CrdsValue | {
2509
+ if self . verify_node_instance ( value) {
2510
+ info ! ( "greg: node instance verify good" ) ;
2511
+ true
2512
+ } else {
2513
+ info ! ( "greg: node instance verify bad" ) ;
2514
+ self . stats . num_unverifed_node_instances . add_relaxed ( 1 ) ;
2515
+ false
2516
+ }
2517
+ } ;
2508
2518
// Split packets based on their types.
2509
2519
let mut pull_requests = vec ! [ ] ;
2510
2520
let mut pull_responses = vec ! [ ] ;
@@ -2522,13 +2532,15 @@ impl ClusterInfo {
2522
2532
Protocol :: PullResponse ( _, mut data) => {
2523
2533
check_duplicate_instance ( & data) ?;
2524
2534
data. retain ( & mut verify_gossip_addr) ;
2535
+ data. retain ( & mut verify_node_instance) ;
2525
2536
if !data. is_empty ( ) {
2526
2537
pull_responses. append ( & mut data) ;
2527
2538
}
2528
2539
}
2529
2540
Protocol :: PushMessage ( from, mut data) => {
2530
2541
check_duplicate_instance ( & data) ?;
2531
2542
data. retain ( & mut verify_gossip_addr) ;
2543
+ data. retain ( & mut verify_node_instance) ;
2532
2544
if !data. is_empty ( ) {
2533
2545
push_messages. push ( ( from, data) ) ;
2534
2546
}
@@ -2578,6 +2590,23 @@ impl ClusterInfo {
2578
2590
Ok ( ( ) )
2579
2591
}
2580
2592
2593
+ fn verify_node_instance ( & self , value : & CrdsValue ) -> bool {
2594
+ let pubkey = match & value. data {
2595
+ CrdsData :: NodeInstance ( node) => node. from ( ) ,
2596
+ _ => return true , // If not a NodeInstance, nothing to verify.
2597
+ } ;
2598
+ match self . lookup_contact_info ( pubkey, |ci| ci. clone ( ) ) {
2599
+ Some ( _) => {
2600
+ info ! ( "greg: got contact info for pk: {pubkey:?}" ) ;
2601
+ true
2602
+ } ,
2603
+ None => {
2604
+ info ! ( "greg: no contact info for pk: {pubkey:?}" ) ;
2605
+ false // Need to receive contact info first
2606
+ }
2607
+ }
2608
+ }
2609
+
2581
2610
// Consumes packets received from the socket, deserializing, sanitizing and
2582
2611
// verifying them and then sending them down the channel for the actual
2583
2612
// handling of requests/messages.
@@ -3350,9 +3379,6 @@ fn verify_gossip_addr<R: Rng + CryptoRng>(
3350
3379
let ( pubkey, addr) = match & value. data {
3351
3380
CrdsData :: ContactInfo ( node) => ( node. pubkey ( ) , node. gossip ( ) ) ,
3352
3381
CrdsData :: LegacyContactInfo ( node) => ( node. pubkey ( ) , node. gossip ( ) ) ,
3353
- CrdsData :: NodeInstance ( node) => {
3354
- ClusterInfo :: lookup_contact_info ( & self , id, map)
3355
- }
3356
3382
_ => return true , // If not a contact-info, nothing to verify.
3357
3383
} ;
3358
3384
// For (sufficiently) staked nodes, don't bother with ping/pong.
0 commit comments