@@ -616,6 +616,9 @@ pub fn process_new_vote_state(
616
616
let timely_vote_credits = feature_set. map_or ( false , |f| {
617
617
f. is_active ( & feature_set:: timely_vote_credits:: id ( ) )
618
618
} ) ;
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
+ } ) ;
619
622
let mut earned_credits = if timely_vote_credits { 0_u64 } else { 1_u64 } ;
620
623
621
624
if let Some ( new_root) = new_root {
@@ -625,7 +628,11 @@ pub fn process_new_vote_state(
625
628
if current_vote. slot ( ) <= new_root {
626
629
if timely_vote_credits || ( current_vote. slot ( ) != new_root) {
627
630
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
+ ) )
629
636
. expect ( "`earned_credits` does not overflow" ) ;
630
637
}
631
638
current_vote_state_index = current_vote_state_index
@@ -738,11 +745,19 @@ pub fn process_vote_unfiltered(
738
745
slot_hashes : & [ SlotHash ] ,
739
746
epoch : Epoch ,
740
747
current_slot : Slot ,
748
+ timely_vote_credits : bool ,
749
+ deprecate_unused_legacy_vote_plumbing : bool ,
741
750
) -> Result < ( ) , VoteError > {
742
751
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
+ } ) ;
746
761
Ok ( ( ) )
747
762
}
748
763
@@ -752,6 +767,8 @@ pub fn process_vote(
752
767
slot_hashes : & [ SlotHash ] ,
753
768
epoch : Epoch ,
754
769
current_slot : Slot ,
770
+ timely_vote_credits : bool ,
771
+ deprecate_unused_legacy_vote_plumbing : bool ,
755
772
) -> Result < ( ) , VoteError > {
756
773
if vote. slots . is_empty ( ) {
757
774
return Err ( VoteError :: EmptySlots ) ;
@@ -773,6 +790,8 @@ pub fn process_vote(
773
790
slot_hashes,
774
791
epoch,
775
792
current_slot,
793
+ timely_vote_credits,
794
+ deprecate_unused_legacy_vote_plumbing,
776
795
)
777
796
}
778
797
@@ -789,6 +808,8 @@ pub fn process_vote_unchecked(vote_state: &mut VoteState, vote: Vote) -> Result<
789
808
& slot_hashes,
790
809
vote_state. current_epoch ( ) ,
791
810
0 ,
811
+ true ,
812
+ true ,
792
813
)
793
814
}
794
815
@@ -1036,7 +1057,18 @@ pub fn process_vote_with_account<S: std::hash::BuildHasher>(
1036
1057
) -> Result < ( ) , InstructionError > {
1037
1058
let mut vote_state = verify_and_get_vote_state ( vote_account, clock, signers) ?;
1038
1059
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
+ ) ?;
1040
1072
if let Some ( timestamp) = vote. timestamp {
1041
1073
vote. slots
1042
1074
. iter ( )
@@ -1219,7 +1251,7 @@ mod tests {
1219
1251
134 , 135 ,
1220
1252
]
1221
1253
. 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 ) ) ;
1223
1255
1224
1256
let version1_14_11_serialized = bincode:: serialize ( & VoteStateVersions :: V1_14_11 ( Box :: new (
1225
1257
VoteState1_14_11 :: from ( vote_state. clone ( ) ) ,
@@ -1511,11 +1543,11 @@ mod tests {
1511
1543
let slot_hashes: Vec < _ > = vote. slots . iter ( ) . rev ( ) . map ( |x| ( * x, vote. hash ) ) . collect ( ) ;
1512
1544
1513
1545
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 ) ,
1515
1547
Ok ( ( ) )
1516
1548
) ;
1517
1549
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 ) ,
1519
1551
Ok ( ( ) )
1520
1552
) ;
1521
1553
assert_eq ! ( recent_votes( & vote_state_a) , recent_votes( & vote_state_b) ) ;
@@ -1528,12 +1560,12 @@ mod tests {
1528
1560
let vote = Vote :: new ( vec ! [ 0 ] , Hash :: default ( ) ) ;
1529
1561
let slot_hashes: Vec < _ > = vec ! [ ( 0 , vote. hash) ] ;
1530
1562
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 ) ,
1532
1564
Ok ( ( ) )
1533
1565
) ;
1534
1566
let recent = recent_votes ( & vote_state) ;
1535
1567
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 ) ,
1537
1569
Err ( VoteError :: VoteTooOld )
1538
1570
) ;
1539
1571
assert_eq ! ( recent, recent_votes( & vote_state) ) ;
@@ -1593,7 +1625,7 @@ mod tests {
1593
1625
let vote = Vote :: new ( vec ! [ 0 ] , Hash :: default ( ) ) ;
1594
1626
let slot_hashes: Vec < _ > = vec ! [ ( * vote. slots. last( ) . unwrap( ) , vote. hash) ] ;
1595
1627
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 ) ,
1597
1629
Ok ( ( ) )
1598
1630
) ;
1599
1631
assert_eq ! (
@@ -1609,7 +1641,7 @@ mod tests {
1609
1641
let vote = Vote :: new ( vec ! [ 0 ] , Hash :: default ( ) ) ;
1610
1642
let slot_hashes: Vec < _ > = vec ! [ ( * vote. slots. last( ) . unwrap( ) , vote. hash) ] ;
1611
1643
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 ) ,
1613
1645
Ok ( ( ) )
1614
1646
) ;
1615
1647
@@ -1628,7 +1660,7 @@ mod tests {
1628
1660
let vote = Vote :: new ( vec ! [ 0 ] , Hash :: default ( ) ) ;
1629
1661
let slot_hashes: Vec < _ > = vec ! [ ( * vote. slots. last( ) . unwrap( ) , vote. hash) ] ;
1630
1662
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 ) ,
1632
1664
Ok ( ( ) )
1633
1665
) ;
1634
1666
@@ -1645,7 +1677,7 @@ mod tests {
1645
1677
1646
1678
let vote = Vote :: new ( vec ! [ ] , Hash :: default ( ) ) ;
1647
1679
assert_eq ! (
1648
- process_vote( & mut vote_state, & vote, & [ ] , 0 , 0 ) ,
1680
+ process_vote( & mut vote_state, & vote, & [ ] , 0 , 0 , true , true ) ,
1649
1681
Err ( VoteError :: EmptySlots )
1650
1682
) ;
1651
1683
}
@@ -1901,7 +1933,9 @@ mod tests {
1901
1933
& vote,
1902
1934
& slot_hashes,
1903
1935
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
1905
1939
) ,
1906
1940
Ok ( ( ) )
1907
1941
) ;
@@ -2793,7 +2827,7 @@ mod tests {
2793
2827
// error with `VotesTooOldAllFiltered`
2794
2828
let slot_hashes = vec ! [ ( 3 , Hash :: new_unique( ) ) , ( 2 , Hash :: new_unique( ) ) ] ;
2795
2829
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 ) ,
2797
2831
Err ( VoteError :: VotesTooOldAllFiltered )
2798
2832
) ;
2799
2833
@@ -2807,7 +2841,7 @@ mod tests {
2807
2841
. 1 ;
2808
2842
2809
2843
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 ( ) ;
2811
2845
assert_eq ! (
2812
2846
vote_state
2813
2847
. votes
@@ -2836,8 +2870,17 @@ mod tests {
2836
2870
. unwrap ( )
2837
2871
. 1 ;
2838
2872
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 ( ) ;
2841
2884
}
2842
2885
2843
2886
vote_state
0 commit comments