Filecoin 🛠Building Applications with Filecoin & FEVM - Zak Ayesh
ETHGlobal·Mon, Oct 9, 2023, 12:00 AM
Join Zak Ayesh of Protocol Labs for a workshop titled "Building Applications with Filecoin & FEVM". 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
foreign [Music] and welcome to the hack FS Workshop building applications with filecoin and fevm joining us today is Zac Ash who will be taking us through the session and with that I'll pass it over to Zach to get the session started awesome thank you hey everyone if you don't know me my name is Zach ayush I'm a developer Advocate with the fbm team and uh protocol labs and today I'm going to be talking about building applications on the filecoin virtual machine specifically we're going to go over data dials and back allow our compute over data and we'll talk about what that means in a bit so we'll go over like a quick intro and while we're doing all this you know and uh quick intro to fvm if you missed some of the other talks I'll keep it brief uh we'll go over the fvm data dial kit and we'll introduce uh bacalao and compute over data and uh maybe show some demo of back allow working right so what is the the file coin Vision right it's it's here as part of the greater web 3 Vision decentralized internet uh specifically Falcon was created to decentralized data storage right so to store the the webs data foreign here's a like pretty inspirational quote from uh CEO of protocol Labs um the properties of the internet is Technologies Define us and our human rights which is why uh you know everyone in web 3 is really enthusiastic about how this technology uh can really move us forward right so we're going to be talking a lot about data you're going to hear the stuff compute over data um you know file coin stores data um data information these are some of the most important things and Assets in our era um you know before we went through you mine are part of the rise of big data right and how data was like the the oil of the future um and it's it's really coming to be true we're seeing how data could be used for like many positive things and and developing our understanding of the human genome and health uh but can be used for negative things as in you know using our data against us uh to manipulate people and all kinds of other things right so I think it's very important that uh we have a decentralized infrastructure uh for data in this new paradigm of the world all right so Falcon is trying to uh bring the foundations for the decentralized internet with four key areas right uh so the first main one uh is verifiable storage so Falcon launched uh to mainnet in October 2020 and its original purpose was to create a provable storage Market uh for storage providers to prove that they had data stored um in their hard drives right so essentially uh storage providers would take up deal storage Deals they would take the data they would convert it and we'll talk a little bit about this process in a bit and provide proofs on uh the file coin blockchain that they are storing this data right and um this is an important piece of infrastructure that Adam been created in web3 yet you know we had you know Bitcoin which quit which really kicked off this whole web three blockchain um technology and it was decent neutralizing value transfer then ethereum came through and said hey what if we take this property and generalize it and allow arbitrary code to be written on top of this blockchain and decentralized uh logic like generalized programming logic and uh you know Falco came around and said what if we could take that and also decentralize the storage of large data sets right uh regular blockchains can't store large data sets efficiently it costs a lot of money because you're replicating it across all these nodes right so uh we need a new kind of infrastructure to handle that problem and uh coming up next is retrievals right which has still been a work in progress but currently one billion weekly retrieval requests uh are passing through um ipfs gateways um and the next phase of all of this is CDN quality retrieval there's a project called file core and Saturn you may have heard of and um that's kind of enabling that and also allowing retrievals on the the file coin Network on top of ipfs and uh we have the filecoin virtual machine now right so this is kind of where I come in and what I've been focused on but this allows smart contracts on top of California so what I mentioned earlier with smart contracts on top of ethereum we can do that on top of filecoin and uh this allows us to do what we call computation over estate and we'll talk about that in a second um and finally uh we have computation over data our back allow and uh we'll talk about that in a sec as well so um you know you heard me say computation overstate computation over data what is computation over state so as you know the follicle and virtual machine delivers on-chain programming ability to follow coin Network much like ethereum but the way it was built is actually uh quite different right so um the virtual machine the fem uh follicle and virtual machine was built using wasm webassembly and the ethereum virtual machine is actually virtualized top of that um kind of like a hypervisor on your computer right so if you're running a Windows machine and you want to uh run uh Mac OS or Linux on top of Windows you'll probably download a hypervisor a virtual machine and run that on top right and so the follicle and virtual machine is kind of built um built in that way right so um any kind of theoretically any kind of virtual machine could be virtualized on top of the VM right and so the first thing that was built on top of it was the f evm and uh the reason for the evm is because it is the most widely used blockchain and web3 virtual machine environment and so uh filecoin could take advantage of solidity uh Foundry hard hat all the tools and uh ecosystem that has developed around the evm and solidity that's pretty robust today right so you can think of it as like a kind of stack of layers right so uh at its like base filecoin was was and is still designed around storage right so storing large data sets um and on top of that we have the fvm which allows us to compute over the state of this file coin blockchain right and uh what is that state well we'll go on that a bit but essentially deals and um on top of that we have what we call computation over data right which is about allow right so you can think of com computation over State as like okay this is the computation over the blockchain state right or the storage deals what are they what are the information we can we can retrieve that and we can compute over that while computation over data is like computational over large data sets are what data the storage providers might be holding actually is so yeah again you know computation over state computational on the metadata of the data stored on file corn right so you have the storage providers they've got their data um but the deals themselves the ones that bind the storage providers that what they have to provide proofs for or else they get slashed um is the state that we're talking about so essentially the storage deals and these storage deals can be found on any other blockchain which was which is what makes fevm very unique compared to other evm chains um I see a question here was wondering if we'll get some info over data dials and how we can do storage shelves yep uh I'm just about to talk about that actually so a great question um what are deals right that's uh that's the next slide so um storage deals are the the the state on the final coin blockchain that determine um how your data is going to be stored uh with these storage providers right how long that's going to be stored how long this will cost how much will be paid uh and you know collateral um all kinds of information well let's just dive into it and we can we can look in and see what that looks like right uh so we're going to go to Phil Fox here this is actually pointing to hyperspace which is now deprecated so we are gonna go to Phil Fox the manual way right and uh currently we are on Main net which we could go to but we're going to go to calibrationnet as calibration that is the uh main supported test net of the file corn blockchain right now uh we just switched from hyperspace so you may see something still being switched in documentation and some of the kits but uh most everything should be switched over by this point and if we go here and just tab blockchain you'll see an area called deal list right and these are those active storage deals uh that I was talking about right you can find this on me net as well I'm just going to go over calibration net since that's what most developers in the socket that are going to use before they go into media right so you just click on any random deal ID right here and we'll get some of that metadata that we we can compute over or you know do that computation over State over right so you have the deal ID just a basic ID to identify the deal create time when the deal was created at one block and you'll see these two uh important pieces of data they might look like jargon the message and pcid we'll go over those in a second if the deal is verified we'll fill plus if you're not familiar with sill plus fill plus is a um program that allows people to if they have very important data that they want stored uh give storage providers an incentive to store the stereo important data I highly suggest checking it out and if you have some time at the end I can go over it um but yeah uh we have the pcid here uh which is kind of like the the root hash of the data we'll talk about how that's computed here in a minute and uh the client the person requesting the data the provider and how much collateral each person has set up right so each each person needs to put up some collateral on testnet this isn't necessary um the client uh this is the client provider in this image have zero collateral sort at the bottom here um but the client needs collateral in order to prove that they can pay continuously for that storage deal over time and the provided is open up collateral because if they go offline or stop proving that they have the data stored um they get slashed for that collateral right so this gives them an incentive to make sure they stay honest because uh they're not going to want to lose that money all right so that's kind of what deals look like um we also have this idea of the comp P our pcid that I mentioned earlier right right so I said you can think of it as like a root hash um it's a little bit more complex than that because it's not just like taking the data through housing algorithm we first convert any data that we want stored on the file calling chain into what we call a car file um the car file is uh then padded to make it the proper size and a Merkel dag is created which is very similar to our Merkle tree if you're familiar with Bitcoin or ethereum uh but instead of some dag a directed acyclic graph and essentially we create this tree and it hashes all the way up to this comp pcib right so it's a little bit more involved than just and it has a little bit more data in it than just a hash but that's essentially what you can think of it as it's a representative of the data being stored right and so into that deal making flow right um originally deal making flow was a pretty manual process um a client would have to find what storage providers uh are wanting like what what their minimum asks are for deals like maybe it might be a certain size deal a certain amount of price or length and um some messages would be sent on chain to the on-chain apis eventually let's say a deal is made a storage provider would take up that deal uh proposal what we call it would be signed by the client um the provider would download the data um make sure that everything matches send a message on chain called publish storage deal and that deal would be live right and that was basically the deal making low um and you know that was all fun and nice but it was kind of limited uh you know it was basically we just had those basic apis and now we have the fvm right which allows a compute over a state right and allows us to build all these kind of awesome crazy applications on top of it um and so that's really allowed us to take a deal making to another level right so we'll go over in a second but there's a client contract that allows us to admit an event through a smart contract on the file form blockchain and that um allows storage providers to take up deals that are coming directly from Smart contracts on chain right and um with this you can create all kinds of interesting applications uh like decentralized verifiable computation with bacalao which we'll talk about data dials which is coming up next um you know sector auctions uh quality of service improvements um you know storage Insurance Perpetual Source contract um all kinds of fun things on the platform uh blockchain that we are excited to see Packers build uh during the second thought so I'm going to go over um this data dial kit um real quick I think we have a question so is a proving tree the same as the Merkle tree um it's very similar um so I'll go back real quick image right here um essentially it's basically a Merkle tree um if you go into the the file coin spec uh you can learn a little bit more about it almost a little bit more complicated than that because they you know it they consider it a dag instead so it can go both ways and this I think is part of ipld in a planetary um uh layer link data um like format to make it a little bit more generalizable but um essentially yeah it's like you can think of it very similarly to that and then Most states it may even be that right um so I hope that answered your question all right so I'm just going to give you a brief look at the uh fevm data dial kit um so we're talking about data dials right we I mentioned them as one of the possible use cases we've got a question on it right um so what do we mean by a data dial right if you don't know what a dow is it's a decentralized autonomous organization right essentially we're taking voting structures and organization and putting them on chain um and uh kind of organizing a decentralized group of people together that way and um kind of what we mean in the final coin Network when we say data dials and data dials are still kind of a term that's being defined industry-wide is Dallas based around data being stored in the storage provider right and so in the datadel kit what we have is a couple of example contracts and these are based actually on um an old colleague of mine Patrick Collins you may be familiar with him he did a great Dow tutorial which I actually linked to in the readme here that if um you want to go more in depth and how dials are built I highly suggest you watch um but we have a couple of co uh contracts in this kit um I did a governance token a governor contract a timeline contract and what I call the Dow deal client right so remember how I said it earlier we had the old method uh and still a viable method of creating storage deals and a newer method which is creating storage deals uh for um storage deals for uh via Smart contracts right and so this deal client is kind of uh a standardized way to do that you know it has uh the struct for the deal requests that we can put in and essentially amidst an event deal proposal create that um storage providers can listen to and um you know pick up the deal from the smart contract right so essentially what this dial kit allows you to do is deploy this Dow deal client with these Governor contracts uh wrapped around it so a dow can vote on what data they want to request to be stored on the 501 blockchain right and this is basically a very bare minimum dial template and we I'd really like to see um people over the hackathon build on top of this maybe build some more complex functionality on top um build some more tools we're hoping to see things like like storage renewal um like automation tools to be built on top of this um would be great to see right so that's kind of the datadout kit a quick overview if you want to learn more I suggest check it out uh please feel free to make some PRS we just had someone make a PR here on a fix right um so yeah so we have a question on a specific contract let's see 1970 . yeah this is a very specific to the governor contract code on line 70 here right line 75 right super proposed all right so is this calling so you know solidity allows um inheritance in it right so we're actually inheriting uh in this government contract to open Zeppelin contract standards and this is calling that uh with some low-level stuff the call data is like the low level data that we're passing in um the description is like the actual proposal um again if you want to learn more I don't really have time to go too in depth into this in this talk but I was just going through uh and going through those like um tutorials that I linked to in this readme uh in here so if we go here you'll see I have a video and uh the original repo made by Patrick Collins here that this is based off of that we're building off of and uh I highly suggest that you check these out and you can learn a little bit more about the specifics of how these contracts work right and here is um a link tree to some other fem resources a link tree um we have the starter kit so the fevm hard hat kit and The fevm Foundry kit if you have a preference for either Foundry and validity development and a Cod starter kit which I'm about to talk about what Cod is compute over data um but that's kind of a wrap around what we'll talk about here Lily Pad in a second right so we've talked about compute overstate and we talked about fbm and we've gone a little bit over the um uh data dial kit right um but I want to go over a little bit with some of the time we have left over to bacalao and compute over data so um basically back allow is a network of open compute resources uh uh open to solve any data processing workload right well blockchains are more resource constrained because of their architecture that allow is more open while still trying to maintain a level of decentralization right and so together they kind of complement each other's weaknesses where fem is maximally decentralized computation over State back allow maybe not quite as decentralized but allows a lot more heavy Computing on top of it by the way if you don't know what bakalao means it's a salted cod dish in Lisbon and I think that's a call back to all of the web 3 uh work that's been done in uh Lisbon Portugal right all right so again as a recap you know the base layer we have um storage providers um storing data and their and their um hard drives and then we have the deals that live on the file coin blockchain and that's where we have the fvm and computational overstate which allows us to write logic over those deals and now we have computational over data which allows us to take heavier data which maybe that data stored with the storage providers or really anything and uh new computation over that right um so we've kind of already talked about what this is you know we have computational overstated computation over data I'm not going to go over too much since we're short on time but um a cool bakulao project is a project uh Lily Pad right which um it's kind of like the bridge between fem and bakulao and so we can check out their GitHub at baculyle project lilypad um colleague uh Ali she's mainly been working on this and um I highly suggest you check out developer alley on uh on Twitter or on as you see here on GitHub and um everything you need to know is in the readme of these but essentially what's going on in lily pad is that you have a user contract that inherits another contract called lilypad events contract which is all in that repo and um with that inheritance you can call a function that will emit an event right and bakilao over here on the right is always listening to this event via the lily pad Bridge statement right and once it here's that event you know the event will say hey like in the example of Lily Pad one of the main examples is you can call it an event that says hey call stable diffusion with this prompt uh here's the payment for the event and um you know uh please uh do this computation and return the the result CID like store this data on ipfs and return the result CID on chain in this contract right um so this is a demo of it working uh uh Ali going through the contract we don't have time to go through that but essentially um you know it's a simple call an event is emitted uh you can find this demo on the readme so you know back here in the back of all projects actually lilypad um it's all I hear so I highly suggest uh checking out the readme and going through this as well right and there's also water lily which is live on VMA net which is trying to solve the um kind of ethical concerns around uh AI generated art um which um you know this kind of does it while attributing the original artists and uh you know down the line can be used to actually pay them for the work they use to train the AI right and um you know there's all kinds of uses that you can find for Lily Pad including like some uh basically a generalized Oracle use case where Lily Pad can be used to retrieve and do computational over data so we need then to put on chain uh vrf be a d Rand um there's all kinds of EI um like the default use case they have is again stable diffusion running on um bacalao and returning the CID of that generated image on chain and much much more okay a couple of questions here can you please send me your Discord name yeah um you'll be able to find me after this I'll try to head to the hackaths Discord for file coin and maybe I can answer your specific question here mad half um can we have the data stored in filecoin and use that data to try some AI models through back it loud yes if yes what is the use of vacuole in it as data would only be stored so back a lot was actually generalizable compute it doesn't actually have to be data stored on uh file coin only but that is one use case you can do when it is connected through uh to this file core and storage providers so I I meant to train some AI models uh yeah if you'd like I think uh the back allow it's very generalizable um if you check out the general back allow docs I think they show more how to run it um like I actually don't like I'm not with the back Cloud team so I haven't actually run back a while but I've called it from Smart contracts uh but yeah they have like a stable diffusion running in it so I I assume you can do that well Pence yep is there any YouTube video guide on how we can create customized data down on top of fevm data dial kit and store the data on the phone storage so uh again uh for that for the data dial kit um I highly recommend you check out um you know Patrick Collins uh video which I link here and in this video he kind of goes over Dows in general because most of the most of the data dial problem is around the Dow itself and how you're going to organize it and how you choose you want to do it and uh Dallas can be very intricate right which is why I link to this I think it's a very good overview video um um but there's also um the client contract which has its own like kind of Kit which is the core unique thing that's on uh filecoin so if you want to learn more about how deal making works on filecoin uh you can check this out and I'll provide the link it should be in that link tree that I provided earlier but I'll provide the link here and this is kind of how deal making works and I think I'm on time so yep um you know thanks for the presentation um that's my Twitter handle and that's Ally if you want to get in contact with more of the uh bakalao side of things um I hope you all found this um presentation helpful and it motivates you to build some cool applications using data dials or back allow on the fpvm so thank you cheers thank you Zach thank you for the great presentation and thank you everybody for joining today um yeah that concludes this presentation so uh yeah hope you have a great rest of the day you too bye
Automatic transcript — names and jargon may be misspelled.