message: Use `RwLock` to handle `digests_without_missing_descendants` cache
diff: -use std::{collections::HashMap, ops::Deref, sync::Arc};
  +use std::{
  + collections::{HashMap, HashSet},
  + ops::Deref,
  + sync::{Arc, RwLock},
  +};
  use casper_hashing::{ChunkWithProof, Digest};
  use casper_types::{bytesrepr::Bytes, Key, StoredValue};
  +use tracing::info;
  use crate::{
  shared::{additive_map::AdditiveMap, newtypes::CorrelationId, transform::Transform},
  @@ -35,6 +40,7 @@ pub struct LmdbGlobalState {
  // TODO: make this a lazy-static
  /// Empty root hash used for a new trie.
  pub(crate) empty_root_hash: Digest,
  + digests_without_missing_descendants: RwLock<HashSet<Digest>>,
  }
  /// Represents a "view" of global state at a particular root hash.
  @@ -75,6 +81,7 @@ impl LmdbGlobalState {
  environment,
  trie_store,
  empty_root_hash,
  + digests_without_missing_descendants: Default::default(),
  }
  }
  @@ -276,23 +283,51 @@ impl StateProvider for LmdbGlobalState {
  }
  /// Finds all of the keys of missing descendant `Trie<K,V>` values.
  + #[allow(clippy::needless_collect)]
  fn missing_trie_keys(
  &self,
  correlation_id: CorrelationId,
  trie_keys: Vec<Digest>,
  ) -> Result<Vec<Digest>, Self::Error> {
  + let trie_keys_filtered: Vec<_> = trie_keys
  + .iter()
  + .filter(|digest| {
  + !self
  + .digests_without_missing_descendants
  + .read()
  + .unwrap()
  + .contains(digest)
  + })
  + .collect();
  +
  + if trie_keys_filtered.is_empty() {
  + info!("no need to call missing_trie_keys");
  + Ok(vec![])
  + } else {
  let txn = self.environment.create_read_txn()?;
  - let missing_descendants =
  - missing_trie_keys::<Key, StoredValue, lmdb::RoTransaction, LmdbTrieStore, Self::Error>(
  + let missing_descendants = missing_trie_keys::<
  + Key,
  + StoredValue,
  + lmdb::RoTransaction,
  + LmdbTrieStore,
  + Self::Error,
  + >(
  correlation_id,
  &txn,
  self.trie_store.deref(),
  - trie_keys,
  + trie_keys.clone(),
  )?;
  txn.commit()?;
  + if missing_descendants.is_empty() {
  + self.digests_without_missing_descendants
  + .write()
  + .unwrap()
  + .extend(&trie_keys);
  + }
  Ok(missing_descendants)
  }
  }
  +}
  #[cfg(test)]
  mod tests {
  