From f860ffb3e7b36c8c9a49cf1f0621552f8085ee55 Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Fri, 30 Apr 2021 09:30:41 +0200 Subject: [PATCH] chore: add migration guide to 0.31 (#912) --- doc/migrations/v0.30-v0.31.md | 123 ++++++++++++++++++++++++++++++++++ package.json | 8 +-- 2 files changed, 127 insertions(+), 4 deletions(-) create mode 100644 doc/migrations/v0.30-v0.31.md diff --git a/doc/migrations/v0.30-v0.31.md b/doc/migrations/v0.30-v0.31.md new file mode 100644 index 00000000..8ccb12d1 --- /dev/null +++ b/doc/migrations/v0.30-v0.31.md @@ -0,0 +1,123 @@ + +# 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 `libp2p@0.29` 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: + + + +```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 `multiaddr@9.0.0`. 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. diff --git a/package.json b/package.json index 4ee93ca4..0d7dd61e 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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",