Skip to content

Commit

Permalink
Merge branch 'master' into weboko/fleet-test
Browse files Browse the repository at this point in the history
  • Loading branch information
weboko authored Aug 2, 2023
2 parents 730d6df + af5d613 commit 78048f0
Show file tree
Hide file tree
Showing 24 changed files with 215 additions and 98 deletions.
20 changes: 10 additions & 10 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"packages/utils": "0.0.9",
"packages/utils": "0.0.10",
"packages/proto": "0.0.5",
"packages/interfaces": "0.0.16",
"packages/message-hash": "0.1.5",
"packages/enr": "0.0.15",
"packages/peer-exchange": "0.0.14",
"packages/core": "0.0.21",
"packages/dns-discovery": "0.0.15",
"packages/message-encryption": "0.0.19",
"packages/relay": "0.0.4",
"packages/sdk": "0.0.17"
"packages/interfaces": "0.0.17",
"packages/message-hash": "0.1.6",
"packages/enr": "0.0.16",
"packages/peer-exchange": "0.0.15",
"packages/core": "0.0.22",
"packages/dns-discovery": "0.0.16",
"packages/message-encryption": "0.0.20",
"packages/relay": "0.0.5",
"packages/sdk": "0.0.18"
}
21 changes: 21 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@ All notable changes to this project will be documented in this file.
The file is maintained by [Release Please](https://github.com/googleapis/release-please) based on [Conventional Commits](https://www.conventionalcommits.org) specification,
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.0.22](https://github.com/waku-org/js-waku/compare/core-v0.0.21...core-v0.0.22) (2023-08-02)


### Features

* ConnectionManager extends EventEmitter & exposed on the Waku interface (& minor improvements) ([#1447](https://github.com/waku-org/js-waku/issues/1447)) ([0b8936f](https://github.com/waku-org/js-waku/commit/0b8936f1f1ad33f6cb90eb88d027a19e787ae7a2))


### Bug Fixes

* Improve connection manager error handling + edge cases ([#1450](https://github.com/waku-org/js-waku/issues/1450)) ([785df52](https://github.com/waku-org/js-waku/commit/785df528fe6e5010a61391994e222028dbc4e4c5))
* Refactors message decoding to abort as soon as a suitable decoder found ([#1414](https://github.com/waku-org/js-waku/issues/1414)) ([30fcace](https://github.com/waku-org/js-waku/commit/30fcacea84d9aefbe71e7f4b48506a088f2e1bf8))


### Dependencies

* The following workspace dependencies were updated
* dependencies
* @waku/interfaces bumped from 0.0.16 to 0.0.17
* @waku/utils bumped from 0.0.9 to 0.0.10

## [0.0.21](https://github.com/waku-org/js-waku/compare/core-v0.0.20...core-v0.0.21) (2023-07-26)


Expand Down
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@waku/core",
"version": "0.0.21",
"version": "0.0.22",
"description": "TypeScript implementation of the Waku v2 protocol",
"types": "./dist/index.d.ts",
"module": "./dist/index.js",
Expand Down Expand Up @@ -73,9 +73,9 @@
},
"dependencies": {
"@noble/hashes": "^1.3.0",
"@waku/interfaces": "0.0.16",
"@waku/interfaces": "0.0.17",
"@waku/proto": "0.0.5",
"@waku/utils": "0.0.9",
"@waku/utils": "0.0.10",
"debug": "^4.3.4",
"it-all": "^3.0.2",
"it-length-prefixed": "^9.0.1",
Expand Down
109 changes: 58 additions & 51 deletions packages/core/src/lib/connection_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,51 +174,67 @@ export class ConnectionManager
private async dialPeer(peerId: PeerId): Promise<void> {
this.currentActiveDialCount += 1;
let dialAttempt = 0;
while (dialAttempt <= this.options.maxDialAttemptsForPeer) {
while (dialAttempt < this.options.maxDialAttemptsForPeer) {
try {
log(`Dialing peer ${peerId.toString()}`);
log(`Dialing peer ${peerId.toString()} on attempt ${dialAttempt + 1}`);
await this.libp2p.dial(peerId);

const tags = await this.getTagNamesForPeer(peerId);
// add tag to connection describing discovery mechanism
// don't add duplicate tags
this.libp2p
.getConnections(peerId)
.forEach(
(conn) => (conn.tags = Array.from(new Set([...conn.tags, ...tags])))
);
this.libp2p.getConnections(peerId).forEach((conn) => {
conn.tags = Array.from(new Set([...conn.tags, ...tags]));
});

this.dialAttemptsForPeer.delete(peerId.toString());
return;
} catch (e) {
const error = e as AggregateError;

// Dialing succeeded, break the loop
break;
} catch (error) {
if (error instanceof AggregateError) {
// Handle AggregateError
log(`Error dialing peer ${peerId.toString()} - ${error.errors}`);
} else {
// Handle generic error
log(
`Error dialing peer ${peerId.toString()} - ${
(error as any).message

Check warning on line 200 in packages/core/src/lib/connection_manager.ts

View workflow job for this annotation

GitHub Actions / check

Unexpected any. Specify a different type

Check warning on line 200 in packages/core/src/lib/connection_manager.ts

View workflow job for this annotation

GitHub Actions / proto

Unexpected any. Specify a different type
}`
);
}
this.dialErrorsForPeer.set(peerId.toString(), error);
log(`Error dialing peer ${peerId.toString()} - ${error.errors}`);

dialAttempt = this.dialAttemptsForPeer.get(peerId.toString()) ?? 1;
this.dialAttemptsForPeer.set(peerId.toString(), dialAttempt + 1);

if (dialAttempt <= this.options.maxDialAttemptsForPeer) {
log(`Reattempting dial (${dialAttempt})`);
}
dialAttempt++;
this.dialAttemptsForPeer.set(peerId.toString(), dialAttempt);
}
}

try {
log(
`Deleting undialable peer ${peerId.toString()} from peer store. Error: ${JSON.stringify(
this.dialErrorsForPeer.get(peerId.toString()).errors[0]
)}
}`
);
this.dialErrorsForPeer.delete(peerId.toString());
return await this.libp2p.peerStore.delete(peerId);
} catch (error) {
throw `Error deleting undialable peer ${peerId.toString()} from peer store - ${error}`;
} finally {
this.currentActiveDialCount -= 1;
this.processDialQueue();
// Always decrease the active dial count and process the dial queue
this.currentActiveDialCount--;
this.processDialQueue();

// If max dial attempts reached and dialing failed, delete the peer
if (dialAttempt === this.options.maxDialAttemptsForPeer) {
try {
const error = this.dialErrorsForPeer.get(peerId.toString());

let errorMessage;
if (error instanceof AggregateError) {
errorMessage = JSON.stringify(error.errors[0]);
} else {
errorMessage = error.message;
}

log(
`Deleting undialable peer ${peerId.toString()} from peer store. Error: ${errorMessage}`
);

this.dialErrorsForPeer.delete(peerId.toString());
await this.libp2p.peerStore.delete(peerId);
} catch (error) {
throw new Error(
`Error deleting undialable peer ${peerId.toString()} from peer store - ${error}`
);
}
}
}

Expand Down Expand Up @@ -302,25 +318,16 @@ export class ConnectionManager
Tags.BOOTSTRAP
);

if (isBootstrap) {
this.dispatchEvent(
new CustomEvent<PeerId>(
EPeersByDiscoveryEvents.PEER_DISCOVERY_BOOTSTRAP,
{
detail: peerId,
}
)
);
} else {
this.dispatchEvent(
new CustomEvent<PeerId>(
EPeersByDiscoveryEvents.PEER_DISCOVERY_PEER_EXCHANGE,
{
detail: peerId,
}
)
);
}
this.dispatchEvent(
new CustomEvent<PeerId>(
isBootstrap
? EPeersByDiscoveryEvents.PEER_DISCOVERY_BOOTSTRAP
: EPeersByDiscoveryEvents.PEER_DISCOVERY_PEER_EXCHANGE,
{
detail: peerId,
}
)
);

try {
await this.attemptDial(peerId);
Expand Down
17 changes: 17 additions & 0 deletions packages/dns-discovery/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* devDependencies
* @waku/interfaces bumped from 0.0.13 to 0.0.14

## [0.0.16](https://github.com/waku-org/js-waku/compare/dns-discovery-v0.0.15...dns-discovery-v0.0.16) (2023-08-02)


### Bug Fixes

* Improve connection manager error handling + edge cases ([#1450](https://github.com/waku-org/js-waku/issues/1450)) ([785df52](https://github.com/waku-org/js-waku/commit/785df528fe6e5010a61391994e222028dbc4e4c5))


### Dependencies

* The following workspace dependencies were updated
* dependencies
* @waku/enr bumped from 0.0.15 to 0.0.16
* @waku/utils bumped from 0.0.9 to 0.0.10
* devDependencies
* @waku/interfaces bumped from 0.0.16 to 0.0.17

## [0.0.15](https://github.com/waku-org/js-waku/compare/dns-discovery-v0.0.14...dns-discovery-v0.0.15) (2023-07-26)


Expand Down
8 changes: 4 additions & 4 deletions packages/dns-discovery/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@waku/dns-discovery",
"version": "0.0.15",
"version": "0.0.16",
"description": "DNS Peer Discovery (EIP-1459)",
"types": "./dist/index.d.ts",
"module": "./dist/index.js",
Expand Down Expand Up @@ -53,8 +53,8 @@
"dependencies": {
"@libp2p/interface-peer-discovery": "^2.0.0",
"@libp2p/interfaces": "^3.3.2",
"@waku/enr": "0.0.15",
"@waku/utils": "0.0.9",
"@waku/enr": "0.0.16",
"@waku/utils": "0.0.10",
"debug": "^4.3.4",
"dns-query": "^0.11.2",
"hi-base32": "^0.5.1",
Expand All @@ -71,7 +71,7 @@
"@rollup/plugin-node-resolve": "^15.0.2",
"@types/chai": "^4.3.4",
"@waku/build-utils": "*",
"@waku/interfaces": "0.0.16",
"@waku/interfaces": "0.0.17",
"chai": "^4.3.7",
"cspell": "^6.31.1",
"karma": "^6.4.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/dns-discovery/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const enrTree = {

const DEFAULT_BOOTSTRAP_TAG_NAME = "bootstrap";
const DEFAULT_BOOTSTRAP_TAG_VALUE = 50;
const DEFAULT_BOOTSTRAP_TAG_TTL = 120000;
const DEFAULT_BOOTSTRAP_TAG_TTL = 100_000_000;

export interface DnsDiscoveryComponents {
peerStore: PeerStore;
Expand Down
8 changes: 8 additions & 0 deletions packages/enr/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* devDependencies
* @waku/interfaces bumped from 0.0.14 to 0.0.15

### Dependencies

* The following workspace dependencies were updated
* dependencies
* @waku/utils bumped from 0.0.9 to 0.0.10
* devDependencies
* @waku/interfaces bumped from 0.0.16 to 0.0.17

## [0.0.15](https://github.com/waku-org/js-waku/compare/enr-v0.0.14...enr-v0.0.15) (2023-07-26)


Expand Down
6 changes: 3 additions & 3 deletions packages/enr/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@waku/enr",
"version": "0.0.15",
"version": "0.0.16",
"description": "ENR (EIP-778) for Waku",
"types": "./dist/index.d.ts",
"module": "./dist/index.js",
Expand Down Expand Up @@ -56,7 +56,7 @@
"@libp2p/peer-id": "^2.0.4",
"@multiformats/multiaddr": "^12.0.0",
"@noble/secp256k1": "^1.7.1",
"@waku/utils": "0.0.9",
"@waku/utils": "0.0.10",
"debug": "^4.3.4",
"js-sha3": "^0.8.0"
},
Expand All @@ -70,7 +70,7 @@
"@types/chai": "^4.3.4",
"@types/mocha": "^10.0.1",
"@waku/build-utils": "*",
"@waku/interfaces": "0.0.16",
"@waku/interfaces": "0.0.17",
"chai": "^4.3.7",
"cspell": "^6.31.1",
"karma": "^6.4.1",
Expand Down
7 changes: 7 additions & 0 deletions packages/interfaces/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The file is maintained by [Release Please](https://github.com/googleapis/release-please) based on [Conventional Commits](https://www.conventionalcommits.org) specification,
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.0.17](https://github.com/waku-org/js-waku/compare/interfaces-v0.0.16...interfaces-v0.0.17) (2023-08-02)


### Features

* ConnectionManager extends EventEmitter & exposed on the Waku interface (& minor improvements) ([#1447](https://github.com/waku-org/js-waku/issues/1447)) ([0b8936f](https://github.com/waku-org/js-waku/commit/0b8936f1f1ad33f6cb90eb88d027a19e787ae7a2))

## [0.0.16](https://github.com/waku-org/js-waku/compare/interfaces-v0.0.15...interfaces-v0.0.16) (2023-07-26)


Expand Down
2 changes: 1 addition & 1 deletion packages/interfaces/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@waku/interfaces",
"version": "0.0.16",
"version": "0.0.17",
"description": "Definition of Waku interfaces",
"types": "./dist/index.d.ts",
"module": "./dist/index.js",
Expand Down
8 changes: 8 additions & 0 deletions packages/message-encryption/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* @waku/interfaces bumped from 0.0.14 to 0.0.15
* @waku/utils bumped from 0.0.7 to 0.0.8

### Dependencies

* The following workspace dependencies were updated
* dependencies
* @waku/core bumped from 0.0.21 to 0.0.22
* @waku/interfaces bumped from 0.0.16 to 0.0.17
* @waku/utils bumped from 0.0.9 to 0.0.10

## [0.0.19](https://github.com/waku-org/js-waku/compare/message-encryption-v0.0.18...message-encryption-v0.0.19) (2023-07-26)


Expand Down
8 changes: 4 additions & 4 deletions packages/message-encryption/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@waku/message-encryption",
"version": "0.0.19",
"version": "0.0.20",
"description": "Waku Message Payload Encryption",
"types": "./dist/index.d.ts",
"module": "./dist/index.js",
Expand Down Expand Up @@ -72,10 +72,10 @@
},
"dependencies": {
"@noble/secp256k1": "^1.7.1",
"@waku/core": "0.0.21",
"@waku/interfaces": "0.0.16",
"@waku/core": "0.0.22",
"@waku/interfaces": "0.0.17",
"@waku/proto": "0.0.5",
"@waku/utils": "0.0.9",
"@waku/utils": "0.0.10",
"debug": "^4.3.4",
"js-sha3": "^0.8.0"
},
Expand Down
8 changes: 8 additions & 0 deletions packages/message-hash/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
* devDependencies
* @waku/interfaces bumped from 0.0.15 to 0.0.16

### Dependencies

* The following workspace dependencies were updated
* dependencies
* @waku/utils bumped from 0.0.9 to 0.0.10
* devDependencies
* @waku/interfaces bumped from 0.0.16 to 0.0.17

## [0.1.2](https://github.com/waku-org/js-waku/compare/message-hash-v0.1.1...message-hash-v0.1.2) (2023-05-18)


Expand Down
Loading

0 comments on commit 78048f0

Please sign in to comment.