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

chore: export @libp2p/bootstrap from within @waku/sdk #1863

Closed
danisharora099 opened this issue Feb 26, 2024 · 5 comments · Fixed by #1871
Closed

chore: export @libp2p/bootstrap from within @waku/sdk #1863

danisharora099 opened this issue Feb 26, 2024 · 5 comments · Fixed by #1871
Assignees

Comments

@danisharora099
Copy link
Collaborator

danisharora099 commented Feb 26, 2024

This is a bug report

Problem

js-waku is released released in interims of ~4 weeks normally.

During this window, it was found out that @libp2p/bootstrap was upgraded by libp2p, which was incompatible with our latest release candidate on npmjs: https://discord.com/channels/1110799176264056863/1211389001920151603/1211662475385245766

Proposed Solutions

Re-export @libp2p/bootstrap from within @waku/sdk

Notes

  • Can be added as a peer dependency as well
@fryorcraken fryorcraken added this to Waku Feb 26, 2024
@danisharora099 danisharora099 changed the title chore: export @libp2p/bootstrap from within @waku chore: export @libp2p/bootstrap from within @waku/sdk Feb 27, 2024
@chair28980 chair28980 moved this to In Progress in Waku Feb 28, 2024
@chair28980 chair28980 assigned weboko and unassigned danisharora099 Feb 28, 2024
@weboko
Copy link
Collaborator

weboko commented Feb 28, 2024

Problem

User tries to init a node with:

const NODE_OPTIONS = {
    libp2p: {
        peerDiscovery: [
            bootstrap({ list: peers }),
        ],
    },
};

what doesn't work due t o bootstrap from @libp2p/bootstrap being of wrong version:

Possible solutions:

  1. export @libp2p/bootstrap - the best place will be @waku/discovery from feat: create a new package @waku/discovery to encapsulate all discovery mechanisms available within Waku #1862;
  2. lock @libp2p/bootstrap version with peerDependency to prevent wrong version being used;
  3. cover particular need of bootstrapping with list of peers directly without need of extra dependency;

Initially my though was 2 is preferable choice but it was based on the assumption this package is already present. It is optional so due to this I think it might be misleading to have a dependency in @waku/sdk/package.json which is not used directly.

Conceptually 1 to me looks good as it is one of the discoveries Waku supports. cc @danisharora099

For now will:

  • define peerDependency as temporary measure;
  • provide way to bootstrap with list of multiaddrs;

Next steps (blocked by #1862):

  • re-export @libp2p/bootstrap from @waku/discovery so that consumer doesn't need to install @libp2p/bootstrap;

Even though I propose this I think it should be only used for advanced cases and preferred way will be to improve configuration options so that there are no extra dependencies or convoluted structure of options passed.

@weboko weboko moved this from In Progress to Code Review / QA in Waku Feb 29, 2024
@danisharora099
Copy link
Collaborator Author

I was initially in the favour of re-exporting it from @waku/discovery (still see pros to it), but as discussed in the PM meeting yesterday, and @fryorcraken's comment here https://discord.com/channels/1110799176264056863/1211676794214944808/1211899679508537344 con I see: it's libp2p's package, so could be misleading to simply re-export it as @waku/bootstrap. Simply just locking the version with peerDependency on @waku/sdk seems better.

In future, we should abstract away libp2p's peerDiscovery option and provide peerDiscovery as part of Waku options and internally use bootstrap

I'd propose to simply add it as a peer dependency for now, and tackle abstracting away discoveries using SDK in a future PR

@weboko
Copy link
Collaborator

weboko commented Feb 29, 2024

In future, we should abstract away libp2p's peerDiscovery option and provide peerDiscovery as part of Waku options and internally use bootstrap

exactly what I implement here #1871

next iteration after #1862 is complete will be to add @libp2p/bootstrap internally to @waku/discovery and export wrapper around it so that it can be used in @waku/sdk/create.ts instead of this line:

peerDiscovery.push(bootstrap(options.bootstrapPeers));

@weboko
Copy link
Collaborator

weboko commented Mar 1, 2024

Once #1871 is merged - the task is locked by #1862

@weboko weboko moved this from Code Review / QA to Blocked in Waku Mar 1, 2024
@danisharora099
Copy link
Collaborator Author

danisharora099 commented Mar 1, 2024

Once #1871 is merged - the task is locked by #1862

instead of it being blocked, we could address additional changes as a followup PR. we can proceed with merging #1871

@github-project-automation github-project-automation bot moved this from Blocked to Done in Waku Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants