https://cirrus-ci.com/task/5603470202896384?logs=ci#L2681
assert(!Instance->m_chain || Instance->m_chain == &chain);
    Instance->m_chain = &chain;
    // Unless allowed, ensur files are not reused across chains
    if (!gArgs.GetBoolArg("-crosschain", DEFAULT_WALLETCROSSCHAIN)) {
        WalletBatch batch(Instance->GetDatabase());
        CBlockLocator locator;
        if (batch.ReadBestBlock(locator) && locator.vHave.size() > 0 && chain.getHeight()) {
            // Wallet 
            // chain d
            if (chain.getBlockHash(0) != locator.vHave.back()) {
                error = Untranslated("Wallet files should not be reused across chains. Restart bitcoind with -crosschain to override.");
                return false;
            }
        }
    }
    // Register  with validationinterface. It's done before rescan to avoid
    // missing block connections between end of rescan and validation subscribing.
    // Because of  lock being hold, block connection notifications are going to
    // be pending on the validation-side until lock rele It's likely to have
    // block processing duplicata (if rescan block range overlaps with notification one)
    // but we guarantee at least than  state is correct after notifications delivery.
    // However, chainStateFlushed notifications are ignored until the rescan is finished
    // so that in case of a shutdown event, the rescan will be repeated at the next start.
    // This is temporary until rescan and notifications delivery are unified under same
    // interface.
    Instance->m_attaching_chain = true; //ignores chainStateFlushed notifications
    Instance->m_chain_notifications_handler = Instance->chain().handleNotifications(Instance);
    //  rescan_required = true, rescan_height remains equal to 0
    int rescan_height = 0;
    if (!rescan_required)