message: Change the getter for the highest block to use completed_blocks
diff: @@ -1563,17 +1563,28 @@ impl Storage {
  }
  /// Retrieves the highest block header from storage, if one exists. May return an LMDB error.
  - fn get_highest_block_header_with_metadata_with_sufficient_finality_signatures<
  - Tx: Transaction,
  - >(
  + fn get_header_of_highest_complete_block<Tx: Transaction>(
  &self,
  txn: &mut Tx,
  fault_tolerance_fraction: Ratio<u64>,
  trusted_validator_weights: BTreeMap<PublicKey, U512>,
  ) -> Result<Option<BlockHeaderWithMetadata>, FatalStorageError> {
  - // TODO: Use GetBlockHeaderAndMetadataByHash
  - for (_, block_hash) in self.block_height_index.iter().rev() {
  - let maybe_block = self.get_single_block_header_with_metadata(txn, block_hash)?;
  + let highest_complete_block_height = match self.completed_blocks.highest_sequence() {
  + Some(sequence) => sequence.high(),
  + None => {
  + return Ok(None);
  + }
  + };
  + let highest_complete_block_hash =
  + match self.block_height_index.get(&highest_complete_block_height) {
  + Some(hash) => hash,
  + None => {
  + warn!("couldn't find the highest complete block in block height index");
  + return Ok(None);
  + }
  + };
  + let maybe_block =
  + self.get_single_block_header_with_metadata(txn, highest_complete_block_hash)?;
  match maybe_block {
  Some(highest_block) => {
  if matches!(
  @@ -1584,18 +1595,17 @@ impl Storage {
  ),
  SignaturesFinality::Sufficient
  ) {
  - return Ok(Some(highest_block));
  + Ok(Some(highest_block))
  + } else {
  + warn!("highest complete block didn't have sufficient signatures");
  + Ok(None)
  }
  }
  None => {
  - warn!("no highest block found");
  - return Ok(None);
  - }
  + warn!("couldn't find the highest complete block in storage");
  + Ok(None)
  }
  }
  -
  - warn!("no highest block with sufficient finality signatures found");
  - return Ok(None);
  }
  /// Returns vector blocks that satisfy the predicate, starting from the latest one and following
  @@ -1717,9 +1727,11 @@ impl Storage {
  trusted_validator_weights: BTreeMap<PublicKey, U512>,
  ) -> Result<Option<Vec<BlockHeaderWithMetadata>>, FatalStorageError> {
  // TODO: Could use that: switch_block_era_id_index
  - // TODO: Replace with `disjoint_sequences::top`.
  + // TODO: using the `trusted_validator_weights` here is incorrect - the highest block might
  + // be from a different era; do we even need to check that it has enough signatures if it is
  + // in `completed_blocks`?
  let maybe_highest_block_header_with_sufficient_signatures = self
  - .get_highest_block_header_with_metadata_with_sufficient_finality_signatures(
  + .get_header_of_highest_complete_block(
  txn,
  fault_tolerance_fraction,
  trusted_validator_weights,
  @@ -1747,7 +1759,7 @@ impl Storage {
  Some(block_header_with_metadata) => block_header_with_metadata,
  None => {
  warn!(?parent_hash, "block header not found");
  - todo!()
  + return Ok(None);
  }
  };
  if parent_block_header_with_metadata.block_header.hash() == *block_hash {
  