Skip to content

fix(download): reject zero blocks_per_file in snapshot manifest - #27049

Open
Aditya-9-6 wants to merge 1 commit into
paradigmxyz:mainfrom
Aditya-9-6:fix/snapshot-manifest-reject-zero-blocks-per-file
Open

fix(download): reject zero blocks_per_file in snapshot manifest#27049
Aditya-9-6 wants to merge 1 commit into
paradigmxyz:mainfrom
Aditya-9-6:fix/snapshot-manifest-reject-zero-blocks-per-file

Conversation

@Aditya-9-6

@Aditya-9-6 Aditya-9-6 commented Sep 7, 2026

Copy link
Copy Markdown

Description

Resolves #27030

A modular snapshot manifest with blocks_per_file: 0 triggers a divide-by-zero panic in ChunkedArchive::num_chunks() (self.total_blocks.div_ceil(self.blocks_per_file)) when calculating chunk counts and expanding snapshot archives.

This PR addresses this by:

  1. Adding SnapshotManifest::validate(&self) to check that any chunked component specifies blocks_per_file > 0.
  2. Calling manifest.validate()? early in DownloadCommand::load_manifest() right after verifying chain_id.
  3. Adding an explicit guard in collect_planned_archives() before chunk consistency verification.
  4. Adding defensive zero guards in ChunkedArchive::num_chunks() and ChunkedArchive::tail_chunks_for_distance(), plus saturating arithmetic in ChunkedArchive::chunk_relative_path().
  5. Adding unit tests for manifest validation and non-panicking ChunkedArchive behavior.

Reject zero blocks_per_file before expanding snapshot archives or computing chunk counts. Fixes paradigmxyz#27030.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

download: reject zero blocks_per_file before expanding snapshot archives

1 participant