message: validation: Pass in chainstate to AcceptToMemoryPoolWithTime
diff: @@ -864,6 +864,7 @@ MempoolAcceptResult MemPoolAccept::AcceptSingleTransaction(const CTransactionRef
  /** (try to) add transaction to memory pool with a specified acceptance time **/
  static MempoolAcceptResult AcceptToMemoryPoolWithTime(const CChainParams& chainparams, CTxMemPool& pool,
  + CChainState& active_chainstate,
  const CTransactionRef &tx, int64_t nAcceptTime,
  bool bypass_limits, bool test_accept)
  EXCLUSIVE_LOCKS_REQUIRED(cs_main)
  @@ -871,7 +872,8 @@ static MempoolAcceptResult AcceptToMemoryPoolWithTime(const CChainParams& chainp
  std::vector<COutPoint> coins_to_uncache;
  MemPoolAccept::ATMPArgs args { chainparams, nAcceptTime, bypass_limits, coins_to_uncache, test_accept };
  - const MempoolAcceptResult result = MemPoolAccept(pool, ::ChainstateActive()).AcceptSingleTransaction(tx, args);
  + assert(std::addressof(::ChainstateActive()) == std::addressof(active_chainstate));
  + const MempoolAcceptResult result = MemPoolAccept(pool, active_chainstate).AcceptSingleTransaction(tx, args);
  if (result.m_result_type != MempoolAcceptResult::ResultType::VALID) {
  // Remove coins that were not present in the coins cache before calling ATMPW;
  // this is to prevent memory DoS in case we receive a large number of
  @@ -879,17 +881,17 @@ static MempoolAcceptResult AcceptToMemoryPoolWithTime(const CChainParams& chainp
  // (`CCoinsViewCache::cacheCoins`).
  for (const COutPoint& hashTx : coins_to_uncache)
  - ::ChainstateActive().CoinsTip().Uncache(hashTx);
  + active_chainstate.CoinsTip().Uncache(hashTx);
  }
  // After we've (potentially) uncached entries, ensure our coins cache is still within its size limits
  BlockValidationState state_dummy;
  - ::ChainstateActive().FlushStateToDisk(chainparams, state_dummy, FlushStateMode::PERIODIC);
  + active_chainstate.FlushStateToDisk(chainparams, state_dummy, FlushStateMode::PERIODIC);
  return result;
  }
  MempoolAcceptResult AcceptToMemoryPool(CTxMemPool& pool, const CTransactionRef &tx, bool bypass_limits, bool test_accept)
  {
  - return AcceptToMemoryPoolWithTime(Params(), pool, tx, GetTime(), bypass_limits, test_accept);
  + return AcceptToMemoryPoolWithTime(Params(), pool, ::ChainstateActive(), tx, GetTime(), bypass_limits, test_accept);
  }
  CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMemPool* const mempool, const uint256& hash, const Consensus::Params& consensusParams, uint256& hashBlock)
  @@ -4754,7 +4756,7 @@ bool LoadMempool(CTxMemPool& pool)
  }
  if (nTime > nNow - nExpiryTimeout) {
  LOCK(cs_main);
  - if (AcceptToMemoryPoolWithTime(chainparams, pool, tx, nTime, false /* bypass_limits */,
  + if (AcceptToMemoryPoolWithTime(chainparams, pool, ::ChainstateActive(), tx, nTime, false /* bypass_limits */,
  false /* test_accept */).m_result_type == MempoolAcceptResult::ResultType::VALID) {
  ++count;
  } else {
  