HomePhabricator

blockstorage: Adjust fastprune limit if block exceeds blockfile size

Description

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

Details

Provenance
Martin Zumsande <mzumsande@gmail.com>Authored on Feb 28 2023, 23:26
PiRKCommitted on Fri, Apr 19, 14:47
PiRKPushed on Fri, Apr 19, 14:47
Reviewer
Restricted Project
Differential Revision
D16023: blockstorage: Adjust fastprune limit if block exceeds blockfile size
Parents
rABCaf1b6173188b: test: simplify tests by using the pre-mined chain
Branches
Unknown
Tags
Unknown