Cartesi 🛠 Build more powerful DApps using familiar stacks and libraries – Gabriel Barros<a href="https://www.youtube.com/watch?v=QVYm43KnVl4" target="_blank" rel="noopener">Source</a>

Foreign [Applause] [] So for right moment I'm gonna be presenting to You somewhat bit about optimistic calm down And additionally how critazzi makes use of it uh for our in what it could actually supply to Whoever builds in it And um First uh we're gonna begin with a fast of Cortez simply very briefly and Then I'm gonna evaluate somewhat bit uh Numbers I view the variations between Web two three and the way it appears whenever you Build on cartesi after which I'm gonna Explain somewhat bit about uh Roll-Ups Finally I'm gonna current to you a really Simple a small easy code of our Cortezid app written in Python So here's a tab written in Python that Works proper now contained in the promoting Machine I don't anticipate you to grasp it Right now nevertheless it's simply to point out that It's a easy enjoying Python and you may Have libraries and you may have Interactions inside the machine you'll be able to Have entry to different apis that you simply Develop so it's actually a server Um used as a dab So cartesi is a basis that has been Working on this since 2018 we've been a While constructing stuff uh so it's not simply Some new firm arising when Road

Labs confirmed up Um And uh the group Has been constructing this machine for a Long whereas after which the relapse uh Technique appeared and it simply really feel like A glove so we tailored the machine to to Be an actual love resolution and scale So the primary thought behind courtesy however I Guess to some extent uh our relapse is That ethereum is superior uh there's a Lot of attention-grabbing stuff about it specifically Like uh it's safe it's a censorship Resistant uh it strives to be Decentralized and that's actually good however That comes out with plenty of Consequences and prices Uh it's low it will get to be very Expensive and which means uh we're Always Building a technique of gentrification of The community so we're evicting depths They at the moment are worthwhile though they May be for the communities And for the newcomer builders Cumbersome as a result of you want to Understand about machine structure You have to learn the way the evm works and Then uh a brand new language like solidity Viper and even low degree stuff when you Actually have to go that far So it limits you in a number of methods even Though it brings one other plenty of new

Interesting options So the primary thought is like why what if we Could have advanced computation inside a Blockchain and preserve safety Guarantees So the curtasis resolution is uh Transparent VM so as an alternative of being Another evm based mostly Network a sidechain or Even lots relapse may have a danger 5 Emulator danger 5 is an instruction set For a beneficiant goal processor simply Like those in your hand on your Computer or your cellphone so you'll be able to suppose Of it like a Docker machine of kinds or A virtualbox And uh we made it deterministic so we Got one thing verse 5 is open supply Open durable to be extra particular so uh we Got it from the neighborhood and we made it Deterministic and we utilized it to Blockchain So Um right here's issues that you simply get so like Any firm and individual can construct on prime Of danger 5 it's auditable it's extra that as a result of plenty of People has have been working on this Project It's a platform processor like I mentioned so You can run an operational system inside It inside it in order that's why we had been ready To Port Linux to the blockchain uh we Made a deterministic so which means you Can dispute any computation that occurs

On it and naturally as a result of it's a full Machine it's very uh capable of do Computation and you may increase on it Like you'd do in any server or Server software Uh the primary distinction between most Optimistic relapse and what we do at Cortez is like we've got an area consensus So if you consider ethereum the extra Computers you add to the community you're Adding on safety Decentralization however you're not including Processing energy you're not including Throughput However with native consensus or depth Specific relapse what you've got is adapts That don't combat for the sources they Don't combat amongst themselves they've Their personal units of validators Or what which means is now As the extra depths you've got on the You're truly rising the general Capacity of ethereum To course of issues And that's all actually good and doable Because of the dispute protocol so Whenever you've got an issue at any time when There isn't a disagreement between Validators it's not a majority Consensus it's actually uh it actually goes Back to ethereum and makes use of it as a choose So the identical emulator I simply talked to You concerning the one danger 5 that you may Run on a machine for catasi node can also be

