What does "Activating Best Chain" mean? My Bitcoin Core doesn't freeze, it just takes a while. I'm curious as to what it's doing.
Bitcoin Core maintains two databases:
- The block index
- The chain state (or UTXO set)
The first one just contains a list of all blocks we know about, valid and invalid. It contains all forks we have ever heard about, and all branches that result from it. It also contains information about where on disk these are stored. It does however not contain any information about which blocks we consider part of the "best chain".
The second one contains a snapshot of all existing unspent transaction outputs up to one particular block (and it also stores the hash of this block it is "synchronized" to). The process of validating blocks consists of "applying" the effects of blocks to this state, and possibly undoing those effects when the block turns out to be invalid, or we need to reorganize to another branch.
At startup, it is possible that the first database contains blocks that could be valid but aren't part of the snapshot the second database represents. This can happen when you manually overwrite the block index (restoring from a backup, for example), but more commonly: because Bitcoin crashed after downloading some blocks that ended up being written to the block index, but the resulting chain state was never dumped to disk. When this happens, we will activate the best chain, loading blocks from the second database and applying them to the first (while doing full validation on them in the process).
Since Bitcoin Core heavily caches the chain state in memory, it is possible that there are hundreds or thousands of blocks missing from the chain state after an unclean shutdown. It can take a while to validate them again.
TL;DR: It's verifying blocks that were downloaded already but not processed yet (because the result of processing wasn't properly written to disk, most likely).