The main commit in this PR is the second commit adding a btck_chainstate_manager_set_clock_time API which lets kernel applications run validation code deterministically without depending on the system clock. This is an alternative to #35496, and one of several alternatives discussed in that PR, with some tradeoffs described in #35496 (comment).
The other commits are indirectly related and could be moved to separate PRs (or dropped):
<details><summary>Details</summary> <p>
The first commit fixes a timing race in the
chainstatemanager_ibd_exit_after_loading_blockstest that happened because test code and validation code (inUpdateIBDStatus) were both callingNodeClock::now()to get the current clock time, and test relied on the times being the same fortip_recent=truechecks. The failure this fixes should be rare, but I noticed it when I experimented with making time comparison inIsTipRecentmore precise.The third commit refactors mempool code to use a consistent way of getting and representing clock times, allowing the fourth commit to enforce that no libbitcoinkernel code uses nondeterministic clock times unintentionally. The third and fourth commits do not need to be part of this PR, but I implemented them to be sure the main commit was complete and all call sites were using the right clock times.
</p> </details>