Implemented in solidity for the evm so Whatever course of you are able to do I've chain You can do on chain as nicely however with This verification recreation dispute you Actually go right down to the very Instructional cycle that you simply disagree With the opposite node and also you solely have to Prove one instruction cycle on the Ethereum machine and that's doable Because the machine is unmertilized so You know precisely why the instruction Cycle must entry just like the reminiscence States and also you simply have to add this Section of the machine in different employee Proofs for it That implies that even when there's Collusion amongst validator nodes of a Specific faucet so long as you've got one Known as validator you'll be able to return to Ethereum and have the proper settlement So how does optimistic prolapse truly Work any Roll-Ups normally however utilizing This particularly so that you begin with the Ethereum blockchain And no matter you do you're all the time making State transitionings uh contained in the Domain chain the Roll-Ups it adjustments a Little bit so that you go there to a sure Block and also you principally State the Initial state of your computation Outside you say hey I'm beginning a brand new Machine right here and that is the state in People who be part of your roll up principally They are agreeing with you that the

Initial stage is appropriate Then you state exterior for a quantity of Time that you simply specify principally these days We've been utilizing seven days due to The safety ensures of it so for Seven days you go on doing issues off Chain Uh when the time is up you return to The principal chain you say hey in spite of everything That's occurred that is the brand new stage of The machine and other people have the possibility To confirm whether or not or not you're telling The reality in the event that they disagree they'll go Back and do the dispute and uh Fight you on precisely the place you would possibly Have been mistaken nevertheless in the event that they agree After seven days all the things is settled All this computation doesn't have to Happen once more inside you and in order that's Why optimistic relapse they increase the Main chain they're tied to in Computational sources So the overview Here's only a baseline so that you all the time Have some sort of a UI principally these days Browser Then you've got the software program for the Browser that you really want the UI to to work With you then're going to have a Connection it may be a socket connection It might be https for example with a set Of servers they're centralized they usually Connect to a set of databases which are Centralized as nicely that's how web2

Works principally we're very conversant in That the place three particularly with Ethereum you modify the panorama Because now what you are promoting logic doesn't Leave wherever bodily it's within the Blockchain itself supposedly all people Is operating their very own notes to allow them to Just talk however there are not any native Nodes Uh Honestly although we all know uh we've been Using inferior an excessive amount of we've been utilizing Quick no one and why not It is what it's However it's rather more safe as a result of Whenever there's any points anyone can Just spin up their very own full node and even A light-weight node and make it possible for the Information they're receiving is appropriate Uh in a well mannered way may be very related right here Just did a really clear model of it and We're gonna break it down however these two Are connecting to notes similar to Ethereum nodes so supposedly Should be operating their very own uh validator Node a validator slash reader node of Their adapt they're connecting to And inside a curtising machine I made a Shirt to have this picture over right here Because uh we're used to the evm however How would a Docker like machine work Right so there is no such thing as a entry to the Internet I have to stress this level a Lot so Because it's a Linux server it doesn't

Mean it must have web Connection it communicates uh by way of The blockchain and that communication Happens utilizing Linux drives and that's Cumbersome and tough to make use of so Instead of educating you how one can use the Operational system to that degree we've Created this HTTP dispatcher it's an API That's operating inside a machine that Wraps up all this uh complexity and simply Changes it into a number of Four endpoints they're actually easy to Use so by simply doing Ras communication With these 4 endpoints you'll be able to Receive info and output Information again to the blockchain So now it's the Blown up model of it So first you continue to see the Json RPC over There and that's as a result of we've got the availability downside so blockchain Is each information and computational energy Optimistic collapse they're not fixing The information downside they're simply fixing The computational downside so what it Means is that if we're enjoying chess in a Relapse you've seen a necessity to have the ability to Prove that the strikes occurred so if we Don't have the as a knowledge Availability supply for the for the Information it means individuals can cheat by Just denying info so let's say I'm enjoying somebody somebody right here And they're lose they'll say

