blockstorage: Adjust fastprune limit if block exceeds blockfile size
Summary:
If the added block exceeds the blockfile size in test-only
-fastprune mode, the node would get stuck in an infinite loop and
run out of memory.
Avoid this by raising the blockfile size to the size of the added block
in this situation.
Co-authored-by: TheCharlatan <seb.kung@gmail.com>
This is a backport of core#27191
Depends on D16028
Note that this fix does not address the non-test issue of blocks larger than 128 MiB. But at least now we get a meaningful assertion failure rather than an OOM crash.
Test Plan:
ninja all check-all
Check that without the change in blockstorage.cpp the new test slowly consumes all the memory and the test eventually fails.
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D16023