Skip to content

fix(peer): drop empty addrs in peer records#3494

Merged
MarcoPolo merged 1 commit intomasterfrom
fix/filter-empty-multiaddr-in-peer-record
Apr 28, 2026
Merged

fix(peer): drop empty addrs in peer records#3494
MarcoPolo merged 1 commit intomasterfrom
fix/filter-empty-multiaddr-in-peer-record

Conversation

@lidel
Copy link
Copy Markdown
Member

@lidel lidel commented Apr 27, 2026

A zero-value Multiaddr (since go-multiaddr v0.15 is a slice type) has no components and encodes to zero bytes on the wire. go-libp2p was sealing such empty entries into signed peer records, where peers that skip the empty-input check render them as "/" and reject the address.

Changes

  • core/peer/record.go: skip empty addrs in addrsToProtobuf, and in addrsFromProtobuf as a defensive read
  • p2p/host/basic/addrs_manager.go: drop empty addrs in makeSignedPeerRecord before sealing the envelope

go-libp2p's own decoder errors on zero-byte input via NewMultiaddrBytes, but other implementations such as js-libp2p do not.

A zero-value Multiaddr (since go-multiaddr v0.15 is a slice type) has
no components and encodes to zero bytes on the wire. go-libp2p was
sealing such empty entries into signed peer records, where peers that
skip the empty-input check render them as "/" and reject the address.

- core/peer/record.go: skip empty addrs in addrsToProtobuf, and in
  addrsFromProtobuf as a defensive read
- p2p/host/basic/addrs_manager.go: drop empty addrs in
  makeSignedPeerRecord before sealing the envelope

go-libp2p's own decoder errors on zero-byte input via
NewMultiaddrBytes, but other implementations such as js-libp2p do not.

See libp2p/js-libp2p#3478 (comment)
Copy link
Copy Markdown
Contributor

@guillaumemichel guillaumemichel left a comment

Choose a reason for hiding this comment

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

Fix looks good

Test failure seem unrelated to recent changes

@MarcoPolo MarcoPolo merged commit 544db45 into master Apr 28, 2026
10 of 12 checks passed
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