@@ -397,7 +397,7 @@ impl BlockStore {
397397 self . rebuild ( root, blocks, quorum_certs) . await ;
398398 storage. consensus_db ( ) . ledger_db . metadata_db ( ) . set_latest_ledger_info ( ledger_infos. last ( ) . unwrap ( ) . clone ( ) ) ;
399399
400- if ledger_infos. last ( ) . unwrap ( ) . ledger_info ( ) . ends_epoch ( ) {
400+ if !ledger_infos . is_empty ( ) && ledger_infos. last ( ) . unwrap ( ) . ledger_info ( ) . ends_epoch ( ) {
401401 retriever
402402 . network
403403 . send_epoch_change ( EpochChangeProof :: new (
@@ -625,7 +625,14 @@ impl BlockStore {
625625 let mut parent_id = HashValue :: zero ( ) ;
626626 let mut is_last_block = false ;
627627 if let Some ( executed_block) = self . get_block ( id) {
628- let qc = self . get_quorum_cert_for_block ( id) . unwrap ( ) ;
628+ let qc = match self . get_quorum_cert_for_block ( id) {
629+ Some ( qc) => qc,
630+ None => {
631+ info ! ( "Cannot find quorum cert for block id {}" , id) ;
632+ status = BlockRetrievalStatus :: QuorumCertNotFound ;
633+ break ;
634+ }
635+ } ;
629636 is_last_block = qc. commit_info ( ) . round ( ) == 0 ;
630637 quorum_certs. push ( ( * qc) . clone ( ) ) ;
631638 let randomness = match executed_block. block ( ) . block_number ( ) {
@@ -637,7 +644,19 @@ impl BlockStore {
637644 } else if let Ok ( Some ( executed_block) ) =
638645 self . storage . consensus_db ( ) . get_block ( retrieval_epoch, id)
639646 {
640- let qc = self . storage . consensus_db ( ) . get_qc ( retrieval_epoch, id) . unwrap ( ) . unwrap ( ) ;
647+ let qc = match self . storage . consensus_db ( ) . get_qc ( retrieval_epoch, id) {
648+ Ok ( Some ( qc) ) => qc,
649+ Ok ( None ) => {
650+ info ! ( "Cannot find quorum cert for block id {} in epoch {}" , id, retrieval_epoch) ;
651+ status = BlockRetrievalStatus :: QuorumCertNotFound ;
652+ break ;
653+ }
654+ Err ( e) => {
655+ error ! ( "Error retrieving quorum cert for block id {} in epoch {}: {:?}" , id, retrieval_epoch, e) ;
656+ status = BlockRetrievalStatus :: QuorumCertNotFound ;
657+ break ;
658+ }
659+ } ;
641660 is_last_block = qc. commit_info ( ) . round ( ) == 0 ;
642661 quorum_certs. push ( qc) ;
643662 let randomness = self . storage . consensus_db ( ) . get_randomness ( executed_block. block_number ( ) . unwrap ( ) ) . unwrap ( ) ;
0 commit comments