message: added consideration of progress in sync_instructions switch to CaughtUp
diff: @@ -13,7 +13,7 @@ use itertools::Itertools;
  use num_rational::Ratio;
  use tracing::{debug, error, warn};
  -use casper_types::{EraId, PublicKey, Timestamp};
  +use casper_types::{EraId, PublicKey, TimeDiff, Timestamp};
  use crate::{
  components::Component,
  @@ -114,6 +114,7 @@ impl BlocksAccumulator {
  // |------------- future chain ------------------------> ?
  const ATTEMPT_EXECUTION_THRESHOLD: u64 = 3; // TODO: make chainspec or cfg setting
  + const BLOCKS_ACCUMULATOR_DEAD_AIR_INTERVAL_SECS: u32 = 180; // TODO: make chain / cfg
  let should_fetch_execution_state = starting_with.have_block() == false;
  let block_hash = starting_with.block_hash();
  @@ -151,11 +152,17 @@ impl BlocksAccumulator {
  // the starting-with block may be close to perceived tip
  let height_diff = highest_block_height.saturating_sub(block_height);
  if height_diff == 0 {
  - // TODO: maybe add some time slippage awareness re: the last time
  - // we heard anything via gossiping, timestamp on the highest block
  - // we currently know about, etc
  + // NOTE: what we're trying to protect against here is if we
  + // haven't seen any new info about new blocks but we should have;
  + // either the network is hung / skipping a lot of blocks
  + // or this node is partitioned. In such a case, attempt a leap
  + // to see where other nodes think the tip is
  + let since_when = TimeDiff::from_seconds(BLOCKS_ACCUMULATOR_DEAD_AIR_INTERVAL_SECS);
  + if self.recent_progress(since_when) {
  return SyncInstruction::CaughtUp;
  }
  + return SyncInstruction::Leap;
  + }
  if height_diff <= ATTEMPT_EXECUTION_THRESHOLD {
  if let Some(child_hash) = self.block_children.get(&block_hash) {
  if let Some(block_acceptor) = self.block_gossip_acceptors.get_mut(child_hash) {
  @@ -298,6 +305,13 @@ impl BlocksAccumulator {
  self.filter.push(block_header.hash())
  }
  + pub(crate) fn recent_progress(&self, since_when: TimeDiff) -> bool {
  + match self.last_progress() {
  + Some(last_progress) => last_progress > Timestamp::now().saturating_sub(since_when),
  + None => false,
  + }
  + }
  +
  pub(crate) fn last_progress(&self) -> Option<Timestamp> {
  self.block_gossip_acceptors
  .iter()
  