Protocol Labs 🛠How to build projects unique to the Filecoin ecosystem
ETHGlobal·Wed, Oct 9, 2024, 12:00 AM
A Protocol Labs workshop! Embark on a journey with ETHIndia, where innovation thrives, collaboration knows no bounds, and hierarchies fade into self-sovereign ownership. The most skilled web3 developers, designers and product builders from all around the globe came together for a weekend-long adventure to advance the Ethereum ecosystem at ETHIndia in December of 2023! ----------------- Follow us: https://x.com/ethglobal Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com
Transcript
[Music] thank you so my name is Matt Hamilton I'm a developer Advocate at protocol Labs uh we are generally known for filecoin ipfs number of other Technologies like lib P2P it's networking protocol that's used in about a dozen different uh blockchain systems uh so today I'm going to be talking about building projects kind of unique to the filecoin ecosystem so filecoin has a in the context of this hackathon here filecoin has a virtual machine fvm and FM that allows you to deploy solidity contracts to filecoin well that's all great that's just like any other um evm type blockchain but what sort of interesting things can you do related to filecoin related to storage I'm also going to talk about some exciting upcoming Tech that we're demoing here as well and previewing uh very much Cutting Edge stuff but there's some really interesting in stuff there that people might want to uh take on so I'm going to quickly go through just to set the scene here some of the challenge statements um we can go over this again later so I'm going to go through this relatively quickly now we've broken it into a number of categories so we've got programmatic storage if anybody was in the talk uh by our friends from Lighthouse uh Lighthouse is a storage aggregator that stores data onto ipfs and filecoin they covered some ideas uh with regards to programmatic storage um as well so things to do with uh automatic renewal and repair of data we've got a service called Raz which is a set of contracts that allow you to uh indicate that you would like a particular piece of data to be automatically renewed at the end of its storage Lifetime on filecoin data Dows so uh decentralized autonomous organizations in which they manage data so this might be you have something in which uh you want to upload some data and have it collectively managed by a group of people maybe we even have something like an endowment fund that generates passive income through some other mechanism within web 3 and uses that income to then pay for the future storage of uh data on filecoin State Storage integration uh this is a uh kind of concept that we've that we we we're showing here that allows you to on FM or any other blockchain actually pull data in from things like ipfs and filecoin uh so it's more of a sort of a pattern and a interface to use but you can use it very flexibly on multiple different blockchains to pull data into smart contracts uh defi so one of the unique things about FM and about filecoin is filecoin is a huge network with a large number of storage providers on the network the network is a is a total of about uh I think it's about 11 exabytes of data at the moment it's about 1% of the entire data center storage capacity worldwide and that is a large amount of infrastructure there you may have heard the phrase deepin decentralized physical infrastructure well fcoin is probably one of the largest examples of deepin around it's also coincidentally one of the largest implementations of zero knowledge proofs uh something that some people might not realize that Falin uses zero knowledge proofs has done for about the past three years as probably the largest production implementation of zero knowledge proofs um out there at the moment but uh yeah with all of that infrastructure out there and all of that effectively Equity within the infrastructure it gives rise to some really interesting defi models because these storage providers have storage deals that they may be getting paid for and they might want to borrow the filecoin token fill in order to pay uh collateral for those storage deals uh conversely they might want to um so they might want to either lend against future Revenue that they might have or they might want to borrow um as well uh from that and then we get on to new tech breakthroughs this is the bit that gets really quite exciting um be warning there be dragons this is really cutting edge stuff here that we are working on anybody who was in Phil Bangalore will uh will know this because I went to demo some of it but uh we have got the mycelium test net up and running now so you can have a go with it so there's a couple of new things around IPC which is interplanetary consensus so IPC allows you I'm going to cover this in a little more detail uh to have subnets on the network so individual networks that come off of the main Network so think of it like Layer Two but in a recursive fashion layer two three four five you can have U multiple subnets there so like I said I'm going to cover that in a bit but this gives the ability to be more flexible so you could create a subnet in which you replace the virtual machine run time on that subnet so you can replace fvm that we have on there or rather FM which is the ethereum layer on top of the filecoin virtual machine with another virtual machine so something like moves VM or poker VM salana VM for example you could could Implement on top of that now it's a lot to do within 36 hours but I know that some people that are up for a challenge it would certainly be interesting to see people kind of have an attempt at that and with these new tech breakthroughs we're going to be a little more lenient on the judging on them because we know that these are real stretch goals so people that make a you know a valiant attempt even if you don't necessarily cross the Finishing Line with what you're doing but uh you know you show some very significant progress and learning then uh we'd be very interested in that so new run times also large scale applications so using things like uh blockchain for gaming so for example things like turnbas games you could make something like a simple um like a board game for example and you could use a blockchain for that you could use a subnet for that because we're reducing the the block time right the way down to you know a couple of seconds and so you could actually use that um as part of storage and part of the the logic system of a uh game so onto a little bit of background so that's the uh the um bounties kind of gone through and we'll go through those again um later uh but protocol Labs like I said you know us mainly from probably the three biggest things we're known for ipfs filecoin and lib P2P um people that use any of the technology uh that we have developed there uh up here are eligible for bounties including some of the storage aggregators like nft storage and Lighthouse and the CDN that we have Saturn that is a a Content distribution Network for for web 3 as well so bonus projects for building out unique ideas please don't just you know go and uh store a little bit of data on ipfs um and come to us it needs to be something more than just ipfs right if you're using one of the storage aggregators like I said Light House nft storage that that's fine um we'd really love to see something more exciting than just storing a little bit of data on ipfs uh it's one of those uh kind of almost unfortunate um paradoxes that we have ipfs is so simple to use which is great but on the other hand it means that sometimes we can get some uh projects that are not as exciting as they could be because uh one line of code to store something in ipfs um we'd like to see somebody uh stretching things a little bit further if they can do so the filecoin master plan uh build the world's largest decentralized storage Network we've done that and that's continuing to grow even more on board and Safeguard Humanities data we have a number of projects that are pulling in large scale data from public archives research organizations that kind of stuff to be stored on the network we're also looking for people within the web 3 ecosystem to be uh using filecoin as well for storing data and then the next stage is bringing compute to the data so uh you can kind of think of this as as a bit of an evolution where we're talking layers here we're not talking layers um quite in terms of um layers like as in blockchain layers but more as in sort of conceptual layers so if you think about um ipfs and lib P2P as being kind of the ground layer on which a lot of these Technologies are built and then we've got things like layer zero the filecoin uh blockchain itself and then layer one the FM the filecoin virtual machine and that allows you to do compute over state of data so this is just something to be clear about with filecoin the actual data itself is not stored on a blockchain there's no way we could be storing 10 exabytes of data on a blockchain and getting consensus on that globally so the data itself is stored offchain what is stored on filecoin is the metadata the accounting data and the proof that that data is actually stored and is safe so fbm allows you to do computation around that and logic around that state so how long is something stored for is it still valid um can I instigate a renewal of that data or replication of that data that's all kind of things around fpm and also like I mentioned defi things like loans for example you know how much storage capacity has this storage provider got and could I use that as collateral for a loan and then we get into like Layer Two which is IPC the interplanetary consensus and that allows then really performant daps uh with chain scale ability scaling both horizontally so you can create multiple subnets and scale horizontally so that might be Regional scaling um or it might be uh scaling based upon a particular application for example or use case or vertical scalability because with um uh IPC you can actually chain um blockchains and have layer you know layer two layer three layer 4 Etc going down I'll talk a bit about more about that in a bit so I mentioned FM onchain programmability um I mentioned about how FM manipulates and allows you to interrogate the metadata around the storage deals um on filecoin allows programmatic storage um with smart contracts like Raz so if you saw lighthouses talk earlier they showed an example of using Raz uh which stands for replication as a service or renew or repair as a service um and they demonstrated using a smart contract to actually instigate that uh that that logic around renewing uh storage there and uh the fvm the the FM layer on top is fully evm compatible so you can use You Know metamask Remix all your standard tools um hard hat uh to work with it so here's a developer resource uh for programmatic storage um if people want to grab that uh QR code there so uh that will take you through to um I think that takes you through to some documentation on lighthouse on how to use Raz with it we also have a renewal as a service starting kit as well uh within the Falin project on GitHub so uh the Raz starter kit can help there as well then another example is data Dows now I'm going to actually uh yeah I think we've got time uh do hopefully a very quick demo of a data da so like I said a data da is a decentralized autonomous organization that can deal with the management of that data so what we've got is an example where we're using a governor smart contract that's a standard contract from the open Zeppelin project that's used by many uh Dow projects and what we're going to do with that um Governor contract is we're going to submit a proposal and that proposal is to store a what's called a CID so content identifier um on the filecoin network so this is something that's already stored on ipfs somewhere and we want to store it on the filecoin network for longer term archival verifiable storage on there so we're going to make a proposal to this to this Governor contract now this Governor contract for the purposes of this demo is only going to require one vote for this to be approved and the voting period is only going to be 3 minutes right typically you'd have something you know longer and more in depth and once that's approved you can then execute that um proposal and executing that proposal will then cause it to be sent to lighthouses Ras contract and then stored via Lighthouse onto filecoin so I can give you um like a little quick demo of this um just deployed these you can see here with uh hard hat uh I've just deployed these uh contracts and so the next thing I need to do um if we look at the documentation here for the dayod D kit um it gives us an example here so I am going to propose a particular CID to be stored on the network so if I clear that put that up there uh so yarn hard hat propos I give it the CID and I give it a reason hello bangaluru so I'm going to going to do that that is going to propose that to the network that's going to take a little while to actually execute on the filecoin network so in the interest of time what I'm going to do is I'm going to skip forward a few slides talk about a few more things and I'll pop back to this demo kind of as we're going along okay so this is making a proposal once we've made a proposal we're going to vote on it actually maybe what I'll do is I'll just wait until this goes through and I'll execute the vote and then we can then we can move on so going back here we can see there's a vote uh command and in the vote command we need the proposal ID that proposal ID is going to come out of um this uh uh proposal command so we'll see in a minute once this finishes executing we'll get a proposal ID and we'll feed that into the next command like I say this is all in the uh data Dow starter kit uh the QR code is there if anybody wants to grab that to uh follow along with this this will be a good basis for if you want to try and do some things here regarding managing data I talked to some people that are interested in things like refi um you know some interesting examples with regards to storing data for conservation purposes for example that might be uh interesting here so that's finished it's come back with a proposal ID so if I just paste in this vote command I'm just going to replace the proposal ID there with the one it's come back with and that's going to now vote so we have 3 minutes um to vote so this vote should go through within 3 minutes and after 3 minutes I can then execute the proposal so whilst that's waiting I'm just going to continue on here I'll talk about the system State Storage I mentioned this right at the start with the uh with the bounties so State Storage again there's a QR code that will take you there to a state storage starter kit that we have and this is a mechanism by which you can um uh request that some data from a CID be loaded into your smart contract now obviously bear in mind you don't want to load huge amounts of data into a smart contract because you've only got limited processing within solidity and costs gas fees memory usage Etc um again you don't want to be loading too much but if you have a small CID that is uh under a single chunk size I can't remember exactly what a chunk size is on ipfs um a few kilobytes I think um you can request that that be loaded in so what happens is you have a smart contract um with a method called request blob load and you pass in the CID um a reward that you want to pay and you could Implement a reward function within this as well and a timeout and that emits an event that is listened to by a uh little demon that you run if you look in the starit there's a little JavaScript demon that you run that connects to the network and listens for that and when it gets that um back back it fetches that CID from ipfs you have to run a local copy of what's called ipfs desktop in the example we've given obviously you can extend that to do whatever you want to do um but if you've got local copy of ipfs desktop it'll communicate with that fetch that CID and then call this deliver blob method and pass in uh the thingle correlation ID um that it gets and the actual payload of that CID and it will validate that that uh data is is valid because a Content identifier if you're not aware within ipfs and filecoin data is referenced by content identifier that is in simple terms a hash of the data so if you have the content identify if you have its address you can verify that the data is in fact intact and the data that you requested is actually the valid data because you can actually take a hash of that data compute the CID and see if that matches what you requested um so you can do that and get the data in and then you could do some processing on that within solidity let's see how our vote is going so our vote's gone um I'm going to now do a I'm going to execute the execute command looks very much like the proposed command um and so hopefully our 3 minutes is up now the voting period is over if it hasn't I'll get an error here telling me that voting period is not quite over um in this case it looks like it is uh it's going through so this is now going to execute that command and send that CID off to Lighthouse to now go and get stored and I don't know if we'll have time to to see it but in in a bit we can probably check the block Explorer and we should be able to see that having gone through uh so state store I mentioned um oh yeah this is just a diagram of kind of outlaying what I mentioned here you have a client dap so looking at the yellow boxes along the top a client Dap You you have a uh what's called the data management smart contract that's included in the starter kit you have a data relay demon again that's included in the starter kit that just fetches locally from a a local ipfs node um and fetches that data from there so you see kind of going through the top here we go from the client to the smart contract to data relay demon to ipfs and then the data comes back basically the opposite direction um back through there so but in that starter kit there's examples there you can basically play with so on to some more exciting stuff interplanetary consensus so interplanetary consensus uh is unlocking basically web scale uh you know or planetary scale performance for web 3 apps and like I said both horizontal and vertical scalability there a couple of QR codes here the top one will take you to an IP uh an IPC uh Docker uh image that's made by the developer experience team the DX team that I'm a part of uh that will allow you to get started fairly quickly using just Docker be aware it will download a fair bit under Docker um and then there's the IPC docs that's the next QR code down they'll take you to the documentation about IPC as well there's a lot more information there um we've got here uh so this is the docks here that QR code will take you to within the docs we've got a couple of quick starts that allow you to do things like deploy a smart contract to IPC so we have a public test net called melium and you can just configure metamask there's instructions there how to configure metamask to point to mycelium and you can deploy to that just like you would do um you know any other Layer Two or layer one network but where it gets really exciting is you can deploy your own subnets um so you may be able to see on the the right hand side here uh we have a number of subnets that kind of come off of the root Network each subnet is its own entire complete blockchain so in IPC it uses tender um and Comet bft for the uh consensus protocol and you have a number of nodes uh running there they are a complete working uh blockchain in and of themselves right we actually have in that DX container you can actually run a local what's called a test node yourself that is entire subnet that's not even anchored to any other network so if you want to have a play around with something locally really quick you can deploy a test node and interact with that but you can anchor the subnet up to a parent Network so in this case you could anchor it up to filecoin but actually it's uh you could anchor it to any evm network I was talking to somebody from polygon who is interested in anchoring it to polygon I said yeah sure give it a try um so uh that should work periodically the subnet then checkpoints its um chain State up to the parent subnets and that's how you get the effectively the long-term security there uh from the the parent chain so you can use IPC to to Shard applications or Shard a network into either uh networks sub networks per application or potentially per geographic region for example um on there uh so here we go here's an example here we've got like main Nets Layer Two networks oh sorry layer one networks at the top and then going down to things like you could have a gaming subnet or a database subnet um and then maybe different games and then for example you know Regional subnets underneath there as well the ultimate goal that we're aiming for with this is that these um IPC subnets will be so lightweight you'll actually be able to run a subnet node within your browser it's not here yet that's the direction we're going though but that'll give you a bit of an example as to what might be possible for example you can have a game in which the main long-term game State imagine things like the high score table for example are stored in a regular subnet off of IPC maybe where we have you know one of these uh like game game a or C along here one of those could be that game right then when a group of us go into the game Lobby and start a game maybe a dozen of us start some kind of interactive game with each other then each of our browsers could spin up an IPC node to create a subnet an ephemeral subnet that just lasts for the duration of that game now that game subnet could be responsible for just things like our score Within the game we are playing enforcing the rules and the consensus within the game we are playing making sure that one of us is not cheating making sure that in-game currency or items can be passed between us in a secure and fair manner once we get to the end of the game somebody's the winner say their score could then be propagated up to the higher subnet that is the longer running subnet and the subnet that's within our browsers the ephemeral subnet that was just for that game can be discarded right we don't need that anymore that was just around to ensure that the game play was fair for the duration of the game but the the actual long-term artifacts of that like the high score for example could be passed up to a longer running chain so that's a kind of an example as to where this kind of all fits in together thank you so just to reiterate going back to the challenge statements I'm just going to bring up again the new tech breakthroughs one because like I said we've got a number of challenge statements um here U most of which if you've been to any of the other uh eth Global hackathons or eth online um hackathons may be familiar to you but we've got some new stuff like I said there be dragons this is stretch goals uh it's a lot to potentially do within 36 hours but if somebody wants a challenge then by all means take it on we could look at things like like I said new run times uh larger scale applications running games that kind of thing on there would be really interesting to see so that's everything uh thank thank you very much and if anybody has any further questions um I'll be just down and probably just actually just at the entrance of this room here uh myself and Juan Benet founder of protocol Labs who's just sat here in the front um we'll be just stood outside here if people have any specific questions we've also got the filecoin booth which is directly opposite here on the far wall so you can come and chat to us come get some swag as well okay thanks very much I
Automatic transcript — names and jargon may be misspelled.