Skip to content
This repository was archived by the owner on Aug 1, 2023. It is now read-only.

feat!: upgrade to esm libp2p/ipfs#462

Merged
achingbrain merged 88 commits intomasterfrom
feat/upgrade-to-esm-libp2p
Sep 16, 2022
Merged

feat!: upgrade to esm libp2p/ipfs#462
achingbrain merged 88 commits intomasterfrom
feat/upgrade-to-esm-libp2p

Conversation

@achingbrain
Copy link
Copy Markdown
Member

Updates deps and adds types to tests.

BREAKING CHANGE: needs ESM release of ipfs/libp2p

@BigLep
Copy link
Copy Markdown

BigLep commented May 27, 2022

CI won't pass until new js-ipfs ships.

@BigLep BigLep requested a review from SgtPooki May 27, 2022 14:07
@BigLep BigLep marked this pull request as draft May 27, 2022 14:08
go1.api.swarm.connect(go0.api.peerId.addresses[0]),
js0.api.swarm.connect(go0.api.peerId.addresses[0]),
go0.api.swarm.connect(js0.api.peerId.addresses[0])
js0.api.swarm.connect(js1.peer.addresses[0]),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some type failures here. not sure if they're expected.

@@ -5,11 +5,16 @@ import allV1 from './circuit/v1/all.js'
import allV2 from './circuit/v2/all.js'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You should add the ts-check pragma to the top of files if you're using jsdoc typings until you move this to typescript.

