message: [MNs] Ping was not being checked against the active chain.
  Which could lead to MNs running in the main chain accepting pings from nodes in forks.
diff: @@ -744,22 +744,23 @@ bool CMasternodePing::CheckAndUpdate(int& nDos, bool fRequireEnabled, bool fChec
  return false;
  }
  + // Check if the ping block hash exists in disk
  BlockMap::iterator mi = mapBlockIndex.find(blockHash);
  - if (mi != mapBlockIndex.end() && (*mi).second) {
  - if ((*mi).second->nHeight < chainActive.Height() - 24) {
  - LogPrint(BCLog::MASTERNODE,"CMasternodePing::CheckAndUpdate - Masternode %s block hash %s is too old\n", vin.prevout.hash.ToString(), blockHash.ToString());
  - // Do nothing here (no Masternode update, no mnping relay)
  - // Let this node to be visible but fail to accept mnping
  -
  + if (mi == mapBlockIndex.end() || !(*mi).second) {
  + LogPrint(BCLog::MASTERNODE,"CMasternodePing::CheckAndUpdate - ping block not in disk. Masternode %s block hash %s\n", vin.prevout.hash.ToString(), blockHash.ToString());
  return false;
  }
  - } else {
  - LogPrint(BCLog::MASTERNODE,"CMasternodePing::CheckAndUpdate - Masternode %s block hash %s is unknown\n", vin.prevout.hash.ToString(), blockHash.ToString());
  - // maybe we stuck so we shouldn't ban this node, just fail to accept it
  - // TODO: or should we also request this block?
  + // Verify ping block hash in main chain and in the [ tip > x > tip - 24 ] range.
  + {
  + LOCK(cs_main);
  + if (!chainActive.Contains((*mi).second) || (chainActive.Height() - (*mi).second->nHeight > 24)) {
  + LogPrint(BCLog::MASTERNODE,"CMasternodePing::CheckAndUpdate - Masternode %s block hash %s is too old or has an invalid block hash\n", vin.prevout.hash.ToString(), blockHash.ToString());
  + // Do nothing here (no Masternode update, no mnping relay)
  + // Let this node to be visible but fail to accept mnping
  return false;
  }
  + }
  pmn->lastPing = *this;
  