Skip to content

Commit

Permalink
libp2p: stop reporting ProtocolVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorropo committed Jul 21, 2023
1 parent dbe14ac commit 048f8e7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 26 deletions.
17 changes: 5 additions & 12 deletions core/commands/id.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ import (
const offlineIDErrorMessage = "'ipfs id' cannot query information on remote peers without a running daemon; if you only want to convert --peerid-base, pass --offline option"

type IdOutput struct { // nolint
ID string
PublicKey string
Addresses []string
AgentVersion string
ProtocolVersion string
Protocols []protocol.ID
ID string
PublicKey string
Addresses []string
AgentVersion string
Protocols []protocol.ID
}

const (
Expand Down Expand Up @@ -126,7 +125,6 @@ EXAMPLE:
output := format
output = strings.Replace(output, "<id>", out.ID, -1)
output = strings.Replace(output, "<aver>", out.AgentVersion, -1)
output = strings.Replace(output, "<pver>", out.ProtocolVersion, -1)
output = strings.Replace(output, "<pubkey>", out.PublicKey, -1)
output = strings.Replace(output, "<addrs>", strings.Join(out.Addresses, "\n"), -1)
output = strings.Replace(output, "<protocols>", strings.Join(protocol.ConvertToStrings(out.Protocols), "\n"), -1)
Expand Down Expand Up @@ -178,11 +176,6 @@ func printPeer(keyEnc ke.KeyEncoder, ps pstore.Peerstore, p peer.ID) (interface{
info.Protocols = append(info.Protocols, protocols...)
sort.Slice(info.Protocols, func(i, j int) bool { return info.Protocols[i] < info.Protocols[j] })

if v, err := ps.Get(p, "ProtocolVersion"); err == nil {
if vs, ok := v.(string); ok {
info.ProtocolVersion = vs
}
}
if v, err := ps.Get(p, "AgentVersion"); err == nil {
if vs, ok := v.(string); ok {
info.AgentVersion = vs
Expand Down
5 changes: 0 additions & 5 deletions core/commands/swarm.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,11 +490,6 @@ func (ci *connInfo) identifyPeer(ps pstore.Peerstore, p peer.ID) (IdOutput, erro
sort.Slice(info.Protocols, func(i, j int) bool { return info.Protocols[i] < info.Protocols[j] })
}

if v, err := ps.Get(p, "ProtocolVersion"); err == nil {
if vs, ok := v.(string); ok {
info.ProtocolVersion = vs
}
}
if v, err := ps.Get(p, "AgentVersion"); err == nil {
if vs, ok := v.(string); ok {
info.AgentVersion = vs
Expand Down
12 changes: 12 additions & 0 deletions docs/changelogs/v0.22.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- [Overview](#overview)
- [🔦 Highlights](#-highlights)
- [`ipfs name publish` now supports V2 only IPNS records](#ipfs-name-publish-now-supports-v2-only-ipns-records)
- [go-libp2p v0.29.0 update](#go-libp2p-v0.29.0-update)
- [📝 Changelog](#-changelog)
- [👨‍👩‍👧‍👦 Contributors](#-contributors)

Expand All @@ -23,6 +24,17 @@ to V2 only in the future.

**TODO**: add links to IPIP https://github.com/ipfs/specs/issues/376

# go-libp2p v0.29.0 update

We updated from [go-libp2p](https://github.com/libp2p/go-libp2p) [v0.27.7](https://github.com/libp2p/go-libp2p/releases/tag/v0.27.7) to [v0.29.0](https://github.com/libp2p/go-libp2p/releases/tag/v0.29.0).

The main intresting new feature is smart dialling, this is a prioritisation algorithm that will try to rank addresses and protocols.
So when we are contacting one peer we aren't firing ~4 connections at attempts in parallel anymore.

This includes a breaking change to `ipfs id` and some of the `ipfs swarm` commands, we do not report `ProtocolVersion` anymore.

This used to be harcoded `ipfs/0.1.0` and sent to other peers but never did anything intresting.

### 📝 Changelog

### 👨‍👩‍👧‍👦 Contributors
14 changes: 5 additions & 9 deletions test/cli/swarm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ import (
// TODO: Migrate the rest of the sharness swarm test.
func TestSwarm(t *testing.T) {
type identifyType struct {
ID string
PublicKey string
Addresses []string
AgentVersion string
ProtocolVersion string
Protocols []string
ID string
PublicKey string
Addresses []string
AgentVersion string
Protocols []string
}
type peer struct {
Identify identifyType
Expand Down Expand Up @@ -53,7 +52,6 @@ func TestSwarm(t *testing.T) {
actualPublicKey := output.Peers[0].Identify.PublicKey
actualAgentVersion := output.Peers[0].Identify.AgentVersion
actualAdresses := output.Peers[0].Identify.Addresses
actualProtocolVersion := output.Peers[0].Identify.ProtocolVersion
actualProtocols := output.Peers[0].Identify.Protocols

expectedID := otherNode.PeerID().String()
Expand All @@ -62,7 +60,6 @@ func TestSwarm(t *testing.T) {
assert.Equal(t, actualID, expectedID)
assert.NotNil(t, actualPublicKey)
assert.NotNil(t, actualAgentVersion)
assert.NotNil(t, actualProtocolVersion)
assert.Len(t, actualAdresses, 1)
assert.Equal(t, expectedAddresses[0], actualAdresses[0])
assert.Greater(t, len(actualProtocols), 0)
Expand All @@ -89,7 +86,6 @@ func TestSwarm(t *testing.T) {
assert.Equal(t, outputIdentify.ID, otherNodeIDOutput.ID)
assert.Equal(t, outputIdentify.PublicKey, otherNodeIDOutput.PublicKey)
assert.Equal(t, outputIdentify.AgentVersion, otherNodeIDOutput.AgentVersion)
assert.Equal(t, outputIdentify.ProtocolVersion, otherNodeIDOutput.ProtocolVersion)
assert.ElementsMatch(t, outputIdentify.Addresses, otherNodeIDOutput.Addresses)
assert.ElementsMatch(t, outputIdentify.Protocols, otherNodeIDOutput.Protocols)

Expand Down

0 comments on commit 048f8e7

Please sign in to comment.