Skip to content

fix: raise block size limits from 1MiB to 2MiB#1101

Merged
lidel merged 2 commits intomainfrom
fix/block-size-limit-2mib
Feb 6, 2026
Merged

fix: raise block size limits from 1MiB to 2MiB#1101
lidel merged 2 commits intomainfrom
fix/block-size-limit-2mib

Conversation

@lidel
Copy link
Member

@lidel lidel commented Feb 6, 2026

align chunker and importer block size limits with the bitswap spec (https://specs.ipfs.tech/bitswap-protocol/#block-sizes) which mandates 2MiB as the maximum block size.

the previous 1MiB limit broke things like Kubo's dag import of 1MiB-chunked non-raw-leaf data where protobuf wrapping pushes blocks slightly over 1MiB (see ipfs/kubo#8968 (comment))

max chunker size is set to 2MiB - 256 bytes to leave room for protobuf framing overhead when chunks are wrapped in non-raw leaves. IPIP-499 profiles use lower chunk sizes (256KiB and 1MiB) and are not affected.

align chunker and importer block size limits with the bitswap spec
(https://specs.ipfs.tech/bitswap-protocol/#block-sizes) which mandates
2MiB as the maximum block size.

the previous 1MiB limit broke `dag import` of 1MiB-chunked non-raw-leaf
data where protobuf wrapping pushes blocks slightly over 1MiB.

max chunker size is set to 2MiB - 256 bytes to leave room for protobuf
framing overhead when chunks are wrapped in non-raw leaves. IPIP-499
profiles use lower chunk sizes (256KiB and 1MiB) and are not affected.
@codecov

This comment was marked as off-topic.

- chunker: verify ChunkSizeLimit + ChunkOverheadBudget == BlockSizeLimit
- bitswap/message: verify BlockSizeLimit block (CIDv1+raw+SHA2-256)
  serializes within libp2p network.MessageSizeMax and round-trips
- use explicit byte values instead of bit-shift notation
@lidel lidel marked this pull request as ready for review February 6, 2026 22:32
@lidel lidel requested a review from a team as a code owner February 6, 2026 22:32
Copy link
Member Author

@lidel lidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merging as the new 2MiB block size limit matches the bitswap spec and is well above any chunk size used by IPIP-499 profiles (unixfs-v1-2025 uses 1MiB, unixfs-v0-2015 uses 256KiB). Existing users are not affected.

If someone creates blocks between 2MiB and ~4MiB using --allow-big-block, they will still transfer fine over bitswap. The actual hard limit on the wire is network.MessageSizeMax (4MiB) minus a few bytes of protobuf envelope. We have tests confirming this in ipfs/kubo#11185, including regression tests at the exact byte boundary where libp2p starts rejecting messages.

The 256-byte overhead budget (ChunkSizeLimit = BlockSizeLimit - 256) is a precaution that accounts for protobuf/UnixFS framing when --raw-leaves=false, so the max --chunker value produces blocks that stay within 2MiB after wrapping.

@lidel lidel merged commit 77bd614 into main Feb 6, 2026
17 checks passed
@lidel lidel deleted the fix/block-size-limit-2mib branch February 6, 2026 22:42
lidel added a commit to ipfs/kubo that referenced this pull request Feb 6, 2026
IPIP-499's unixfs-v1-2025 profile uses 1MiB chunks. with
--raw-leaves=false, protobuf wrapping pushes blocks slightly over 1MiB.
the previous 1MiB SoftBlockLimit rejected these blocks on dag import.

raise SoftBlockLimit to 2MiB to match the bitswap spec, which requires
implementations to support blocks up to 2MiB.

- raise SoftBlockLimit to 2MiB per the bitswap spec
- update error messages and help text
- bump boxo to main with ipfs/boxo#1101 (raised ChunkSizeLimit/BlockSizeLimit,
  256-byte overhead budget)
- update sharness tests for 2MiB boundary
- add test/cli boundary tests for block put, dag put, dag import,
  ipfs add (raw and wrapped leaves), and bitswap exchange including
  regression tests for the libp2p message size hard limit
lidel added a commit to ipfs/kubo that referenced this pull request Feb 6, 2026
IPIP-499's unixfs-v1-2025 profile uses 1MiB chunks. with
--raw-leaves=false, protobuf wrapping pushes blocks slightly over 1MiB.
the previous 1MiB SoftBlockLimit rejected these blocks on dag import.

raise SoftBlockLimit to 2MiB to match the bitswap spec, which requires
implementations to support blocks up to 2MiB.

- raise SoftBlockLimit to 2MiB per the bitswap spec
- update error messages and help text
- bump boxo to main with ipfs/boxo#1101 (raised ChunkSizeLimit/BlockSizeLimit,
  256-byte overhead budget)
- update sharness tests for 2MiB boundary
- add test/cli boundary tests for block put, dag put, dag import,
  ipfs add (raw and wrapped leaves), and bitswap exchange including
  regression tests for the libp2p message size hard limit
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.

1 participant