-
Notifications
You must be signed in to change notification settings - Fork 445
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
chore: config typescript #904
Conversation
141f2b3
to
170ebfb
Compare
@@ -12,10 +12,10 @@ jobs: | |||
runs-on: ubuntu-latest | |||
steps: | |||
- uses: actions/checkout@v2 | |||
- run: yarn | |||
- run: yarn lint | |||
- run: npm install |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because yarn does not run prepare in the dependencies, libp2p-interfaces branch does not have types
concurrency = MAX_PARALLEL_DIALS, | ||
timeout = DIAL_TIMEOUT, | ||
perPeerLimit = MAX_PER_PEER_DIALS, | ||
maxParallelDials = MAX_PARALLEL_DIALS, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an internal breaking change. No one should be creating a dialer from here though. If we don't want to change this, we can create a separate typedef for core options and keep things as they were. However, keeping different names for the same things does not seem the best call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"No one should be" famous last words, how much confidence do you have in this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not make sense to require the Dialer
and use it as a specific piece. However, I agree and it will be safe to just ship a breaking change at this point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're adding types it's good to ship as a major anyway as there will almost certainly be some disruption.
* @property {number} [interval = 300e3] | ||
* @property {number} [timeout = 10e3] | ||
* | ||
* @typedef {Object} DhtOptions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably go away when we work on the configuration improvements project. We currently also specify the DHT options in https://github.com/libp2p/js-libp2p/blob/master/src/config.js#L52 , but in theory we should accept other DHT implementations and this might mean different configurations.
@@ -118,8 +130,8 @@ class Keychain { | |||
this.opts = mergeOptions(defaultOptions, options) | |||
|
|||
// Enforce NIST SP 800-132 | |||
if (this.opts.passPhrase && this.opts.passPhrase.length < 20) { | |||
throw new Error('passPhrase must be least 20 characters') | |||
if (this.opts.pass && this.opts.pass.length < 20) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same situation as in the Dialer
718bc3d
to
09fb967
Compare
09fb967
to
5e9c17d
Compare
5e9c17d
to
a3a2f15
Compare
754a7b9
to
59a40a3
Compare
@@ -362,7 +365,7 @@ class ConnectionManager extends EventEmitter { | |||
*/ | |||
_maybeDisconnectOne () { | |||
if (this._options.minConnections < this.connections.size) { | |||
const peerValues = Array.from(this._peerValues).sort(byPeerValue) | |||
const peerValues = Array.from(new Map([...this._peerValues.entries()].sort((a, b) => a[1] - b[1]))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a bug! this.peerValues
is a map<string, number>
for (const [, topology] of this.topologies) { | ||
topology.disconnect(connection.remotePeer, error) | ||
topology.disconnect(connection.remotePeer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
topology.disconnect only has one parameter
59a40a3
to
a18ed22
Compare
9c1d7da
to
78019a1
Compare
@@ -3,6 +3,7 @@ | |||
"version": "0.0.1", | |||
"private": true, | |||
"description": "", | |||
"main": "dist/index.html", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing it's a parcel thing ..?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parcel thing per their new updates
package.json
Outdated
@@ -127,22 +137,24 @@ | |||
"libp2p-delegated-peer-routing": "^0.8.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lots of ^
in here for <1 dependencies, seems over-optimistic about how this is going to get consumed into the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future, I would like that we get confidence in the APIs to ship v1 of all the things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My personal preference is to get to 1.0.0 ASAP (I've even set my default version to 1.0.0) because of the semver mess below 1 is just madness for signalling and ranges. The rules are basically "YOLO" which is useless for downstream users.
The problem with <0 is that your only signal for "breaking" changes is the minor version, but we've got ^
in here so there's no way to block breaking changes slipping in when we update one of these components. For <1, it's usually best to use ~
to account for the semver-minor bumps for breaking changes. Anyone using the current version of the library, even if they pin to the specific version, is going to get a newer, broken transitive dependency (like libp2p-delegated-peer-routing) when they do their next npm install
because we've shipped with ^
.
Alternatively, just don't treat 1.0.0 as anything special and ship it so we can use semver properly from there on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes,I totally agree on this. The team has had a lot of concerns about shipping 1.0.0, but we need to have a plan to get to this point. I think that as part of sudo work we should create a plan on where should we be to land 1.0.0 on everything
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please ship v1 of things!
Alternatively, just don't treat 1.0.0 as anything special and ship it so we can use semver properly from there on.
Yes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we will need to do this refactor as part of the maintenance work and will affect most of our repos. So, this might be a good opportunity to ship v1 of libp2p modules
src/insecure/plaintext.js
Outdated
const { Exchange, KeyType } = require('./proto') | ||
const protocol = '/plaintext/2.0.0' | ||
|
||
/** | ||
* @typedef {import('libp2p-interfaces/src/connection').Connection} Connection | ||
*/ | ||
|
||
/** | ||
* @param {{ id: Uint8Array; pubkey: { Type: any, Data: Uint8Array; }; }} exchange |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
potential candidate for a named type?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed by relying on protobufjs instead of protons, which offers us all the types for protobuf definitions
src/metrics/stats.js
Outdated
@@ -82,7 +82,7 @@ class Stats extends EventEmitter { | |||
/** | |||
* Returns a clone of the internal movingAverages | |||
* | |||
* @returns {Object} | |||
* @returns {typeof Object.assign} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weird, can you explain this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this, it can be inferred automatically. Good catch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the versioning strategy going to be with this one? seems like a lot of potential to break for users - aside from the Dialer options the types might introduce breakage?
bd10429
to
2bff878
Compare
My initial idea was to ship a patch, but with all the types changes, I feel it will be safer to release a breaking change. This will have consequences on the release chain of upcoming releases (pinned issues), but they will probably be affected either way. |
58bf45e
to
040495d
Compare
f436ef9
to
5159d23
Compare
src/index.js
Outdated
@@ -152,7 +192,9 @@ class Libp2p extends EventEmitter { | |||
this._discovery = new Map() // Discovery service instances/references | |||
|
|||
// Create the Connection Manager | |||
if (this._options.connectionManager.minPeers) { // Remove in 0.29 | |||
// @ts-ignore deprecated, needs to be removed on breaking change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are doing a breaking change, I am going to remove this!
c47f022
to
8e91334
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just some small nits.
@@ -12,11 +12,11 @@ jobs: | |||
runs-on: ubuntu-latest | |||
steps: | |||
- uses: actions/checkout@v2 | |||
- run: yarn | |||
- run: yarn lint | |||
- uses: gozala/typescript-error-reporter-action@v1.0.8 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did this get pulled out intentionally? It is quite useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed based on: https://github.com/ipfs/aegir/blob/master/md/github-actions.md
Thought the recommendation was ts -p check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error reporter action shows you which lines have errors in a visual form as part of the PR, the aegir command makes you dig through the console output. Both do the same thing and use the same rules but the action is a little more user friendly IMHO.
5d10d7e
to
d206a25
Compare
Co-authored-by: Alex Potsides <alex@achingbrain.net>
d206a25
to
98325d9
Compare
This PR aims to:
any
allowedesbuild
There are internal breaking changes in the Dialer and Keychain property names to match what comes from the external config
Needs:
Unblocks:
Closes: #891
Solves some of the items from #830 (DHT, Config and Keychain)
BREAKING CHANGES:
top level types were updated, multiaddr@9.0.0 is used, dialer and keychain internal property names changed and connectionManager minPeers is not supported anymore