2828 solana_hash:: Hash ,
2929 solana_pubkey:: Pubkey ,
3030 solana_runtime:: { bank:: Bank , validated_block_finalization:: ValidatedBlockFinalizationCert } ,
31- std:: { cmp :: Ordering , collections:: BTreeMap , num:: NonZero , sync:: Arc } ,
31+ std:: { collections:: BTreeMap , num:: NonZero , sync:: Arc } ,
3232 thiserror:: Error ,
3333} ;
3434
@@ -629,33 +629,15 @@ impl ConsensusPool {
629629 }
630630
631631 pub ( crate ) fn get_certs_for_standstill ( & self ) -> Vec < Arc < Certificate > > {
632- let ( highest_slot, has_fast_finalize ) = self
632+ let highest_slot = self
633633 . highest_finalized_slot_cert
634634 . as_ref ( )
635- . map ( |certs| ( certs . slot ( ) , certs . is_fast ( ) ) )
636- . unwrap_or ( ( 0 , false ) ) ;
635+ . map ( ValidatedBlockFinalizationCert :: slot)
636+ . unwrap_or ( 0 ) ;
637637 self . completed_certificates
638638 . iter ( )
639639 . filter_map ( |( cert_type, cert) | {
640- let cert_to_send = match (
641- cert_type. slot ( ) . cmp ( & highest_slot) ,
642- cert_type,
643- has_fast_finalize,
644- ) {
645- ( Ordering :: Greater , _, _)
646- | (
647- Ordering :: Equal ,
648- CertificateType :: Finalize ( _) | CertificateType :: Notarize ( _) ,
649- false ,
650- )
651- | ( Ordering :: Equal , CertificateType :: FinalizeFast ( _) , true ) => {
652- Some ( cert. clone ( ) )
653- }
654- ( Ordering :: Equal , CertificateType :: FinalizeFast ( _) , false ) => {
655- panic ! ( "Should not happen while certificate pool is single threaded" )
656- }
657- _ => None ,
658- } ;
640+ let cert_to_send = ( cert_type. slot ( ) > highest_slot) . then ( || cert. clone ( ) ) ;
659641 if cert_to_send. is_some ( ) {
660642 trace ! (
661643 "{}: Refreshing certificate {:?}" ,
@@ -1917,13 +1899,10 @@ mod tests {
19171899 bitmap : dummy_bitmap ( ) ,
19181900 } ;
19191901 ctx. add_message ( ConsensusMessage :: Certificate ( cert_5) ) ;
1920- // Should return only FinalizeFast cert on 5
1902+ // Slot 5 is now the highest finalized slot, so standstill cert refresh only returns
1903+ // certificates for later slots.
19211904 let certs = ctx. pool . get_certs_for_standstill ( ) ;
1922- assert_eq ! ( certs. len( ) , 1 ) ;
1923- assert ! (
1924- certs[ 0 ] . cert_type. slot( ) == 5
1925- && matches!( certs[ 0 ] . cert_type, CertificateType :: FinalizeFast ( _) )
1926- ) ;
1905+ assert ! ( certs. is_empty( ) ) ;
19271906
19281907 // Now add Notarize cert on 6
19291908 let cert_6 = Certificate {
@@ -1935,11 +1914,9 @@ mod tests {
19351914 bitmap : dummy_bitmap ( ) ,
19361915 } ;
19371916 ctx. add_message ( ConsensusMessage :: Certificate ( cert_6) ) ;
1938- // Should return certs on 5 and 6
1917+ // Should return certs after highest finalized slot 5.
19391918 let certs = ctx. pool . get_certs_for_standstill ( ) ;
1940- assert_eq ! ( certs. len( ) , 2 ) ;
1941- assert ! ( certs. iter( ) . any( |cert| cert. cert_type. slot( ) == 5
1942- && matches!( cert. cert_type, CertificateType :: FinalizeFast ( _) ) ) ) ;
1919+ assert_eq ! ( certs. len( ) , 1 ) ;
19431920 assert ! ( certs. iter( ) . any( |cert| cert. cert_type. slot( ) == 6
19441921 && matches!( cert. cert_type, CertificateType :: Notarize ( _) ) ) ) ;
19451922
@@ -1960,14 +1937,10 @@ mod tests {
19601937 bitmap : dummy_bitmap ( ) ,
19611938 } ;
19621939 ctx. add_message ( ConsensusMessage :: Certificate ( cert_6_notarize_fallback) ) ;
1963- // This should not be returned because 6 is the current highest finalized slot
1964- // only Notarize/Finalze/FinalizeFast should be returned
1940+ // Slot 6 is now the current highest finalized slot, so no slot-6 certs should
1941+ // be returned by the queued refresh path.
19651942 let certs = ctx. pool . get_certs_for_standstill ( ) ;
1966- assert_eq ! ( certs. len( ) , 2 ) ;
1967- assert ! ( certs. iter( ) . any( |cert| cert. cert_type. slot( ) == 6
1968- && matches!( cert. cert_type, CertificateType :: Finalize ( _) ) ) ) ;
1969- assert ! ( certs. iter( ) . any( |cert| cert. cert_type. slot( ) == 6
1970- && matches!( cert. cert_type, CertificateType :: Notarize ( _) ) ) ) ;
1943+ assert ! ( certs. is_empty( ) ) ;
19711944
19721945 // Add another skip on 7
19731946 let cert_7 = Certificate {
@@ -1976,13 +1949,9 @@ mod tests {
19761949 bitmap : dummy_bitmap ( ) ,
19771950 } ;
19781951 ctx. add_message ( ConsensusMessage :: Certificate ( cert_7) ) ;
1979- // Should return certs on 6 and 7
1952+ // Should return certs after highest finalized slot 6.
19801953 let certs = ctx. pool . get_certs_for_standstill ( ) ;
1981- assert_eq ! ( certs. len( ) , 3 ) ;
1982- assert ! ( certs. iter( ) . any( |cert| cert. cert_type. slot( ) == 6
1983- && matches!( cert. cert_type, CertificateType :: Finalize ( _) ) ) ) ;
1984- assert ! ( certs. iter( ) . any( |cert| cert. cert_type. slot( ) == 6
1985- && matches!( cert. cert_type, CertificateType :: Notarize ( _) ) ) ) ;
1954+ assert_eq ! ( certs. len( ) , 1 ) ;
19861955 assert ! (
19871956 certs. iter( ) . any( |cert| cert. cert_type. slot( ) == 7
19881957 && matches!( cert. cert_type, CertificateType :: Skip ( _) ) )
@@ -2005,13 +1974,10 @@ mod tests {
20051974 } ;
20061975 ctx. add_message ( ConsensusMessage :: Certificate ( cert_8_notarize) ) ;
20071976
2008- // Should only return certs on 8 now
1977+ // Slot 8 is now the current highest finalized slot, so latest-finalization
1978+ // certs are refreshed from highest_finalized instead of this queue.
20091979 let certs = ctx. pool . get_certs_for_standstill ( ) ;
2010- assert_eq ! ( certs. len( ) , 2 ) ;
2011- assert ! ( certs. iter( ) . any( |cert| cert. cert_type. slot( ) == 8
2012- && matches!( cert. cert_type, CertificateType :: Finalize ( _) ) ) ) ;
2013- assert ! ( certs. iter( ) . any( |cert| cert. cert_type. slot( ) == 8
2014- && matches!( cert. cert_type, CertificateType :: Notarize ( _) ) ) ) ;
1980+ assert ! ( certs. is_empty( ) ) ;
20151981 }
20161982
20171983 #[ test]
0 commit comments