No I by no means did this transfer how am I Supposed to show that they really did It now you put up this info to Ethereum and now you've got a proof that They truly did the transfer within the Chessboard Um in order that's why we nonetheless have the Json RPC communication so he's nonetheless Communicating with ethereal node and People ought to be posting their Transactions Eventually if you consider different Solutions uh different tasks which have The similar resolution so like arbitrine or Optimism you're gonna see they use Sequencers for that however successfully what They're doing is posting the issues uh To ethereal Network And then on the very finish you see there Is a graphical API so this graphical API Is simple it's helpful for you whenever you're Handling the UI what's being despatched what Is being produced uh from the node so we Have three principal outputs from the Curtising node we've got a which is Basically only a log you'll be able to nonetheless act If you're operating the node you'll be able to nonetheless Access the complete log of the method however It's actually great way of getting a transparent And clear entry to the machine whenever you Are utilizing different processes so report for Instance may be very helpful I'm sorry It's very helpful uh As a ethereum name for example so if

You're checking a stability of your C20 You don't wish to make a transaction you Just need the AVM to inform you what's The stability on the present state so that you Can generate experiences for that we're Gonna see this Um a discover it's like an ethereum occasion However with the spin you'll be able to show that The occasion occurred so if anyone Creates a recreation and there's like occasions About winners and losers of the sport and Suddenly one other challenge reveals up and Say you understand what I wish to create a Badge for whoever wins 10 video games Now the individual have a PR has an issue Because how they're supposed to make use of the Ethereum occasions to show they gained you Can't you'll be able to't try this on chain nevertheless The discover that you simply produce right here on the Christmas machine is a tie tied to the Cortez machine state so you've got a Marker proof that the discover occurred so It's often helpful in that means the Voucher is rather like they discover in that Sense so it's possible nevertheless it's additionally Gonna change into a transaction so we name it Voucher since you nonetheless want to attend For the seven day window so it's not Truly a transaction till the second it Is so at any time when the Roll-Ups is settled You can as a person or as a developer you Can automatize that as nicely you'll be able to decide Up the voucher for example a withdrawal Request and go to the system to develop

System and say hey I've a legitimate Voucher I want to execute it so it Becomes a real transaction and ethereum So you should use that to work together with Other smash contracts and apps And lastly we've got the HTTP relaxation there And that's the your direct communication With the node so the ethereum name was Talking about could be truly completed Through the examine request So you ship a fast Um a fast request to the machine it's Gonna get up spin up do no matter you Program it to do and die and roll again To the preliminary state so it doesn't Affect the interior state of the machine Long time period So it's actually helpful for uh populating UI information is to make use of it for so that you can be Debugging the interior state of the of Your program Um and no matter else you'll be able to suppose that This doesn't have to uh transition the State So going again to the code I confirmed you Before you're gonna discover on the very Beginning The um I'm sorry one second that we're Actually importing python libraries this Is not a python-like library it is a Python area particular one thing for Blockchain that is really python operating Uh it was simply compiled for danger 5 On the yellow facet uh we created a

Utility for individuals a CLI that it's based mostly On Hard Hat by the best way that helps you Send fast uh information to the machine so that you Don't must be creating your personal Scripts simply to check issues out so right here Uh we're principally creating a brand new Transaction and sending hi there there uh Payload after which you should use the identical CLI to checklist any new notices new experiences Or vouchers that was created uh since You final name it Um so right here I've an instance of a Pythonia code app so it's imagined to Send again no matter I ship it to it so Going again there you're going to note That I grabbed the knowledge for the Httpd particular I used to be speaking earlier than the The relaxation API the combo issues simpler from The atmosphere so that you don't have to Hard code it wherever And right here I'm Um How to say I'm I'm signing up two varieties Of handlers So there's too many uh too excessive degree of Handlers inside a criticizing machine When it comes to those requests one is The superior stage in order that's these ones I used to be speaking about at any time when there's an Input you're truly gonna change the State of the machine And the examine state is people who come From the HTTP examine request I simply Talked concerning the ephemera stuff

And right here comes an important Request on this program So everytime you begin this program You truly beginning issues up proper Like uh Uh registering beginning your course of Heating up the machine in a means so Basically uh the very first time your Machine wakes up you want to inform the Architecture that it's completed it's It's like deploying a brand new contract So you name this end Endpoint over right here so what it does is Tells the uh wrapper that I advised you it Gets that info and tells the Framework that it's prepared to just accept new Requests so from the attitude of your Code the machine went to sleep over right here So the road 24 your program dies for a Second Whenever there's a new request wakes up Exactly on the line 24 and resolves the Post request Returning to response their new request Now we simply unwrap the Json request We verify what sort of requests we've got Which is the of the sort Advance or Inspect since it's enter that I've despatched It's going to be a deal with Advanced sort So we're gonna go there to the perform You're gonna see them grabbing the information From the information the payload from the information I simply obtained and I'm simply placing you Back into a brand new discover so I'm making a

Notice proper now I'm not going to do something with this Data as a result of it's an echo And now I simply have to name the discover Endpoint to create a brand new discover With that Um I've principally concluded many of the Things that this wants to take action line Nine is simply ensuring that I end With a settle for state as a result of when you Reject you roll again the machine So you're gonna see that in line 27 I'm sorry Go ahead yeah traces 27 I'm simply Refilling the Finish standing with settle for And as a result of we're in a loop I'm gonna Go again to the Finish state So I'm gonna return to the put up on one Second I'm gonna return right here and cue The machine once more I'm simply telling the Framework I'm completed I've completed different Process that I wanted If I used to be sending an HTTP request you Would come right here to the handouts examine And on this case I can solely produce so like I mentioned notices and Vouchers they arrive with proof and Because that is gonna be rolled again There isn't any proof for these so you'll be able to Create as a lot as you prefer it's simply not Going to do something the framework Doesn't implement you it doesn't break Your machine simply don't do something So right here I'm making a report

And if I had been to checklist the experiences later I'd see on the opposite facet Finish settle for Now supposedly I'd be itemizing the New notices and you'd see the the Payload over there Um that's it for the workshop uh I'm Open for questions now you probably have some So she requested me if I can change the State of a sensible contract on chain whereas The operation system So sure however by way of the voucher so let's Say I have to switch uh to Somebody uh we create a voucher that Will be later executed and the execution Of a transaction is definitely altering The state that was my contract proper So that's how I'd speak again with the Native ethereum depths So uh we noticed there that we've got inputs Being despatched to the machine how that that Is doable on the ethereum community we Are truly deploying a set of Contracts for the roll-up structure In the set of contracts are literally an Alias for the public sale code you see right here So this step this attribute app Actually has a ethereum deal with at any time when You work together with it it's truly an Input And no matter vouchers get executed it's Executed with the message sender from That deal with so uh all the opposite apps Understand that it's coming from these

Address that it doesn't know what it's Exactly nevertheless it's principally the Characterized app so there's an alias There a proxy and an alias on the similar Time Does it make sense Yes sir Are you positive So it's not non-public key based mostly so it's a Set of validators proper So you've got a set of validators they're Enabled to work together with that and act Um as homeowners so to talk nevertheless it's additionally a Voting in a way that's why you've got The seven day window so if anyone has Anything [Music] Um they they see is mistaken they'll Dispute that and it could actually hold disputing For some time till you get to the proper State and which means no one's is the Owner precisely But they're like accountable individuals for That Does it make sense It's like a voting season in a means in a Way By both be sure that execution is Correct as a result of you've got the emulator on Chain as nicely So that's an excellent query as a result of it's An absolute particular roll-up as a Developer you outline what's the Requirements so if it must run on a

Calculator simply don't use an excessive amount of Resources in your dap however when you wanted To do like machine studying or one thing It might be as beefy as you need your Validator node Yes sure however you want to be conscious as You are creating like what sort of Knows do I wish to have do I wish to Have all my customers operating it so if I Went to my customers operating it Maybe I don't ought to be placing the node To be so busy proper in any other case easy Computers gained't be operating it so it's Like on the dab developer to resolve what They need Because of the the opposite slide I present Like This one Every uh dap is it's solely little Networking away So you resolve Yes Yes so when you say that's solely gonna be Like 12 liters positive possibly like a chess Game and that's positive if you'd like Something that could be a bit larger however 10 is Fine positive then if you wish to have Something that everyone is ready to at Least validate Then you want to be conscious of that But there's no like intrinsic Limitations Just like Docker in a means Are we good right here

So we're right here for all through the entire Weekend uh on the desk we're You are so nicely welcome to to go to us And ask us any query so on the very End uh have a hyperlink tree for Cortez right here If you wish to verify for communications Medium And why not Thank you [Applause]