This avoids having to rely on implicit casts when passing them to the
various functions allocating the caches.
This also ensures that if the requested amount of db_cache does not fit
in a size_t, it is clamped to the maximum value of a size_t.
Also take this opportunity to make the total amounts of cache in the
chainstate manager a size_t too.
This concludes backport of core#31483
https://github.com/bitcoin/bitcoin/pull/31483/commits/2a92702bafca5c78b270a9502a22cb9deac02cfc
Depends on D18583