message: fix(shell_automaton): not always responding to GetCurrentHead
diff: @@ -663,13 +663,9 @@ where
  requested_explicitly,
  prechecked_head,
  }) => {
  - let applied_block = match &store.state().mempool.local_head_state {
  + let applied_block = match store.state().current_head.get() {
  Some(v) => v,
  - None => {
  - // should always have current head here
  - // TODO(vlad): should be forbidden by enabling condition
  - return;
  - }
  + None => return,
  };
  let (block_is_applied, header, head_hash) = match prechecked_head.as_ref() {
  Some(prechecked_head) if prechecked_head != &applied_block.hash => {
  @@ -681,11 +677,7 @@ where
  return;
  }
  }
  - _ => (true, &applied_block.header, &applied_block.hash),
  - };
  - let peer = match store.state().mempool.peer_state.get(&address) {
  - Some(v) => v,
  - None => return,
  + _ => (true, &*applied_block.header, &applied_block.hash),
  };
  // TODO(vlad): for debug
  @@ -701,7 +693,7 @@ where
  .branch_delayed
  .iter()
  .filter_map(|v| {
  - if v.is_endorsement? && !peer.seen_operations.contains(&v.hash) {
  + if v.is_endorsement? {
  Some(v.hash.clone())
  } else {
  None
  @@ -713,17 +705,16 @@ where
  .validated_operations
  .applied
  .iter()
  - .filter_map(|v| {
  - if !peer.seen_operations.contains(&v.hash) {
  - Some(v.hash.clone())
  - } else {
  - None
  - }
  - })
  + .map(|v| v.hash.clone())
  .chain(delayed_endorsements)
  .collect::<Vec<_>>()
  }
  } else {
  + let seen_operations_default = Default::default();
  + let seen_operations = match store.state().mempool.peer_state.get(&address) {
  + Some(v) => &v.seen_operations,
  + None => &seen_operations_default,
  + };
  store
  .state()
  .mempool
  @@ -731,7 +722,7 @@ where
  .ops
  .iter()
  .filter_map(|(hash, op)| {
  - if !peer.seen_operations.contains(hash)
  + if !seen_operations.contains(hash)
  // when broadcasting prechecked head, only include operations for that head
  && (block_is_applied || head_hash == op.branch())
  {
  @@ -751,7 +742,7 @@ where
  .pending_operations
  .iter()
  .filter_map(|(hash, op)| {
  - if !peer.seen_operations.contains(hash) && head_hash.eq(op.branch()) {
  + if head_hash.eq(op.branch()) {
  Some(hash.clone())
  } else {
  None
  @@ -763,7 +754,7 @@ where
  };
  let mempool = if *send_operations {
  let mempool = Mempool::new(known_valid.clone(), pending.clone());
  - if mempool.is_empty() {
  + if !requested_explicitly && mempool.is_empty() {
  return;
  }
  mempool
  