Skip to content

Commit a8a1473

Browse files
author
Akim
authored
fix: Update libp2p deps (#419)
* Update libp2p packages * Try another libp2p version * Add test resolutions * Bump ver * remove override * redo removing override * fix * Fix * Fix * Fix * Fix * Deny connections from internal nox network * Fix eslint * Fix review
1 parent 5696e3b commit a8a1473

File tree

4 files changed

+3087
-3987
lines changed

4 files changed

+3087
-3987
lines changed

.eslintrc.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"root": true,
23
"parser": "@typescript-eslint/parser",
34
"parserOptions": {
45
"ecmaVersion": 2022,

packages/core/js-client/package.json

+10-9
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,29 @@
3030
"author": "Fluence Labs",
3131
"license": "Apache-2.0",
3232
"dependencies": {
33+
"@libp2p/utils": "5.2.2",
3334
"@chainsafe/libp2p-noise": "14.0.0",
3435
"@chainsafe/libp2p-yamux": "6.0.1",
3536
"@fluencelabs/avm": "0.55.0",
3637
"@fluencelabs/interfaces": "workspace:*",
3738
"@fluencelabs/js-client-isomorphic": "workspace:*",
3839
"@fluencelabs/marine-worker": "0.5.1",
3940
"@fluencelabs/threads": "^2.0.0",
40-
"@libp2p/crypto": "3.0.1",
41-
"@libp2p/identify": "1.0.4",
42-
"@libp2p/interface": "1.0.1",
43-
"@libp2p/peer-id": "4.0.1",
44-
"@libp2p/peer-id-factory": "4.0.0",
45-
"@libp2p/ping": "1.0.4",
46-
"@libp2p/websockets": "8.0.5",
47-
"@multiformats/multiaddr": "11.3.0",
41+
"@libp2p/crypto": "4.0.1",
42+
"@libp2p/identify": "1.0.11",
43+
"@libp2p/interface": "1.1.2",
44+
"@libp2p/peer-id": "4.0.5",
45+
"@libp2p/peer-id-factory": "4.0.5",
46+
"@libp2p/ping": "1.0.10",
47+
"@libp2p/websockets": "8.0.12",
48+
"@multiformats/multiaddr": "12.1.12",
4849
"bs58": "5.0.0",
4950
"debug": "4.3.4",
5051
"it-length-prefixed": "9.0.3",
5152
"it-map": "3.0.5",
5253
"it-pipe": "3.0.1",
5354
"js-base64": "3.7.5",
54-
"libp2p": "1.0.7",
55+
"libp2p": "1.2.0",
5556
"multiformats": "11.0.1",
5657
"rxjs": "7.5.5",
5758
"uint8arrays": "4.0.3",

packages/core/js-client/src/connection/RelayConnection.ts

+25-3
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,23 @@ export interface RelayConnectionConfig {
8080
maxOutboundStreams: number;
8181
}
8282

83+
type DenyCondition = (ma: Multiaddr) => boolean;
84+
85+
const dockerNoxDenyCondition: DenyCondition = (ma) => {
86+
const [routingProtocol] = ma.stringTuples();
87+
const host = routingProtocol?.[1];
88+
89+
// Nox proposes 3 multiaddr to discover when used inside docker network,
90+
// e.g.: [/dns/nox-1, /ip4/10.50.10.10, /ip4/127.0.0.1]
91+
// First 2 of them are unreachable outside the docker network
92+
// Libp2p cannot handle these scenarios correctly, creating interruptions which affect e2e tests execution.
93+
return (
94+
host === undefined || host.startsWith("nox-") || host.startsWith("10.50.10")
95+
);
96+
};
97+
98+
const denyConditions = [dockerNoxDenyCondition];
99+
83100
/**
84101
* Implementation for JS peers which connects to Fluence through relay node
85102
*/
@@ -128,13 +145,18 @@ export class RelayConnection implements IConnection {
128145
...(this.config.dialTimeoutMs !== undefined
129146
? {
130147
dialTimeout: this.config.dialTimeoutMs,
148+
autoDialInterval: 0,
131149
}
132150
: {}),
133151
},
134152
connectionGater: {
135-
// By default, this function forbids connections to private peers. For example multiaddr with ip 127.0.0.1 isn't allowed
136-
denyDialMultiaddr: () => {
137-
return Promise.resolve(false);
153+
// By default, this function forbids connections to private peers. For example, multiaddr with ip 127.0.0.1 isn't allowed
154+
denyDialMultiaddr: (ma: Multiaddr) => {
155+
return Promise.resolve(
156+
denyConditions.some((dc) => {
157+
return dc(ma);
158+
}),
159+
);
138160
},
139161
},
140162
services: {

0 commit comments

Comments
 (0)