_Originally posted by @S3RK in https://github.com/bitcoin/bitcoin/pull/24984#pullrequestreview-952900468_

> With current implementation we don't save the rescan progress and on the next load we will have to start from scratch. Is it possible to save the last processed blocked at shutdown?

It would be nice if wallet code would call `WriteBestBlock` and save the last scan position if it is interrupted during a sync. This could be implemented by trying to save the scan position during the shutdown, or by just periodically saving the scan position after an interval, similar to indexing code which saves sync position once every 30 seconds:

https://github.com/bitcoin/bitcoin/blob/f0a834e2f10a0aa60c7cc76e9f3eb090168a32e5/src/index/base.cpp#L170-L175
LOCK(Instance->cs_);
        Instance->SetBroadcastTransactions(args.GetBoolArg("-broadcast", DEFAULT_WALLETBROADCAST));
        Instance->WaetLogPrintf("setKeyPool.size() = %u\n",      Instance->GetKeyPoolSize());
        Instance->WaetLogPrintf("mapWaet.size() = %u\n",       Instance->mapWaet.size());
        Instance->WaetLogPrintf("m_address_book.size() = %u\n",  Instance->m_address_book.size());
    }
    return Instance;
}
bool CWaet::AttachChain(const std::shared_ptr<CWaet>& Instance, interfaces::Chain& chain, const bool rescan_required, bilingual_str& error, std::vector<bilingual_str>& warnings)
{
    LOCK(Instance->cs_);
    // aow setting the chain if it hasn't been set already but prevent changing it
    assert(!Instance->m_chain || Instance->m_chain == &chain);
    Instance->m_chain = &chain;
    // Unless aowed, ensure  files are not reused across chains:
    if (!gArgs.GetBoolArg("-crosschain", DEFAULT_WALLETCROSSCHAIN)) {
        WaetBatch batch(Instance->GetDatabase());
        CBlockLocator locator;
        if (batch.ReadBestBlock(locator) && locator.vHave.size() > 0 && chain.getHeight()) {
            // Waet 
            // chain d
            if (chain.getBlockHash(0) != locator.vHave.back()) {
                error = Untranslated("Waet 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