Problem: Kernel applications can only override the time validation uses for the whole process, with btck_set_mock_time (#35496). Every chainstate manager in the process sees the same time, so a time set for one test, run, or thread leaks into the others unless the application remembers to reset it.
Solution: Add btck_chainstate_manager_options_set_clock_time and btck_chainstate_manager_set_clock_time, which set the time for a single chainstate manager, before it is created (so it also applies to checks made while it loads the chainstate) and afterwards. Validation code gets the time from a new ChainstateManager::Now() method instead of calling NodeClock::now() directly. Details are in the commit messages.
Keeping the time in the chainstate manager instead of in a global makes kernel applications more reliable, because state from one run or thread can't affect another.
Other commits:
- The first commit fixes a rare timing race in the
chainstatemanager_ibd_exit_after_loading_blockstest, where test code and validation code read the clock separately and assumed they got the same time. - The last two commits switch that test and the
utxo_total_supplyfuzz target to the new per-chainman clock, as suggested in #35557 (comment).
Two related commits that were previously part of this PR are in a follow-up branch based on it, https://github.com/ryanofsky/bitcoin/commits/pr/kclock2: a mempool refactor to represent clock times consistently, and a change that makes NodeClock::now() unavailable in libbitcoinkernel so kernel code can't use the system clock by accident.