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

Loading player…

Kariy | Dojo: The Provable Game Engine14th Oct 2023 | Sunway University | ETHKL 2023

Ethereum MalaysiaWed, Oct 9, 2024, 12:00 AM

The ETHKL 2023 conference is a two-day event that covers a wide range of topics, including Zero Knowledge Proofs, Layer 2, DeFi, Data infrastructure, security, and more. This gathering brings together industry experts and pioneers to explore the latest advancements in Ethereum. Attendees will have access to insightful discussions and presentations on various subjects related to Ethereum technology.

Transcript

um hello my name is Kari I'm a software engineer cartridge and I'm one of the core developer for the dojo engine project so may I know like how many of you guys are familiar with onchain games all right okay and and what about uh how many of you guys know about starnet okay not many all right I guess it's it's uh it's nice to talk about a games in general a little bit so onchain games uh the idea of onchain game is that uh the idea itself is not really very new it's uh it's been around in the blockchain space for quite a bit and but the idea of onch game is that instead of uh having like a conventional games that we are all familiar with now where we have games and then all the logic is stuff is uh served by like a centralized server usually Wasted by the game company itself so instead of having a centralized server what if we put all the game logic inside of a blockchain and have all the execution runs handled by the blockchain itself and U uh before this um when when the IDE you have still very still very like immature uh onchain games people when when people trying to build onchain games They Don't Really they know just trying out different stuff like instead of deploying instead of having everything on on the on on on the blockchain they like kind of maybe have something skins like Collectibles as an nfts so only like a little bit of part of the game uh it's not exactly that ful onchain it's just like still traditional but some part of it is onchain and also like maybe something like ingame currency uh you can be into a token for example so yeah and there's like right now there's a lot of research and development efforts have been put into uh into making this uh like a proper and into an actual stuff compelling stuff so uh and one of this is this our our project so okay okay so uh Dojo is a a community effort on starnet to build a provable game engine uh to build onchain games and autonomous world so uh Dojo is inspired a lot by um it's we took a lot of lessons from all the teams and people that have been building onchain games on Stark Knight because and Dojo also is um uh because uh back then when when uh oh yeah I forgot not many of you guys here know about staright so I guess okay so staright is uh back on the early days of stock night it stock z roll up on ethereum back on the early days of stock night uh and people were still uh in the dark ages of stock would say and people were still writing Kyo zero and for those who don't know what uh Kyo what Kyo zero is Kyo is a smart contract language on starnet and it was very notorious for being such a bad language to work with it was like compared to something like solidity is very low level is is it's kind of like Assembly Language in some way and but then even even back then even when uh the languages that still very unusable and still very like hard to work with there was still a lot of people that were already exploring and trying to really push the boundaries of what is possible with the language and and uh the car the execution environment itself and one of the um and even even even when it's still very early there are already teams that were already trying to build games with it uh especially some uh when back then there were this guy called guy gai because I've heard of it topology uh he was really uh I think he was one of the that pioneered this movement of on games on Stark knite uh he was really trying to push uh the the capabilities of Cairo by trying to build this like physics simulations and engines using CYO but fully on Cairo and then yeah and then it made people realize like how like uh the possibilities now that we have with uh stocket and Caro because all this uh this execution resources that we have compared to something like ethereum which is uh for for game it's it's not really um it's not really viable in any way because the etherum itself like it's it's very expensive so you can't really do a lot of computations in it so it's not really something that's very good for games because know games itself um and it really depends on how you build the onch games because some games might uh need maybe all interactions from user on the game may may require sending transactions because that's how you can execute uh uh execute something on the blockchain so if you design a game that's like very that requires a lot of interaction from the user so user would have to send a lot of transactions and that that means user would have to pay money which is and especially on ethereum because the guas prics are very expensive so it's it's not going to be something that people want would want to play if you have to pay like $10 to to like move doesn't make sense I don't want to play games where I have to play $10 to just move one spot now so and and that's why people like kind of like Flock to all this like uh l2s and like rollups because they promises like um um like more uh execution resources but while while being like still very cheap and u sorry all right and and and that's what happened with Dojo uh when when people already building uh games on Stark Knight um uh we realize that uh we need something uh something like mud for those who don't know about mud mud is also a game engine but is basically on on the evm land and we took a lot of inspiration from mud we took a lot of inspiration from mud uh and all the teams that we're building on starnet and then we pull all of our resources into building a generic uh game engine for people to build instead of having to uh design uh like a be spoke design for your game so when the new uh Cairo came along just just like very recently uh in CYO before this was it's like very it's such a bad language I don't want to like emphasize how bad it it but it's still very powerful because no the the the good thing about Kyo is that it's a uh uh it's a language that's designed specifically for building programs whose computations can be proven all right and and uh people and onine games uh people realize that this is a very powerful feature for like very important very powerful feature for uh building onchain games because it it it allows you to um instead of having everything running on chain there's you could what you could do it once you can do something that can be proven you can instead of have having running everything on chain you can somehow offload some computation of chain and then just post the proof on chain so it's kind of like you can think of it as like ziku rollup but it's not ziku rollup so it's like app chain in some way but yeah so anyways uh when the new Cairo came along they introduced is like very powerful like a lot of uh new features uh it took a lot of inspiration from rust and um they introduces all like high level abstractions and features like traits uh implementations macros and type safety that if you guys are familiar with rice it's like it tookes a lot of inspiration and uh syntax are very much similar and also has these very powerful features and the new CaRu also introduces this new a very powerful plugin systems where in dojo we use this this we use this very extensively and we extend the C compiler itself so that we can Define our own set of macros and uh this macros are really important because it really it helps us to provide like a nice abstraction layer and makes the development process much much easier for people to build on doer because we're able to hide a lot of the the lowlevel complexities and um um and also with macros uh for those who are familiar with it it helps us to uh like reduce lot of boil plates that you would uh usually do without macros so it makes the the development much much cleaner and easier and uh like I mentioned ad Dojo is uh it's a ECS framework and it's it's a game engine based largely on the ECS software AR architectural pattern so ECS is a design that's very popular with video games uh game engine like unity and Bevy are also using uh ECS and it is very powerful because it um it separate concerns into three main categories which is entity component and system and uh the the benefit of using ECS because it's it's it's very composable and it's very modular so it it helps in terms of like um modularity and also helps the the it just makes because now instead of having people to consider about how you would interact with how you access data so with the ECS everything just like very uh cleanly separated because you everything's not like you only need to consider what this the three things The Entity component system and with dojo we handles like most of the stuff for you so for the for the developers it's very very very it's very very good because you don't have to think about all the like all the technicalities it it helps developers to focus more on design the game itself rather than having to learn about all the the the the lowlevel stuff they would have they only need to really focus on the creative aspect of of when building the games oh yeah okay so this is uh how you would Define a a component in Doo It's if you can see this syntax is a very similar to the syntax is very similar to R so you def find a struct and then the the model name and then you would put you would annotate the the type with this model uh derive macro and then uh at compile time when you compile the contract it will generate all the necessary implementations uh in order for uh that uh in order for it to work with uh the the dojo World later I will show and then you can derve all the things that's like the copy and drops that that's like very that's CYO stuff so it's not really related to Dojo but anyways and then you have the key this is how uh the the component will be indexed in the dojo storage this how you fetch the key is necessary because that's how you would fetch the the the model value and then the rest you can just put uh whatever uh types of model that you need to and then uh in terms of systems this is how you define Sy def find systems so it's the the syntax is very similar to uh stocket contract so if you guys have uh ever written a stocket contract before uh then the syntax will be very very similar just it just it can be like any arbitrary contract actually you you don't you don't even have to uh annotate the contract with this Dojo contract you can just use the normal St contract anyways the yeah the system is just how you defined the logic of the game and this is mostly how you define the logic and where you would um change the Val the model values Etc and like I mentioned before we find our macros like a uh unique macros that only exist on dojo it doesn't exist in the uh base language itself so we Define uh several different several macros and one of macros is get it's a get macro that is used to fetch the uh component entity component values and uh and with this macro it you really have the syntax are very simple you don't have to think about yeah uh the macros allows uh allows us to really hide a lot of the stuff from you it reduce a lot of boiler plate because when at compile time this Gap micro will expand into like a more complex stuff it will do all this like bit packing and then uh serialization but you don't need to know all of that we hide everything so you only have to think about how to do like you only you sorry you only to like Define this like little I have to put whatever based on the based on the uh Keys the keys Bas on the keys here which is in this case would be like the player so we put the key and then the type of the model that you want to fatch and also we also def finded another macro which is set this is how you set a value of a model again it's it's very simple you don't need to think about all the stuff is happening underneath we just have to really use it and then this how you like get and set the the value entities so this kind of like the the high level overview of what a dojo world looks like so at the top of everything at a very high level you have the world contract uh which is kind of like an operating system uh it's kind of like the operating system for your for your um world it handles a lot of the lowlevel stuff like um authorization access control like um and also data storage and everything and then you have uh in the in your world you have the systems that you have defined and the components uh components components uh but in in dojo we call it as model now because we want to avoid the confusion between uh component and an actual like Ciro component which was just like released a few weeks ago and then and then at the world we have this like Tor which I'll explain a little bit is like one of the tools that we have in our tool chain and Tor is like an indexer where you would index the world and then you would interact with the uh with the your Tory instance you would use our sdks like we have we will have something like Unity sdks react sdks that we that we can use to interact with your world so I go through a little bit about uh the tool chain the doo tool chain so one of the things that we uh really uh want to focus on dojo is we want to um make the on boarding as smooth as possible we want to create as less friction as possible for people to uh play and also build on chain games so that's one of the reason why we really put a lot of effort into building our tool chain we have several tools that you can use when building on dojo first of all is uh Soo is a CLI tool you can think of it as a Swiss army knife that would allow you to this is pretty much like how you would uh the the main tool that we use to in throughout the whole development you use it to build to test or to deploy and to interact Al to inspect your world and it also includes this like a little migration planner where you would uh when you want to deploy uh a game on a Manet on a chain on a testet for example that would do all the stuff for you don't have to think about anything just do a simple like one command and you will uh deploy everything on on the on your desired chain and then another tool that we have is Tori Tori is an indexer it's a world indexer it index all the uh components and systems of your world and index it in a SQL database that's like very nicely formatted so and then you can query all these values using graphql and in the grpc endpoints I served and also Tori also includes um type client sdks like I mentioned before we we have a react sdks and also uh rust sdks and soon later we will uh include like third party integration like unity and Bevy uh so that we can inct so you can use Dojo with it like so that you can use Dojo with all the game manes that you already used to and also uh we have optimistic execution so this one of uh important things about um onchain games because if because onchain games are in some way are limited by the the latency of the blockchain that is being deployed to so if you deploy a game on some on a chain where the block time is like 5 seconds then you would have to wait for like 5 Seconds you know in order for the state to change so that let's say you um execute something you up so that for example if you move in a game and then you interact with the game you move for example then if the block time is like 5 seconds then you would have to wait like 5 seconds until the the yeah the your player actually move the the position but with optimistic execution is that um we we don't have to rely on the on the it on the Block time anymore it's so it's kind of like similar to how optimistic rollup works so in optimistic rollup Works in a way that uh it doesn't need proofs because people can uh can check that hey this extion is correct and everyone can check correct so if it's nothing wrong with it then we don't we don't have to do anything if it's wrong then we can send FR proofs in some way but yeah that's kind of similar of of how it works with uh our uh our opom execution and then lastly we also have Katana Katana is a is a blazing fast development sequencer uh which has a gaming it's a gaming specific sequence it's a gaming specific sequencer to develop and test uh your I think it's not working okay um to to develop uh is [Music] it all right okay all right okay so anyways uh Katana is our bling blazing fast development uh sequencer which has a gaming specific features for you to uh deploy and test uh your um Doo games it's highly configurable and it's also very low latency so you don't have to be limited with um like you can configure like how many block how the latency of the the the block time yeah and that's pretty much like all the stuff that we have at dojo and uh also want to like show a little bit about what games that have been built uh with dojo and one of which is Drive AI which uh we did this uh during uh for the demo at um ECC where uh where we have this like um machine learning simulation written in Cairo uh using uh Giza if I'm not mistaken using Giza and and all the and everything is like running on using Doo so it's like very very cool and also we have uh and also the cartridge we also just recently we released uh this game called roll your own uh and it also built using the entire stack of Dojo so if you guys are interested in playing you can just uh scan a QR code there so it's a uh it's a it's a if you guys have played like drug wars before it's pretty much that and also I also have more games that were built uh this we have uh brick who is also doing migration to dojo and we have this all this um other games that were built during um this recently we have our first ever like Dojo game Jam which is kind of like a hackathon and people were this all the projects that were built during that time and yeah and um in a few more days which is October 20 which is I think this Friday we'll be hosting our next Dojo game J it's our second one and uh yeah we uh we have $10,000 uh in in the price po so if you guys are interested you can join just scan a QR code above we we are planning to do this in like um every month or so so yeah so if you guys are interested you can scan right okay so yeah if you guys are interested in in uh how just contributing to Dojo you can uh just open our gith hot Reaper we have a lot of contributors that are contributing to dojo and also I think we have in in this target ecosystem we have one of the most active and most like uh very strong community so if you guys like interested in in helping up helping us developing Dojo you can just jump in and and and yeah yeah and yeah if you guys are interested in joining you can scan the the QR code with to join our Discord Channel very much it thank you before um any questions from the floor we have about three minutes maybe for one or two question yeah uh I'm just curious about the sequencer uh what what does it mean to be a gaming like specific sequencer like oh good question good question so uh for so for for gaming to for onchain games to actually be viable at all uh you need a a block that a blockchain that would have like a very low latency because if you were to play games uh on a like let's say you deploy onchain games on ethereum for example and ethereum has like this 12 seconds block time approximate 12C block time so uh it also depends on how you design the game yourself so if you design a game where all the interactions uh are required some formal transactions from the user so if user send transactions and then they have to wait like 12 seconds for it to be uh accepted on on in ethereum then only then the the state will change and then they will only then after 12 seconds then they will see like they uh like um their their new position or something so with our gaming specific sequencer is very you can um change the latency of the uh the blockchain itself and also well and soon we also have uh like forking like sharding as well so the idea of sharding is that um you can you can have something like um let's say you have a one a server in one location so instead of let's say you have I have a server in US and then instead of and and I'm living here in Malaysia so instead of having like to connect to the US sequencer that I can just like uh I can somehow like um spin up uh the same the same like game but instead on on Malaysia for for example and then people from Malaysia can just connect to that one instead instead of having to go to the US something like that yeah thank you I'm okay I mean I can just do ask all right uh thank you very much har thank you if um any of you has more question he's going to be here so please reach out to him

Automatic transcript — names and jargon may be misspelled.