diff --git a/README.md b/README.md index 30a5aae349..8e8bbdd60e 100644 --- a/README.md +++ b/README.md @@ -195,7 +195,6 @@ List of packages currently in existence for libp2p | [`@chainsafe/libp2p-noise`](//github.com/ChainSafe/js-libp2p-noise) | [![npm](https://img.shields.io/npm/v/%40chainsafe%2Flibp2p-noise.svg?maxAge=86400&style=flat-square)](//github.com/ChainSafe/js-libp2p-noise/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40chainsafe%2Flibp2p-noise?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40chainsafe%2Flibp2p-noise) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/ChainSafe/js-libp2p-noise/js-test-and-release.yml?branch=master&label=ci&style=flat-square)](//github.com/ChainSafe/js-libp2p-noise/actions?query=branch%3Amaster+workflow%3Aci+) | [![codecov](https://codecov.io/gh/ChainSafe/js-libp2p-noise/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/ChainSafe/js-libp2p-noise) | | [`@libp2p/plaintext`](//github.com/libp2p/js-libp2p/tree/main/packages/connection-encrypter-plaintext) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fplaintext.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/connection-encrypter-plaintext/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fplaintext?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40libp2p%2Fplaintext) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/connection-encrypter-plaintext/main.yml?branch=main&label=ci&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/connection-encrypter-plaintext/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/connection-encrypter-plaintext/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/connection-encrypter-plaintext) | | **stream multiplexers** | -| [`@libp2p/mplex`](//github.com/libp2p/js-libp2p/tree/main/packages/stream-multiplexer-mplex) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fmplex.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/stream-multiplexer-mplex/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fmplex?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40libp2p%2Fmplex) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/stream-multiplexer-mplex/main.yml?branch=main&label=ci&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/stream-multiplexer-mplex/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/stream-multiplexer-mplex/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/stream-multiplexer-mplex) | | [`@chainsafe/libp2p-yamux`](//github.com/ChainSafe/js-libp2p-yamux) | [![npm](https://img.shields.io/npm/v/%40chainsafe%2Flibp2p-yamux.svg?maxAge=86400&style=flat-square)](//github.com/ChainSafe/js-libp2p-yamux/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40chainsafe%2Flibp2p-yamux?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40chainsafe%2Flibp2p-yamux) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/ChainSafe/js-libp2p-yamux/js-test-and-release.yml?branch=master&label=ci&style=flat-square)](//github.com/ChainSafe/js-libp2p-yamux/actions?query=branch%3Amaster+workflow%3Aci+) | [![codecov](https://codecov.io/gh/ChainSafe/js-libp2p-yamux/branch/master/graph/badge.svg?style=flat-square)](https://codecov.io/gh/ChainSafe/js-libp2p-yamux) | | **peer discovery** | | [`@libp2p/bootstrap`](//github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-bootstrap) | [![npm](https://img.shields.io/npm/v/%40libp2p%2Fbootstrap.svg?maxAge=86400&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-bootstrap/releases) | [![Deps](https://img.shields.io/librariesio/release/npm/%40libp2p%2Fbootstrap?logo=Libraries.io&logoColor=white&style=flat-square)](//libraries.io/npm/%40libp2p%2Fbootstrap) | [![GitHub CI](https://img.shields.io/github/actions/workflow/status/libp2p/js-libp2p/tree/main/packages/peer-discovery-bootstrap/main.yml?branch=main&label=ci&style=flat-square)](//github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-bootstrap/actions?query=branch%3Amain+workflow%3Aci+) | [![codecov](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/peer-discovery-bootstrap/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/libp2p/js-libp2p/tree/main/packages/peer-discovery-bootstrap) | diff --git a/doc/ARCHITECTURE.md b/doc/ARCHITECTURE.md index 59489f3f42..8aa13ccefe 100644 --- a/doc/ARCHITECTURE.md +++ b/doc/ARCHITECTURE.md @@ -3,10 +3,10 @@ js-libp2p is comprised of a number of components that work together to provide functionality such as dailling peers, managing connections, registering protocols, storing information about peers and much more. This document aims to provide a high level overview of the components and how they interact with each other. - [Libp2p Architecture](#libp2p-architecture) - - [Component Diagram](#component-diagram) - - [Sequence Diagrams](#sequence-diagrams) - - [Dialing a Peer](#dialing-a-peer) - - [Opening a stream on a connection](#opening-a-stream-on-a-connection) + - [Component Diagram](#component-diagram) + - [Sequence Diagrams](#sequence-diagrams) + - [Dialing a Peer](#dialing-a-peer) + - [Opening a stream on a connection](#opening-a-stream-on-a-connection) ## Component Diagram @@ -57,7 +57,6 @@ flowchart TB subgraph Multiplexer[Stream Multiplexers] direction TB Yamux - Mplex end Multiplexer ~~~ Encryption ~~~ Transports diff --git a/doc/CONFIGURATION.md b/doc/CONFIGURATION.md index acfae869eb..5e6511c246 100644 --- a/doc/CONFIGURATION.md +++ b/doc/CONFIGURATION.md @@ -89,7 +89,6 @@ If you want to know more about libp2p transports, you should read the following Some available stream multiplexers are: -- [@libp2p/mplex](https://github.com/libp2p/js-libp2p/tree/main/packages/stream-multiplexer-mplex) - [@chainsafe/libp2p-yamux](https://github.com/chainsafe/js-libp2p-yamux) Some transports such as WebRTC and WebTransport come with their own built-in stream multiplexing capabilities. @@ -100,7 +99,7 @@ If you want to know more about libp2p stream multiplexing, you should read the f - https://docs.libp2p.io/concepts/stream-multiplexing - https://github.com/libp2p/specs/tree/master/connections -- https://github.com/libp2p/specs/tree/master/mplex +- https://github.com/libp2p/specs/tree/master/yamux #### Muxer Selection @@ -239,7 +238,7 @@ It's important to note that some services depend on others in order to function // Creating a libp2p node with: // listen on tcp ports 9001 and 9002 on all interfaces // transport: websockets + tcp -// stream-muxing: mplex +// stream-muxing: yamux // crypto-channel: noise // discovery: multicast-dns // dht: kad-dht @@ -248,7 +247,6 @@ It's important to note that some services depend on others in order to function import { createLibp2p } from 'libp2p' import { tcp } from '@libp2p/tcp' import { webSockets } from '@libp2p/websockets' -import { mplex } from '@libp2p/mplex' import { noise } from '@chainsafe/libp2p-noise' import { mdns } from '@libp2p/mdns' import { kadDHT } from '@libp2p/kad-dht' @@ -266,7 +264,7 @@ const node = await createLibp2p({ tcp(), webSockets() ], - streamMuxers: [yamux(), mplex()], + streamMuxers: [yamux()], connectionEncrypters: [noise()], peerDiscovery: [MulticastDNS], services: { @@ -281,7 +279,6 @@ const node = await createLibp2p({ ```js import { createLibp2p } from 'libp2p' import { tcp } from '@libp2p/tcp' -import { mplex } from '@libp2p/mplex' import { yamux } from '@chainsafe/libp2p-yamux' import { noise } from '@chainsafe/libp2p-noise' import { mdns } from '@libp2p/mdns' @@ -289,7 +286,7 @@ import { bootstrap } from '@libp2p/bootstrap' const node = await createLibp2p({ transports: [tcp()], - streamMuxers: [yamux(), mplex()], + streamMuxers: [yamux()], connectionEncrypters: [noise()], peerDiscovery: [ mdns({ @@ -321,7 +318,6 @@ Potential methods for discovering peers include: ```js import { createLibp2p } from 'libp2p' import { tcp } from '@libp2p/tcp' -import { mplex } from '@libp2p/mplex' import { yamux } from '@chainsafe/libp2p-yamux' import { noise } from '@chainsafe/libp2p-noise' import { gossipsub } from 'libp2p-gossipsub' @@ -333,8 +329,7 @@ const node = await createLibp2p({ tcp() ], streamMuxers: [ - yamux(), - mplex() + yamux() ], connectionEncrypters: [ noise() @@ -360,7 +355,6 @@ The kadDHT service requires the Identify service to discover other peers that su ```js import { createLibp2p } from 'libp2p' import { tcp } from '@libp2p/tcp' -import { mplex } from '@libp2p/mplex' import { noise } from '@chainsafe/libp2p-noise' import { kadDHT } from '@libp2p/kad-dht' import { identify } from '@libp2p/identify' @@ -370,8 +364,7 @@ const node = await createLibp2p({ tcp() ], streamMuxers: [ - yamux(), - mplex() + yamux() ], connectionEncrypters: [ noise() @@ -391,7 +384,6 @@ const node = await createLibp2p({ ```js import { createLibp2p } from 'libp2p' import { tcp } from '@libp2p/tcp' -import { mplex } from '@libp2p/mplex' import { yamux } from '@chainsafe/libp2p-yamux' import { noise } from '@chainsafe/libp2p-noise' import { create as ipfsHttpClient } from 'ipfs-http-client' @@ -418,8 +410,7 @@ const node = await createLibp2p({ tcp() ], streamMuxers: [ - yamux(), - mplex() + yamux() ], connectionEncrypters: [ noise() @@ -447,7 +438,6 @@ Thus, it is recommended to include the Identify service in your services configu ```js import { createLibp2p } from 'libp2p' import { tcp } from '@libp2p/tcp' -import { mplex } from '@libp2p/mplex' import { yamux } from '@chainsafe/libp2p-yamux' import { noise } from '@chainsafe/libp2p-noise' import { circuitRelayTransport, circuitRelayServer } from '@libp2p/circuit-relay-v2' @@ -463,8 +453,7 @@ const node = await createLibp2p({ }) ], streamMuxers: [ - yamux(), - mplex() + yamux() ], connectionEncrypters: [ noise() @@ -505,7 +494,6 @@ In this configuration the libp2p node will search the network for one relay with ```js import { createLibp2p } from 'libp2p' import { tcp } from '@libp2p/tcp' -import { mplex } from '@libp2p/mplex' import { yamux } from '@chainsafe/libp2p-yamux' import { noise } from '@chainsafe/libp2p-noise' import { circuitRelayTransport } from '@libp2p/circuit-relay-v2' @@ -518,8 +506,7 @@ const node = await createLibp2p({ }) ], streamMuxers: [ - yamux(), - mplex() + yamux() ], connectionEncrypters: [ noise() @@ -534,7 +521,6 @@ In this configuration the libp2p node is a circuit relay client which connects t ```js import { createLibp2p } from 'libp2p' import { tcp } from '@libp2p/tcp' -import { mplex } from '@libp2p/mplex' import { noise } from '@chainsafe/libp2p-noise' import { circuitRelayTransport } from '@libp2p/circuit-relay-v2' @@ -549,8 +535,7 @@ const node = await createLibp2p({ ] }, streamMuxers: [ - yamux(), - mplex() + yamux() ], connectionEncrypters: [ noise() @@ -572,7 +557,6 @@ The keychain will store keys encrypted in the datastore which default is an in m ```js import { createLibp2p } from 'libp2p' import { tcp } from '@libp2p/tcp' -import { mplex } from '@libp2p/mplex' import { yamux } from '@chainsafe/libp2p-yamux' import { noise } from '@chainsafe/libp2p-noise' import { FsDatastore } from 'datastore-fs'; @@ -586,8 +570,7 @@ const node = await createLibp2p({ tcp() ], streamMuxers: [ - yamux(), - mplex() + yamux() ], connectionEncrypters: [ noise() @@ -610,7 +593,6 @@ See the [API docs](https://libp2p.github.io/js-libp2p/interfaces/index._internal ```js import { createLibp2p } from 'libp2p' import { tcp } from '@libp2p/tcp' -import { mplex } from '@libp2p/mplex' import { yamux } from '@chainsafe/libp2p-yamux' import { noise } from '@chainsafe/libp2p-noise' @@ -619,8 +601,7 @@ const node = await createLibp2p({ tcp() ], streamMuxers: [ - yamux(), - mplex() + yamux() ], connectionEncrypters: [ noise() @@ -759,7 +740,6 @@ The Transport Manager is responsible for managing the libp2p transports life cyc ```js import { createLibp2p } from 'libp2p' import { tcp } from '@libp2p/tcp' -import { mplex } from '@libp2p/mplex' import { yamux } from '@chainsafe/libp2p-yamux' import { noise } from '@chainsafe/libp2p-noise' import { FaultTolerance } from '@libp2p/interface-transport' @@ -769,8 +749,7 @@ const node = await createLibp2p({ tcp() ], streamMuxers: [ - yamux(), - mplex() + yamux() ], connectionEncrypters: [ noise() @@ -798,7 +777,6 @@ The below configuration example shows how the metrics should be configured. Asid ```js import { createLibp2p } from 'libp2p' import { tcp } from '@libp2p/tcp' -import { mplex } from '@libp2p/mplex' import { yamux } from '@chainsafe/libp2p-yamux' import { noise } from '@chainsafe/libp2p-noise' @@ -807,8 +785,7 @@ const node = await createLibp2p({ tcp() ], streamMuxers: [ - yamux(), - mplex() + yamux() ], connectionEncrypters: [ noise() @@ -843,7 +820,6 @@ The below configuration example shows how the PeerStore should be configured. As ```js import { createLibp2p } from 'libp2p' import { tcp } from '@libp2p/tcp' -import { mplex } from '@libp2p/mplex' import { yamux } from '@chainsafe/libp2p-yamux' import { noise } from '@chainsafe/libp2p-noise' import { LevelDatastore } from 'datastore-level' @@ -857,8 +833,7 @@ const node = await createLibp2p({ tcp() ], streamMuxers: [ - yamux(), - mplex() + yamux() ], connectionEncrypters: [ noise() diff --git a/doc/GETTING_STARTED.md b/doc/GETTING_STARTED.md index 55972424ad..1d41b084e7 100644 --- a/doc/GETTING_STARTED.md +++ b/doc/GETTING_STARTED.md @@ -148,7 +148,7 @@ If you want to know more about libp2p stream multiplexing, you should read the f - https://docs.libp2p.io/concepts/stream-multiplexing - https://github.com/libp2p/specs/tree/master/connections -- https://github.com/libp2p/specs/tree/master/mplex +- https://github.com/libp2p/specs/tree/master/yamux #### Running Libp2p diff --git a/doc/LIMITS.md b/doc/LIMITS.md index d60f442e1a..7505384da9 100644 --- a/doc/LIMITS.md +++ b/doc/LIMITS.md @@ -10,7 +10,6 @@ This is important for [DoS](https://en.wikipedia.org/wiki/Denial-of-service_atta - [Closing connections](#closing-connections) - [Inbound connection threshold](#inbound-connection-threshold) - [Stream limits](#stream-limits) - - [Mplex](#mplex) - [Yamux](#yamux) - [Protocol limits](#protocol-limits) - [Transport specific limits](#transport-specific-limits) @@ -101,50 +100,6 @@ libp2p stream multiplexers impose limits on the amount of streams that can be op These settings are done on a per-muxer basis, please see the README of the relevant muxer you are using. -### Mplex - -[@libp2p/mplex](https://github.com/libp2p/js-libp2p/tree/main/packages/stream-multiplexer-mplex) supports the following. - -All fields are optional. The default values are defined in [@libp2p/mplex/src/mplex.ts](https://github.com/libp2p/js-libp2p/blob/main/packages/stream-multiplexer-mplex/src/mplex.ts) - please see that file for the current values. - -```TypeScript -import { createLibp2p } from 'libp2p' -import { mplex } from '@libp2p/mplex' - -const node = await createLibp2p({ - streamMuxers: [ - mplex({ - /** - * The total number of inbound protocol streams that can be opened on a given connection - */ - maxInboundStreams: 100, - - /** - * The total number of outbound protocol streams that can be opened on a given connection - */ - maxOutboundStreams: 100, - - /** - * How much incoming data in bytes to buffer while attempting to parse messages - peers sending many small messages in batches may cause this buffer to grow - */ - maxUnprocessedMessageQueueSize: 50, - - /** - * How much message data in bytes to buffer after parsing - slow stream consumers may cause this buffer to grow - */ - maxStreamBufferSize: 20, - - /** - * Mplex does not support backpressure so to protect ourselves, if `maxInboundStreams` is - * hit and the remote opens more than this many streams per second, close the connection - */ - disconnectThreshold: 20, - }), - ], -}); - -``` - ### Yamux [@chainsafe/libp2p-yamux](https://github.com/Chainsafe/js-libp2p-yamux) supports the following. diff --git a/interop/chromium-version.json b/interop/chromium-version.json index e67e005804..a1301932cb 100644 --- a/interop/chromium-version.json +++ b/interop/chromium-version.json @@ -17,5 +17,5 @@ } ], "secureChannels": ["noise"], - "muxers": ["mplex", "yamux"] + "muxers": ["yamux", "mplex"] } diff --git a/interop/webkit-version.json b/interop/webkit-version.json index 04cfbd0f04..dc6d817f50 100644 --- a/interop/webkit-version.json +++ b/interop/webkit-version.json @@ -6,7 +6,7 @@ "noise" ], "muxers": [ - "mplex", - "yamux" + "yamux", + "mplex" ] } \ No newline at end of file diff --git a/packages/libp2p/package-list.json b/packages/libp2p/package-list.json index f466d36104..80fb134954 100644 --- a/packages/libp2p/package-list.json +++ b/packages/libp2p/package-list.json @@ -22,7 +22,6 @@ ["libp2p/js-libp2p/tree/main/packages/connection-encrypter-plaintext", "@libp2p/plaintext", "main", "main.yml"], "stream multiplexers", - ["libp2p/js-libp2p/tree/main/packages/stream-multiplexer-mplex", "@libp2p/mplex", "main", "main.yml"], ["ChainSafe/js-libp2p-yamux", "@chainsafe/libp2p-yamux", "master", "js-test-and-release.yml"], "peer discovery", diff --git a/packages/protocol-perf/README.md b/packages/protocol-perf/README.md index af3924ced3..872319f368 100644 --- a/packages/protocol-perf/README.md +++ b/packages/protocol-perf/README.md @@ -31,7 +31,6 @@ The PerfService implements the [perf protocol](https://github.com/libp2p/specs/b ```typescript import { noise } from '@chainsafe/libp2p-noise' import { yamux } from '@chainsafe/libp2p-yamux' -import { mplex } from '@libp2p/mplex' import { tcp } from '@libp2p/tcp' import { createLibp2p, type Libp2p } from 'libp2p' import { plaintext } from '@libp2p/plaintext' @@ -55,7 +54,7 @@ async function createNode (): Promise> { noise(), plaintext() ], streamMuxers: [ - yamux(), mplex() + yamux() ], services: { perf: perf() diff --git a/packages/protocol-perf/src/index.ts b/packages/protocol-perf/src/index.ts index 5c3c9b2d17..a9d117508b 100644 --- a/packages/protocol-perf/src/index.ts +++ b/packages/protocol-perf/src/index.ts @@ -8,7 +8,6 @@ * ```typescript * import { noise } from '@chainsafe/libp2p-noise' * import { yamux } from '@chainsafe/libp2p-yamux' - * import { mplex } from '@libp2p/mplex' * import { tcp } from '@libp2p/tcp' * import { createLibp2p, type Libp2p } from 'libp2p' * import { plaintext } from '@libp2p/plaintext' @@ -32,7 +31,7 @@ * noise(), plaintext() * ], * streamMuxers: [ - * yamux(), mplex() + * yamux() * ], * services: { * perf: perf() diff --git a/packages/transport-webtransport/.aegir.js b/packages/transport-webtransport/.aegir.js index 4fa1f3a589..fe79d0c6a6 100644 --- a/packages/transport-webtransport/.aegir.js +++ b/packages/transport-webtransport/.aegir.js @@ -38,7 +38,7 @@ async function createGoLibp2p () { '-noise=true', '-dhtServer', '-relay', - '-muxer=mplex', + '-muxer=yamux', '-echo' ], { reject: false,