EigenLayer Hackathon: Beyond EVM

EigenLayer Hackathon 2024 · May 2024 · 18:49

Dima Romanov of Layer N walks through how the Ethereum virtual machine works as a machine of instructions, memory and persistence, and where blockchain performance can improve. The workshop compares Solidity bytecode with native code, explains why WebAssembly is a popular compilation target across projects such as Arbitrum Stylus, and shows how the Merkle Patricia trie slows state access, with Monad and new trie designs as alternatives. It closes with fast cross-rollup messaging and audience questions.

Speakers

Topics

From EigenLayer Hackathon 2024, hosted by Encode.

Transcript

hello everyone happy Friday great to see you all back here again again we're seeing lots of faces coming for every single session so great to see you um I'm going to drop my GMS in the chat just whil I invite our speaker to the stage hello Sheria how are you so um very simple presentation I'll just give a brief brief overview of what um but did you see this is everything clear yeah that's perfect thank you all right yeah so this is a very simple very very basic simple presentation basically

I assume you know nothing and then try of build up build up the concepts um to understand at a high level how blockchain architectures today work okay um so first of all I'll describe what a machine is so evm here means ethereum virtual machine so you model you model the entirety of of the of the blockchain as like one big machine right and we say virtual because it's like a machine that runs within other like you know physical machines right so what is a machine and generally we divide machines into three parts so you have the instructions uh in other words the steps that the machine so for a given program right for a given program you have instructions you have the memory which which is the kind of

think of it as as like the the working set or like the the current stuff that the the program is operating on and persistence in other words like you want to whatever you compute right like let's say you are a um a let's say you're you're an order book right you want to store the state of the order book between operations so that's a persistence layer so um at a high level this is how ethereum Works currently right so so okay well for that first of all how do programs typically work right so on the left here I have a basic C program um and then these are this is like you know a human readable T program but this is not very much this is not really like a computer readable program right how do you make it into a computer readable you

turn it into what we call like machine code so essentially on the left here is is you have what what a human would write and on the right here you have what a computer would read right so here um yeah first here sorry um first of all here you have uh you know you you essentially have the variable that tracks what the total sum is you have the variable that tracks with the iterator variable is so here the I um and then you Loop here and the Machine code basically goes like this and this and this and this and this and this go back and and so on right so it's basically like a very primitive set um and this is what typically like the hardware does now what does ether doing

something very similar but I would say a little bit more complicated so on the left here you have solidity solidity code that is identical to what we have here and on the right here we have the equivalent well a subset of the equivalent um solidity evm op code so like what are the the Primitive operations that the Ed executes right so here um I won't go into the details here but Ed is what we call like a stack based machine where essentially um it pushes and pops into its memory um the operations are happening here so you can see here already um so on on this slide we have what like your physical computers typically execute it's like a very

simple idea and you'll see here that on the solidity side of things there's a lot more going on it's it's somewhat more complex um you know for various reasons relating to like how blockchains work um and requires a c of humo operations already you can see that there's some work we can do here to like improve the performance here right um the second part is a memory um and this you basically just imagine is like one massive array and so address zero is you know the zero slot I just want as the first slot okay there's not much we we're going to change here this is basically identical between like physical computers and the evm okay so now what should do here um the third part is a persistence so how does ethereum store how does ethereum store

the world state right like you know I have a program that runs a certain operation um like an amm pool for example and then I want to update the balances for example of the users right they're stored somewhere physical on the discs right and an etherum uses what we call um a merco Patricia tribe and I won't go into details of that but essentially the idea is that the whole Merkle the whole world state of ethereum is stored in a tree like object so you see this is the root of the tree and then for each address you would walk down the tree until you get to the last and this is where the data is stored for your account so let's say for example your account address is like I don't know 1357 or sorry one let's

say 11 21 it it will go to the first Noe and the second Noe Etc and it'll walk down until it gets the leaf Noe and then that's your data okay and already you can see that um there's a bit of complexity involv here like for any time you fetch data you have to walk down this street to get that data out right so already we see some level up position you can make make here that quite a few projects are exploring right so what can we improve here okay um and then I'll describe basically improvements we can make at the level of the op codes and that we can make at the level of the um State okay at a very very high level so instructions here what we have is that

