@@ -616,6 +616,9 @@ pub fn process_new_vote_state(
616616 let timely_vote_credits = feature_set. map_or ( false , |f| {
617617 f. is_active ( & feature_set:: timely_vote_credits:: id ( ) )
618618 } ) ;
619+ let deprecate_unused_legacy_vote_plumbing = feature_set. map_or ( false , |f| {
620+ f. is_active ( & feature_set:: deprecate_unused_legacy_vote_plumbing:: id ( ) )
621+ } ) ;
619622 let mut earned_credits = if timely_vote_credits { 0_u64 } else { 1_u64 } ;
620623
621624 if let Some ( new_root) = new_root {
@@ -625,7 +628,11 @@ pub fn process_new_vote_state(
625628 if current_vote. slot ( ) <= new_root {
626629 if timely_vote_credits || ( current_vote. slot ( ) != new_root) {
627630 earned_credits = earned_credits
628- . checked_add ( vote_state. credits_for_vote_at_index ( current_vote_state_index) )
631+ . checked_add ( vote_state. credits_for_vote_at_index (
632+ current_vote_state_index,
633+ timely_vote_credits,
634+ deprecate_unused_legacy_vote_plumbing,
635+ ) )
629636 . expect ( "`earned_credits` does not overflow" ) ;
630637 }
631638 current_vote_state_index = current_vote_state_index
@@ -738,11 +745,19 @@ pub fn process_vote_unfiltered(
738745 slot_hashes : & [ SlotHash ] ,
739746 epoch : Epoch ,
740747 current_slot : Slot ,
748+ timely_vote_credits : bool ,
749+ deprecate_unused_legacy_vote_plumbing : bool ,
741750) -> Result < ( ) , VoteError > {
742751 check_slots_are_valid ( vote_state, vote_slots, & vote. hash , slot_hashes) ?;
743- vote_slots
744- . iter ( )
745- . for_each ( |s| vote_state. process_next_vote_slot ( * s, epoch, current_slot) ) ;
752+ vote_slots. iter ( ) . for_each ( |s| {
753+ vote_state. process_next_vote_slot (
754+ * s,
755+ epoch,
756+ current_slot,
757+ timely_vote_credits,
758+ deprecate_unused_legacy_vote_plumbing,
759+ )
760+ } ) ;
746761 Ok ( ( ) )
747762}
748763
@@ -752,6 +767,8 @@ pub fn process_vote(
752767 slot_hashes : & [ SlotHash ] ,
753768 epoch : Epoch ,
754769 current_slot : Slot ,
770+ timely_vote_credits : bool ,
771+ deprecate_unused_legacy_vote_plumbing : bool ,
755772) -> Result < ( ) , VoteError > {
756773 if vote. slots . is_empty ( ) {
757774 return Err ( VoteError :: EmptySlots ) ;
@@ -773,6 +790,8 @@ pub fn process_vote(
773790 slot_hashes,
774791 epoch,
775792 current_slot,
793+ timely_vote_credits,
794+ deprecate_unused_legacy_vote_plumbing,
776795 )
777796}
778797
@@ -789,6 +808,8 @@ pub fn process_vote_unchecked(vote_state: &mut VoteState, vote: Vote) -> Result<
789808 & slot_hashes,
790809 vote_state. current_epoch ( ) ,
791810 0 ,
811+ true ,
812+ true ,
792813 )
793814}
794815
@@ -1036,7 +1057,18 @@ pub fn process_vote_with_account<S: std::hash::BuildHasher>(
10361057) -> Result < ( ) , InstructionError > {
10371058 let mut vote_state = verify_and_get_vote_state ( vote_account, clock, signers) ?;
10381059
1039- process_vote ( & mut vote_state, vote, slot_hashes, clock. epoch , clock. slot ) ?;
1060+ let timely_vote_credits = feature_set. is_active ( & feature_set:: timely_vote_credits:: id ( ) ) ;
1061+ let deprecate_unused_legacy_vote_plumbing =
1062+ feature_set. is_active ( & feature_set:: deprecate_unused_legacy_vote_plumbing:: id ( ) ) ;
1063+ process_vote (
1064+ & mut vote_state,
1065+ vote,
1066+ slot_hashes,
1067+ clock. epoch ,
1068+ clock. slot ,
1069+ timely_vote_credits,
1070+ deprecate_unused_legacy_vote_plumbing,
1071+ ) ?;
10401072 if let Some ( timestamp) = vote. timestamp {
10411073 vote. slots
10421074 . iter ( )
@@ -1219,7 +1251,7 @@ mod tests {
12191251 134 , 135 ,
12201252 ]
12211253 . into_iter ( )
1222- . for_each ( |v| vote_state. process_next_vote_slot ( v, 4 , 0 ) ) ;
1254+ . for_each ( |v| vote_state. process_next_vote_slot ( v, 4 , 0 , false , true ) ) ;
12231255
12241256 let version1_14_11_serialized = bincode:: serialize ( & VoteStateVersions :: V1_14_11 ( Box :: new (
12251257 VoteState1_14_11 :: from ( vote_state. clone ( ) ) ,
@@ -1511,11 +1543,11 @@ mod tests {
15111543 let slot_hashes: Vec < _ > = vote. slots . iter ( ) . rev ( ) . map ( |x| ( * x, vote. hash ) ) . collect ( ) ;
15121544
15131545 assert_eq ! (
1514- process_vote( & mut vote_state_a, & vote, & slot_hashes, 0 , 0 ) ,
1546+ process_vote( & mut vote_state_a, & vote, & slot_hashes, 0 , 0 , true , true ) ,
15151547 Ok ( ( ) )
15161548 ) ;
15171549 assert_eq ! (
1518- process_vote( & mut vote_state_b, & vote, & slot_hashes, 0 , 0 ) ,
1550+ process_vote( & mut vote_state_b, & vote, & slot_hashes, 0 , 0 , true , true ) ,
15191551 Ok ( ( ) )
15201552 ) ;
15211553 assert_eq ! ( recent_votes( & vote_state_a) , recent_votes( & vote_state_b) ) ;
@@ -1528,12 +1560,12 @@ mod tests {
15281560 let vote = Vote :: new ( vec ! [ 0 ] , Hash :: default ( ) ) ;
15291561 let slot_hashes: Vec < _ > = vec ! [ ( 0 , vote. hash) ] ;
15301562 assert_eq ! (
1531- process_vote( & mut vote_state, & vote, & slot_hashes, 0 , 0 ) ,
1563+ process_vote( & mut vote_state, & vote, & slot_hashes, 0 , 0 , true , true ) ,
15321564 Ok ( ( ) )
15331565 ) ;
15341566 let recent = recent_votes ( & vote_state) ;
15351567 assert_eq ! (
1536- process_vote( & mut vote_state, & vote, & slot_hashes, 0 , 0 ) ,
1568+ process_vote( & mut vote_state, & vote, & slot_hashes, 0 , 0 , true , true ) ,
15371569 Err ( VoteError :: VoteTooOld )
15381570 ) ;
15391571 assert_eq ! ( recent, recent_votes( & vote_state) ) ;
@@ -1593,7 +1625,7 @@ mod tests {
15931625 let vote = Vote :: new ( vec ! [ 0 ] , Hash :: default ( ) ) ;
15941626 let slot_hashes: Vec < _ > = vec ! [ ( * vote. slots. last( ) . unwrap( ) , vote. hash) ] ;
15951627 assert_eq ! (
1596- process_vote( & mut vote_state, & vote, & slot_hashes, 0 , 0 ) ,
1628+ process_vote( & mut vote_state, & vote, & slot_hashes, 0 , 0 , true , true ) ,
15971629 Ok ( ( ) )
15981630 ) ;
15991631 assert_eq ! (
@@ -1609,7 +1641,7 @@ mod tests {
16091641 let vote = Vote :: new ( vec ! [ 0 ] , Hash :: default ( ) ) ;
16101642 let slot_hashes: Vec < _ > = vec ! [ ( * vote. slots. last( ) . unwrap( ) , vote. hash) ] ;
16111643 assert_eq ! (
1612- process_vote( & mut vote_state, & vote, & slot_hashes, 0 , 0 ) ,
1644+ process_vote( & mut vote_state, & vote, & slot_hashes, 0 , 0 , true , true ) ,
16131645 Ok ( ( ) )
16141646 ) ;
16151647
@@ -1628,7 +1660,7 @@ mod tests {
16281660 let vote = Vote :: new ( vec ! [ 0 ] , Hash :: default ( ) ) ;
16291661 let slot_hashes: Vec < _ > = vec ! [ ( * vote. slots. last( ) . unwrap( ) , vote. hash) ] ;
16301662 assert_eq ! (
1631- process_vote( & mut vote_state, & vote, & slot_hashes, 0 , 0 ) ,
1663+ process_vote( & mut vote_state, & vote, & slot_hashes, 0 , 0 , true , true ) ,
16321664 Ok ( ( ) )
16331665 ) ;
16341666
@@ -1645,7 +1677,7 @@ mod tests {
16451677
16461678 let vote = Vote :: new ( vec ! [ ] , Hash :: default ( ) ) ;
16471679 assert_eq ! (
1648- process_vote( & mut vote_state, & vote, & [ ] , 0 , 0 ) ,
1680+ process_vote( & mut vote_state, & vote, & [ ] , 0 , 0 , true , true ) ,
16491681 Err ( VoteError :: EmptySlots )
16501682 ) ;
16511683 }
@@ -1901,7 +1933,9 @@ mod tests {
19011933 & vote,
19021934 & slot_hashes,
19031935 0 ,
1904- vote_group. 1 // vote_group.1 is the slot in which the vote was cast
1936+ vote_group. 1 , // vote_group.1 is the slot in which the vote was cast
1937+ true ,
1938+ true
19051939 ) ,
19061940 Ok ( ( ) )
19071941 ) ;
@@ -2793,7 +2827,7 @@ mod tests {
27932827 // error with `VotesTooOldAllFiltered`
27942828 let slot_hashes = vec ! [ ( 3 , Hash :: new_unique( ) ) , ( 2 , Hash :: new_unique( ) ) ] ;
27952829 assert_eq ! (
2796- process_vote( & mut vote_state, & vote, & slot_hashes, 0 , 0 ) ,
2830+ process_vote( & mut vote_state, & vote, & slot_hashes, 0 , 0 , true , true ) ,
27972831 Err ( VoteError :: VotesTooOldAllFiltered )
27982832 ) ;
27992833
@@ -2807,7 +2841,7 @@ mod tests {
28072841 . 1 ;
28082842
28092843 let vote = Vote :: new ( vec ! [ old_vote_slot, vote_slot] , vote_slot_hash) ;
2810- process_vote ( & mut vote_state, & vote, & slot_hashes, 0 , 0 ) . unwrap ( ) ;
2844+ process_vote ( & mut vote_state, & vote, & slot_hashes, 0 , 0 , true , true ) . unwrap ( ) ;
28112845 assert_eq ! (
28122846 vote_state
28132847 . votes
@@ -2836,8 +2870,17 @@ mod tests {
28362870 . unwrap ( )
28372871 . 1 ;
28382872 let vote = Vote :: new ( vote_slots, vote_hash) ;
2839- process_vote_unfiltered ( & mut vote_state, & vote. slots , & vote, slot_hashes, 0 , 0 )
2840- . unwrap ( ) ;
2873+ process_vote_unfiltered (
2874+ & mut vote_state,
2875+ & vote. slots ,
2876+ & vote,
2877+ slot_hashes,
2878+ 0 ,
2879+ 0 ,
2880+ true ,
2881+ true ,
2882+ )
2883+ . unwrap ( ) ;
28412884 }
28422885
28432886 vote_state
0 commit comments