Bitswap: CIDv0 blocks are sent with an empty prefix in 1.1.0/1.2.0 messages
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- distributed-systems, networking
Research direction
Start with get_cid_prefix() in libp2p/bitswap/cid.py and trace its callers in client.py, gated_decision_engine.py, and wantlist.py. Check the CID prefix handling and existing unit tests. Done means CIDv0 blocks carry the 00 70 12 20 prefix in Bitswap 1.1.0 and 1.2.0 messages, with tests covering the behavior.
Written by the indexing model from the issue text.
Description
Summary
get_cid_prefix() in libp2p/bitswap/cid.py returns b"" for a CIDv0. That value is used as the prefix of Block entries in /ipfs/bitswap/1.1.0 and 1.2.0 messages (client.py, gated_decision_engine.py, wantlist.py), so CIDv0 blocks go out with an empty prefix.
The Bitswap spec defines the prefix for every block as <version><codec><mh-type><mh-len>. boxo decodes it with cid.PrefixFromBytes(b.GetPrefix()) (bitswap/message/message.go) and rejects the whole message when that fails, which it does for an empty prefix. So py-libp2p cannot serve CIDv0 blocks to Kubo/boxo over 1.1.0+.
Expected behavior
CIDv0 blocks carry the CIDv0 prefix 00 70 12 20 (version 0, dag-pb, sha2-256, 32 bytes), the same bytes as go-cid's Prefix().Bytes().
Actual behavior
>>> get_cid_prefix(cidv0_bytes)
b''
Possible Solution
Return cid_obj.prefix().to_bytes() for CIDv0 as well (drop the version != CID_V1 early return). On the receiving side, reconstruct_cid_from_prefix_and_data already accepts this prefix and still accepts an empty one, so this stays compatible with peers that send an empty prefix. I have a small patch with a unit test and can open a PR referencing this issue.
This issue was written with help from an AI assistant (Claude Code) and reviewed before submitting.
- Dominant language
- Python
- Stars
- 629
- Forks
- 261
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 30
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from libp2p/py-libp2p
-
Difficulty 2/5 1-3 hours Newbie friendliness 22/100
Maintainers usually reply within 1 day
-
Windows: make lint/typecheck/test/docs/pr fail after setup_dev.ps1Possibly taken @LevelVoid claimed this 18 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
libp2p/py-libp2p#1595 · 4 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
Tracking: post-quantum key exchange (X25519MLKEM768) on the QUIC transportPossibly taken @paschal533 claimed this 5 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 25/100
libp2p/py-libp2p#1581 · 7 comments ·
Maintainers usually reply within 1 day
-
discussion enhancement feature Interoperability
Difficulty 5/5 Over a week Newbie friendliness 28/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 58/100
Maintainers usually reply within 1 day
All issues in libp2p/py-libp2p
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
litestar-org/sqlspec#946 ·
Maintainers usually reply within 1 day
-
area:cli area:docs Platform vdr
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
NVIDIA-NeMo/Gym#7192 ·
Maintainers usually reply within 2 days
-
Bug: CaseInsensitiveDict (event.headers) returns True for both == and != against the same mappingOpenbug triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
aws-powertools/powertools-lambda-python#8948 ·
Maintainers usually reply within 1 day
-
SofyaBotOpen
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
ai-robots-txt/ai.robots.txt#324 ·
-
[Resource]: DashbarOpenresource-submission validation-passed
Difficulty 1/5 Under an hour Newbie friendliness 78/100
hesreallyhim/awesome-claude-code#3821 · 1 comment ·