@@ -411,7 +411,7 @@ pub struct DutiesService<S, T> {
411411 pub proposers : RwLock < ProposerMap > ,
412412 /// Map from validator index to sync committee duties.
413413 pub sync_duties : SyncDutiesMap ,
414- /// Maps an epoch to all *local* PTC duties for that epoch with their dependent root .
414+ /// Maps an epoch to PTC duties for locally-managed validators .
415415 pub ptc_duties : RwLock < PtcMap > ,
416416 /// Provides the canonical list of locally-managed validators.
417417 pub validator_store : Arc < S > ,
@@ -1243,25 +1243,6 @@ fn get_uninitialized_validators<S: ValidatorStore, T: SlotClock + 'static>(
12431243 . collect :: < Vec < _ > > ( )
12441244}
12451245
1246- /// Get a filtered list of local validators for which we don't already know their PTC duties for that epoch
1247- fn get_uninitialized_ptc_validators < S : ValidatorStore , T : SlotClock + ' static > (
1248- duties_service : & Arc < DutiesService < S , T > > ,
1249- epoch : & Epoch ,
1250- local_pubkeys : & HashSet < PublicKeyBytes > ,
1251- ) -> Vec < u64 > {
1252- let ptc_duties = duties_service. ptc_duties . read ( ) ;
1253-
1254- local_pubkeys
1255- . iter ( )
1256- . filter ( |pubkey| {
1257- ptc_duties
1258- . get ( epoch)
1259- . map_or ( true , |( _, duties) | !duties. contains_key ( pubkey) )
1260- } )
1261- . filter_map ( |pubkey| duties_service. validator_store . validator_index ( pubkey) )
1262- . collect :: < Vec < _ > > ( )
1263- }
1264-
12651246fn update_per_validator_duty_metrics < S : ValidatorStore , T : SlotClock + ' static > (
12661247 duties_service : & Arc < DutiesService < S , T > > ,
12671248 epoch : Epoch ,
@@ -1807,17 +1788,12 @@ async fn poll_beacon_ptc_attesters_for_epoch<
18071788 & [ validator_metrics:: UPDATE_PTC_FETCH ] ,
18081789 ) ;
18091790
1810- // Request duties for all uninitialized validators. If there isn't any, we will just request for
1811- // `INITIAL_PTC_DUTIES_QUERY_SIZE` validators. We use the `dependent_root` in the response to
1812- // determine whether validator duties need to be updated. This is to ensure that we don't
1813- // request for extra data unless necessary in order to save on network bandwidth.
1814- let uninitialized_validators =
1815- get_uninitialized_ptc_validators ( duties_service, & epoch, local_pubkeys) ;
1816- let initial_indices_to_request = if !uninitialized_validators. is_empty ( ) {
1817- uninitialized_validators. as_slice ( )
1818- } else {
1819- & local_indices[ 0 ..min ( INITIAL_PTC_DUTIES_QUERY_SIZE , local_indices. len ( ) ) ]
1820- } ;
1791+ // Make a small initial request to check the dependent_root and determine if we need to fetch
1792+ // all duties. We use the `dependent_root` in the response to determine whether validator
1793+ // duties need to be updated. This is to ensure that we don't request for extra data unless
1794+ // necessary in order to save on network bandwidth.
1795+ let initial_indices_to_request =
1796+ & local_indices[ 0 ..min ( INITIAL_PTC_DUTIES_QUERY_SIZE , local_indices. len ( ) ) ] ;
18211797
18221798 let response =
18231799 post_validator_duties_ptc ( duties_service, epoch, initial_indices_to_request) . await ?;
@@ -1830,7 +1806,7 @@ async fn poll_beacon_ptc_attesters_for_epoch<
18301806 let ptc_duties = duties_service. ptc_duties . read ( ) ;
18311807 let needs_update = ptc_duties
18321808 . get ( & epoch)
1833- . map_or ( true , |( prior_root, _duties) | {
1809+ . is_none_or ( |( prior_root, _duties) | {
18341810 // Update if dependent_root changed
18351811 * prior_root != dependent_root
18361812 } ) ;
0 commit comments