Skip to content

Conversation

@DashCoreAutoGuix
Copy link
Owner

Summary

Backport of Bitcoin Core PR bitcoin#27191 (commit 8a373a5).

This PR fixes a critical bug in the -fastprune debug option where blocks larger than the 64kb blockfile size would cause an infinite loop in BlockManager::FindBlockPos, leading to out-of-memory crashes.

Changes:

  1. Core Fix (src/node/blockstorage.cpp): Dynamically adjusts the maximum blockfile size when a block exceeds the fastprune limit, preventing infinite loops
  2. Test Addition (test/functional/feature_fastprune.py): Adapted for Dash (no segwit) - creates large blocks using many regular transactions instead of witness data

Dash-Specific Adaptations:

  • Removed witness-specific code from test (annex, witness commitment)
  • Test now creates 500 transactions to generate a block larger than 64kb
  • Test logic and purpose remain identical to Bitcoin version

Original Bitcoin PR:

bitcoin#27191

ACKs for Bitcoin commit:

  • ryanofsky
  • TheCharlatan
  • pinheadmz

Part of batch 415 backporting Bitcoin Core v0.26 to Dash Core

fanquake and others added 2 commits September 30, 2025 11:29
…ceeds blockfile size

8f14fc8 test: cover fastprune with excessive block size (Matthew Zipkin)
271c23e blockstorage: Adjust fastprune limit if block exceeds blockfile size (Martin Zumsande)

Pull request description:

  The debug-only `-fastprune` option used in several tests is not always safe to use:
  If a `-fastprune` node receives a block larger than the maximum blockfile size of `64kb` bad things happen: The while loop in `BlockManager::FindBlockPos` never terminates, and the node runs oom because memory for `m_blockfile_info` is allocated in each iteration of the loop.
  The same would happen if a naive user used `-fastprune` on anything other than regtest (so this can be tested by syncing on signet for example, the first block that crashes the node is at height 2232).

  Change the approach by raising the blockfile size to the size of the block, if that block otherwise wouldn't fit (idea by TheCharlatan).

ACKs for top commit:
  ryanofsky:
    Code review ACK 8f14fc8. Added new assert, test, and comment since last review
  TheCharlatan:
    ACK 8f14fc8
  pinheadmz:
    ACK 8f14fc8

Tree-SHA512: df2fea30613ef9d40ebbc2416eacb574f6d7d96847db5c33dda22a29a2c61a8db831aa9552734ea4477e097f253dbcb6dcb1395d43d2a090cc0588c9ce66eac3
Since Dash doesn't have segwit/witness support, adapt the test to create
a large block using many regular transactions instead of using witness
data to inflate block size. This maintains the test's purpose of ensuring
-fastprune handles blocks larger than 64kb without crashing.
@coderabbitai
Copy link

coderabbitai bot commented Sep 30, 2025

Warning

Rate limit exceeded

@DashCoreAutoGuix has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 29 minutes and 20 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 54e2588 and f0b677c.

📒 Files selected for processing (3)
  • src/node/blockstorage.cpp (1 hunks)
  • test/functional/feature_fastprune.py (1 hunks)
  • test/functional/test_runner.py (1 hunks)
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch backport-0.25-batch-415-pr-27191

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants