New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

Cartesi 🛠️ Billions of Reasons to Use Cartesi - Carlo Fragni

ETHGlobalMon, Oct 9, 2023, 12:00 AM

Join Carlo Fragni from Cartesi for a talk titled "Billions of Reasons to Use Cartesi". Thank you to everyone who joined us for ETHGlobal Lisbon! After being away from Europe for almost a year, we've decided to bring the heat and excitement back to the stunning historic streets of Lisbon! All over the world, hundreds of thousands of developers, users, hobbyists, creators, artists, and market makers spend their days and nights thinking, building, talking about Ethereum because we are... excited. We're excited by the idea that Ethereum can change things. This May, we invited you to come learn what all the talk is about. We were joined by the leading teams in the ecosystem such as Polygon, Metamask, Aave, 1inch and Gnosis Chain who have a number of prizes up for grabs! This event is focused on building a new product/protocol, learning at the summits through talks and workshops, and giving opportunities to gain valuable feedback from ecosystem champions at the beautiful Convento do Beato. Find your future team at our Hacker Café and create even more meaningful connections while engaging with some of the most notable speakers in the industry at Pragma Lisbon. At ETHGlobal Lisbon you'll have the support of a huge community of experts, mentors, sponsors, developer advocates, and other community members who want to help you build something awesome. ----------------- Follow us: https://twitter.com/ETHGlobal​ Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com

Transcript

foreign [Music] hello good afternoon to you guys my name is Carlo I'm with Cortez and today I'm going to try to convince you to use our Cool Tech to do some increasing stuff the name of this is billions of reasons to use car salesy and I hope it becomes clear during the presentation well okay so today we'll be covering basically this quick overview of what Cortez is and then an issue into the Art Attack which is Cortez rubs its interfaces a really simple application of how you can build a Cortez application in in this case in Python and then I'll go through a couple of things that are being built with Cartesian are nice things to inspire others so this is just a preview I'll come back to this later but this is a really simple program in Cortez in this case it's a neck publication whatever you throw it it froze back at you and if you check the code on the right side which is uh the the whole application code for the ones that are familiar with python this is just traditional web tool python code there's nothing that is screaming right free you don't have to learn anything new you're just using requests which is a well-known HTTP client so it's really easy for anyone used to web2 to get started with Cortez but as I said I'll go back to this layer so let's get started uh so what's the idea behind curtising so Cortez started in 2017 uh ethereum was booming at that time and the theory is really nice so we have all these decentralization properties censorship resistance uh no one can tamper with anything because if they try to it's really hard you have to lie with thousands of nodes in order to get you right and um it's awesome but it comes with its disadvantages as well so on ethereum everything is low is expensive and it's cumbersome why slow because well we are sharing a single VM all the resources with old applications that are running on it expensive because you're you're always bidding for the resources that are scars available in there so you have to purchase that resources and over bid others trying to use it and Converse them because uh ethereum was designed around evm which is really good for sandboxing make sure that no one's messing with someone else's computation but it's not similar to anything that came before so all the tooling has to be built from the ground up so what's the idea behind characterizing what if we could have much more complex computations still having these really cool guarantee is that blockchain gives us but with great selling and that's what we achieve so uh what's our solution so we have this really cool application specific roll-up solution we basically do this uh roll up for each application that the deployment Cortez each one of them has their own VM and this VM is based on this risk five architecture which is an open Hardware processor and uh since everyone's got their own processor the applications are not completed for resources and it's based on this traditional computation platform well we can put Linux and by booting Linux we'll bring all the web to goodies for web pre-development you don't have to learn solidity to have all this really steep curve for doing your decentralized application you can just use what you used to want to and uh in order to make it easier for people to onboard we wrapped all the complexity of the framework on an HTTP interface so how do we achieve this this is achieved by using a very cool uh dispute resolution protocol that secures this computation it's based on on something called verification game uh I'm not getting gonna get uh really down on some details of how it works anyone interested on that can talk later to me but uh basically what happens is that all these competitions that happen in Cortez machine the Cortez machine is deterministic so if someone disagrees about the competition they engage on this verification game protocol uh we said what's the first point of the computation you don't agree and that single instruction is arbitrated by the underlying chain on a copy of the Cortez machine implemented in solidity so when you have a dispute it's an entire blockchain you're using under underlying that's actually arbitrating if you're right or wrong so it's uh it's a very safe our security guarantee is that a single party willing to enforce the correct result is enough to guarantee it okay just being a bit graphical here so if you're in touring is really scarce because as I said AVM is not compatible with anything that came before so everything is being built from growthup and when it comes to fertazzi oh well you have everything released on web2 so you can use all the libraries all the services all the languages that you're used to this is just a quick overview of how you can make your Cortez machine Drive in which contains your application everything you're going to use so when you're building your Cortez machine you can take advantage of a Docker container which uses camo to emulate risk 5 and all the Linux resistors that are already built for it and you just use whatever you want to install your environment so in this case here I'm just using I'm just starting from this risk 5 build of Sling Jammy for python which is a Ubuntu distro you can use whatever you want Alpine these are a cup of tea go for it you want to use a vanilla Linux go for it as well whatever you want you can start in there see some Ubuntu and I want to use a sqlite database as well I just aptically solid and it's available inside the machine for for my usage then I just copied that directory in there to this optic cortized app because on my directory I'll have the actual python files for this application which actually has my logic and Edge can just install the dependencies like I would do on any Linux machine so for a web to developer this is all a very simple if you're used to docker now let's talk a bit about the computational scalability so if you take a look at V for scanner or whatever your Source you can take a look that ethereum blocks they generally have like 30 million gas on all the transactions within it so considering you have the entire block just for yourself and you're doing the cheapest possible useful computation so if you take a look at the funeral Play codes the cheapest one is adding and that costs three gas so that gives you a boundary of about 10 million instructions for the most you can do on an ethereum block considering you have the entire block for yourself which is something really hard to get okay just as a comparison uh this is hard to read I guess but in here I have a terminal and in this terminal I'm just booting the Cortez machine and holding it doing nothing just booting Linux and just shutting down and this is using along about 37 million risk 5 CPU Cycles which are much more complex than just adding so if you do equivalent operations on the on the evm it's not going to cost uh three uh I guess it's going to cost way more but that's just to give you an idea of the scale the competition you can do and booting Linux and shutting down which takes about 37 million uh risk five CPU instructions happens in a laptop in 0.2 seconds so it's pretty fast now just another comparison um I've done some dumb computation here using a shell script and that took 3.7 billion CPU instructions okay and on us on a regular laptop that took about 13 seconds which is the average block time of ethereum so just to have a perspective of how that is compared to those 30 million instructions you can have a fury Block it's this weird so the left top corner is a yellow square and that would be 30 million instructions and then 3.7 video instructions will be all this blue grid and that's not the limit of Cortez machine computation I just limit to 30 seconds but you can actually have as large computations as you want remembering that this machine is just for application it's not shared among everyone just like in ethereum so let's get started on curtiserable Roll-Ups uh this is the overview of a cartesia rollups application so on the client side traditionally you're going to do a web application so you'll probably be using HTML CSS JavaScript some framework you're used to like angular react to the UJS or whatever your capacity is and then you need a couple of libraries to connect to the Cortez framework the Cortez framework has three interfaces you're going to use the first one is the Json RPC one and why is that because our framework is deployed on top of an evm blockchain and in order to provide inputs to the cartridge machine there's a data availability problem so we force this to go through the blockchain for a special smart Contour Cloud framework and well to talk to ethereum or any other blockchain you generally do this using gsrpc interface into an ethereum or polygon organosis or whatever you do not then we have an HTTP request API that's used for something like ethereum calls so it's a ethereal calls you do to check some machine states that doesn't really do anything it's a read-only operation right and finally we have a further interface which is a graphical one in which you can create a Cartesian node for events and things that you emitted on your logic now your decentralized logic actually resides inside reporters machine and in order to make it easy for you to program we have this HTTP dispatcher component that wraps up the entire framework complexity on this simple HTTP interface uh what does it look like well let's go back to that first slide now let's go in details so if you take a look at this code we just start like our traditional Python program we're importing requests which is our HTTP Library we're importing the environment module from OS because we want to read the environment variable in this case it's being used online for because we're looking at this roller HTTP server URL which is an environment variable we set with the address of this HTTP dispatcher okay well once we know it we ask for it what do we have to process so the basic structure of a characterizing program is an iterator in which you call this finish endpoint and when you call it you're doing two things the first thing is you're putting a payload saying what happened with the previous video process is it okay is it invalid if it's okay you return uh uh a status accept saying it's fine the Cortez machine should eventually State it's fine everything is valid if it's something that will corrupt your application or anything like that you can just reject it by returning a payload with status reject once it happens the characterized machine holds and it's waiting for the next input the next input comes these call returns and you get a response with the data of the next thing you should process the payload itself is in a field called data and then you have some useful metadata one of them is message address which is the sender address you have the timestamp of the block unit which you received it and a couple of interesting things on line 26 specifically we're looking for this request type this is a pretty simple usage it's just a metadata that can come with Advanced state or a spec state or lines 19 and 20. and that's for you to differentiate when you have an input that came through the blockchain that should Advance your application state or if that's if call a female call in which you just want to generate some state of the application maybe for a front-end to consume or something like this so just an example let's say you have a chess application you move a piece that changes the application State that's going to come on Advanced date now you just open your application you want to know if a game is going on or something like that traditionally you would have to go through the blockchain check all the transactions that you have to rebuild the application state or use something like graphql to index estate and query it with Cortez you can use this inspatch state you just provide your address and it's going to return Json maybe with your chest configuration chessboard configuration and the player server right so this is the difference in this really simple example we handle either Advanced and inspect States the same way we just pick up the payload of the input we put it on a Json and we meet an event with it in case it's a handle Advanced we use our interface called notice which is equivalent to an ethereum event and in case of Henry spec we use the report which is the wrapper for a for responses for these ephemeral call which is the inspect API now on the left side we're using a really simple front-end application we built in typescript that implements those three interfaces of the other slide so if you call this command ER start input send Dash payload whatever you put in there and in this case hello there it's the binary payload that's going to go on this add input framework and it's going to be piped into the Cortez machine so that hello there it's a rising knee here foreign and after we process this response in line 8 that Json with a notice it's going to post it with exactly that payload so now if you call this front-end application with the iron start notice list it will go to that graphql interface of the node and it's going to say hey give me the notes and you have a nice gnosis in there with the hello there because this Echo application just pipes the input back to the output so this is a really really simple crash course on how to use cartesia it's a 27 line python code you can make it even less if you want and it's just using hdp interfaces nothing nothing fancy nothing different cool uh now that you have a crash course on how to make a Cortez application and the interface and stuff let's take a look at some usages and some nice things people are doing with it so generally people use Cortez either to further decentralize that logic because most apps you do when you go to High computation or something complex you generally put a part of that app in smart contracts and then you put some also the logic centralized that works for game for dollars for a lot of stuff so with practice since you have a Linux machine with great tooling and a lot of computational power you can actually decentralize this logic logic because you got all the tuning all the libraries so you can have really complex mathematical functions that you just import and use you can use numpy you can use data analytics you can use machine learning all the stuff that's already been developed leveraging traditional stacks and it's also way easier to onboard webto developers into web free because after all they're using the tooling they're used to so a first school use case I want to show is this game is developed by a Taiwanese studio called efforts and the game name is Dazzle it's basically a Pokemon in crane crash mashup so you have your team you attack the other one whenever you want to attack the other player you do a combo on this shared puzzle and then there's no problem about anyone needing to trust the server about anyone temporary with the random numbers that's going to fill the the puzzle so you're in a competitive match you know that no one can produce with your board to get a better combo next turn or anything like that the client itself is done in unity it's pretty beautiful it's got some pretty nice effects 3D characters that they use as nfcs and they give me logic they're building rust and it runs inside the cartels machine so each match you can just run your own node check its it checks out nothing was separate with if someone tries to temper with it you can just prove they're wrong and enforce the correct result this is a nice defy application that was done uh inspired by the mango hack on Solana so there's this D5 protocol Landing in in Solano that's really simple and it was hacked by a guy that checked that they accepted a certain asset as Quadro and this asset had a really poor liquidity so this guy got something like 5 million dollars purchased the asset from the price goes to Mango says Hey I want 100 million U.

S stable usdt or another stable coin gets it because it just goes to a price Oracle checks out but then if they try to liquidate it it won't hold it it's not worth 400 million it's worth those 5 million paid so inspired by this these guys they made this really nice risk analysis protocol called Netflix and uh well they feed the Cortez machine with prices and volumes of assets and then they use numpy to do some sophisticated analysis and come up with some robust metrics about liquidity and volatility and then the recommendations like yeah this assets is not good you cannot liquidate over 10K on it it's gonna hold or no this is a great asset weights the liquidity low volatility you can liquidate a million bucks and no issues here this one is more machine learning and image processing so these guys has this problem of people tampering with fingerprints uh in many places in the world it's used either for Access for clocking in and clocking out of work this kind of stuff and people mess with it so they make fake silicone fingers to go in go out or to gain access or photocopy and this kind of stuff what this guy did is he made this dapping cartastic which is specialized on defining if a fingerprint was poofed or not how does it work he gets inputs as a fingerprint image then has a first C plus plus program using opencv it processes this image and describes it in an array of features that is fed into a Python program with a really cool machine learning model he trained and this model was trained to differentiate the real fingerprint for some bits both from Silicon or our paper or anything like that this one is more on games AI this is from a guy that came from our community and it's called ultrashes so chassis has displayed that people don't really play chess online they open up a game but you're not playing versus a human they just open a computer game whatever you throw at them they throw the computer whatever clever move the converter does they throw back at you so this guy said Okay so let's make it part of the game you can play as a heroin sure but the main focus on Ultra chest is actually you're a trainer of the bot that's gonna play so you do your AI you train it you change its parameters you put it in there and then inside the Cortez machine automated matches happen and your King of the Hill you turn your your Bot you you defeat someone that's producing the video so it becomes a bot automated game and the focus is on your training and improving your Bot since it's happening inside the Cortez machine if you win or you lose a match it's not because I'm on temporary with the match there's nothing to temper with anyone can reproduce all of the matches and check that everything's fine in this case you build it in Python and uh and the web user interface the Bots themselves they use a protocol that established and they can be developed in in any language you that you want so you can do a binary in C plus plus a rest or you can do a python script or JavaScript or whatever you want this one is a really cool application that came from India so Indians they have a problem with car insurances uh basically there you have an accident you activate your insurance and they deny you the payment and why is that they claim you're a bad driver how do you dispute it you go to the justice the the decisions behind closed doors and you cannot really dispute it so what this guy is doing is a decentralized car insurance protocol so most cars today they have this old bdb 2 port in which you can export all the data from the car computer they feed it into the cartel machine then inside the Cortez machine they have this model that analyzes this data and come up with a risk metric saying you're a good driver you're a bad driver you're ever driver and based on that data they deny you or approve your insurance and they make it cheaper or more expensive so if your insurance is expensive or is denied or anything like that you don't have to go behind a port for something uh well you just check the data is in there the model is in there yeah I'm a better driver or no I'm a good driver they make a false claim they dispute it and you force a correct result this one was also built in Python this is a really nice application that was done in a Harvard hackathon so these guys they got this retro style emulator called ikim and go that those games like Street Fighter they put it inside recorders machine they make a Python program wrapping it and they created all these crazy nfts for Pikachu Pokemon pizza delivery guy you name it and then this application called Coliseum you will have a batting phase everyone says I think this guy's going to win this guy's going to win they all put their money it ends then you have the automated match happening inside a Cortez machine and then you have the result and you pay the winners once you have the result they also render the the whole match into old-school Style video so it's interesting you bet then you watch the the match like you're watching anime or something like that and then you get your money in case you want once again nothing to tamper with is someone tampered with a fight you just enforce that correct result by the speeding propagation and this is a really cool guy the these guys they made this uh for a hackathon in Bogota so nfts have this problem in which nft itself it's not the assets you want it's actually a certificate pointing to the asset so there are a couple of cases in which you purchase this really expensive nft and then the person changes those that beautiful art for a blank canvas on the server or something like that so these guys they actually wanted to generate an NFC collection with provable art how did they do it well they generated the art within cartized machine and in this case they use a competition intensive algorithm that generates fractals called a meadowbrot they implemented it in Rust so you should have an nft from their collection until someone tries to temper with the art or anything you just go to the Cortez machine say hey this is not a real art the real artist this one this is a computation that generated anyone can just verify this is the right art this is a more traditional application but still it's an interesting use okay so this is from a team of Poland and what it is they did a decentralized parking app I'm not sure about your personal experience but sometimes you get to find for not paying your parking but you were on time all the stuff you have to go through the common Justice to dispute it it's a hassle especially if you're not from the place sometimes you don't know how to pay for the parking meter all the stuff so they make this really nice application the front end is web review and they use rust and post sqlite on the back end is this nice application which you have the parking zones you have the fees you can just go in there and fill up your meter anyone can go in there and check that you're still on your time and do your thing so it's a more traditional web show application it made it very easily in inside the Cortez machine um all these and many others we have things with carbon credits we have other things really interesting news with machine learning so sentiment analysis all this stuff they're available on this showcase page we have our games we have uh yeah uh some really nice projects in there they're a winner and just to inspire you guys a bit more on what you can do on Cartesian so we have this this track with a total price of 10K the first winner is going to get a nice price of 7K and then we also have a SharePoint for the runner-ups so three teams share one thousand dollar each okay so uh we had this tweeter on February of this guy asking well if ethereum is really the work computer can someone explain how no one has managed to get their own working in it and we had a very clever engineering our emulator team we said challenge accepted so yeah he put the real time running inside the Cortez mission and uh yeah it's really cool so if you look at his suite I can give you the link later there's a render of him play and there's also a GitHub repo for the the courageous to use because he hacked this refresh so it's not really easy to reproduce it but it's in there okay and that's all thank you very very much for attention I hope you learned something maybe and whatever doubt you have you can shoot at me we're gonna be on our stand during the whole hackathon so if you want to exchange an idea if you have something you want to build if you want to brainstorm if you're trying to build with us and you have some problems you need debugging or anything like that where they're available for you thank you guys so I think we have some time for questions if anyone wants to ask something sure how what's it works on Randomness okay so the question is how Randomness work and that's a great question so the the way it works is when you generate a random number on a computer it's not really random it's best random right and the source of entropy in the Cortes machine is controlled otherwise it's not deterministic so when you generate a random number in a cartel machine it's always going to be the same because other people will produce it and it's the same that doesn't mean you cannot have random numbers within it how do you do it there are multiple techniques and that depends on your application so let's let's get Dazzle for example which is a multiplayer game right you need to generate a random number to refill the the the marks the way you do it is you use a seat that's a joint number from both players in order for you to have both players contributing without one mining Advantage random number we use a scheme that's well known comes called committing reveal so basically when players commits to a number maybe the hash of their number the other player submits the actual number and then the first player has to review the first number and then it's a hash so you hash the number he provided if it checks out that's a number if it doesn't he tries to tamper with it everything is fine combine both you have a seat for a random number that's a strategy you can use our approaches it depends on your application you can let's say you have a SWOT machine application for instance you can use something that's hard to control like the block hash of the input that's coming requesting number uh you want to be maybe a little more safe you can use Oracle from chain link you can use a vrf uh yeah there are many options yeah because you can always reset the seed on the Linux system so yeah you just set the the seat on the system and that's going to be used Universal yeah cool any one has got further questions as I said uh with hackathon for everyone if you need this want to trade a word or something we'll be on our booth and happy to talk to you guys have a good evening

Automatic transcript — names and jargon may be misspelled.