@@ -612,6 +612,9 @@ pub fn process_new_vote_state(
612
612
let timely_vote_credits = feature_set. map_or ( false , |f| {
613
613
f. is_active ( & feature_set:: timely_vote_credits:: id ( ) )
614
614
} ) ;
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
+ } ) ;
615
618
let mut earned_credits = if timely_vote_credits { 0_u64 } else { 1_u64 } ;
616
619
617
620
if let Some ( new_root) = new_root {
@@ -621,7 +624,11 @@ pub fn process_new_vote_state(
621
624
if current_vote. slot ( ) <= new_root {
622
625
if timely_vote_credits || ( current_vote. slot ( ) != new_root) {
623
626
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
+ ) )
625
632
. expect ( "`earned_credits` does not overflow" ) ;
626
633
}
627
634
current_vote_state_index = current_vote_state_index
@@ -734,11 +741,19 @@ pub fn process_vote_unfiltered(
734
741
slot_hashes : & [ SlotHash ] ,
735
742
epoch : Epoch ,
736
743
current_slot : Slot ,
744
+ timely_vote_credits : bool ,
745
+ deprecate_unused_legacy_vote_plumbing : bool ,
737
746
) -> Result < ( ) , VoteError > {
738
747
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
+ } ) ;
742
757
Ok ( ( ) )
743
758
}
744
759
@@ -748,6 +763,8 @@ pub fn process_vote(
748
763
slot_hashes : & [ SlotHash ] ,
749
764
epoch : Epoch ,
750
765
current_slot : Slot ,
766
+ timely_vote_credits : bool ,
767
+ deprecate_unused_legacy_vote_plumbing : bool ,
751
768
) -> Result < ( ) , VoteError > {
752
769
if vote. slots . is_empty ( ) {
753
770
return Err ( VoteError :: EmptySlots ) ;
@@ -769,6 +786,8 @@ pub fn process_vote(
769
786
slot_hashes,
770
787
epoch,
771
788
current_slot,
789
+ timely_vote_credits,
790
+ deprecate_unused_legacy_vote_plumbing,
772
791
)
773
792
}
774
793
@@ -785,6 +804,8 @@ pub fn process_vote_unchecked(vote_state: &mut VoteState, vote: Vote) -> Result<
785
804
& slot_hashes,
786
805
vote_state. current_epoch ( ) ,
787
806
0 ,
807
+ true ,
808
+ true ,
788
809
)
789
810
}
790
811
@@ -1067,7 +1088,18 @@ pub fn process_vote_with_account<S: std::hash::BuildHasher>(
1067
1088
) -> Result < ( ) , InstructionError > {
1068
1089
let mut vote_state = verify_and_get_vote_state ( vote_account, clock, signers) ?;
1069
1090
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
+ ) ?;
1071
1103
if let Some ( timestamp) = vote. timestamp {
1072
1104
vote. slots
1073
1105
. iter ( )
@@ -1250,7 +1282,7 @@ mod tests {
1250
1282
134 , 135 ,
1251
1283
]
1252
1284
. 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 ) ) ;
1254
1286
1255
1287
let version1_14_11_serialized = bincode:: serialize ( & VoteStateVersions :: V1_14_11 ( Box :: new (
1256
1288
VoteState1_14_11 :: from ( vote_state. clone ( ) ) ,
@@ -1732,11 +1764,11 @@ mod tests {
1732
1764
let slot_hashes: Vec < _ > = vote. slots . iter ( ) . rev ( ) . map ( |x| ( * x, vote. hash ) ) . collect ( ) ;
1733
1765
1734
1766
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 ) ,
1736
1768
Ok ( ( ) )
1737
1769
) ;
1738
1770
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 ) ,
1740
1772
Ok ( ( ) )
1741
1773
) ;
1742
1774
assert_eq ! ( recent_votes( & vote_state_a) , recent_votes( & vote_state_b) ) ;
@@ -1749,12 +1781,12 @@ mod tests {
1749
1781
let vote = Vote :: new ( vec ! [ 0 ] , Hash :: default ( ) ) ;
1750
1782
let slot_hashes: Vec < _ > = vec ! [ ( 0 , vote. hash) ] ;
1751
1783
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 ) ,
1753
1785
Ok ( ( ) )
1754
1786
) ;
1755
1787
let recent = recent_votes ( & vote_state) ;
1756
1788
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 ) ,
1758
1790
Err ( VoteError :: VoteTooOld )
1759
1791
) ;
1760
1792
assert_eq ! ( recent, recent_votes( & vote_state) ) ;
@@ -1814,7 +1846,7 @@ mod tests {
1814
1846
let vote = Vote :: new ( vec ! [ 0 ] , Hash :: default ( ) ) ;
1815
1847
let slot_hashes: Vec < _ > = vec ! [ ( * vote. slots. last( ) . unwrap( ) , vote. hash) ] ;
1816
1848
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 ) ,
1818
1850
Ok ( ( ) )
1819
1851
) ;
1820
1852
assert_eq ! (
@@ -1830,7 +1862,7 @@ mod tests {
1830
1862
let vote = Vote :: new ( vec ! [ 0 ] , Hash :: default ( ) ) ;
1831
1863
let slot_hashes: Vec < _ > = vec ! [ ( * vote. slots. last( ) . unwrap( ) , vote. hash) ] ;
1832
1864
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 ) ,
1834
1866
Ok ( ( ) )
1835
1867
) ;
1836
1868
@@ -1849,7 +1881,7 @@ mod tests {
1849
1881
let vote = Vote :: new ( vec ! [ 0 ] , Hash :: default ( ) ) ;
1850
1882
let slot_hashes: Vec < _ > = vec ! [ ( * vote. slots. last( ) . unwrap( ) , vote. hash) ] ;
1851
1883
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 ) ,
1853
1885
Ok ( ( ) )
1854
1886
) ;
1855
1887
@@ -1866,7 +1898,7 @@ mod tests {
1866
1898
1867
1899
let vote = Vote :: new ( vec ! [ ] , Hash :: default ( ) ) ;
1868
1900
assert_eq ! (
1869
- process_vote( & mut vote_state, & vote, & [ ] , 0 , 0 ) ,
1901
+ process_vote( & mut vote_state, & vote, & [ ] , 0 , 0 , true , true ) ,
1870
1902
Err ( VoteError :: EmptySlots )
1871
1903
) ;
1872
1904
}
@@ -2163,7 +2195,9 @@ mod tests {
2163
2195
& vote,
2164
2196
& slot_hashes,
2165
2197
0 ,
2166
- vote_group. 1 // vote_group.1 is the slot in which the vote was cast
2198
+ vote_group. 1 , // vote_group.1 is the slot in which the vote was cast
2199
+ true ,
2200
+ true
2167
2201
) ,
2168
2202
Ok ( ( ) )
2169
2203
) ;
@@ -3055,7 +3089,7 @@ mod tests {
3055
3089
// error with `VotesTooOldAllFiltered`
3056
3090
let slot_hashes = vec ! [ ( 3 , Hash :: new_unique( ) ) , ( 2 , Hash :: new_unique( ) ) ] ;
3057
3091
assert_eq ! (
3058
- process_vote( & mut vote_state, & vote, & slot_hashes, 0 , 0 ) ,
3092
+ process_vote( & mut vote_state, & vote, & slot_hashes, 0 , 0 , true , true ) ,
3059
3093
Err ( VoteError :: VotesTooOldAllFiltered )
3060
3094
) ;
3061
3095
@@ -3069,7 +3103,7 @@ mod tests {
3069
3103
. 1 ;
3070
3104
3071
3105
let vote = Vote :: new ( vec ! [ old_vote_slot, vote_slot] , vote_slot_hash) ;
3072
- process_vote ( & mut vote_state, & vote, & slot_hashes, 0 , 0 ) . unwrap ( ) ;
3106
+ process_vote ( & mut vote_state, & vote, & slot_hashes, 0 , 0 , true , true ) . unwrap ( ) ;
3073
3107
assert_eq ! (
3074
3108
vote_state
3075
3109
. votes
@@ -3098,8 +3132,17 @@ mod tests {
3098
3132
. unwrap ( )
3099
3133
. 1 ;
3100
3134
let vote = Vote :: new ( vote_slots, vote_hash) ;
3101
- process_vote_unfiltered ( & mut vote_state, & vote. slots , & vote, slot_hashes, 0 , 0 )
3102
- . unwrap ( ) ;
3135
+ process_vote_unfiltered (
3136
+ & mut vote_state,
3137
+ & vote. slots ,
3138
+ & vote,
3139
+ slot_hashes,
3140
+ 0 ,
3141
+ 0 ,
3142
+ true ,
3143
+ true ,
3144
+ )
3145
+ . unwrap ( ) ;
3103
3146
}
3104
3147
3105
3148
vote_state
0 commit comments