validation: MaybeRebalanceCaches when chain leaves IBD
Summary:
When a snasphot is initially loaded, the snapshot chain gets most of the cache to catch up to the tip as fast as possible. When it leaves IBD, we can then allocate most of the cache again to the background IBD chain.
This is a partial backport of core#27596
https://github.com/bitcoin/bitcoin/pull/27596/commits/9f2318c76cc6986d48e13831cf5bd8dab194fdf4
Test Plan:
Tested with the feature_assumeutxo functional test and a test on mainnet on my dev branch.
(we need the loadtxoutset RPC to test this)
Reviewers: #bitcoin_abc, roqqit
Reviewed By: #bitcoin_abc, roqqit
Differential Revision: https://reviews.bitcoinabc.org/D17888