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

fix: Update libp2p deps #419

Merged
merged 14 commits into from
Jan 19, 2024
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
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2022,
Expand Down
19 changes: 10 additions & 9 deletions packages/core/js-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,29 @@
"author": "Fluence Labs",
"license": "Apache-2.0",
"dependencies": {
"@libp2p/utils": "5.2.2",
"@chainsafe/libp2p-noise": "14.0.0",
"@chainsafe/libp2p-yamux": "6.0.1",
"@fluencelabs/avm": "0.55.0",
"@fluencelabs/interfaces": "workspace:*",
"@fluencelabs/js-client-isomorphic": "workspace:*",
"@fluencelabs/marine-worker": "0.5.1",
"@fluencelabs/threads": "^2.0.0",
"@libp2p/crypto": "3.0.1",
"@libp2p/identify": "1.0.4",
"@libp2p/interface": "1.0.1",
"@libp2p/peer-id": "4.0.1",
"@libp2p/peer-id-factory": "4.0.0",
"@libp2p/ping": "1.0.4",
"@libp2p/websockets": "8.0.5",
"@multiformats/multiaddr": "11.3.0",
"@libp2p/crypto": "4.0.1",
"@libp2p/identify": "1.0.11",
"@libp2p/interface": "1.1.2",
"@libp2p/peer-id": "4.0.5",
"@libp2p/peer-id-factory": "4.0.5",
"@libp2p/ping": "1.0.10",
"@libp2p/websockets": "8.0.12",
"@multiformats/multiaddr": "12.1.12",
"bs58": "5.0.0",
"debug": "4.3.4",
"it-length-prefixed": "9.0.3",
"it-map": "3.0.5",
"it-pipe": "3.0.1",
"js-base64": "3.7.5",
"libp2p": "1.0.7",
"libp2p": "1.2.0",
"multiformats": "11.0.1",
"rxjs": "7.5.5",
"uint8arrays": "4.0.3",
Expand Down
28 changes: 25 additions & 3 deletions packages/core/js-client/src/connection/RelayConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,23 @@ export interface RelayConnectionConfig {
maxOutboundStreams: number;
}

type DenyCondition = (ma: Multiaddr) => boolean;

const dockerNoxDenyCondition: DenyCondition = (ma) => {
const [routingProtocol] = ma.stringTuples();
const host = routingProtocol?.[1];

// Nox proposes 3 multiaddr to discover when used inside docker network,
// e.g.: [/dns/nox-1, /ip4/10.50.10.10, /ip4/127.0.0.1]
// First 2 of them are unreachable outside the docker network
// Libp2p cannot handle these scenarios correctly, creating interruptions which affect e2e tests execution.
return (
host === undefined || host.startsWith("nox-") || host.startsWith("10.50.10")
Copy link
Contributor

@shamsartem shamsartem Jan 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am understanding correctly that when this is true - then dialing this multiaddr is forbidden?
why specifically nox- and 10.50.10. Would be nice to leave the comment about that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should be a more general way to handle that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if non-available addresses returned in real life, not in tests?

);
};

const denyConditions = [dockerNoxDenyCondition];

/**
* Implementation for JS peers which connects to Fluence through relay node
*/
Expand Down Expand Up @@ -128,13 +145,18 @@ export class RelayConnection implements IConnection {
...(this.config.dialTimeoutMs !== undefined
? {
dialTimeout: this.config.dialTimeoutMs,
autoDialInterval: 0,
}
: {}),
},
connectionGater: {
// By default, this function forbids connections to private peers. For example multiaddr with ip 127.0.0.1 isn't allowed
denyDialMultiaddr: () => {
return Promise.resolve(false);
// By default, this function forbids connections to private peers. For example, multiaddr with ip 127.0.0.1 isn't allowed
denyDialMultiaddr: (ma: Multiaddr) => {
return Promise.resolve(
denyConditions.some((dc) => {
return dc(ma);
}),
);
},
},
services: {
Expand Down
Loading