message: validation: Pass in coins cache to ::LimitMempoolSize
diff: @@ -324,7 +324,7 @@ bool CheckSequenceLocks(const CTxMemPool& pool, const CTransaction& tx, int flag
  // Returns the script flags which should be checked for a given block
  static unsigned int GetBlockScriptFlags(const CBlockIndex* pindex, const Consensus::Params& chainparams);
  -static void LimitMempoolSize(CTxMemPool& pool, size_t limit, std::chrono::seconds age)
  +static void LimitMempoolSize(CTxMemPool& pool, CCoinsViewCache& coins_cache, size_t limit, std::chrono::seconds age)
  EXCLUSIVE_LOCKS_REQUIRED(pool.cs, ::cs_main)
  {
  int expired = pool.Expire(GetTime<std::chrono::seconds>() - age);
  @@ -334,8 +334,9 @@ static void LimitMempoolSize(CTxMemPool& pool, size_t limit, std::chrono::second
  std::vector<COutPoint> vNoSpendsRemaining;
  pool.TrimToSize(limit, &vNoSpendsRemaining);
  + assert(std::addressof(::ChainstateActive().CoinsTip()) == std::addressof(coins_cache));
  for (const COutPoint& removed : vNoSpendsRemaining)
  - ::ChainstateActive().CoinsTip().Uncache(removed);
  + coins_cache.Uncache(removed);
  }
  /* Make mempool consistent after a reorg, by re-adding or recursively erasing
  @@ -386,7 +387,7 @@ static void UpdateMempoolForReorg(CTxMemPool& mempool, DisconnectedBlockTransact
  // We also need to remove any now-immature transactions
  mempool.removeForReorg(&::ChainstateActive().CoinsTip(), ::ChainActive().Tip()->nHeight + 1, STANDARD_LOCKTIME_VERIFY_FLAGS);
  // Re-limit mempool size, in case we added any transactions
  - LimitMempoolSize(mempool, gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000, std::chrono::hours{gArgs.GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY)});
  + LimitMempoolSize(mempool, ::ChainstateActive().CoinsTip(), gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000, std::chrono::hours{gArgs.GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY)});
  }
  /**
  @@ -805,7 +806,7 @@ bool MemPoolAccept::Finalize(const ATMPArgs& args, Workspace& ws)
  // trim mempool and check if tx was trimmed
  if (!bypass_limits) {
  - LimitMempoolSize(m_pool, gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000, std::chrono::hours{gArgs.GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY)});
  + LimitMempoolSize(m_pool, ::ChainstateActive().CoinsTip(), gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000, std::chrono::hours{gArgs.GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY)});
  if (!m_pool.exists(hash))
  return state.Invalid(TxValidationResult::TX_MEMPOOL_POLICY, "mempool full");
  }
  