# The Optimistic Virtual Machine: an Ov(m)erview by Karl Floersch (Devcon5)

- Speakers: [Karl Floersch](https://streameth.org/speakers/karl-floersch)
- Channel: [Devcon](https://streameth.org/devcon)
- Date: 2020-10-09
- Duration: 23:38
- Topics: blockchain, smart contracts, distributed ledger, ethereum
- Watch: https://streameth.org/watch/yt-KZmLmt9f_uk
- YouTube: https://www.youtube.com/watch?v=KZmLmt9f_uk

## Description

Visit the https://archive.devcon.org/ to gain access to the entire library of Devcon talks with the ease of filtering, playlists, personalized suggestions, decentralized access on IPFS and more.
https://archive.devcon.org/archive/watch/5/the-optimistic-virtual-machine-an-ovmerview

The Optimistic Virtual Machine (OVM) is a language for expressing layer 2 scaling solutions like state channels and plasma as a local fork choice. The language is built on a formal model of logical game semantics, along with a "cryptoeconomic dispute assumption." Composing these primitives allows us to describe complex properties of layer 2 state. These layer 2 systems can be written as OVM "programs" which are compiled into both a client-side "proof checker" (the local OVM) and ethereum-side code. The Ethereum code acts as OVM "interpreter" contract on the Ethereum blockchain, which can interpret disputes for any and all of these layer 2 system (state channels, plasmas, etc.). We will go over the details of both the game semantics and Ethereum smart contracts in this workshop.

Speaker(s): Karl Floersch, Ben Jones
Skill level: Intermediate
Track: Execution layer
Keywords: OVM, optimism, academic

Follow us: https://twitter.com/efdevcon, https://twitter.com/ethereum
Learn more about devcon: https://www.devcon.org/
Learn more about ethereum: https://ethereum.org/ 

Devcon is the Ethereum conference for developers, researchers, thinkers, and makers. 
Devcon 5 was held in Osaka, Japan on Oct 8 - 11, 2019.
Devcon is organized and presented by the Ethereum Foundation, with the support of our sponsors. To find out more, please visit https://ethereum.foundation/

## Transcript

I am Karl Floersch and I'm here to talk to you about not just optimistic things, but optimistic roll up. This is Ethereum layer two. The last talk very inspirational talking about how we can make Ethereum great and you know, not suffer from the massive economic divides and I'm just going to tell you how to make the user experience a little better, but I think it's very important nonetheless. Um so of course, PG that's plasma group shout out represent. Um don't forget about Ethereum layer two. It is extremely extremely powerful. So first I'm going to talk about trees. I recently started growing plants and by that I mean I recently started killing plants and it has been a wonderful experience. Every time I look at my plant, I see mathematical constructions with you know, the golden ratio and these you know, fractal branching patterns and just unbelievable unbelievable complexity emergent complexity. In fact, you know, that that whole emergent emergence thing was definitely not planned and very very convenient. It's because it's about self-organization. All of these things coming together all of these different pieces, you know, adding up and emergent complexity I had it in my slides. The growth of a plant from the you know, the soil that you place it against the wall. You watch it grow. It's like this incredible thing and of course, as I'm staring at my plant, I start to see crypto economics. I'm like wow, it's the same thing. It's like you're planting the soil. You're you're fertilizing the ground. You're writing your smart contract that says, "Hey, if you wear a hat, I'll give you a token." And then people start wearing hats as long as you've positioned your plant right and you've you know, watered it correctly. So it's this it's this emergent phenomenon both of them and this entire community is this emergent phenomenon. It's really quite amazing. And so this is my plant. It's very this is all what I do to think about how how to not think about this this very sad dying plant, but nonetheless nonetheless we we continue on. Very sad. Um so as I was you know, preparing for this talk of course, I I you know, stumble across a Vitalik uh presentation as I often do and one thing that he said was JavaScript was the foundation for innovation. He was introducing his new JavaScript framework. Um you know, he was introducing Solidity and smart contracts this Ethereum blockchain and he said, you know, "That is what I hope to bring to the world of cryptocurrency. I want to set the foundation by creating smart contracts the ability to program smart contracts and use that to grow an ecosystem. And so you know, Vitalik and many others worked really hard to bring us smart contracts and it has birthed this incredible community so many people that I am you know, you know, everyone in this conference is so great. Anyway, I'm getting choked up about how great people are. Um but you know, it inspired me to talk about crypto economics, right? My my Devcon 3 talk I was all about crypto economics. I was describing these mechanisms which we can create hopefully you know, driving good incentives and avoiding the bad ones and and and building the you know, just the right mechanisms and learning how to you know, design them in such a way that we actually promote good outcomes and in fact the the kind of subject of my talk was was Uniswap because it felt like a very good you know, crypto economic mechanism that would drive economic behavior and you know, thankfully that that seems to have have panned out reasonably well, but the dream right this dream of crypto economics and building building systems with with you know, cryptography and economics and giving us all superpowers that we can all program our smart contracts. That dream became a little bit a little bit of a nightmare, right? Because when we you know, when I actually used our systems unfortunately, I would be presented with these like very you know, 69 digit you know, expansions and and this you know, crazy thing where we approve all of the tokens to be transferred on you know, on our behalf for a random smart contract that we don't really know about right like these crazy user experience problems and pending you know, we're waiting for our transaction to go through and waiting and waiting and no matter how much on metamask I press speed up, it never gets faster than 15 or 1 minute or even 10 minutes sometimes is horrible horrible situation which I you know, hope to remedy. Anyway, all of this to buy my CryptoKitties and spend 30 cents on gas, right? This is this is the experience the plight of the incredible dream that we have and really honestly we have come so far. Like this is you know, no shots against it, but a lot of you know, this is this is it's tough love. Anyway, so so this caused me to kind of talk about scale and how do we solve some of the big problems that face you know, the the Ethereum ecosystem today and like how can we build solutions which scale up and resemble you know, the quote centralized the great experience that centralized systems can give you because they don't have to deal with all of this you know, complexity about you know, ensuring users safety and all that kind of stuff. Who who you know, that's an afterthought. And so how can we actually build our systems so that they resemble those and we can get that mass adoption that we need. And so of course, you know, I myself and a few others you know, Jing and and Ben are in the in the audience here today form plasma group and you know, try to solve this solve this usability problem using Ethereum's layer two, right? And so we could upgrade Ethereum using layer two using only smart contracts. The actual like ability that you have to you know, impact change with smart contracts is massive. And so just superpowers, right? These smart contracts are incredibly incredibly liberating. Such power much wow. And so a couple months later we you know, released this testnet and we you know, scaled thousands of transactions per second with plasma and it was this amazing thing, but then like an annoying parent I would hear from people like Hayden and others, "But can it run Uniswap?" Right? You talked about Uniswap. You love Uniswap, but can it run Uniswap? And the sad truth is no, it couldn't at the time run Uniswap. And so we went back to the drawing board and we thought of generalized plasma and this time it had predicates and plats and just incre you know, we we can actually upgrade the the the functionality of plasma and you know, really unlocked a bunch of you know, technically smart contract programming you know, features. However, yet again Vitalik was like, "But can it run Uniswap?" And once again the sad answer was no, it cannot. We did not have smart contracts. We did not have the unstoppable smart contracts of Ethereum layer one using a developer experience like Solidity that people are familiar with. And so that was a real problem and to kind of demonstrate this problem, here's a little graph which shows the different ways that we solve the validity and availability problems of layer two. I won't get into the details because there's only there's only some you know, so much time, but for those in the know, um on the on the on the right hand side you have put all data on chain. That's roll up. On the left hand side you have plasma and on the top right that's how we provide availability. So either we put it all on chain or we use this crypt this this availability availability game. And on the top we have optimistic validity proof. So that is essentially this kind of you know, the classic layer two. It's only it's only it's correct. We assume it correct if there's a timeout that we that that occurs and you know, no one has challenged it. And then we can also use fancy math to solve the to solve the validity problem using zero knowledge proofs. And so there's a whole bunch of layer two solutions on this on this kind of map and notably something that is a little strange is there's a little bit you know, a section that's kind of missing that was definitely missing from my conception of layer two and you know, a very you know, potentially very interesting. And so before I go into what that section is here generalize these are the kind of benefits of each system. So generalized computation when you have an when you have one of these validity games enforced with crypto economics, you can do general computation. On the bottom you have objective proofs up front. That means that we can prove to the main chain validity immediately because it's you know, succinct enough to be verified. And here on the roll up side we have no data withholding which means we don't have to deal with you know, the the same problems of a plasma operator going offline or you know, whatever it may be. But here on the on the plasma side we have like infinite transactions per second cuz we don't have that data availability bottleneck. But of course, there is this you know, this blank open space. So what is that point? Well, we're very clever and so we came up with the name optimistic roll up. And so it turns out that within this in this trade-off space you can get general computation and you can get the no data withholding you know, problem the kind of unstoppable nature the liveness properties of Ethereum. And so that gives you what really resembles smart contracts inside of layer two and that is a huge huge you know, deal from a developer user experience perspective which is you know, uh honestly a user experience that is often neglected especially you know, especially in in in Ethereum and and other places. Now, notably this this kind of trade-off space had not not been explored before, not not been explored before. In 2014, Vitalik came up with shadow chains, which is essentially what this is. And you know, a bunch of other people had also come up with this. And so this is a kind of work expanding on shadow chains. And so, now I'm going to give an optimistic roll roll up overview in 2 minutes. I was told that my talks they they were someone so I was giving a slower talk and they were like, "I want a really fast talk, Karl." And so I was like, "Okay, how fast can I make this fast talk?" And it's just way too fast. So this you're not going to understand it, but you'll experience it and you'll love it. You'll love it. Um so bam, oh yeah, I was going to do that. Bam, that's another one. All right, so we have Ethereum, right? That's pretty straightforward. We have an Ethereum block. We deploy a optimistic roll up contract to Ethereum. There's our optimistic roll up chain. It's deployed. We have an aggregator. They are bonded. In fact, we can have multiple aggregators. Anyone can submit new blocks as long as they have a bond. Now, we're going to you know, enter the chain pretty straightforward. We can you know, send a transaction to the main chain and deposit in or you can just receive money on the chain itself. You know, either way works. Now, the next thing is we can send transactions. So note remember this is that that block down there, that is an optimistic roll up block. And so we're going to create more of those. So if Alice is going to send a transaction to the aggregator, the aggregator is going to you know, create a new an updated state root. They're going to calculate what the actual state root is. Notably, this is an account model, not a UTXO model that is kind of more familiar in plasma because we can do that with this technology. We're going to commit to these transactions and intermediate state roots so that we can prove invalidity in one step. Then we are going to submit that as a block to Ethereum. Submitting the block to Ethereum, we're going to create a Merkle tree of that block, which is the probably the most confusing part because we're doing a Merkle tree in a Merkle tree in a Merkle tree in a Merkle tree. There are four layers of Merkle trees here. Um we're going to then add it to a smart contract with a large number of blocks. It is constant size and so we get to save a lot of gas. I'll talk about the exact transactions per second that we get later. And now we're going to submit that block. Great, we've done it. And so we can download that block off chain, calculate our off chain state and we are set and good to go. Now, we're going to interact with the smart contract. Pretty straightforward. Someone deployed a smart contract to Ethereum, the same thing that you do that there you do an optimistic roll up. It goes off chain. Now, someone sends a transaction to Uniswap off chain, the Uniswap balances get computed, you know, any smart contract execution gets computed, and we compute a new state root, and we're good to go. We submit we commit to that that new state root. And now we submit all of that in a roll up block and we are set. And we you know, of course update our balances once again. Now, we're going to do something bad. The aggregator is going to be evil, evil, malicious. So now what is going to happen? Well, we're going to create an invalid transaction. We're going to create an invalid state root, compute that state root, and we're going to place it onto the main chain as a block. Oh, is are they going to get away with it? What's going to happen? Well, everyone's going to notice that this thing is invalid, you know, from Etherscan to you to your Infura to every full node that's running in a full node optimistic roll up chain, and they're going to challenge that invalid block. Notably, this challenge is not interactive. That makes it a lot easier because honestly, these programs these protocols are too hard to build. They're way too hard to build. I've done too much work, and I haven't seen enough progress. But now they're way easier cuz we made simplifications. So now we submit this validity proof. I'm not even going to explain it cuz it's just so ridiculously, you know, like complicated. But you can read the smart contract, and we will have it formally verified because formal verification is important. But that verification is not validation. You should read about it. Now, also the you we're going to burn the aggregator deposit because this is a totally totally attributable fault, and we will have a challenge successful. So great, we can delete that block, and we can continue moving. The aggregator got scooped, but there's another aggregator to take its place. Anyone keeps going. Great success. You know, it's very good. So if you don't understand what I just said, which you no one did, then you can just think we put a blockchain on the blockchain. It's real easy, everybody. Put it in the in the in. There's the Fibonacci. There's the the the golden ratio. Breathe deeply. Okay. But can it run Uniswap? Yes, my gosh. Of course it can run Uniswap. That's why we did it. It's very very hard to do. Um Oh, my god, I'm exhausted. Whoa. Okay. Well, not only can it run Uniswap, but we built it in the past like month and a half or something. We worked very hard, you know, shout out to to everyone. Will Um and uh and and the and the Uniswap team. So sorry, we collaborated with the Uniswap team, us Plasma group, them Uniswap, and we created unipig.exchange. Everyone in this audience has used it, I heard. Right? Everyone's used If you haven't used it, you have to go to unipig.exchange and support the team piggy. There are two tokens, one pig, one uni. What you do is you get air dropped piggy and uni, and you dump the uni. That's the game. You know, no I'm just kidding. You can you can you can you can dump the piggy if you want, but you know. And notably, we're doing this and we're solving those horrible UX problems that I talked about in the beginning. For instance, there's no approve all, you know, approve all tokens. Of course you can solve this on main chain Ethereum, and you should. Don't don't do the approve all things. It's just very scary. Um unless you're really confident. Maybe don't do it anyway. Um another thing is we get you know, pretty good transactions per second. We're not at Plasma infinity scale, but we can get you know, easily 200 transactions per second, put bump it up a little bit more. Um this is by the way based on the availability bottleneck that I'm I'm talking about. Um and then additionally, we can get way we can get 2,000 if we optimize with something like a BLS signature. But that's also pretty hard, and you know, I definitely you know, we'll get to 200, 400 that area, and then we can hit the hit the BLS optimization if we if we so if we so choose. And then we get way more with Ethereum 2 or any availability oracle that we that we choose. You know, if if if we make the data available and we trust it's available, then this scheme works. Additionally, probably my favorite thing, I don't know, um is how fast these transactions get confirmed, right? We get really really fast transaction confirmations, and this is basically you can you can kind of like tune tune the optimistic roll up parameters and you know, get either fast confirmations and anyway, I'll go we can go into that in another lightning lightning section of a light you know, one of these talks. So, this is pretty cool. It is a user experience that kind of like rivals centralized stuff in my in my humble opinion, and also you know, is a secure Ethereum dapp. I'm very very happy. So unipig.exchange, shout out to all the people who made it. It's really really you know, amazing that it that it came together. And team piggy, y'all team piggy. Get it get a get a get represent. So, back to Vitalik, right? We're setting the foundation for innovation, and part of that foundation means giving users good user experience so that when they use Ethereum, they're using the you know, a a they're feeling good, and they're not dropping off after you know, the first 2 minutes. And we hopefully can provide the same we can provide the same smart contract development experience that you know, we know and love about Ethereum and we'll know and hate, but like you know, we'll we'll get better. We'll work together to get better um and make Ethereum smart contract development experience even better. And so back back to the you know, this this wonderful tree. I you know, I don't remember how I tied this in actually. I I made these slides very recently uh very recently. So they you know, just pray for my plant. I just hope it gets better. I just hope it gets better. And grows into that's right. It it's going to grow into this magnificent plant because right now the soil, the lighting, you know, the watering, definitely my watering is sub sub par. And so, you know, hopefully hopefully with the right circumstances, it will grow into this amazing thing. And so we can use cryptography, we can use economics, and really achieve the global impact that we want. And notably, remember that whole the the debt discussion and that stuff that we were you know, the last presenter was talking about. That's a very real thing, and I'm very worried about that as well. But once again, this is a humble talk about user experience. Thank you very much. I technically should have a 2 minute, 1 minute, something like that of for questions if if y'all want. Everybody wants. Is there just one aggregator at a given time? Great question. In my diagram, there was, but it's a very goofy it was accidental, to be honest. Um no. So there different schemes, but the probably the in all of them essentially, there multiple aggregators. Um because we have this property that we can detect invalidity and like attribute-ably destroy it, it makes it much easier for like a bad aggregator to come in, submit an invalid block, we just prune it, and then we go on with our day, you know. So it's not this kind of you know, you need one aggregator, one system that we have in off chain systems often times because the actual like the the downside of an in you know, a really malicious aggregator is is like huge, right? We've kind of reduced the bad things that they can do. And that gives us the ability to have many. Sure. Do you also have um denial of service issues where I could know who the aggregator is and take them down? If we're all talking to one central server, could I like DOS them? Oh, yeah. 100% and I heard this person say that they feel like we think a lot about clients, but we don't think enough about aggregators because aggregators are going to be like real targets for denial of service. Now, how we solve like denial of service, of course, you know, there are fees, that's that's clear, but also just general like, you know, our traditional DDoS vectors. We'll have to employ, you know, standard techniques and we actually have employed standard techniques on our unipig.exchange to kind of protect the aggregator. But don't don't mess with our aggregator. Cool, thanks. It was a fun talk, thank you. Oh, thank you. I appreciate it. Can you get that down to 1 minute for next Devcon? I I I'm planning on investing all of my time and energy into telepathy so I can go on stage and I can just go and then leave. So, next time. Great talk, man. Can you explain more about the validity proof that you have Yeah, you said that it is complicated. So, how can I prove that the state transition is going wrong? Great. Um so, uh from a I'll answer from two perspectives. The first perspective is pretty simple. From a client perspective, all I do is I take all the transactions, I run them locally, I compute the state root, and I compare the difference. And I say if the state root is different, I know something went wrong and I can automated, you know, easily send a transaction proving fraud and delete the prune the block. Now, from the kind of formal verification of the smart contract side, this gets into a whole 'nother, you know, area of how do we make sure that we sandbox our state transition environment, how do we make sure that we don't run into like out of gas issues, um how do we make sure that we are uh you know, uh doing all the all of the hubbub around formal verification and of course auditing. However, thankfully, this is a closed system built in a smart contract and it's so it is very isolated. One of the one of the real problems that we faced with like layer two constructions often times is like how do you audit this like multi-agent, multi-party distributed system where like everyone is adversarial? Turns out to be like extremely, extremely difficult. So, doing that is like is quite hard and doing a, you know, an audit for a smart contract state verification game is, you know, at least more tightly scoped. So, that is the that is the hope for why that is significantly easier. And actually, in fact, we know it is significantly easier to do the smart contract style stuff because if we were to think of, um for instance, building a, you know, order book exchange, right, on optimistic roll up. Technically, you can do that, but doing a a uh you know, doing Uniswap was way easier because everything is on chain, everything's in a smart contract, there's like, you know, it's it's much easier to kind of manage conceptually. Anyway, a little long-winded, but that's that. Okay, thank you.
