Merge 34ae04d775 into merged_master (Bitcoin PR bitcoin/bitcoin#21726)

This changed the node pruning logic and moved test/functional/feature_blockfilterindex_prune.py
to test/functional/feature_index_prune.py.

Please verify that:
1. I migrated the test correctly
2. The magic numbers in the test look fine

With respect to #2: I believe the magic numbers are wrong. I previously had to tweak them heavily
in commit 1278b31. I don't think I did it correctly then, and so I don't believe them to be correct now.

To summarize what this tweaking was: I changed the magic numbers in the test to work properly,
but I suspect that in changing them, I may have nullified what the test was testing.

It's very possible that the reason the test was failing was because of an underlying bug with the pruning
in elements which we have to fix, rather than just being an issue with the test itself.
This commit is contained in:
James Dorfman 2024-08-06 05:53:19 +00:00
commit 01e944c8aa
15 changed files with 265 additions and 115 deletions

View file

@ -911,10 +911,9 @@ static RPCHelpMan pruneblockchain()
PruneBlockFilesManual(active_chainstate, height);
const CBlockIndex* block = CHECK_NONFATAL(active_chain.Tip());
while (block->pprev && (block->pprev->nStatus & BLOCK_HAVE_DATA)) {
block = block->pprev;
}
return uint64_t(block->nHeight);
const CBlockIndex* last_block = node::GetFirstStoredBlock(block);
return static_cast<uint64_t>(last_block->nHeight);
},
};
}
@ -1411,11 +1410,7 @@ RPCHelpMan getblockchaininfo()
if (node::fPruneMode) {
const CBlockIndex* block = CHECK_NONFATAL(tip);
while (block->pprev && (block->pprev->nStatus & BLOCK_HAVE_DATA)) {
block = block->pprev;
}
obj.pushKV("pruneheight", block->nHeight);
obj.pushKV("pruneheight", node::GetFirstStoredBlock(block)->nHeight);
// if 0, execution bypasses the whole if block.
bool automatic_pruning{args.GetIntArg("-prune", 0) != 1};