Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Include protocols with PeerInfo broadcast #110

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

justin0mcateer
Copy link

The PeerInfo structure emitted by PeerDiscovery includes a 'protocols' field. However, the _broadcast method doesn't send this data and the _onMessage method uses a static empty array. This seems like a missed opportunity to learn a discovered Peer's supported protocols in less round trips.

I've simply updated the PeerInfo structure used by PubSub Peer Discovery to comply to the latest PeerInfo interface and gathered the protocols from the Registrar component. If there is a better place the protocols could be gathered from, that would be easy to change.

@achingbrain
Copy link
Member

The PeerInfo structure emitted by PeerDiscovery includes a 'protocols' field.

This was a mistake and will be removed in a future version of libp2p. A PeerInfo should just be a PeerID + Multaddrs.

If we supply protocols it creates an attack vector whereby we can send bogus or incorrect protocols on behalf of other peers.

They should be exchanged via Identify after connection, though granted this involves more round trips.

Another option might be extending signed peer records to include protocols - the data here is guaranteed to have originated from the signing peer, but there's no attempt to ensure the protocol list is not stale.

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.

2 participants