fix(network): enforce checkpoint-safe block apply budget#292
Merged
p0mvn merged 3 commits intoJun 28, 2026
Conversation
2eef6a1 to
c7e9164
Compare
Author
|
Pre-split backup note before rewriting this PR:
#295 is intentionally left unchanged. |
Author
|
Additional pre-split backup note: #292 advanced from
The original |
7a3f186 to
440110c
Compare
4 tasks
A configured `max_inflight_block_bytes` below the checkpoint-range floor (`MIN_BS_CHECKPOINT_SUBMITTED_BLOCK_APPLIES * BS_PER_BLOCK_WORST_CASE_BYTES`, ~802 MB) cannot hold one full worst-case checkpoint range, so checkpoint sync would deadlock. Previously the config validation rejected such a value, which made zebrad refuse to start on older Zakura configs (e.g. the stored `v4.5.0-zakura-blocksync.toml`, 256 MiB) and broke `config_tests`. Instead of rejecting, clamp a positive-but-too-small budget up to the floor and warn once, so older configs keep starting while checkpoint sync stays deadlock-free. Zero is still rejected by `validate` as an explicit misconfiguration. Adds unit + deserialize regression tests.
p0mvn
approved these changes
Jun 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The post-stack audit found one portable runtime safety gap from
evan/perf-plus-download-fixes: the block-sync apply window and byte budget need to be large enough to submit one full checkpoint range plus the resolving checkpoint block. If the configured budget cannot hold that range, checkpoint verification can stall below the boundary because no submitted body becomes durable and no body bytes are released.Solution
DEFAULT_BS_MAX_SUBMITTED_BLOCK_APPLIESfromMAX_CHECKPOINT_HEIGHT_GAPtoMAX_CHECKPOINT_HEIGHT_GAP + 1.BS_CHECKPOINT_RANGE_BYTE_FLOORvalidation formax_inflight_block_bytes.max_submitted_block_applies = 401.Scope boundary: this intentionally does not port the later Committer/apply-queue split or benchmark tooling.
Tests
Passed locally on
codex/block-sync-checkpoint-byte-floor-pr:cargo fmt --all -- --checkcargo test -p zebra-network zakura::block_sync --lib(146 passed)cargo test -p zebra-network p2p_v2_block_sync_config_validation_rejects_degenerate_values --libAttempted but blocked before test execution by the local RocksDB C++ build issue:
cargo test -p zebrad --test acceptance latest_config_is_stored -- --nocapturelibrocksdb-sysfails compiling RocksDB headers whereuint64_tis used without<cstdint>.Specifications & References
Stack context:
review/blocksync-throughput-defaultsAI Disclosure
PR Checklist
type(scope): description