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

chore: add migration guide to 0.31 #912

Merged
merged 3 commits into from
Apr 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 123 additions & 0 deletions doc/migrations/v0.30-v0.31.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<!--Specify versions for migration below-->
# Migrating to libp2p@31

A migration guide for refactoring your application code from libp2p v0.30.x to v0.31.0.

## Table of Contents

- [Types](#types)
- [API](#api)
- [Module Updates](#module-updates)

## Types

Most of the type definitions in the libp2p configuration were `any` or were not included before this release. This might cause breaking changes on upstream projects relying on the previous provided types, as well as to libp2p modules implemented by the libp2p community.

## API

### Core API

`libp2p.dialProtocol` does not accept empty or null protocols returning a connection anymore and `dial` must be used instead.

```js
const connection = await libp2p.dialProtocol(peerId)
```

**After**

```js
const connection = await libp2p.dial(peerId)
```

### Connection Manager Options

We updated the connection manager options naming in `[email protected]` but kept it backward compatible until now.

**Before**

```js
const node = await Libp2p.create({
connectionManager: {
minPeers: 0
}
})
```

**After**

```js
const node = await Libp2p.create({
connectionManager: {
minConnections: 0
}
})
```

You can see full details on how to configure the connection manager [here](https://github.com/libp2p/js-libp2p/blob/master/doc/CONFIGURATION.md#configuring-connection-manager).

### Dialer and Keychain components

Internal property names to create a libp2p `Dialer` and `Keychain` were updated to reflect the properties naming in the libp2p configuration. These are internal modules of libp2p core and should not impact most of the users, but as it is possible to use them separately here follow the changes:

***Before**

```js
const dialer = new Dialer({
transportManager,
peerStore,
concurrency,
perPeerLimit,
timeout,
resolvers,
addressSorter
})

const keychain = new Keychain(datastore, {
passPhrase
})
```

**After**

```js
this.dialer = new Dialer({
transportManager,
peerStore,
maxParallelDials,
maxDialsPerPeer,
dialTimeout,
resolvers,
addressSorter
})

const keychain = new Keychain(datastore, {
pass
})
```

## Module Updates

With this release you should update the following libp2p modules if you are relying on them:

<!--Specify module versions in JSON for migration below.
It's recommended to check package.json changes for this:
`git diff <release> <prev> -- package.json`
-->

```json
"libp2p-bootstrap": "^0.12.3",
"libp2p-crypto": "^0.19.4",
"libp2p-interfaces": "^0.10.0",
"libp2p-delegated-content-routing": "^0.10.0",
"libp2p-delegated-peer-routing": "^0.9.0",
"libp2p-floodsub": "^0.25.1",
"libp2p-gossipsub": "^0.9.0",
"libp2p-kad-dht": "^0.22.0",
"libp2p-mdns": "^0.16.0",
"libp2p-noise": "^3.0.0",
"libp2p-tcp": "^0.15.4",
"libp2p-webrtc-star": "^0.22.2",
"libp2p-websockets": "^0.15.6"
```

One of the main changes in this new release is the update to `[email protected]`. This should also be updated in upstream projects to avoid several multiaddr versions in the bundle and to avoid potential problems when libp2p interacts with provided outdated multiaddr instances.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"it-merge": "1.0.0",
"it-pipe": "^1.1.0",
"it-take": "1.0.0",
"libp2p-crypto": "^0.19.0",
"libp2p-crypto": "^0.19.4",
"libp2p-interfaces": "^0.10.3",
"libp2p-utils": "^0.3.1",
"mafmt": "^9.0.0",
Expand Down Expand Up @@ -155,9 +155,9 @@
"libp2p-mdns": "^0.16.0",
"libp2p-mplex": "^0.10.1",
"libp2p-noise": "^3.0.0",
"libp2p-tcp": "^0.15.1",
"libp2p-webrtc-star": "^0.22.0",
"libp2p-websockets": "^0.15.0",
"libp2p-tcp": "^0.15.4",
"libp2p-webrtc-star": "^0.22.2",
"libp2p-websockets": "^0.15.6",
"multihashes": "^4.0.2",
"nock": "^13.0.3",
"p-defer": "^3.0.0",
Expand Down