describe('exchange files', function () {
this.timeout(timeout)

/** @type {Record<string, ('go' | 'js')[]>} */
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This seems to be an incorrect type for what you're trying to accomplish. lmk if you want to allow a 3-tuple.

type arr = ('go' | 'js')[]

const array: arr = ['go', 'js', 'go'] // False Positive
const array1: arr = ['go', 'go'] // True positive
const array2: arr = ['go', 'js'] // True positive
const array3: arr = ['js', 'go'] // True positive
const array4: arr = ['js', 'js'] // True positive

type goOrJs = 'go' | 'js'
type arrFix = [goOrJs, goOrJs]

const arrayFixed: arrFix = ['go', 'js', 'go'] // True Negative
const arrayFixedException1: arrFix = ['go', 'go'] // True positive
const arrayFixedException2: arrFix = ['go', 'js'] // True positive
const arrayFixedException3: arrFix = ['js', 'go'] // True positive
const arrayFixedException4: arrFix = ['js', 'js'] // True positive

Playground Link: Provided

}

/**
* @template T
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You should restrict the types of your template. @template {Type} T

Comment on lines +9 to 12
// @ts-expect-error env var could be undefined
ipfsHttpModule = await import(process.env.IPFS_JS_HTTP_MODULE)
} catch {
ipfsHttpModule = await import('ipfs-http-client')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Elsewhere you use await import(process.env.IPFS_JS_HTTP_MODULE || 'ipfs-http-client') should we create a wrapper for the module import and use that everywhere?

Comment on lines +16 to 19
// @ts-expect-error env var could be undefined
ipfsModule = await import(process.env.IPFS_JS_MODULE)
} catch {
ipfsModule = await import('ipfs')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ditto

Comment on lines +5 to 6
// @ts-expect-error no types
import goenv from 'go-platform'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

create global.d.ts with declare module 'go-platform'

}
}
const config = JSON.parse(fs.readFileSync(configPath))
const config = JSON.parse(fs.readFileSync(configPath).toString())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

try/catch around this?

Copy link
Copy Markdown
Member

@SgtPooki SgtPooki left a comment

Choose a reason for hiding this comment

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

LGTM (the changes since last review)

@SgtPooki
Copy link
Copy Markdown
Member

tried running code from this locally since I'm on mac and that CI test is failing and I get a different error:

  1) circuit
       v1
         js-rv1-js
           connect:
     HTTPError: All promises were rejected
      at Object.errorHandler [as handleError] (file:///Users/sgtpooki/code/work/protocol.ai/ipfs/interop/node_modules/ipfs-http-client/src/lib/core.js:103:15)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at Client.fetch (node_modules/ipfs-utils/src/http.js:149:9)
      at Object.connect (file:///Users/sgtpooki/code/work/protocol.ai/ipfs/interop/node_modules/ipfs-http-client/src/swarm/connect.js:14:17)
      at Object.connect (file:///Users/sgtpooki/code/work/protocol.ai/ipfs/interop/test/utils/circuit.js:283:3)



Command failed with exit code 1: mocha test/node.{js,cjs,mjs} test/**/*.spec.{js,cjs,mjs} dist/test/node.{js,cjs,mjs} dist/test/**/*.spec.{js,cjs,mjs} --ui bdd --require source-map-support/register --timeout=60000 --bail

@SgtPooki
Copy link
Copy Markdown
Member

here is the output from DEBUG='ipfs*,libp2p*' GOLOG_LOG_LEVEL='debug,core/server=debug' npm run test -- -g 'js-rv1-js' -d &> js-rv1-js.log: js-rv1-js.log

top of the stack trace:

  ipfsd-ctl:daemon:stderr 2022-09-13T18:31:53.261Z libp2p:upgrader:error error multiplexing outbound stream Error: protocol selection failed
  ipfsd-ctl:daemon:stderr     at Module.select (file:///Users/sgtpooki/code/work/protocol.ai/ipfs/interop/node_modules/@libp2p/multistream-select/dist/src/select.js:43:19)
  ipfsd-ctl:daemon:stderr     at processTicksAndRejections (node:internal/process/task_queues:96:5)
  ipfsd-ctl:daemon:stderr     at async EventTarget._multiplexOutbound (file:///Users/sgtpooki/code/work/protocol.ai/ipfs/interop/node_modules/libp2p/dist/src/upgrader.js:483:42)
  ipfsd-ctl:daemon:stderr     at async EventTarget.upgradeOutbound (file:///Users/sgtpooki/code/work/protocol.ai/ipfs/interop/node_modules/libp2p/dist/src/upgrader.js:206:37)
  ipfsd-ctl:daemon:stderr     at async WebSockets.dial (file:///Users/sgtpooki/code/work/protocol.ai/ipfs/interop/node_modules/@libp2p/websockets/dist/src/index.js:28:22)
  ipfsd-ctl:daemon:stderr     at async EventTarget.dial (file:///Users/sgtpooki/code/work/protocol.ai/ipfs/interop/node_modules/libp2p/dist/src/transport-manager.js:78:20)
  ipfsd-ctl:daemon:stderr     at async DialRequest.dialAction (file:///Users/sgtpooki/code/work/protocol.ai/ipfs/interop/node_modules/libp2p/dist/src/connection-manager/dialer/index.js:179:20)
  ipfsd-ctl:daemon:stderr     at async file:///Users/sgtpooki/code/work/protocol.ai/ipfs/interop/node_modules/libp2p/dist/src/connection-manager/dialer/dial-request.js:67:28
  ipfsd-ctl:daemon:stderr     at async Promise.any (index 0)
  ipfsd-ctl:daemon:stderr     at async DialRequest.run (file:///Users/sgtpooki/code/work/protocol.ai/ipfs/interop/node_modules/libp2p/dist/src/connection-manager/dialer/dial-request.js:53:20) {
  ipfsd-ctl:daemon:stderr   code: 'ERR_UNSUPPORTED_PROTOCOL'
  ipfsd-ctl:daemon:stderr }

@achingbrain
Copy link
Copy Markdown
Member Author

achingbrain commented Sep 14, 2022

tried running code from this locally since I'm on mac and that CI test is failing and I get a different error:

That's very strange - I'm also on a Mac and I don't see any failures at all, nor on Windows running under Parallels, only on CI. *shakes fist at sky*.

I didn't have any time to look at this more today, I'll try again tomorrow.

@SgtPooki
Copy link
Copy Markdown
Member

tried running code from this locally since I'm on mac and that CI test is failing and I get a different error:

That's very strange - I'm also on a Mac and I don't see any failures at all, nor on Windows running under Parallels, only on CI. shakes fist at sky.

I didn't have any time to look at this more today, I'll try again tomorrow.

Are you on M1 mac? (sw_vers && arch)

╰─ ✔ ❯ gh-issue-info
ProductName:    macOS
ProductVersion: 12.5.1
BuildVersion:   21G83
arm64
nodejs          16.17.0         /Users/sgtpooki/code/work/protocol.ai/ipfs/interop/.tool-versions

Also, which node version did you use? GH action is using 16.17.0
image

@achingbrain
Copy link
Copy Markdown
Member Author

Yes, M1 Max and node 16.17.0. The only difference I can see is that the CI machine will be resource constrained and my laptop significantly less so, so there must be a difference in timing somewhere.

@achingbrain
Copy link
Copy Markdown
Member Author

ipfsd-ctl:daemon:stderr 2022-09-13T18:31:53.261Z libp2p:upgrader:error error multiplexing outbound stream Error: protocol selection failed

I just saw this locally running the tests on a linux VM. Removing the downloaded libp2p-relay-daemon binary and old *.identity files from /scripts in the repo "fixed" it, now all the tests are back to passing.

@achingbrain
Copy link
Copy Markdown
Member Author

image

@achingbrain
Copy link
Copy Markdown
Member Author

image

@achingbrain achingbrain merged commit 939e6d6 into master Sep 16, 2022
@achingbrain achingbrain deleted the feat/upgrade-to-esm-libp2p branch September 16, 2022 17:30
achingbrain added a commit that referenced this pull request Sep 16, 2022
Updates all dependencies and adds types to tests.

BREAKING CHANGE: uses ESM release of ipfs/libp2p
@BigLep
Copy link
Copy Markdown

BigLep commented Sep 16, 2022

Wow @achingbrain ! You're a hero. Thanks a lot!

achingbrain added a commit that referenced this pull request Sep 16, 2022
Updates all dependencies and adds types to tests.

BREAKING CHANGE: uses ESM release of ipfs/libp2p
achingbrain added a commit that referenced this pull request Sep 16, 2022
Updates all dependencies and adds types to tests.

BREAKING CHANGE: uses ESM release of ipfs/libp2p
@SgtPooki
Copy link
Copy Markdown
Member

@achingbrain you rock!

github-actions bot pushed a commit that referenced this pull request Sep 17, 2022
## [9.0.0](v8.0.11...v9.0.0) (2022-09-17)

### ⚠ BREAKING CHANGES

* uses ESM release of ipfs/libp2p

### Features

* upgrade to esm libp2p/ipfs ([#462](#462)) ([b006606](b006606))

### Bug Fixes

* remove randomness from get directory tests ([#497](#497)) ([56f3370](56f3370))
@achingbrain achingbrain restored the feat/upgrade-to-esm-libp2p branch October 27, 2022 16:04
@achingbrain achingbrain deleted the feat/upgrade-to-esm-libp2p branch October 27, 2022 16:26
@achingbrain achingbrain restored the feat/upgrade-to-esm-libp2p branch October 27, 2022 16:36
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants