From c6a58561cdcc06d30e7a9a365b6c226d5b30aac5 Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Fri, 27 Nov 2020 12:43:27 +0100 Subject: [PATCH 01/14] chore: update libp2p to 0.30 --- packages/ipfs-core/package.json | 8 ++++---- packages/ipfs-core/test/libp2p.spec.js | 4 +--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/ipfs-core/package.json b/packages/ipfs-core/package.json index 0f39fad8a3..c1344c3104 100644 --- a/packages/ipfs-core/package.json +++ b/packages/ipfs-core/package.json @@ -88,11 +88,11 @@ "it-first": "^1.0.4", "it-last": "^1.0.4", "it-pipe": "^1.1.0", - "libp2p": "^0.29.3", + "libp2p": "libp2p/js-libp2p#0.30.x", "libp2p-bootstrap": "^0.12.1", "libp2p-crypto": "^0.18.0", - "libp2p-floodsub": "^0.23.1", - "libp2p-gossipsub": "^0.6.1", + "libp2p-floodsub": "^0.24.0", + "libp2p-gossipsub": "^0.7.0", "libp2p-kad-dht": "^0.20.1", "libp2p-mdns": "^0.15.0", "libp2p-mplex": "^0.10.0", @@ -100,7 +100,7 @@ "libp2p-record": "^0.9.0", "libp2p-tcp": "^0.15.1", "libp2p-webrtc-star": "^0.20.1", - "libp2p-websockets": "^0.14.0", + "libp2p-websockets": "^0.15.0", "mafmt": "^8.0.0", "merge-options": "^2.0.0", "mortice": "^2.0.0", diff --git a/packages/ipfs-core/test/libp2p.spec.js b/packages/ipfs-core/test/libp2p.spec.js index 7991ca1ac4..e347f29b9e 100644 --- a/packages/ipfs-core/test/libp2p.spec.js +++ b/packages/ipfs-core/test/libp2p.spec.js @@ -148,9 +148,7 @@ describe('libp2p customization', function () { }, pubsub: { enabled: true, - emitSelf: true, - signMessages: true, - strictSigning: true + emitSelf: true } }) const transports = Array.from(libp2p.transportManager.getTransports()) From 12721b9fea4d83c7bc9aaf1c49188284d76fbf5c Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Thu, 10 Dec 2020 16:11:31 +0100 Subject: [PATCH 02/14] chore: use 0.30 rc --- packages/ipfs-core/package.json | 2 +- packages/ipfs-core/src/components/index.js | 2 ++ packages/ipfs-core/src/components/is-online.js | 2 +- packages/ipfs-core/src/components/key/export.js | 5 ++--- packages/ipfs-core/src/components/key/import.js | 5 ++--- packages/ipfs-core/src/components/key/info.js | 3 +-- packages/ipfs-core/src/components/key/list.js | 13 ++----------- packages/ipfs-core/src/components/key/rename.js | 6 +++--- packages/ipfs-core/src/components/key/rm.js | 3 +-- packages/ipfs-core/src/components/libp2p.js | 2 +- packages/ipfs-core/src/components/ping.js | 17 ++++++++++++----- packages/ipfs-core/src/components/pubsub.js | 6 ++++-- packages/ipfs-core/src/components/stats/bw.js | 6 ++++-- packages/ipfs-core/src/components/storage.js | 10 ++++++---- .../ipfs-core/src/components/swarm/addrs.js | 2 +- .../ipfs-core/src/components/swarm/connect.js | 2 +- .../src/components/swarm/disconnect.js | 2 +- 17 files changed, 45 insertions(+), 43 deletions(-) diff --git a/packages/ipfs-core/package.json b/packages/ipfs-core/package.json index c1344c3104..f359d2907c 100644 --- a/packages/ipfs-core/package.json +++ b/packages/ipfs-core/package.json @@ -88,7 +88,7 @@ "it-first": "^1.0.4", "it-last": "^1.0.4", "it-pipe": "^1.1.0", - "libp2p": "libp2p/js-libp2p#0.30.x", + "libp2p": "libp2p/js-libp2p#fix/types-with-dist", "libp2p-bootstrap": "^0.12.1", "libp2p-crypto": "^0.18.0", "libp2p-floodsub": "^0.24.0", diff --git a/packages/ipfs-core/src/components/index.js b/packages/ipfs-core/src/components/index.js index f2d8b06759..4f02e91da8 100644 --- a/packages/ipfs-core/src/components/index.js +++ b/packages/ipfs-core/src/components/index.js @@ -70,6 +70,8 @@ class IPFS { }) const dns = createDNSAPI() const isOnline = createIsOnlineAPI({ network }) + // @ts-ignore This type check fails as options. + // libp2p can be a function, while IPNS router config expects libp2p config const ipns = new IPNSAPI(options) const dagReader = DagAPI.reader({ ipld, preload }) diff --git a/packages/ipfs-core/src/components/is-online.js b/packages/ipfs-core/src/components/is-online.js index 1e9593a0f8..9bb6467ef1 100644 --- a/packages/ipfs-core/src/components/is-online.js +++ b/packages/ipfs-core/src/components/is-online.js @@ -10,5 +10,5 @@ module.exports = ({ network }) => */ () => { const net = network.try() - return net != null && net.libp2p.isStarted() + return net != null && Boolean(net.libp2p.isStarted()) } diff --git a/packages/ipfs-core/src/components/key/export.js b/packages/ipfs-core/src/components/key/export.js index cbf432ed1c..b4ccc2f661 100644 --- a/packages/ipfs-core/src/components/key/export.js +++ b/packages/ipfs-core/src/components/key/export.js @@ -23,11 +23,10 @@ module.exports = ({ keychain }) => { * ``` * @param {string} name - The name of the key to export * @param {string} password - Password to set on the PEM output - * @param {import('.').AbortOptions} options * @returns {Promise} - The string representation of the key */ - const exportKey = (name, password, options) => - keychain.exportKey(name, password, options) + const exportKey = (name, password) => + keychain.exportKey(name, password) return withTimeoutOption(exportKey) } diff --git a/packages/ipfs-core/src/components/key/import.js b/packages/ipfs-core/src/components/key/import.js index 047ae4d5ce..35eebe224d 100644 --- a/packages/ipfs-core/src/components/key/import.js +++ b/packages/ipfs-core/src/components/key/import.js @@ -21,11 +21,10 @@ module.exports = ({ keychain }) => { * @param {string} name - The name of the key to import * @param {string} pem - The PEM encoded key * @param {string} password - The password that protects the PEM key - * @param {import('.').AbortOptions} options * @returns {Promise} - An object that describes the new key */ - const importKey = (name, pem, password, options) => { - return keychain.importKey(name, pem, password, options) + const importKey = (name, pem, password) => { + return keychain.importKey(name, pem, password) } return withTimeoutOption(importKey) diff --git a/packages/ipfs-core/src/components/key/info.js b/packages/ipfs-core/src/components/key/info.js index 491eed66b6..d585027a8c 100644 --- a/packages/ipfs-core/src/components/key/info.js +++ b/packages/ipfs-core/src/components/key/info.js @@ -9,10 +9,9 @@ const withTimeoutOption = require('ipfs-core-utils/src/with-timeout-option') module.exports = ({ keychain }) => { /** * @param {string} name - * @param {AbortOptions} [options] * @returns {Promise} */ - const info = (name, options = {}) => keychain.findKeyByName(name, options) + const info = (name) => keychain.findKeyByName(name) return withTimeoutOption(info) } diff --git a/packages/ipfs-core/src/components/key/list.js b/packages/ipfs-core/src/components/key/list.js index 379b388547..66e05baca5 100644 --- a/packages/ipfs-core/src/components/key/list.js +++ b/packages/ipfs-core/src/components/key/list.js @@ -23,18 +23,9 @@ module.exports = ({ keychain }) => { * // ] * ``` * - * @param {AbortOptions} [options] - * @returns {Promise} + * @returns {Promise} */ - const list = (options = {}) => keychain.listKeys(options) + const list = () => keychain.listKeys() return withTimeoutOption(list) } - -/** - * @typedef {Object} KeyEntry - * @property {string} name - The name of the key - * @property {string} hash - The hash of the key - * - * @typedef {import('.').AbortOptions} AbortOptions - */ diff --git a/packages/ipfs-core/src/components/key/rename.js b/packages/ipfs-core/src/components/key/rename.js index 26b49c807d..2012a81f87 100644 --- a/packages/ipfs-core/src/components/key/rename.js +++ b/packages/ipfs-core/src/components/key/rename.js @@ -22,11 +22,11 @@ module.exports = ({ keychain }) => { * ``` * @param {string} oldName - The current key name * @param {string} newName - The desired key name - * @param {AbortOptions} [options] * @returns {Promise} */ - const rename = async (oldName, newName, options = {}) => { - const key = await keychain.renameKey(oldName, newName, options) + const rename = async (oldName, newName) => { + const key = await keychain.renameKey(oldName, newName) + return { was: oldName, now: key.name, diff --git a/packages/ipfs-core/src/components/key/rm.js b/packages/ipfs-core/src/components/key/rm.js index 2004a6553b..a27dd8e091 100644 --- a/packages/ipfs-core/src/components/key/rm.js +++ b/packages/ipfs-core/src/components/key/rm.js @@ -20,10 +20,9 @@ module.exports = ({ keychain }) => { * ``` * * @param {string} name - The name of the key to remove - * @param {import('.').AbortOptions} options * @returns {Promise} - An object that describes the removed key */ - const rm = (name, options) => keychain.removeKey(name, options) + const rm = (name) => keychain.removeKey(name) return withTimeoutOption(rm) } diff --git a/packages/ipfs-core/src/components/libp2p.js b/packages/ipfs-core/src/components/libp2p.js index c985b5632f..f0437c0945 100644 --- a/packages/ipfs-core/src/components/libp2p.js +++ b/packages/ipfs-core/src/components/libp2p.js @@ -164,6 +164,6 @@ function getLibp2pOptions ({ options, config, datastore, keys, keychainConfig, p * @typedef {import('.').PeerId} PeerId * @typedef {import('.').Options} IPFSOptions * @typedef {import('libp2p')} LibP2P - * @typedef {import('libp2p').Options} Options + * @typedef {import('libp2p').Libp2pOptions} Options * @typedef {import('.').IPFSConfig} IPFSConfig */ diff --git a/packages/ipfs-core/src/components/ping.js b/packages/ipfs-core/src/components/ping.js index 077986d66d..295263085d 100644 --- a/packages/ipfs-core/src/components/ping.js +++ b/packages/ipfs-core/src/components/ping.js @@ -35,21 +35,28 @@ module.exports = ({ network }) => { peerId = PeerId.createFromCID(peerId) } - let peer = libp2p.peerStore.get(peerId) + const storedPeer = libp2p.peerStore.get(peerId) + let id = storedPeer && storedPeer.id - if (!peer) { + if (!id) { yield { ...basePacket, text: `Looking up peer ${peerId}` } - peer = await libp2p.peerRouting.findPeer(peerId) + const remotePeer = await libp2p.peerRouting.findPeer(peerId) + + id = remotePeer && remotePeer.id + } + + if (!id) { + throw new Error('Peer was not found') } - yield { ...basePacket, text: `PING ${peer.id.toB58String()}` } + yield { ...basePacket, text: `PING ${id.toB58String()}` } let packetCount = 0 let totalTime = 0 for (let i = 0; i < options.count; i++) { try { - const time = await libp2p.ping(peer.id) + const time = await libp2p.ping(id) totalTime += time packetCount++ yield { ...basePacket, time } diff --git a/packages/ipfs-core/src/components/pubsub.js b/packages/ipfs-core/src/components/pubsub.js index db671706f0..56b659477a 100644 --- a/packages/ipfs-core/src/components/pubsub.js +++ b/packages/ipfs-core/src/components/pubsub.js @@ -41,6 +41,7 @@ module.exports = ({ network, config }) => { */ async function subscribe (topic, handler, options) { const { libp2p } = await network.use(options) + // @ts-ignore Libp2p Pubsub is deprecating the handler, using the EventEmitter return libp2p.pubsub.subscribe(topic, handler, options) } @@ -75,6 +76,7 @@ module.exports = ({ network, config }) => { */ async function unsubscribe (topic, handler, options) { const { libp2p } = await network.use(options) + // @ts-ignore Libp2p Pubsub is deprecating the handler, using the EventEmitter libp2p.pubsub.unsubscribe(topic, handler, options) } @@ -111,7 +113,7 @@ module.exports = ({ network, config }) => { */ async function ls (options) { const { libp2p } = await network.use(options) - return libp2p.pubsub.getTopics(options) + return libp2p.pubsub.getTopics() } /** @@ -131,7 +133,7 @@ module.exports = ({ network, config }) => { */ async function peers (topic, options) { const { libp2p } = await network.use(options) - return libp2p.pubsub.getSubscribers(topic, options) + return libp2p.pubsub.getSubscribers(topic) } } diff --git a/packages/ipfs-core/src/components/stats/bw.js b/packages/ipfs-core/src/components/stats/bw.js index 5634bf029c..a418e0d688 100644 --- a/packages/ipfs-core/src/components/stats/bw.js +++ b/packages/ipfs-core/src/components/stats/bw.js @@ -13,7 +13,9 @@ const withTimeoutOption = require('ipfs-core-utils/src/with-timeout-option') function getBandwidthStats (libp2p, opts) { let stats - if (opts.peer) { + if (!libp2p.metrics) { + stats = undefined + } else if (opts.peer) { stats = libp2p.metrics.forPeer(opts.peer) } else if (opts.proto) { stats = libp2p.metrics.forProtocol(opts.proto) @@ -85,7 +87,7 @@ module.exports = ({ network }) => { /** * @typedef {Object} BWOptions - * @property {PeerId|CID|string} [peer] - Specifies a peer to print bandwidth for + * @property {PeerId} [peer] - Specifies a peer to print bandwidth for * @property {string} [proto] - Specifies a protocol to print bandwidth for * @property {boolean} [poll] - Is used to yield bandwidth info at an interval * @property {number|string} [interval=1000] - The time interval to wait between updating output, if `poll` is `true`. diff --git a/packages/ipfs-core/src/components/storage.js b/packages/ipfs-core/src/components/storage.js index 4152d3bd24..14efb7424d 100644 --- a/packages/ipfs-core/src/components/storage.js +++ b/packages/ipfs-core/src/components/storage.js @@ -43,6 +43,8 @@ class Storage { const { peerId, keychain, isNew } = await loadRepo(repo, options) + // TODO: throw error? + // @ts-ignore On start, keychain will always be available return new Storage(peerId, keychain, repo, print, isNew) } } @@ -52,7 +54,7 @@ module.exports = Storage * * @param {Repo} repo * @param {RepoOptions & InitOptions} options - * @returns {Promise<{peerId: PeerId, keychain:Keychain, isNew:boolean }>} + * @returns {Promise<{peerId: PeerId, keychain: Keychain | undefined, isNew:boolean }>} */ const loadRepo = async (repo, options) => { const openError = await openRepo(repo) @@ -96,7 +98,7 @@ const openRepo = async (repo) => { /** * @param {Repo} repo * @param {RepoOptions & InitOptions} options - * @returns {Promise<{peerId: PeerId, keychain:Keychain}>} + * @returns {Promise<{peerId: PeerId, keychain: Keychain | undefined}>} */ const initRepo = async (repo, options) => { // 1. Verify that repo does not exist yet (if it does and we could not @@ -197,7 +199,7 @@ const peerIdToIdentity = (peerId) => ({ * * @param {Repo} repo * @param {ConfigureOptions} options - * @returns {Promise<{peerId: PeerId, keychain:Keychain}>} + * @returns {Promise<{peerId: PeerId, keychain: Keychain | undefined}>} */ const configureRepo = async (repo, { config, profiles, pass }) => { const original = await repo.config.getAll() @@ -297,5 +299,5 @@ const applyProfiles = (config, profiles) => { * @typedef {import('.').IPFSConfig} IPFSConfig * @typedef {import('../interface/repo').Repo} Repo * @typedef {import('libp2p-crypto').KeyType} KeyType - * @typedef {import('libp2p').LibP2PKeychain} Keychain + * @typedef {import('libp2p/src/keychain')} Keychain */ diff --git a/packages/ipfs-core/src/components/swarm/addrs.js b/packages/ipfs-core/src/components/swarm/addrs.js index 03000ed58a..28ae132fd3 100644 --- a/packages/ipfs-core/src/components/swarm/addrs.js +++ b/packages/ipfs-core/src/components/swarm/addrs.js @@ -16,7 +16,7 @@ module.exports = ({ network }) => { async function addrs (options) { // eslint-disable-line require-await const peers = [] const { libp2p } = await network.use(options) - for (const [peerId, peer] of libp2p.peerStore.peers.entries(options)) { + for (const [peerId, peer] of libp2p.peerStore.peers.entries()) { peers.push({ id: peerId, addrs: peer.addresses.map((mi) => mi.multiaddr) diff --git a/packages/ipfs-core/src/components/swarm/connect.js b/packages/ipfs-core/src/components/swarm/connect.js index 306aba2487..49c078a3b8 100644 --- a/packages/ipfs-core/src/components/swarm/connect.js +++ b/packages/ipfs-core/src/components/swarm/connect.js @@ -16,7 +16,7 @@ module.exports = ({ network }) => { */ async function connect (addr, options) { const { libp2p } = await network.use(options) - return libp2p.dial(addr, options) + await libp2p.dial(addr, options) } return withTimeoutOption(connect) diff --git a/packages/ipfs-core/src/components/swarm/disconnect.js b/packages/ipfs-core/src/components/swarm/disconnect.js index 7bfdbbb839..6b4210c8bc 100644 --- a/packages/ipfs-core/src/components/swarm/disconnect.js +++ b/packages/ipfs-core/src/components/swarm/disconnect.js @@ -16,7 +16,7 @@ module.exports = ({ network }) => { */ async function disconnect (addr, options) { const { libp2p } = await network.use(options) - return libp2p.hangUp(addr, options) + return libp2p.hangUp(addr) } return withTimeoutOption(disconnect) From 4d42fd13109f0cc46733ace905af7c092e006514 Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Fri, 11 Dec 2020 17:31:33 +0100 Subject: [PATCH 03/14] chore: apply suggestions from code review Co-authored-by: Hugo Dias --- packages/ipfs-core/package.json | 2 +- packages/ipfs-core/src/components/storage.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/ipfs-core/package.json b/packages/ipfs-core/package.json index f359d2907c..e93f6be3ee 100644 --- a/packages/ipfs-core/package.json +++ b/packages/ipfs-core/package.json @@ -88,7 +88,7 @@ "it-first": "^1.0.4", "it-last": "^1.0.4", "it-pipe": "^1.1.0", - "libp2p": "libp2p/js-libp2p#fix/types-with-dist", + "libp2p": "libp2p/js-libp2p#fix/types", "libp2p-bootstrap": "^0.12.1", "libp2p-crypto": "^0.18.0", "libp2p-floodsub": "^0.24.0", diff --git a/packages/ipfs-core/src/components/storage.js b/packages/ipfs-core/src/components/storage.js index 14efb7424d..9cf7d1b0dd 100644 --- a/packages/ipfs-core/src/components/storage.js +++ b/packages/ipfs-core/src/components/storage.js @@ -54,7 +54,7 @@ module.exports = Storage * * @param {Repo} repo * @param {RepoOptions & InitOptions} options - * @returns {Promise<{peerId: PeerId, keychain: Keychain | undefined, isNew:boolean }>} + * @returns {Promise<{peerId: PeerId, keychain?: Keychain, isNew:boolean }>} */ const loadRepo = async (repo, options) => { const openError = await openRepo(repo) @@ -98,7 +98,7 @@ const openRepo = async (repo) => { /** * @param {Repo} repo * @param {RepoOptions & InitOptions} options - * @returns {Promise<{peerId: PeerId, keychain: Keychain | undefined}>} + * @returns {Promise<{peerId: PeerId, keychain?: Keychain}>} */ const initRepo = async (repo, options) => { // 1. Verify that repo does not exist yet (if it does and we could not @@ -199,7 +199,7 @@ const peerIdToIdentity = (peerId) => ({ * * @param {Repo} repo * @param {ConfigureOptions} options - * @returns {Promise<{peerId: PeerId, keychain: Keychain | undefined}>} + * @returns {Promise<{peerId: PeerId, keychain?: Keychain}>} */ const configureRepo = async (repo, { config, profiles, pass }) => { const original = await repo.config.getAll() From 3be8cda925348e67cdf4aa9dc79fd5d9a7600080 Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Fri, 11 Dec 2020 18:48:00 +0100 Subject: [PATCH 04/14] chore: use rc1 --- packages/ipfs-core/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ipfs-core/package.json b/packages/ipfs-core/package.json index e93f6be3ee..e7a97a955c 100644 --- a/packages/ipfs-core/package.json +++ b/packages/ipfs-core/package.json @@ -88,7 +88,7 @@ "it-first": "^1.0.4", "it-last": "^1.0.4", "it-pipe": "^1.1.0", - "libp2p": "libp2p/js-libp2p#fix/types", + "libp2p": "^0.30.0-rc.1", "libp2p-bootstrap": "^0.12.1", "libp2p-crypto": "^0.18.0", "libp2p-floodsub": "^0.24.0", From c8802cfc547ce9d2223cc697dec1737083eb5b5d Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Mon, 14 Dec 2020 17:21:32 +0100 Subject: [PATCH 05/14] chore: use ws filter all on local address tests --- examples/browser-exchange-files/package.json | 1 + examples/browser-exchange-files/public/app.js | 16 ++++++++++++++++ packages/interface-ipfs-core/package.json | 1 + .../interface-ipfs-core/src/bitswap/transfer.js | 8 +++++--- .../src/bitswap/wantlist-for-peer.js | 4 +++- .../interface-ipfs-core/src/bitswap/wantlist.js | 4 +++- .../src/miscellaneous/resolve.js | 4 +++- packages/interface-ipfs-core/src/ping/ping.js | 4 +++- .../interface-ipfs-core/src/pubsub/peers.js | 4 +++- .../interface-ipfs-core/src/pubsub/subscribe.js | 4 +++- packages/interface-ipfs-core/src/swarm/addrs.js | 4 +++- .../interface-ipfs-core/src/swarm/connect.js | 4 +++- .../interface-ipfs-core/src/swarm/disconnect.js | 4 +++- packages/interface-ipfs-core/src/swarm/peers.js | 8 +++++--- .../utils/ipfs-options-websockets-filter-all.js | 17 +++++++++++++++++ 15 files changed, 72 insertions(+), 15 deletions(-) create mode 100644 packages/interface-ipfs-core/src/utils/ipfs-options-websockets-filter-all.js diff --git a/examples/browser-exchange-files/package.json b/examples/browser-exchange-files/package.json index 0f2458792d..58c1044f76 100644 --- a/examples/browser-exchange-files/package.json +++ b/examples/browser-exchange-files/package.json @@ -20,6 +20,7 @@ "dependencies": { "ipfs": "^0.52.2", "it-all": "^1.0.4", + "libp2p-websockets": "^0.15.0", "rimraf": "^3.0.2", "test-ipfs-example": "^2.0.3" }, diff --git a/examples/browser-exchange-files/public/app.js b/examples/browser-exchange-files/public/app.js index 11d6c8614b..5f42c7b309 100644 --- a/examples/browser-exchange-files/public/app.js +++ b/examples/browser-exchange-files/public/app.js @@ -2,6 +2,10 @@ 'use strict' const IPFS = require('ipfs') +const WS = require('libp2p-websockets') +const filters = require('libp2p-websockets/src/filters') +const transportKey = WS.prototype[Symbol.toStringTag] + const all = require('it-all') const uint8ArrayConcat = require('uint8arrays/concat') const uint8ArrayFromString = require('uint8arrays/from-string') @@ -59,6 +63,18 @@ async function start () { }, // If you want to connect to the public bootstrap nodes, remove the next line Bootstrap: [] + }, + libp2p: { + config: { + transport: { + // This is added for local demo! + // In a production environment the default filter should be used + // where only DNS + WSS addresses will be dialed by websockets in the browser. + [transportKey]: { + filter: filters.all + } + } + } } }) diff --git a/packages/interface-ipfs-core/package.json b/packages/interface-ipfs-core/package.json index a8782fab51..4ba8c38dc3 100644 --- a/packages/interface-ipfs-core/package.json +++ b/packages/interface-ipfs-core/package.json @@ -55,6 +55,7 @@ "it-map": "^1.0.4", "it-pushable": "^1.4.0", "libp2p-crypto": "^0.18.0", + "libp2p-websockets": "^0.15.0", "multiaddr": "^8.0.0", "multibase": "^3.0.0", "multihashing-async": "^2.0.1", diff --git a/packages/interface-ipfs-core/src/bitswap/transfer.js b/packages/interface-ipfs-core/src/bitswap/transfer.js index a6294c329b..c1cb73b3c9 100644 --- a/packages/interface-ipfs-core/src/bitswap/transfer.js +++ b/packages/interface-ipfs-core/src/bitswap/transfer.js @@ -11,6 +11,7 @@ const { nanoid } = require('nanoid') const uint8ArrayFromString = require('uint8arrays/from-string') const pmap = require('p-map') const multihashing = require('multihashing-async') +const getIpfsOptions = require('../utils/ipfs-options-websockets-filter-all') const makeBlock = async () => { const d = uint8ArrayFromString(`IPFS is awesome ${nanoid()}`) @@ -25,6 +26,7 @@ const makeBlock = async () => { * @param {Object} options */ module.exports = (factory, options) => { + const ipfsOptions = getIpfsOptions() const describe = getDescribe(options) const it = getIt(options) @@ -37,7 +39,7 @@ module.exports = (factory, options) => { it('2 peers', async function () { // webworkers are not dialable because webrtc is not available const remote = (await factory.spawn({ type: isWebWorker ? 'go' : undefined })).api - const local = (await factory.spawn()).api + const local = (await factory.spawn({ type: 'proc', ipfsOptions })).api await local.swarm.connect(remote.peerId.addresses[0]) const block = await makeBlock() @@ -51,7 +53,7 @@ module.exports = (factory, options) => { const blocks = await Promise.all([...Array(6).keys()].map(() => makeBlock())) const remote1 = (await factory.spawn({ type: isWebWorker ? 'go' : undefined })).api const remote2 = (await factory.spawn({ type: isWebWorker ? 'go' : undefined })).api - const local = (await factory.spawn()).api + const local = (await factory.spawn({ type: 'proc', ipfsOptions })).api await local.swarm.connect(remote1.peerId.addresses[0]) await local.swarm.connect(remote2.peerId.addresses[0]) await remote1.swarm.connect(remote2.peerId.addresses[0]) @@ -75,7 +77,7 @@ module.exports = (factory, options) => { it('2 peers', async () => { const content = randomBytes(1024 * 1024 * 10) const remote = (await factory.spawn({ type: isWebWorker ? 'go' : undefined })).api - const local = (await factory.spawn()).api + const local = (await factory.spawn({ type: 'proc', ipfsOptions })).api local.swarm.connect(remote.peerId.addresses[0]) const file = await remote.add({ path: 'awesome.txt', content }) diff --git a/packages/interface-ipfs-core/src/bitswap/wantlist-for-peer.js b/packages/interface-ipfs-core/src/bitswap/wantlist-for-peer.js index e65321f16a..47e5ceb0ab 100644 --- a/packages/interface-ipfs-core/src/bitswap/wantlist-for-peer.js +++ b/packages/interface-ipfs-core/src/bitswap/wantlist-for-peer.js @@ -5,6 +5,7 @@ const { getDescribe, getIt } = require('../utils/mocha') const { waitForWantlistKey } = require('./utils') const { isWebWorker } = require('ipfs-utils/src/env') const testTimeout = require('../utils/test-timeout') +const getIpfsOptions = require('../utils/ipfs-options-websockets-filter-all') /** @typedef { import("ipfsd-ctl/src/factory") } Factory */ /** @@ -12,6 +13,7 @@ const testTimeout = require('../utils/test-timeout') * @param {Object} options */ module.exports = (common, options) => { + const ipfsOptions = getIpfsOptions() const describe = getDescribe(options) const it = getIt(options) @@ -23,7 +25,7 @@ module.exports = (common, options) => { const key = 'QmUBdnXXPyoDFXj3Hj39dNJ5VkN3QFRskXxcGaYFBB8CNR' before(async () => { - ipfsA = (await common.spawn()).api + ipfsA = (await common.spawn({ type: 'proc', ipfsOptions })).api // webworkers are not dialable because webrtc is not available ipfsB = (await common.spawn({ type: isWebWorker ? 'go' : undefined })).api // Add key to the wantlist for ipfsB diff --git a/packages/interface-ipfs-core/src/bitswap/wantlist.js b/packages/interface-ipfs-core/src/bitswap/wantlist.js index 1e743966bc..63d31bad59 100644 --- a/packages/interface-ipfs-core/src/bitswap/wantlist.js +++ b/packages/interface-ipfs-core/src/bitswap/wantlist.js @@ -8,6 +8,7 @@ const testTimeout = require('../utils/test-timeout') const AbortController = require('native-abort-controller') const CID = require('cids') const delay = require('delay') +const getIpfsOptions = require('../utils/ipfs-options-websockets-filter-all') /** @typedef { import("ipfsd-ctl/src/factory") } Factory */ /** @@ -15,6 +16,7 @@ const delay = require('delay') * @param {Object} options */ module.exports = (common, options) => { + const ipfsOptions = getIpfsOptions() const describe = getDescribe(options) const it = getIt(options) @@ -26,7 +28,7 @@ module.exports = (common, options) => { const key = 'QmUBdnXXPyoDFXj3Hj39dNJ5VkN3QFRskXxcGaYFBB8CNR' before(async () => { - ipfsA = (await common.spawn()).api + ipfsA = (await common.spawn({ type: 'proc', ipfsOptions })).api // webworkers are not dialable because webrtc is not available ipfsB = (await common.spawn({ type: isWebWorker ? 'go' : undefined })).api // Add key to the wantlist for ipfsB diff --git a/packages/interface-ipfs-core/src/miscellaneous/resolve.js b/packages/interface-ipfs-core/src/miscellaneous/resolve.js index e70978766a..91107486a2 100644 --- a/packages/interface-ipfs-core/src/miscellaneous/resolve.js +++ b/packages/interface-ipfs-core/src/miscellaneous/resolve.js @@ -10,6 +10,7 @@ const { getDescribe, getIt, expect } = require('../utils/mocha') const all = require('it-all') const { isWebWorker } = require('ipfs-utils/src/env') const testTimeout = require('../utils/test-timeout') +const getIpfsOptions = require('../utils/ipfs-options-websockets-filter-all') /** @typedef { import("ipfsd-ctl/src/factory") } Factory */ /** @@ -17,6 +18,7 @@ const testTimeout = require('../utils/test-timeout') * @param {Object} options */ module.exports = (common, options) => { + const ipfsOptions = getIpfsOptions() const describe = getDescribe(options) const it = getIt(options) @@ -25,7 +27,7 @@ module.exports = (common, options) => { let ipfs before(async () => { - ipfs = (await common.spawn()).api + ipfs = (await common.spawn({ type: 'proc', ipfsOptions })).api }) after(() => common.clean()) diff --git a/packages/interface-ipfs-core/src/ping/ping.js b/packages/interface-ipfs-core/src/ping/ping.js index 59744264ca..8bdae916d4 100644 --- a/packages/interface-ipfs-core/src/ping/ping.js +++ b/packages/interface-ipfs-core/src/ping/ping.js @@ -7,6 +7,7 @@ const all = require('it-all') const drain = require('it-drain') const { isWebWorker } = require('ipfs-utils/src/env') const testTimeout = require('../utils/test-timeout') +const getIpfsOptions = require('../utils/ipfs-options-websockets-filter-all') /** @typedef { import("ipfsd-ctl/src/factory") } Factory */ /** @@ -14,6 +15,7 @@ const testTimeout = require('../utils/test-timeout') * @param {Object} options */ module.exports = (common, options) => { + const ipfsOptions = getIpfsOptions() const describe = getDescribe(options) const it = getIt(options) @@ -24,7 +26,7 @@ module.exports = (common, options) => { let ipfsB before(async () => { - ipfsA = (await common.spawn()).api + ipfsA = (await common.spawn({ type: 'proc', ipfsOptions })).api // webworkers are not dialable because webrtc is not available ipfsB = (await common.spawn({ type: isWebWorker ? 'go' : undefined })).api await ipfsA.swarm.connect(ipfsB.peerId.addresses[0]) diff --git a/packages/interface-ipfs-core/src/pubsub/peers.js b/packages/interface-ipfs-core/src/pubsub/peers.js index 3b209c43c1..5d1bc25f9d 100644 --- a/packages/interface-ipfs-core/src/pubsub/peers.js +++ b/packages/interface-ipfs-core/src/pubsub/peers.js @@ -6,6 +6,7 @@ const { getDescribe, getIt, expect } = require('../utils/mocha') const delay = require('delay') const { isWebWorker } = require('ipfs-utils/src/env') const testTimeout = require('../utils/test-timeout') +const getIpfsOptions = require('../utils/ipfs-options-websockets-filter-all') /** @typedef { import("ipfsd-ctl/src/factory") } Factory */ /** @@ -13,6 +14,7 @@ const testTimeout = require('../utils/test-timeout') * @param {Object} options */ module.exports = (common, options) => { + const ipfsOptions = getIpfsOptions() const describe = getDescribe(options) const it = getIt(options) @@ -25,7 +27,7 @@ module.exports = (common, options) => { let subscribedTopics = [] before(async () => { - ipfs1 = (await common.spawn()).api + ipfs1 = (await common.spawn({ type: 'proc', ipfsOptions })).api // webworkers are not dialable because webrtc is not available ipfs2 = (await common.spawn({ type: isWebWorker ? 'go' : undefined })).api ipfs3 = (await common.spawn({ type: isWebWorker ? 'go' : undefined })).api diff --git a/packages/interface-ipfs-core/src/pubsub/subscribe.js b/packages/interface-ipfs-core/src/pubsub/subscribe.js index aca99579e5..0e3f098e1a 100644 --- a/packages/interface-ipfs-core/src/pubsub/subscribe.js +++ b/packages/interface-ipfs-core/src/pubsub/subscribe.js @@ -11,6 +11,7 @@ const { getDescribe, getIt, expect } = require('../utils/mocha') const delay = require('delay') const AbortController = require('native-abort-controller') const { isWebWorker, isNode } = require('ipfs-utils/src/env') +const getIpfsOptions = require('../utils/ipfs-options-websockets-filter-all') /** @typedef { import("ipfsd-ctl/src/factory") } Factory */ /** @@ -18,6 +19,7 @@ const { isWebWorker, isNode } = require('ipfs-utils/src/env') * @param {Object} options */ module.exports = (common, options) => { + const ipfsOptions = getIpfsOptions() const describe = getDescribe(options) const it = getIt(options) @@ -30,7 +32,7 @@ module.exports = (common, options) => { let subscribedTopics = [] before(async () => { - ipfs1 = (await common.spawn()).api + ipfs1 = (await common.spawn({ type: 'proc', ipfsOptions })).api // TODO 'multiple connected nodes' tests fails with go in Firefox // and JS is flaky everywhere diff --git a/packages/interface-ipfs-core/src/swarm/addrs.js b/packages/interface-ipfs-core/src/swarm/addrs.js index 1c5487397a..d6d2889004 100644 --- a/packages/interface-ipfs-core/src/swarm/addrs.js +++ b/packages/interface-ipfs-core/src/swarm/addrs.js @@ -6,6 +6,7 @@ const Multiaddr = require('multiaddr') const { getDescribe, getIt, expect } = require('../utils/mocha') const { isWebWorker } = require('ipfs-utils/src/env') const testTimeout = require('../utils/test-timeout') +const getIpfsOptions = require('../utils/ipfs-options-websockets-filter-all') /** @typedef { import("ipfsd-ctl/src/factory") } Factory */ /** @@ -13,6 +14,7 @@ const testTimeout = require('../utils/test-timeout') * @param {Object} options */ module.exports = (common, options) => { + const ipfsOptions = getIpfsOptions() const describe = getDescribe(options) const it = getIt(options) @@ -23,7 +25,7 @@ module.exports = (common, options) => { let ipfsB before(async () => { - ipfsA = (await common.spawn()).api + ipfsA = (await common.spawn({ type: 'proc', ipfsOptions })).api // webworkers are not dialable because webrtc is not available ipfsB = (await common.spawn({ type: isWebWorker ? 'go' : undefined })).api await ipfsA.swarm.connect(ipfsB.peerId.addresses[0]) diff --git a/packages/interface-ipfs-core/src/swarm/connect.js b/packages/interface-ipfs-core/src/swarm/connect.js index bc0219b8af..76f92c3c5d 100644 --- a/packages/interface-ipfs-core/src/swarm/connect.js +++ b/packages/interface-ipfs-core/src/swarm/connect.js @@ -4,6 +4,7 @@ const { getDescribe, getIt, expect } = require('../utils/mocha') const { isWebWorker } = require('ipfs-utils/src/env') const testTimeout = require('../utils/test-timeout') +const getIpfsOptions = require('../utils/ipfs-options-websockets-filter-all') /** @typedef { import("ipfsd-ctl/src/factory") } Factory */ /** @@ -11,6 +12,7 @@ const testTimeout = require('../utils/test-timeout') * @param {Object} options */ module.exports = (common, options) => { + const ipfsOptions = getIpfsOptions() const describe = getDescribe(options) const it = getIt(options) @@ -20,7 +22,7 @@ module.exports = (common, options) => { let ipfsB before(async () => { - ipfsA = (await common.spawn()).api + ipfsA = (await common.spawn({ type: 'proc', ipfsOptions })).api // webworkers are not dialable because webrtc is not available ipfsB = (await common.spawn({ type: isWebWorker ? 'go' : undefined })).api }) diff --git a/packages/interface-ipfs-core/src/swarm/disconnect.js b/packages/interface-ipfs-core/src/swarm/disconnect.js index 606d4be1d7..09230535e9 100644 --- a/packages/interface-ipfs-core/src/swarm/disconnect.js +++ b/packages/interface-ipfs-core/src/swarm/disconnect.js @@ -4,6 +4,7 @@ const { getDescribe, getIt, expect } = require('../utils/mocha') const { isWebWorker } = require('ipfs-utils/src/env') const testTimeout = require('../utils/test-timeout') +const getIpfsOptions = require('../utils/ipfs-options-websockets-filter-all') /** @typedef { import("ipfsd-ctl/src/factory") } Factory */ /** @@ -11,6 +12,7 @@ const testTimeout = require('../utils/test-timeout') * @param {Object} options */ module.exports = (common, options) => { + const ipfsOptions = getIpfsOptions() const describe = getDescribe(options) const it = getIt(options) @@ -21,7 +23,7 @@ module.exports = (common, options) => { let ipfsB before(async () => { - ipfsA = (await common.spawn()).api + ipfsA = (await common.spawn({ type: 'proc', ipfsOptions })).api // webworkers are not dialable because webrtc is not available ipfsB = (await common.spawn({ type: isWebWorker ? 'go' : undefined })).api }) diff --git a/packages/interface-ipfs-core/src/swarm/peers.js b/packages/interface-ipfs-core/src/swarm/peers.js index 12701a8cdd..6d303f430b 100644 --- a/packages/interface-ipfs-core/src/swarm/peers.js +++ b/packages/interface-ipfs-core/src/swarm/peers.js @@ -7,6 +7,7 @@ const delay = require('delay') const { isBrowser, isWebWorker } = require('ipfs-utils/src/env') const { getDescribe, getIt, expect } = require('../utils/mocha') const testTimeout = require('../utils/test-timeout') +const getIpfsOptions = require('../utils/ipfs-options-websockets-filter-all') /** @typedef { import("ipfsd-ctl/src/factory") } Factory */ /** @@ -14,6 +15,7 @@ const testTimeout = require('../utils/test-timeout') * @param {Object} options */ module.exports = (common, options) => { + const ipfsOptions = getIpfsOptions() const describe = getDescribe(options) const it = getIt(options) @@ -24,7 +26,7 @@ module.exports = (common, options) => { let ipfsB before(async () => { - ipfsA = (await common.spawn()).api + ipfsA = (await common.spawn({ type: 'proc', ipfsOptions })).api ipfsB = (await common.spawn({ type: isWebWorker ? 'go' : undefined })).api await ipfsA.swarm.connect(ipfsB.peerId.addresses[0]) /* TODO: Seen if we still need this after this is fixed @@ -94,7 +96,7 @@ module.exports = (common, options) => { } it('should list peers only once', async () => { - const nodeA = (await common.spawn()).api + const nodeA = (await common.spawn({ type: 'proc', ipfsOptions })).api const nodeB = (await common.spawn({ type: isWebWorker ? 'go' : undefined })).api await nodeA.swarm.connect(nodeB.peerId.addresses[0]) await delay(1000) @@ -133,7 +135,7 @@ module.exports = (common, options) => { '/ip4/127.0.0.1/tcp/26546/ws' ]) - const nodeA = (await common.spawn({ ipfsOptions: { config: configA } })).api + const nodeA = (await common.spawn({ type: 'proc', ipfsOptions: { config: configA, ...ipfsOptions } })).api const nodeB = (await common.spawn({ type: isWebWorker ? 'go' : undefined, ipfsOptions: { diff --git a/packages/interface-ipfs-core/src/utils/ipfs-options-websockets-filter-all.js b/packages/interface-ipfs-core/src/utils/ipfs-options-websockets-filter-all.js new file mode 100644 index 0000000000..63b891bac7 --- /dev/null +++ b/packages/interface-ipfs-core/src/utils/ipfs-options-websockets-filter-all.js @@ -0,0 +1,17 @@ +'use strict' + +const WS = require('libp2p-websockets') +const filters = require('libp2p-websockets/src/filters') +const transportKey = WS.prototype[Symbol.toStringTag] + +module.exports = () => ({ + libp2p: { + config: { + transport: { + [transportKey]: { + filter: filters.all + } + } + } + } +}) From faf1df7f68c5f156c71341d40b11de2b1cdf83a2 Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Mon, 14 Dec 2020 17:35:34 +0100 Subject: [PATCH 06/14] chore: use interop branch --- packages/ipfs/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ipfs/package.json b/packages/ipfs/package.json index 7c65fc8a14..c20c093a85 100644 --- a/packages/ipfs/package.json +++ b/packages/ipfs/package.json @@ -51,7 +51,7 @@ "go-ipfs": "^0.7.0", "interface-ipfs-core": "^0.142.3", "ipfs-http-client": "^48.1.3", - "ipfs-interop": "^3.0.0", + "ipfs-interop": "ipfs/interop#chore/update-websockets", "ipfs-utils": "^5.0.0", "ipfsd-ctl": "^7.1.1", "iso-url": "^1.0.0", From f863a3374bd41294f00a59ed8e97b425ea6215ad Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Mon, 14 Dec 2020 18:52:27 +0100 Subject: [PATCH 07/14] chore: use libp2p rc in libp2p daemon --- packages/interface-ipfs-core/src/swarm/peers.js | 7 +++---- packages/ipfs-daemon/package.json | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/interface-ipfs-core/src/swarm/peers.js b/packages/interface-ipfs-core/src/swarm/peers.js index 6d303f430b..08f8349b70 100644 --- a/packages/interface-ipfs-core/src/swarm/peers.js +++ b/packages/interface-ipfs-core/src/swarm/peers.js @@ -126,8 +126,7 @@ module.exports = (common, options) => { ] } - const configA = getConfig(addresses) - const configB = getConfig(isBrowser && common.opts.type !== 'go' ? [ + const config = getConfig(isBrowser && common.opts.type !== 'go' ? [ '/ip4/127.0.0.1/tcp/14578/ws/p2p-webrtc-star', '/ip4/127.0.0.1/tcp/14579/ws/p2p-webrtc-star' ] : [ @@ -135,11 +134,11 @@ module.exports = (common, options) => { '/ip4/127.0.0.1/tcp/26546/ws' ]) - const nodeA = (await common.spawn({ type: 'proc', ipfsOptions: { config: configA, ...ipfsOptions } })).api + const nodeA = (await common.spawn({ type: 'proc', ipfsOptions })).api const nodeB = (await common.spawn({ type: isWebWorker ? 'go' : undefined, ipfsOptions: { - config: configB + config } })).api diff --git a/packages/ipfs-daemon/package.json b/packages/ipfs-daemon/package.json index d6e055957c..24e2b4d32b 100644 --- a/packages/ipfs-daemon/package.json +++ b/packages/ipfs-daemon/package.json @@ -37,7 +37,7 @@ "ipfs-http-server": "^0.1.4", "ipfs-utils": "^5.0.0", "just-safe-set": "^2.1.0", - "libp2p": "^0.29.3", + "libp2p": "^0.30.0-rc.1", "libp2p-delegated-content-routing": "^0.8.0", "libp2p-delegated-peer-routing": "^0.8.0", "libp2p-webrtc-star": "^0.20.1", From d8f9430229654d48ffa909a2aecdf9b424eeccb8 Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Mon, 14 Dec 2020 20:39:08 +0100 Subject: [PATCH 08/14] chore: use multicoedc with fixed version in libp2p --- .../interface-ipfs-core/src/swarm/peers.js | 18 ------------------ packages/ipfs-core/package.json | 2 +- packages/ipfs-daemon/package.json | 2 +- 3 files changed, 2 insertions(+), 20 deletions(-) diff --git a/packages/interface-ipfs-core/src/swarm/peers.js b/packages/interface-ipfs-core/src/swarm/peers.js index 08f8349b70..ecb5c54aa7 100644 --- a/packages/interface-ipfs-core/src/swarm/peers.js +++ b/packages/interface-ipfs-core/src/swarm/peers.js @@ -108,24 +108,6 @@ module.exports = (common, options) => { it('should list peers only once even if they have multiple addresses', async () => { // TODO: Change to port 0, needs: https://github.com/ipfs/interface-ipfs-core/issues/152 - let addresses - - if (isBrowser && common.opts.type !== 'go') { - addresses = [ - '/ip4/127.0.0.1/tcp/14578/ws/p2p-webrtc-star', - '/ip4/127.0.0.1/tcp/14579/ws/p2p-webrtc-star' - ] - } else if (isWebWorker) { - // webworkers are not dialable (no webrtc available) until stardust is async/await - // https://github.com/libp2p/js-libp2p-stardust/pull/14 - addresses = [] - } else { - addresses = [ - '/ip4/127.0.0.1/tcp/26543/ws', - '/ip4/127.0.0.1/tcp/26544/ws' - ] - } - const config = getConfig(isBrowser && common.opts.type !== 'go' ? [ '/ip4/127.0.0.1/tcp/14578/ws/p2p-webrtc-star', '/ip4/127.0.0.1/tcp/14579/ws/p2p-webrtc-star' diff --git a/packages/ipfs-core/package.json b/packages/ipfs-core/package.json index e7a97a955c..fc6d504c25 100644 --- a/packages/ipfs-core/package.json +++ b/packages/ipfs-core/package.json @@ -88,7 +88,7 @@ "it-first": "^1.0.4", "it-last": "^1.0.4", "it-pipe": "^1.1.0", - "libp2p": "^0.30.0-rc.1", + "libp2p": "libp2p/js-libp2p#chore/fix-multicodec-version", "libp2p-bootstrap": "^0.12.1", "libp2p-crypto": "^0.18.0", "libp2p-floodsub": "^0.24.0", diff --git a/packages/ipfs-daemon/package.json b/packages/ipfs-daemon/package.json index 24e2b4d32b..bb6c78a7fa 100644 --- a/packages/ipfs-daemon/package.json +++ b/packages/ipfs-daemon/package.json @@ -37,7 +37,7 @@ "ipfs-http-server": "^0.1.4", "ipfs-utils": "^5.0.0", "just-safe-set": "^2.1.0", - "libp2p": "^0.30.0-rc.1", + "libp2p": "libp2p/js-libp2p#chore/fix-multicodec-version", "libp2p-delegated-content-routing": "^0.8.0", "libp2p-delegated-peer-routing": "^0.8.0", "libp2p-webrtc-star": "^0.20.1", From 7b50f2d42164a3bf026cd90cfa136b8de763c4a1 Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Mon, 14 Dec 2020 22:48:14 +0100 Subject: [PATCH 09/14] chore: use updated floodsub and gossipsub --- packages/ipfs-core/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ipfs-core/package.json b/packages/ipfs-core/package.json index fc6d504c25..ae5c4a32bf 100644 --- a/packages/ipfs-core/package.json +++ b/packages/ipfs-core/package.json @@ -91,7 +91,7 @@ "libp2p": "libp2p/js-libp2p#chore/fix-multicodec-version", "libp2p-bootstrap": "^0.12.1", "libp2p-crypto": "^0.18.0", - "libp2p-floodsub": "^0.24.0", + "libp2p-floodsub": "libp2p/js-libp2p-floodsub#chore/use-libp2p0.30", "libp2p-gossipsub": "^0.7.0", "libp2p-kad-dht": "^0.20.1", "libp2p-mdns": "^0.15.0", From 6871ddaf7bc56619495117e3598a7afa87933378 Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Tue, 15 Dec 2020 12:19:52 +0100 Subject: [PATCH 10/14] chore: use new gossipsub --- packages/ipfs-core/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ipfs-core/package.json b/packages/ipfs-core/package.json index ae5c4a32bf..8a7aad5bbf 100644 --- a/packages/ipfs-core/package.json +++ b/packages/ipfs-core/package.json @@ -92,7 +92,7 @@ "libp2p-bootstrap": "^0.12.1", "libp2p-crypto": "^0.18.0", "libp2p-floodsub": "libp2p/js-libp2p-floodsub#chore/use-libp2p0.30", - "libp2p-gossipsub": "^0.7.0", + "libp2p-gossipsub": "ChainSafe/js-libp2p-gossipsub#chore/update-to-new-libp2p-interface-with-types", "libp2p-kad-dht": "^0.20.1", "libp2p-mdns": "^0.15.0", "libp2p-mplex": "^0.10.0", From 2c5a6dac407a26c16ed7f687d486f5668211fbe9 Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Tue, 15 Dec 2020 15:10:00 +0100 Subject: [PATCH 11/14] chore: update libp2p dep --- packages/ipfs-core/package.json | 2 +- packages/ipfs-daemon/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/ipfs-core/package.json b/packages/ipfs-core/package.json index 8a7aad5bbf..53e8617da1 100644 --- a/packages/ipfs-core/package.json +++ b/packages/ipfs-core/package.json @@ -88,7 +88,7 @@ "it-first": "^1.0.4", "it-last": "^1.0.4", "it-pipe": "^1.1.0", - "libp2p": "libp2p/js-libp2p#chore/fix-multicodec-version", + "libp2p": "^0.30.0-rc.2", "libp2p-bootstrap": "^0.12.1", "libp2p-crypto": "^0.18.0", "libp2p-floodsub": "libp2p/js-libp2p-floodsub#chore/use-libp2p0.30", diff --git a/packages/ipfs-daemon/package.json b/packages/ipfs-daemon/package.json index bb6c78a7fa..2d2f83457d 100644 --- a/packages/ipfs-daemon/package.json +++ b/packages/ipfs-daemon/package.json @@ -37,7 +37,7 @@ "ipfs-http-server": "^0.1.4", "ipfs-utils": "^5.0.0", "just-safe-set": "^2.1.0", - "libp2p": "libp2p/js-libp2p#chore/fix-multicodec-version", + "libp2p": "^0.30.0-rc.2", "libp2p-delegated-content-routing": "^0.8.0", "libp2p-delegated-peer-routing": "^0.8.0", "libp2p-webrtc-star": "^0.20.1", From 898a75787fad21b841ea852255f73d8158cb3cf5 Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Tue, 15 Dec 2020 15:52:27 +0100 Subject: [PATCH 12/14] chore: add websocket all filter to circuit example --- examples/circuit-relaying/package.json | 1 + examples/circuit-relaying/src/app.js | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/examples/circuit-relaying/package.json b/examples/circuit-relaying/package.json index 3a7a55bc05..7f5b60f476 100644 --- a/examples/circuit-relaying/package.json +++ b/examples/circuit-relaying/package.json @@ -17,6 +17,7 @@ "delay": "^4.4.0", "ipfs": "^0.52.2", "ipfs-pubsub-room": "^2.0.1", + "libp2p-websockets": "^0.15.0", "uint8arrays": "^1.1.0" }, "devDependencies": { diff --git a/examples/circuit-relaying/src/app.js b/examples/circuit-relaying/src/app.js index ffc97f877c..ea8963b358 100644 --- a/examples/circuit-relaying/src/app.js +++ b/examples/circuit-relaying/src/app.js @@ -2,6 +2,9 @@ 'use strict' const IPFS = require('ipfs') +const WS = require('libp2p-websockets') +const filters = require('libp2p-websockets/src/filters') +const transportKey = WS.prototype[Symbol.toStringTag] const Helpers = require('./helpers') document.addEventListener('DOMContentLoaded', async () => { @@ -38,6 +41,18 @@ document.addEventListener('DOMContentLoaded', async () => { }, config: { Bootstrap: [] + }, + libp2p: { + config: { + transport: { + // This is added for local demo! + // In a production environment the default filter should be used + // where only DNS + WSS addresses will be dialed by websockets in the browser. + [transportKey]: { + filter: filters.all + } + } + } } }) From 2bafc884da6f1153f8ab2eea4f2418b372ca80e0 Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Sat, 19 Dec 2020 18:19:26 +0000 Subject: [PATCH 13/14] chore: use final pubsub releases --- packages/ipfs-core/package.json | 6 +++--- packages/ipfs-daemon/package.json | 2 +- packages/ipfs/package.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/ipfs-core/package.json b/packages/ipfs-core/package.json index 53e8617da1..4b712ba43a 100644 --- a/packages/ipfs-core/package.json +++ b/packages/ipfs-core/package.json @@ -88,11 +88,11 @@ "it-first": "^1.0.4", "it-last": "^1.0.4", "it-pipe": "^1.1.0", - "libp2p": "^0.30.0-rc.2", + "libp2p": "^0.30.0", "libp2p-bootstrap": "^0.12.1", "libp2p-crypto": "^0.18.0", - "libp2p-floodsub": "libp2p/js-libp2p-floodsub#chore/use-libp2p0.30", - "libp2p-gossipsub": "ChainSafe/js-libp2p-gossipsub#chore/update-to-new-libp2p-interface-with-types", + "libp2p-floodsub": "^0.24.1", + "libp2p-gossipsub": "^0.8.0", "libp2p-kad-dht": "^0.20.1", "libp2p-mdns": "^0.15.0", "libp2p-mplex": "^0.10.0", diff --git a/packages/ipfs-daemon/package.json b/packages/ipfs-daemon/package.json index 2d2f83457d..8e808baa64 100644 --- a/packages/ipfs-daemon/package.json +++ b/packages/ipfs-daemon/package.json @@ -37,7 +37,7 @@ "ipfs-http-server": "^0.1.4", "ipfs-utils": "^5.0.0", "just-safe-set": "^2.1.0", - "libp2p": "^0.30.0-rc.2", + "libp2p": "^0.30.0", "libp2p-delegated-content-routing": "^0.8.0", "libp2p-delegated-peer-routing": "^0.8.0", "libp2p-webrtc-star": "^0.20.1", diff --git a/packages/ipfs/package.json b/packages/ipfs/package.json index c20c093a85..41cedf256d 100644 --- a/packages/ipfs/package.json +++ b/packages/ipfs/package.json @@ -51,7 +51,7 @@ "go-ipfs": "^0.7.0", "interface-ipfs-core": "^0.142.3", "ipfs-http-client": "^48.1.3", - "ipfs-interop": "ipfs/interop#chore/update-websockets", + "ipfs-interop": "^4.0.1", "ipfs-utils": "^5.0.0", "ipfsd-ctl": "^7.1.1", "iso-url": "^1.0.0", From ca38f19b5ccc9acd6d6660eebc59a98a3fa3c7cb Mon Sep 17 00:00:00 2001 From: Vasco Santos Date: Tue, 29 Dec 2020 10:41:01 +0000 Subject: [PATCH 14/14] chore: await hangup --- packages/ipfs-core/src/components/swarm/disconnect.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ipfs-core/src/components/swarm/disconnect.js b/packages/ipfs-core/src/components/swarm/disconnect.js index 6b4210c8bc..6e3c8ad0f7 100644 --- a/packages/ipfs-core/src/components/swarm/disconnect.js +++ b/packages/ipfs-core/src/components/swarm/disconnect.js @@ -16,7 +16,7 @@ module.exports = ({ network }) => { */ async function disconnect (addr, options) { const { libp2p } = await network.use(options) - return libp2p.hangUp(addr) + await libp2p.hangUp(addr) } return withTimeoutOption(disconnect)