we have solidity code that maps to evm code and one issue here is that slty and evm are kind of very much tied together it's it it is possible theoretically to to know write a program and let's say rust or see or go and compile to evm but it's not simple and I don't think anyone has actually gone through the effort right um can we actually choose a l op codes that actually more General and allows like people to write in whatever language they prefer um also especially like you know as spity like you have to learn you have to learn a lot of the custom stuff from spity whereas you don't want to have to learn that you want to just like you take whatever programming language you know and then compile it down to

whatever the blockchain uses right um so one very common Target is web assembly another one is move you guys might heard of move this is what I think apos and sui use um and that one works just as well but here um I want to show web assembly here so web assembly is a good Target because um basically it's it web assembly is a language that is designed first of all for the web so the idea was that you know some to like blockchains um the web uses only one language JavaScript and the idea was how do we provide a environment that can want any language and then a few people made this standard called Web assembly which essentially meant is meant to be like a common

Target for a wide wide variety of languages um so such that like it web assembly is a much closer like approximation of what your physical machines use um and therefore any language that you typically compile not to like whatever your machine does can use of assembly so this includes rust cc++ go Python and L basically anything you can imagine can in some way be run under web assembly the other point that I wanted to make is like how do you how do you take the code on left of the SPID one right and provide an equivalent that's closer to the metal right um and this is essentially what OB allows as well so this is just like a like a visualization here but essentially um if you were the web on

the left here then it is possible to to compile that ahead of time um down to something that is much much closer to what your computer runs and as you can see here like you know you saw earlier that there was a lot of instructions for the solidity side of things on on the right here you can see there's very few instructions that can run very very very fast natively by CPU so this is where a lot of the performance unlock is um quite a few products have going this direction so there's there's you know there in R xpm um but also polka dot substrate uh defini canisters arbitrum stylus and so on they all kind of use the same idea of using that assembly as the common like um language so that developers can use whatever is

comfortable to them right um the second the second thing I want to discuss here is a persistence so as we saw earlier the the Evan state has a has a pretty slow access time you have to walk down the entire tree um to get any bit of data specifically I think think it's eight or 16 steps down for each address actually I think it's more than that 10 or 20 I believe but yeah in any case um it's not it's not very efficient the other thing I want to add though is that it has a pretty complex encoding I think uh like at the time like they didn't know any better and like the coding that's like very difficult and this is also like difficult to optimize um so again just a reminder of of how it works here right you have like a tree

and there's a lot of good reasons for why it is this way but it is true that like it's it is fairly complex to to up to this so basically two project that are that are are exploring this one is called monad um so monv essentially is a reabilitation of this idea but in such a way that it's much much closer to to the the to how like ssds layout data so essentially um ethereum natively so like the client compony use that get um what they do is that they typically just use a key value store and then have some addition a bunch of additional code to essentially simulate the structure here um what moreb is doing is ESS trying to do that

natively essentially just provide that same stuff on the disk right um and there's a very new project here that's I think much much more much exciting which is called the nearly optimal Merle try um what they're doing essentially is that it's the same idea but in a much more general setting so that any other blockchains that decide to to I decided to also use like a Merkel try for your state tree can use it in a very generic setting without being tied to the model that ZM uses right um and yeah that's the that's the that's the that's a very quick overview of like um what currently blockchain are

exploring in terms of performance um I hope it gives a pretty good idea um any questions yeah I don't think we are welcome to ask your questions in the chat I see catcher in particular very excited I can see her typing again um as well any more details and examples that's very broad but uh Sher I don't know if um if you have any other examples that come to mind per you perhaps you would like to to run over them but I appreciate it's a very broad something example of like any oh of like

databases uh like the latter part maybe you want to elaborate catcher yeah um I find some examples so I think what's one something is interesting look at are SL sorry not slity a sana's model um so salana actually doesn't use a use a try at Allana just has a flat like key value key value key value mapping right um and so typically ethereum and other projects use like a tree because the idea is that you want to have a hash of the entire State um because the idea is that each block in ethereum stores the hash of the real State and so you can like have a proof that this is the state um but salana doesn't actually do that salana has only a flat like key value

