@@ -612,6 +612,9 @@ pub fn process_new_vote_state(
612612 let timely_vote_credits = feature_set. map_or ( false , |f| {
613613 f. is_active ( & feature_set:: timely_vote_credits:: id ( ) )
614614 } ) ;
615+ let deprecate_unused_legacy_vote_plumbing = feature_set. map_or ( false , |f| {
616+ f. is_active ( & feature_set:: deprecate_unused_legacy_vote_plumbing:: id ( ) )
617+ } ) ;
615618 let mut earned_credits = if timely_vote_credits { 0_u64 } else { 1_u64 } ;
616619
617620 if let Some ( new_root) = new_root {
@@ -621,7 +624,11 @@ pub fn process_new_vote_state(
621624 if current_vote. slot ( ) <= new_root {
622625 if timely_vote_credits || ( current_vote. slot ( ) != new_root) {
623626 earned_credits = earned_credits
624- . checked_add ( vote_state. credits_for_vote_at_index ( current_vote_state_index) )
627+ . checked_add ( vote_state. credits_for_vote_at_index (
628+ current_vote_state_index,
629+ timely_vote_credits,
630+ deprecate_unused_legacy_vote_plumbing,
631+ ) )
625632 . expect ( "`earned_credits` does not overflow" ) ;
626633 }
627634 current_vote_state_index = current_vote_state_index
@@ -734,11 +741,19 @@ pub fn process_vote_unfiltered(
734741 slot_hashes : & [ SlotHash ] ,
735742 epoch : Epoch ,
736743 current_slot : Slot ,
744+ timely_vote_credits : bool ,
745+ deprecate_unused_legacy_vote_plumbing : bool ,
737746) -> Result < ( ) , VoteError > {
738747 check_slots_are_valid ( vote_state, vote_slots, & vote. hash , slot_hashes) ?;
739- vote_slots
740- . iter ( )
741- . for_each ( |s| vote_state. process_next_vote_slot ( * s, epoch, current_slot) ) ;
748+ vote_slots. iter ( ) . for_each ( |s| {
749+ vote_state. process_next_vote_slot (
750+ * s,
751+ epoch,
752+ current_slot,
753+ timely_vote_credits,
754+ deprecate_unused_legacy_vote_plumbing,
755+ )
756+ } ) ;
742757 Ok ( ( ) )
743758}
744759
@@ -748,6 +763,8 @@ pub fn process_vote(
748763 slot_hashes : & [ SlotHash ] ,
749764 epoch : Epoch ,
750765 current_slot : Slot ,
766+ timely_vote_credits : bool ,
767+ deprecate_unused_legacy_vote_plumbing : bool ,
751768) -> Result < ( ) , VoteError > {
752769 if vote. slots . is_empty ( ) {
753770 return Err ( VoteError :: EmptySlots ) ;
@@ -769,6 +786,8 @@ pub fn process_vote(
769786 slot_hashes,
770787 epoch,
771788 current_slot,
789+ timely_vote_credits,
790+ deprecate_unused_legacy_vote_plumbing,
772791 )
773792}
774793
@@ -785,6 +804,8 @@ pub fn process_vote_unchecked(vote_state: &mut VoteState, vote: Vote) -> Result<
785804 & slot_hashes,
786805 vote_state. current_epoch ( ) ,
787806 0 ,
807+ true ,
808+ true ,
788809 )
789810}
790811
@@ -1067,7 +1088,18 @@ pub fn process_vote_with_account<S: std::hash::BuildHasher>(
10671088) -> Result < ( ) , InstructionError > {
10681089 let mut vote_state = verify_and_get_vote_state ( vote_account, clock, signers) ?;
10691090
1070- process_vote ( & mut vote_state, vote, slot_hashes, clock. epoch , clock. slot ) ?;
1091+ let timely_vote_credits = feature_set. is_active ( & feature_set:: timely_vote_credits:: id ( ) ) ;
1092+ let deprecate_unused_legacy_vote_plumbing =
1093+ feature_set. is_active ( & feature_set:: deprecate_unused_legacy_vote_plumbing:: id ( ) ) ;
1094+ process_vote (
1095+ & mut vote_state,
1096+ vote,
1097+ slot_hashes,
1098+ clock. epoch ,
1099+ clock. slot ,
1100+ timely_vote_credits,
1101+ deprecate_unused_legacy_vote_plumbing,
1102+ ) ?;
10711103 if let Some ( timestamp) = vote. timestamp {
10721104 vote. slots
10731105 . iter ( )
@@ -1250,7 +1282,7 @@ mod tests {
12501282 134 , 135 ,
12511283 ]
12521284 . into_iter ( )
1253- . for_each ( |v| vote_state. process_next_vote_slot ( v, 4 , 0 ) ) ;
1285+ . for_each ( |v| vote_state. process_next_vote_slot ( v, 4 , 0 , false , true ) ) ;
12541286
12551287 let version1_14_11_serialized = bincode:: serialize ( & VoteStateVersions :: V1_14_11 ( Box :: new (
12561288 VoteState1_14_11 :: from ( vote_state. clone ( ) ) ,
@@ -1732,11 +1764,11 @@ mod tests {
17321764 let slot_hashes: Vec < _ > = vote. slots . iter ( ) . rev ( ) . map ( |x| ( * x, vote. hash ) ) . collect ( ) ;
17331765
17341766 assert_eq ! (
1735- process_vote( & mut vote_state_a, & vote, & slot_hashes, 0 , 0 ) ,
1767+ process_vote( & mut vote_state_a, & vote, & slot_hashes, 0 , 0 , true , true ) ,
17361768 Ok ( ( ) )
17371769 ) ;
17381770 assert_eq ! (
1739- process_vote( & mut vote_state_b, & vote, & slot_hashes, 0 , 0 ) ,
1771+ process_vote( & mut vote_state_b, & vote, & slot_hashes, 0 , 0 , true , true ) ,
17401772 Ok ( ( ) )
17411773 ) ;
17421774 assert_eq ! ( recent_votes( & vote_state_a) , recent_votes( & vote_state_b) ) ;
@@ -1749,12 +1781,12 @@ mod tests {
17491781 let vote = Vote :: new ( vec ! [ 0 ] , Hash :: default ( ) ) ;
17501782 let slot_hashes: Vec < _ > = vec ! [ ( 0 , vote. hash) ] ;
17511783 assert_eq ! (
1752- process_vote( & mut vote_state, & vote, & slot_hashes, 0 , 0 ) ,
1784+ process_vote( & mut vote_state, & vote, & slot_hashes, 0 , 0 , true , true ) ,
17531785 Ok ( ( ) )
17541786 ) ;
17551787 let recent = recent_votes ( & vote_state) ;
17561788 assert_eq ! (
1757- process_vote( & mut vote_state, & vote, & slot_hashes, 0 , 0 ) ,
1789+ process_vote( & mut vote_state, & vote, & slot_hashes, 0 , 0 , true , true ) ,
17581790 Err ( VoteError :: VoteTooOld )
17591791 ) ;
17601792 assert_eq ! ( recent, recent_votes( & vote_state) ) ;
@@ -1814,7 +1846,7 @@ mod tests {
18141846 let vote = Vote :: new ( vec ! [ 0 ] , Hash :: default ( ) ) ;
18151847 let slot_hashes: Vec < _ > = vec ! [ ( * vote. slots. last( ) . unwrap( ) , vote. hash) ] ;
18161848 assert_eq ! (
1817- process_vote( & mut vote_state, & vote, & slot_hashes, 0 , 0 ) ,
1849+ process_vote( & mut vote_state, & vote, & slot_hashes, 0 , 0 , true , true ) ,
18181850 Ok ( ( ) )
18191851 ) ;
18201852 assert_eq ! (
@@ -1830,7 +1862,7 @@ mod tests {
18301862 let vote = Vote :: new ( vec ! [ 0 ] , Hash :: default ( ) ) ;
18311863 let slot_hashes: Vec < _ > = vec ! [ ( * vote. slots. last( ) . unwrap( ) , vote. hash) ] ;
18321864 assert_eq ! (
1833- process_vote( & mut vote_state, & vote, & slot_hashes, 0 , 0 ) ,
1865+ process_vote( & mut vote_state, & vote, & slot_hashes, 0 , 0 , true , true ) ,
18341866 Ok ( ( ) )
18351867 ) ;
18361868
@@ -1849,7 +1881,7 @@ mod tests {
18491881 let vote = Vote :: new ( vec ! [ 0 ] , Hash :: default ( ) ) ;
18501882 let slot_hashes: Vec < _ > = vec ! [ ( * vote. slots. last( ) . unwrap( ) , vote. hash) ] ;
18511883 assert_eq ! (
1852- process_vote( & mut vote_state, & vote, & slot_hashes, 0 , 0 ) ,
1884+ process_vote( & mut vote_state, & vote, & slot_hashes, 0 , 0 , true , true ) ,
18531885 Ok ( ( ) )
18541886 ) ;
18551887
@@ -1866,7 +1898,7 @@ mod tests {
18661898
18671899 let vote = Vote :: new ( vec ! [ ] , Hash :: default ( ) ) ;
18681900 assert_eq ! (
1869- process_vote( & mut vote_state, & vote, & [ ] , 0 , 0 ) ,
1901+ process_vote( & mut vote_state, & vote, & [ ] , 0 , 0 , true , true ) ,
18701902 Err ( VoteError :: EmptySlots )
18711903 ) ;
18721904 }
@@ -2122,7 +2154,9 @@ mod tests {
21222154 & vote,
21232155 & slot_hashes,
21242156 0 ,
2125- vote_group. 1 // vote_group.1 is the slot in which the vote was cast
2157+ vote_group. 1 , // vote_group.1 is the slot in which the vote was cast
2158+ true ,
2159+ true
21262160 ) ,
21272161 Ok ( ( ) )
21282162 ) ;
@@ -3014,7 +3048,7 @@ mod tests {
30143048 // error with `VotesTooOldAllFiltered`
30153049 let slot_hashes = vec ! [ ( 3 , Hash :: new_unique( ) ) , ( 2 , Hash :: new_unique( ) ) ] ;
30163050 assert_eq ! (
3017- process_vote( & mut vote_state, & vote, & slot_hashes, 0 , 0 ) ,
3051+ process_vote( & mut vote_state, & vote, & slot_hashes, 0 , 0 , true , true ) ,
30183052 Err ( VoteError :: VotesTooOldAllFiltered )
30193053 ) ;
30203054
@@ -3028,7 +3062,7 @@ mod tests {
30283062 . 1 ;
30293063
30303064 let vote = Vote :: new ( vec ! [ old_vote_slot, vote_slot] , vote_slot_hash) ;
3031- process_vote ( & mut vote_state, & vote, & slot_hashes, 0 , 0 ) . unwrap ( ) ;
3065+ process_vote ( & mut vote_state, & vote, & slot_hashes, 0 , 0 , true , true ) . unwrap ( ) ;
30323066 assert_eq ! (
30333067 vote_state
30343068 . votes
@@ -3057,8 +3091,17 @@ mod tests {
30573091 . unwrap ( )
30583092 . 1 ;
30593093 let vote = Vote :: new ( vote_slots, vote_hash) ;
3060- process_vote_unfiltered ( & mut vote_state, & vote. slots , & vote, slot_hashes, 0 , 0 )
3061- . unwrap ( ) ;
3094+ process_vote_unfiltered (
3095+ & mut vote_state,
3096+ & vote. slots ,
3097+ & vote,
3098+ slot_hashes,
3099+ 0 ,
3100+ 0 ,
3101+ true ,
3102+ true ,
3103+ )
3104+ . unwrap ( ) ;
30623105 }
30633106
30643107 vote_state
0 commit comments