libp2p 🛠Universal Connectivity with libp2p - David Huseby
ETHGlobal·Mon, Oct 9, 2023, 12:00 AM
Join David Huseby of libp2p Foundation for a workshop titled "Universal Connectivity with libp2p". We are incredibly excited to welcome back a community favorite: From June 2-21, 2023 we are joining forces for the fourth year in a row with Protocol Labs, one of the ecosystem's biggest open-source research, development, and deployment laboratories. Their projects include IPFS, Filecoin, libp2p, and many more. If you enjoyed last year's HackFS event, strap in—because this year will be even more phenomenal! For the first time, we will have prizes from The Filecoin Virtual Machine (FVM) for a HackFS, a runtime environment for smart contracts (also called actors) on the Filecoin network. FVM brings user programmability to Filecoin, unleashing the enormous potential of an open data economy. We are excited to respond to a highly requested community demand after our successful hacks FVM Space Warp in February of this year and Hack FEVM which took place in November of last year with this! ----------------- Follow us: https://twitter.com/ETHGlobal​ Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com
Transcript
Hello everyone and welcome to the HackFS workshop universal connectivity with libp2p. Joining us today is David Hughesby and Prithvi Shahi who will be taking us through this session. And with that I'll pass it over to them to get the session started. Hello everybody. Welcome to the workshop for learning how to use libp2p.
This is associated with the ETHGlobal HackFS um hackathon. So, before I dive into this, um I wanted to say something about the purpose of this workshop and and this presentation. I'm here really just to try to excite you about using libp2p in your projects for the hackathon and beyond. And so, what you'll see here is actually just a brief walk-through of the current state of things uh for libp2p and um give you the tools to get started quickly in your hackathon projects um and then beyond the hackathon, have a great starting point for um all of your your future work at or in and around libp2p. Um and I also want to extend a very warm invitation to all of you to join the libp2p broader open-source community um after you're done with this hackathon um because we're always looking for more people who have uh other perspectives and interests in furthering libp2p and making it better.
So, with that, welcome and thank you for showing up and giving us your attention. So, let's talk about what libp2p is, right? libp2p, as most of you already know, is a peer-to-peer networking library. It's based around a single specification and has multiple implementations in different languages. So, why all the different languages?
There are two main reasons for this. One of them is that we want to have libp2p implementations in whichever language you are most comfortable working in. We want to be present in every working environment including browsers, servers, workstations, um in applications written in Go and JavaScript, um Rust, Nim, C++. There's even a Java implementation, right? Um and I think as of like a month ago, there's even a Zig implementation now.
So, um the idea here is regardless of your language, regardless of your execution environment, we want to have a presence there for doing all of your libp2p needs. Um the other reason is that with all of these different implementations, we avoid sort of the single uh source of failure problem. If there's a bug that arises in one implementation, it is likely not present in the other implementations. And this allows uh easily building heterogeneous peer-to-peer networks that are more resilient in nature simply because a single bug can't take down the entire network. So, also inside of libp2p, there are a lot of low-level features like encryption, authentication, um pretty famous for having good hole punching, getting through NATs and things like that.
All of this is in service of being able to build peer-to-peer networks that are immune largely immune to the chaos of the internet. It doesn't matter where your peer node is or how it's connected to the internet, it should be able to communicate effectively to all of the other peers in the network in in your network. Um So, in addition to all of that, we also add high-level features like DHTs and and gossiping um mostly for peer discovery and for um doing global state synchronization. Basically, everything is in there in libp2p that you need, right? Uh I threw this slide in here because this is how libp2p has always demonstrated what you know, what options we have for connecting and all that kind of stuff.
Um this is a very boring slide. So, we're not going to use that anymore. Um what we you're going to do instead is demo connecting everything everywhere all at once. I think some of you get the reference to this movie um very popular last year. libp2p, we joke uh allows you to connect everything everywhere all at once.
So, to demonstrate that, the team at Protocol Labs and in the greater Protocol Labs network built this simple chat app cuz you know, we all need another chat app. There's just not enough of them out there. But, this is a very good and easy way to demonstrate um the basic functionality of libp2p and to demonstrate it working on multiple languages in multiple execution environments as you'll see. This demo includes browsers and non-browsers, public or private, and all using libp2p. Um my current situation right now, I'm actually behind a NAT.
So, I'm presenting this from the NAT and I'm and the clients I'm running locally here are all going to be NATed. Um we are going to be talking to a server that's has a publicly routable IP address that's a bootstrap node. Um but you'll see that this all works regardless of that network connection status. Um we're going to start off with a Rust peer. It's currently running and uh it has a really pronounceable name.
I just call it Lujam. The this name here is actually derived from the the keys that are used. Um and so, when you'll see it in the demo, it'll be it'll come up as that, right? That's the name of that node. Um so, to start off, we have this node running.
This is our our bootstrap node. And I'm going to now run a Go libp2p CLI tool of the universal connectivity. So, I'm going to bounce over to my console here. And you can see here that I'm telling it, you know, I'm going to run the Go peer and I'm telling it to connect to Lujam, right? Here's Lujam's name right here at the end.
And what we're going to see, hopefully, failed to connect to peer. Excellent. Live demo gods, please please spare me. Prithvi, do you have any idea why I can't connect to Lujam? Is it running?
Yes, I did. Let me make sure it's running. So, go ahead and try again. Okay. There.
Yes. We're up. Okay, cool. So, you can see over here in the peer list, we're talking to MKWJ Lujam, right? And my node is listening on a on several different uh transports and you can see here that I'm actually NATed, right?
So, this is my local um my local IP on my home network. Um this really doesn't matter because we have ways of getting around it. Oh, and look, we're hacked already. Hello. Okay, so this here is a Go uh CLI tool of the universal connectivity app.
There's also a Rust version of this as well um and I think maybe even a Node.js, but I'm not entirely sure. I know that we have a Rust one and a Go one. Okay. So, this is all working.
So, let's get back to the slides. And to further build this network to show how versatile this is, we're going to load up a browser application version of the universal connectivity app and it's written using JS libp2p. So, I'm going to skip over to Chrome and I'm using Chrome because we tested this earlier in Firefox. I think there's still a outstanding bug in Firefox, but we did confirm that it works in in uh Chrome. So, let me load this up.
This is actually running on a local web server here on my on my system. And it's trying to connect uh behind the scenes behind the scenes and you can see here it did connect to Lujam. And let's see what else does it have? Several others. So, AYJJ SFFR, that is our Go libp2p client that I was just running.
And it looks like we've got several others already jumping into the network. So, if we go over to chat, all right, everybody in the network, say hello. Hello. If you're hacking our network, go ahead and say hello. Well, that's from the main Rust peer.
Nobody else, huh? There you go. BY9N says hello. That's cool. So, if we jump over to the Go client, see we've got more hellos.
Hacking libp2p, more hellos. Welcome everybody. Welcome. Welcome. Okay.
So, now this allows me to skip ahead a little bit on the slides. So, I could have started up another um browser, which we can do right now actually. We'll just do that. Start up another browser instance. Um And this should connect to Lujam, right?
Which it did. And then it should also establish connections to all of the other nodes that it can see in the network including the browser one, the other browser. Then if we go over to the other browser, we can see it's connect it's uh this R5AC. So, if we get back to the second one, here. Go back to the second one.
Uh there it is, R5AC. So, now we have browser-to-browser connectivity um using the P2P. So, if we go into chat here, yay. Browser browser. All right, back to the slides.
So, what we've demonstrated so far is our Rust P2P server, Lugem, right? And then I started the Go client in the command line, and I've established two browser instances that are also connected, and they are all connected to each other. Um, what we're doing now, as I'm seeing everybody jumping in, is I'm going to challenge you to go ahead and start playing with the browser one to see if we can get a bunch of them in there. So, how are we going to do that? Um everybody jump onto this URL, universal-connectivity.
vercel.app. Okay, I'm going to dump it in the chat here. vercel.app That should get you a version of the universal connectivity app in your browser.
So, let's see if we can do that over here. Oh, wait. Yep. This one should also join as well. There it is, connected to Lugem.
Great. Now, if everybody else is doing it, we should start seeing a whole bunch of peers jump in here. And we are. Look at these, all these P2P circuits over WebRTC direct. And if we go over to the Go P2P one, we can see our list of peers here.
Excellent. This is growing. This is our stress test. Cool. I uh Okay.
So, the live demo gods have shined favorably upon us. Look at everybody. Cool. Welcome, everybody. All right.
That's basically it for the demo. I just wanted to demo that we can do this in all different environments, different languages. And um here is the link to the universal connectivity app that you can get from GitHub. Now, if you don't know where to start, and you're fairly new to LibP2P in this hackathon, I highly recommend you clone this repo and take a look at it. Um the it it's just a basic getting it configured in whatever language.
It's a mono repo. Sorry, let me start over. It's a mono repo, so the implementations for Rust, Go, and JS LibP2P are all in there. Um, and shows you how to use it in the browser, shows you how to use it uh from the Rust land, and also from Go in the command line. So, this is probably going to be your fastest way to get going on this hackathon, and um it's what we're all most familiar with, all the the mentors and stuff.
So, if you don't know where to start, start here. If you already started, that doesn't matter, you're okay. You might still learn something from this, and um so it's a good resource. The connectivity.libp2p.
io is a great website that talks about all the different um transports and and features and things like that, and many cases there's links to the specification if you have any questions. And then if you want to dig dive deep into the specs, um there's a GitHub for specs. Uh, let me get all the way back to the beginning here, cuz I wanted to point out one last thing. This was built by a huge team of uh people who are in the LibP2P community. These are all GitHub handles.
And some of these people are already mentors in the Discord channel for the hackathon. So, Prithvi uh is in there, Chad is in there, I know Marco's in there. Um I'm in there. I think the uh Discordian might be in there as well. Um so, feel free to reach out to us, any of us um with questions.
We're kind of hovering in the Discord. So, if you get stuck on anything or have questions specifically about this to get going, um yeah, let us know in the Discord. And now I'm going to open it up, cuz we Let's see, how much time do we have? Just a couple minutes. Um yeah, we got about 15 minutes.
So, I'm going to open it up to questions. Um you can ask in the chat, and I'll read them, or if you're brave enough, feel free to I think you can turn your video your audio on and ask the questions if you're in Zoom. I know this is being streamed out onto YouTube and being recorded on Zoom, just so everybody knows. Let's see here. Do we have any questions?
Anything in chat? None. Well, I mean, if we don't have any questions, Prithvi and I can answer. I've got a maybe a question that some people might help or might want to know, like uh what are you what are y'all looking for in terms of uh uh project ideas or projects that you'd like to see uh built on top of LibP2P. That's a fantastic question.
Um we had a couple ideation sessions uh last week um to look at, you know, to talk about ideas and and team formation. I have my ideas, and I know that Prithvi may have some, or Discordian may have some as well. Anybody else have any ideas, I feel feel free to jump in. For me personally, I think something that would be really good uh to work on is browser-based tools that work with Web3 technologies. I mean, this is part of a broader Filecoin and FVM hackathon.
So, if you can make a browser-based tool that interacts with that, that would be amazing. There's a lot of work that needs to be done there, and it'd be fun to fun to play around with that. Um I know that there is one project that is by Doug Anderson that is toying around with implementing protocols in Wasm, and running a Wasm VM on top of LibP2P. So, that one might be really cool. Uh you can talk to Doug.
I think he's in the in the Discord right now if he needs any help. Um let me offer anybody else who has a team that's looking for help, do they want to speak up and pitch their idea here? That's another thing we can spend the time doing, or put it in chat if you don't want to say it out loud. Um because this is really about making this hackathon as successful as possible. And there was a question in the in the chat as well.
Yeah, I had looked into Gun before this. Can you compare and contrast the projects some so I can better grok? I'm honestly unfamiliar with Gun. Prithvi, do you know anything about Gun, or anybody else in here? Uh I can't say I'm familiar with Gun.
I would love to know what it Gun DB. Okay, so is it some sort of distributed uh database? Um you know, LibP2P, you know, we normally uh you know, what we like to refer to it as like a tool kit um that allows you to you build the decentralized peer-to-peer networking layer of your application. Um and so without knowing too much about Gun, you know, I we can't really contrast it that much. Um So, it looks like Dave is showing the screen.
Yeah, it's Okay. I know nothing about Gun, but I mean, if you read this here, it looks like it's a set of tools for me to run encrypted applications, like open-source Firebase or decentralized Dropbox. So, it must have some P2P state sync. Yeah, okay. Um it sounds to me like you could implement this using LibP2P and IPFS, to be honest.
Um I don't know exactly how much they have in way of like hole punching or multiple language implementations or support for different execution environments, but um but yeah, it looks I I I can't compare and contrast. I think what Prithvi was saying is is very important though, like LibP2P is a is a toolbox of lots of peer-to-peer um capabilities. Um looks like you could replicate anything that's in here with with uh LibP2P. This looks like it's all written in JavaScript and TypeScript. So, this may actually limit it to Node and or in the browser.
Um which would be one of the notable differences between LibP2P and Gun. Cool. Right, LibP2P is um you know, a language-agnostic support in multiple implementation languages, and basically helping you get the networking part of your application up and running. And so, what the universal connectivity app that Dave just showed us trying to demonstrate is that across languages like Rust and Go and JavaScript, we have wide variety of support for different transport protocols. Be they your bread-and-butter transport protocols like TCP and quick, or you know, the browser-based transport protocols that allow you to achieve connectivity from the browser to the server using WebRTC or WebTransport or even WebSocket that's been around for so long.
And so, ultimately, we want to enable you guys to build a class of applications that, whether they be browser-based or, you know, running just on a server or a laptop or something, you know, with P2P can help bridge that networking part of the part of the problem for you. Um so, that's that's our ultimate goal is like our vision is that we want to be able to connect the browser world to the server world in a language-agnostic way, something that's really a good foundation to build on. And so, like Dave mentioned, you know, highly recommend you guys to to clone the universal connectivity repo if that's something that you're looking to get in get get a start on. I know like some folks on the Discord like Dr. Hongo and Jose KP have also started using the connectivity app.
So, please jump in there. Happy to answer your questions. Something has just occurred to me that I've said in previous meetings and before we had this presentation for some ideas, things to do with libp2p. I highly encourage that you try to do something around, you know, the Filecoin virtual machine and Filecoin network or even IPFS. But if you have interest else elsewhere, one of the things I've wanted to do with libp2p is to take some existing popular tools like Secure Scuttlebutt or Nostr and rip out their networking library and replace it with libp2p so that something like Nostr is much more, instead of doing its its normal relay store and forward kind of thing, it's much more of a real-time peer-to-peer network.
Or at least, you know, you can run a server that can that is easier to connect to for doing the relay. Something like Secure Scuttlebutt could benefit from this as well cuz imagine if you had a Secure Scuttlebutt client and you were sharing files on your feed and those files were stored in IPFS for instance, right? So, you can combine libp2p and IPFS to recreate and probably have a better user experience. Um it would be kind of, you know, it's probably a harder project. Maybe not something you could get done in 3 weeks, but some of the smaller tools, you know, have pretty straightforward networking and would be good candidates to put libp2p in.
It'd be kind of cool to do um I don't know, like a version of curl that uses libp2p. I don't know, something like that. So, if you if you're short on ideas and you don't have a team here, you don't see a team here that's exciting and you want to join and you want to do something on your own, you know, take an open-source browser-based game or take um any one of these social media apps and and try your hand at replacing the networking layer with libp2p. But like I said, focus I think your first bet would be to and the one that'll get you the most people available to help you would be anything related to Filecoin, the Filecoin virtual machine, anything with IPFS, that kind of stuff. So, looks like we've got 6 more minutes.
Any more questions? Any more suggestions? Anybody want to pitch their team and ask if anybody can help? Scordian, I want someone to make it so I can use libp2p to play Diablo II games with my friends. I think it should be possible.
Absolutely, I think it should be possible. Isn't there an open-source implementation of Diablo II now? And also, um the you could probably do Doom as well. Oh, maybe it's a Diablo I implementation. Yeah, sure.
And Doom would be fun. Peer-to-peer Doom over libp2p, that Well, Meek, are you in the Discord? Great. So, feel free to ask questions. We we have a bunch of mentors hanging out in there um and Yeah, well, I guess I'm concerned you said you barely understand anything.
So, I'd I'd love to get to the heart of that. Um if things could be elaborated on a little bit more, Meek, you know, do let us know either right now or in Discord. Well, we have 5 minutes left. I'm going to take a poll. So, how many of you are associated with a project?
Are you doing something individually or are you part of a group? Solo, Meek. Great. What about you, Carl? Are you solo?
Solo. Solo. Cool. Okay, so a lot of solo people. Does everybody know what they're doing?
It sounds like uh Stefan or Stephanie, I guess, like it says you have no clue what to do. I'm not sure how you pronounce your name. Is it Stephanie or Stefan? Stefan. My apologies.
Thank you. Um Like I said, if you don't have any ideas on what to do, start with the universal connectivity app. Maybe add in the ability to send a file or add features to universal connectivity. I just jumped in the chat. Maybe we can have an ideation session like this hackathon this workshop doesn't have to be the end all, be all.
You know, I'd love to stay connected with you folks and it's okay if you don't have any ideas of what to do right now. I think that's the good thing is um there's a lot of opportunities to do something and maybe it just requires a little bit of poking and prodding. So, I would say, you know, somebody asked about office hours, definitely happy to meet up with people in in office hours. I can post my availability on Discord, but I would love to, you know, continue chatting with folks and help people get a better idea of like what they can build. Um so, do do you folks have a link to the Discord?
I think that would be the best place to connect cuz this this meeting is going to be coming to a close. Yeah. Yeah, I just posted the the main global Discord server link. Excellent. Well, thank you everybody for coming to this session on libp2p.
I was hoping to excite you by showing you all the possibilities. And it seems to me like we have some interest and let's get together on the Discord and figure this out. Get everybody a project and get going. There, that's the uh the link to the channel. Sometimes I don't know if it's uh in Slack or whatever, but sometimes linking to a specific channels in Discord doesn't exactly take you there.
Um but that's the the link to the partner libp2p channel. Um and yeah, thanks thanks everybody for for joining. And thank you thank you, Dave and Prithvi, for organizing, leading everybody through the session, answering questions. And hope to see you all in the Discord. Again, don't be afraid to ask questions, that's what they're there for, that's what the mentors are there for to help help help support you over the next couple of weeks.
Yeah. Thank you, everybody.
Automatic transcript — names and jargon may be misspelled.