store and then you wonder like how exactly do they um how exct they like enforce the state right um and so Bally they have like different methods of validating the state that they use you can look more into it's called around proof history their whole like consens model um there you go yeah top my head but yeah no that's perfect it gives a catch you something to dive into further afterwards as well which is great um and maybe I'm jumping lag a little bit here but um in terms of layer n itself do you want to talk a bit more about some things you working on where people can kind of find out some

more information and and kind of keep up to date with everything that you're you're doing yeah so um just quickly right so what we're building is the XVM so the whole idea the XVM is that um you know we come from background of like running uh a de and our our all thing is like how you lock the in low performance as a trading system um in a blockchain system right in an optimistic roog and so what we what we actually took the approach of is we architect to the XVM like whole pipeline in the same structure as you would um as a high frequency trading system um and so like everything is basically on like solid engineering and getting the most performance out of the system so for example the reason why I

discussed wasm for web assembly is that we were thinking how do you provide a generic environment for developers to use their language but also compiling it down safely something that is as close as possible to the metal right so what you can do here is you can take the program that the the programs that the the the programmers provide you with and then compile that down to the closest POS thing possible to metal um so that's one one one system and then the second part is uning communication so the other thing is like you know similar to I was similar to like like Cosmos and and and polot but essentially provide some Primitives to send messages between other rollups that are running right and the key difference with layer n is that

um so in the in the cosmos model for example um each rollup in so not sorry each app chain in Cosmos um generally don't trust each other and so what happens is that you have a quite a bit of you have to do consensus between whatever communication happens same thing in layer zero same thing in warhole um the idea be lay end is that you want to provide some way of passing messages that um is immediate in the same way of the internet so what we do is that essentially we we remove this lack of trust between the rollups we essentially have these same source of trust for different rollups and what happens that they can now reliably other messages in like single shot so the idea is to enable yeah exactly fast cross maning so you want to enable basically

like I would say under like millisecond latencies for for messages wow very impressive um and then this relates back to the previous um oh there's another one catcher ah very good question um what what are some kind of Concepts how in terms of this hackathon how do you think people might like to kind of integrate your your Tech and use that and again there there any links to docs and things like that we have docs um I can send you guys a link amazing um yeah and but in terms ofing for the

hackthon I would say um like I would stick to whatever is easiest for the hackathon which is like you know I'm guessing the um the I IG stuff um we don't have direct integration with IG at the moment um but in terms of like discovering our tech there we have DOS you can look at perfect awesome well as I said at the start this session is obviously recorded so um for anyone here if any questions pop up afterwards or if you are in fact watching the recording um of course you you can always reach out afterwards to get those uh questions answered we have another question in the chat can you sum

up what you do in three sentences a very tricky one there nice and concise but um yeah yeah I would say um yeah the the main thing I can see sorry the main way I can see of like saying it is the internet are wollups so enabling fast cross chain communication under like millisecond latencies and bare performance perfect smashed it awesome cool well uh yeah as I said yeah thank you in the chat um if any more questions do pop up feel free to ask away um do you have any kind of community boards or anything like that

in particular that you would um Point people towards a Discord channel is is Twitter X best place yes so we have a we have a Twitter I can show the Twitter as well as the um there's also a Discord which I need to find the link too but yes perfect well as you're dropping that in the chat um we've obviously shared the docs so feel free to have a look through that um if any more questions do pop up the Twitter has also just been dropped in the chat which is very helpful um participants dropped the Discord as well so we've got all bases covered um and of course we'll include these in the description of the

recording as well so um sh her unless there's any kind of final remarks from you or or final things to share I think we're all good to wrap things up there yep perfect awesome well thank you once again for joining us um really G great session and lots of uh extra links and docs for people to dive into there um thank you to the participants for joining us and we're looking forward to seeing you again next week thank you very much byebye thanks for your time [Music]

Related talks