shresthagrawal / learnp2p

https://learnp2p.org
https://jslibp2p-chat-tutorial.vercel.app
MIT License
26 stars 6 forks source link

WIP Update Libp2p to v0.27.6 #11

Closed prateekreddy closed 4 years ago

prateekreddy commented 4 years ago

All chapters refactored to libp2p v0.27.6

vercel[bot] commented 4 years ago

This pull request is being automatically deployed with Vercel (learn more). To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/shresthagrawal/jslibp2p-chat-tutorial/j6el6jgf1 ✅ Preview: https://jslibp2p-chat-tutorial-git-fork-prateekreddy-js-libp2p-v0274.shresthagrawal.vercel.app

prateekreddy commented 4 years ago

@prateekreddy awesome work! I ran the bootstrap code 2.2-finished-code.js and then ran the code 2.3-finished-code.js which just dials to the bootstrap. It throws this error:

(node:67986) UnhandledPromiseRejectionWarning: AggregateError:
    Error: protocol selection failed
        at module.exports (/Users/shresthagrawal/Desktop/study/libp2p/jslibp2p-chat-tutorial/assets/node_modules/multistream-select/src/select.js:50:17)
        at async Upgrader._encryptOutbound (/Users/shresthagrawal/Desktop/study/libp2p/jslibp2p-chat-tutorial/assets/node_modules/libp2p/src/upgrader.js:361:36)
        at async Upgrader.upgradeOutbound (/Users/shresthagrawal/Desktop/study/libp2p/jslibp2p-chat-tutorial/assets/node_modules/libp2p/src/upgrader.js:168:11)
        at async ClassIsWrapper.dial (/Users/shresthagrawal/Desktop/study/libp2p/jslibp2p-chat-tutorial/assets/node_modules/libp2p-tcp/src/index.js:42:18)
        at async TransportManager.dial (/Users/shresthagrawal/Desktop/study/libp2p/jslibp2p-chat-tutorial/assets/node_modules/libp2p/src/transport-manager.js:87:14)
        at async /Users/shresthagrawal/Desktop/study/libp2p/jslibp2p-chat-tutorial/assets/node_modules/libp2p/src/dialer/dial-request.js:58:18
        at async /Users/shresthagrawal/Desktop/study/libp2p/jslibp2p-chat-tutorial/assets/node_modules/p-some/index.js:53:19
    at maybeSettle (/Users/shresthagrawal/Desktop/study/libp2p/jslibp2p-chat-tutorial/assets/node_modules/p-some/index.js:31:11)
    at /Users/shresthagrawal/Desktop/study/libp2p/jslibp2p-chat-tutorial/assets/node_modules/p-some/index.js:69:23
(node:67986) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:67986) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

The error seems to disappear once we add secio in the next chapter. Is the support for plaintext removed in the latest version? can you check it out why?

Yes looks like encryption is mandatory now.

acolytec3 commented 4 years ago

Other than the package version issue noted in my above comment, this looks great!

acolytec3 commented 4 years ago

@prateekreddy awesome work! I ran the bootstrap code 2.2-finished-code.js and then ran the code 2.3-finished-code.js which just dials to the bootstrap. It throws this error:

(node:67986) UnhandledPromiseRejectionWarning: AggregateError:
    Error: protocol selection failed
        at module.exports (/Users/shresthagrawal/Desktop/study/libp2p/jslibp2p-chat-tutorial/assets/node_modules/multistream-select/src/select.js:50:17)
        at async Upgrader._encryptOutbound (/Users/shresthagrawal/Desktop/study/libp2p/jslibp2p-chat-tutorial/assets/node_modules/libp2p/src/upgrader.js:361:36)
        at async Upgrader.upgradeOutbound (/Users/shresthagrawal/Desktop/study/libp2p/jslibp2p-chat-tutorial/assets/node_modules/libp2p/src/upgrader.js:168:11)
        at async ClassIsWrapper.dial (/Users/shresthagrawal/Desktop/study/libp2p/jslibp2p-chat-tutorial/assets/node_modules/libp2p-tcp/src/index.js:42:18)
        at async TransportManager.dial (/Users/shresthagrawal/Desktop/study/libp2p/jslibp2p-chat-tutorial/assets/node_modules/libp2p/src/transport-manager.js:87:14)
        at async /Users/shresthagrawal/Desktop/study/libp2p/jslibp2p-chat-tutorial/assets/node_modules/libp2p/src/dialer/dial-request.js:58:18
        at async /Users/shresthagrawal/Desktop/study/libp2p/jslibp2p-chat-tutorial/assets/node_modules/p-some/index.js:53:19
    at maybeSettle (/Users/shresthagrawal/Desktop/study/libp2p/jslibp2p-chat-tutorial/assets/node_modules/p-some/index.js:31:11)
    at /Users/shresthagrawal/Desktop/study/libp2p/jslibp2p-chat-tutorial/assets/node_modules/p-some/index.js:69:23
(node:67986) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:67986) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

The error seems to disappear once we add secio in the next chapter. Is the support for plaintext removed in the latest version? can you check it out why?

Per here, this can be fixed but you have to specify Plaintext as the connEncryption module in the options object for the node. I did this locally 2.2 and 2.3 completed code sections and it works fine.

const Plaintext = require('libp2p/src/insecure/plaintext')
...
let options = {
    modules: {
        transport: [ TCP, WS, WStar ],
        connEncryption: [Plaintext]
    },...
prateekreddy commented 4 years ago

Nice work, can you check out why does the code 6.2-finished-code.js doesn't work? the code until chapter 5 works perfectly

Oops looks like I missed chapter 6 completely. Let me update the code in the chapter as well.

acolytec3 commented 4 years ago

Fired up 2 nodes using the 6.2 finished code and it works great. Thanks for this!

acolytec3 commented 4 years ago

@shresthagrawal @jjperezaguinaga Hey guys, any chance one of you can give this a final look so we can get it merged? I'd love to have it merged this weekend if possible so we can start merging the content updates in the other PRs.