message: validation: Pass in blockman to ContextualCheckBlockHeader
  [META] This commit should be followed up by removing the comments and
  assertions meant only to show that the change is correct.
diff: @@ -3285,7 +3285,7 @@ CBlockIndex* BlockManager::GetLastCheckpoint(const CCheckpointData& data)
  * in ConnectBlock().
  * Note that -reindex-chainstate skips the validation that happens here!
  */
  -static bool ContextualCheckBlockHeader(const CBlockHeader& block, BlockValidationState& state, const CChainParams& params, const CBlockIndex* pindexPrev, int64_t nAdjustedTime) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
  +static bool ContextualCheckBlockHeader(const CBlockHeader& block, BlockValidationState& state, BlockManager& blockman, const CChainParams& params, const CBlockIndex* pindexPrev, int64_t nAdjustedTime) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
  {
  assert(pindexPrev != nullptr);
  const int nHeight = pindexPrev->nHeight + 1;
  @@ -3300,7 +3300,8 @@ static bool ContextualCheckBlockHeader(const CBlockHeader& block, BlockValidatio
  // Don't accept any forks from the main chain prior to last checkpoint.
  // GetLastCheckpoint finds the last checkpoint in MapCheckpoints that's in our
  // BlockIndex().
  - CBlockIndex* pcheckpoint = g_chainman.m_blockman.GetLastCheckpoint(params.Checkpoints());
  + assert(std::addressof(g_chainman.m_blockman) == std::addressof(blockman));
  + CBlockIndex* pcheckpoint = blockman.GetLastCheckpoint(params.Checkpoints());
  if (pcheckpoint && nHeight < pcheckpoint->nHeight) {
  LogPrintf("ERROR: %s: forked chain older than last checkpoint (height %d)\n", __func__, nHeight);
  return state.Invalid(BlockValidationResult::BLOCK_CHECKPOINT, "bad-fork-prior-to-checkpoint");
  @@ -3448,7 +3449,7 @@ bool BlockManager::AcceptBlockHeader(const CBlockHeader& block, BlockValidationS
  LogPrintf("ERROR: %s: prev block invalid\n", __func__);
  return state.Invalid(BlockValidationResult::BLOCK_INVALID_PREV, "bad-prevblk");
  }
  - if (!ContextualCheckBlockHeader(block, state, chainparams, pindexPrev, GetAdjustedTime()))
  + if (!ContextualCheckBlockHeader(block, state, *this, chainparams, pindexPrev, GetAdjustedTime()))
  return error("%s: Consensus::ContextualCheckBlockHeader: %s, %s", __func__, hash.ToString(), state.ToString());
  /* Determine if this block descends from any block which has been found
  @@ -3715,7 +3716,7 @@ bool TestBlockValidity(BlockValidationState& state, const CChainParams& chainpar
  indexDummy.phashBlock = &block_hash;
  // NOTE: CheckBlockHeader is called by CheckBlock
  - if (!ContextualCheckBlockHeader(block, state, chainparams, pindexPrev, GetAdjustedTime()))
  + if (!ContextualCheckBlockHeader(block, state, g_chainman.m_blockman, chainparams, pindexPrev, GetAdjustedTime()))
  return error("%s: Consensus::ContextualCheckBlockHeader: %s", __func__, state.ToString());
  if (!CheckBlock(block, state, chainparams.GetConsensus(), fCheckPOW, fCheckMerkleRoot))
  return error("%s: Consensus::CheckBlock: %s", __func__, state.ToString());
  