Kakarot zkEVM: beyond ethereum compatibility
ETHCC 7 · 10 Jul 2024 · 20:11
Elias Tazartes presents Kakarot, a zkEVM written in Cairo on the Starknet stack, and asks how to go beyond EVM compatibility without losing its network effect. He cites an average of 1.3 years from an EIP's creation to its merge, which he contrasts with rollups' pace. He describes additive specialization, where EVM equivalence is the floor rather than the ceiling, and rollup-led innovation, with Arbitrum Stylus as an example. He says a provable high-level language lets a team ship upgrades quickly, and that Kakarot implemented EIP-3074 in two weeks before it was dropped.
Speakers
Topics
From ETHCC 7, hosted by Ethereum France.
Transcript
On the Starknet stack. And today we're gonna touch on EVM compatibility. It's not directly linked to Kakarot itself as a protocol, but we'll come back to it. But I just want to touch on a subject we've been seeing a lot in the Ethereum ecosystem, which is trying to push the boundaries of EVM, either by going full-on alt VM or bringing new capabilities to the EVM by maybe enhancing its instruction set as well as just uh shipping features way faster. Who here knows what the EIP is?
Okay. So it's an Ethereum improvement proposal. This is how the Ethereum protocol is updated every now and then. And the average um from creation to an of an EIP to its merge is 1.3 years. And I took this on the latest uh Hot Fox of Etherm protocol, which means that if you want to upgrade the Ethereum software, you probably need to wait a long time or like somewhat of a long time, which makes sense. There are hundreds of billions in TVL on Ethereum, and you probably don't want to be able to ship at the speed of a company, which is like probably every month or so. But then Ethereum has adopted this rollup centric uh vision where it gives out uh at least delegates compute uh and innovation to roll-ups where all the users are now making most of the transactions.
And then there's the strength I mentioned, which is to go beyond EVM, right? There is Arbitrum Stylus, which enables people to write WASM smart contracts. There is Mega ETH that expands the capabilities of EVM by going like 10,000 transactions per second, movement, that's a new VM, fuel, new VM, Kakarot, a dual VM with the Cairo ecosystem, RETH AlphaNet, which is a framework to extend actually the capabilities of EVM based on the open optimistic rollup. The idea that anyone can come in, kind of fork, but not fork the OP stack and add new um new capabilities to it, and then Aztec, which is a privacy preserving rollup.
And so today we're gonna see a bit this idea that maybe as a community we want to go beyond EVM, but then the strength of the EVM is its network effect. So this is the main tech the main tension of this talk is that EVM is winning because it has inertia and network effect, just like Twitter is Twitter still has all the followers and Farcaster hasn't like absorbed all the user base, even though Farcaster is built on better primitives. Like there is this idea that sure EVM is legacy, but right now it has way more um power. And then we see that probably these two aspects of like additive specialization and roll-up governance can make um can safeguard the network effect of the greater Ethereum ecosystem.
So yeah, this number. So as much as people want to go for from like to LVM, the liquidity and the real world usage of uh like stable coins being this proxy for real world usage, is still on EVM. The second one is TVL by spark contract language. So I don't know if you see well, but Solidity has a lot of orders of magnitude more than the second best, which is Rust for Solana, probably. So there is still like very very strong network effect on EVM, and as much as everyone wants to break EVM with new alt VMs, it's not so easy to say, guys, uh for the 10 past years, we've worked with legacy, now we can finally trash it all and start from a clean slate. This is just not going to happen.
We have to compose with what exists. And so that's the billion dollar question, right? How do we go beyond EVM? Everyone wanting to go beyond it without losing network effects. That's the first idea is additive specialization. I think it was introduced by Arbitrum, but I could be wrong. And then roll-up led innovation is just to say we're reversing the innovation flow in Ethereum. And I think it is at this process is at its infancy. And we're going to we have a panel uh with some people from EF at the end of the week to actually see how we can build on this. Okay, so what's additive specialization?
I stole the definition from Arbitrum. It's to say EVM equivalence is no longer the ceiling, it's the floor. And then this idea of EVM equivalence is just the idea that whenever you want to have a EVM runtime, what you actually do is you follow L1. So you have a roll-up, Arbitrum, optimism, you build on EVM and you say, okay, whenever L1, Ethereum, the main layer, updates, I will update. So you follow, and then as we saw in the beginning, these updates are once every year or so. So at least the update, which is called a hard fork, packs a few EIPs like six, seven, eight, and then these only happen every once in a while. So this is incompatible with the fast-paced innovation that rollups want to achieve.
So this is what they built, right? Stylus. I don't know if you saw if you know, but Arbitrum uses uh Wasm runtime for their fraud proof. So they thought, sure, we can fraud proof anything that's WASM, and we're proving EVM, so might as well throw in a Wasm runtime for our smart contracts. And our promise is 100x on memory cost and probably 100x on speed. So this unlocks a new trade-off space for devs that may want to be doing new stuff. This is in my mind exactly the same as Figma. Who knows Figma? So it's a front-end, it's a front-end app, right?
What so it relies on JavaScript, but they're as far as far as I know, their um graphic engine is in WASM. So this could be this idea that Solidity is the thing that everyone knows how to do, it's very easy, it has long, long stable community, but for very some use cases, you want a powerhouse, you want a Solana 10k TPS, but in the EVM realm. So this is the this is the idea, at least for optimistic robots. And then Kakarot comes as kind of like a counterpart in the ZK world, saying Kakarot is a Z is an EVM implementation in Cairo. And I don't know if who knows Cairo?
Okay, that's nice. It's um it's a provable high-level language, and we used it as an infra language. So we built ZK infra without anyone in the team being a cryptographer, which is quite a novel way of thinking it. And we see everyone picking up on this with uh risk zero, success, jolt, and the likes. This idea that you no longer need to write circuits, you can rely on high-level ZK infra. And so this is the timeline. We started um a little less than two years ago, right? Bad at math.
And uh we caught up on Etherm compatibility and then we hit the ceiling. We were saying, okay, now we're done with all the Etherm Foundation uh integration test. The one that can confirm your instruction set is implemented correctly. And we said, okay, now what next? Do we want to ship one feature per month? Like how do we actually do it without hitting walls of uh breaking compat? So then we thought, okay, let's build a new way to extend the good extra instruction set of EVM with K RO VM. And then it's exactly the same trade-off. Because KRO is the most performant like language for ZK that is high level and accessible.
And then EVM is the best language for networked effects. And then who knows how a ZKVM works. Okay. It's very dumb. I know it was a buzzword in 23, but 2023, but it's actually an EVM is just the runtime for all smart contracts. And it's the this idea of like shared computer in the Ethereum ecosystem. And when you slap ZK as a prefix, you mean anything that I can execute, I can prove. So why won't you do you want to prove something? It's very simple. It's for scalability, not for privacy.
It's the idea that how do you prove to someone you did something? You trust them. So this is the normal web2 model mental model. You re-execute it. This is exactly what happens when you run a full node on Ethereum L1. You don't have to trust anyone. You run a full node, you run the blocks, you replay them one by one. If it's if it checks out, you're good. You don't have to trust anyone. But this is very costly. And the third option is you verify a proof. And this is supposed to be exponentially cheaper. And so this is the whole premise of why ZK is important for scalability. So a ZK VM is essentially just saying run all your EVM transactions, and I can prove them.
And when you prove them, you bundle them for Kakaot, it's in a start, and then you settle them on L1, and you get exponential scaling, which is supposed to solve this billion user problem. And then so how does Kakaout work? It's simply an implementation of the EVM instruction set in Cairo, and then some wrappers to like supplement the Kero VM, like a KRO VM chain to behave like an EVM chain. So then what do you have to do? You implement the 146 opcodes of EVM. I forgot if they they added like blob based fee and so on. Um and then you have to write the logic of accounts and smart contracts and then an RPC node. Then what you get is actually an incredibly lightweight ZK EVM that's quite customizable and extensible.
Um this design that we have in tested right now is somewhat comparable to going on scroll today in terms of what the user gets. But soon, because you're actually interacting with Cairo and not uh circuit, so halo two for scroll, you're actually expanding all the design space in the future to be able to interrupt with Cairo. So a good uh example I stole from Vitalik, which is that he uh was presenting this morning in Starknet CC that he wrote his uh own prover uh in Python and that it was very slow because Python is slow, but that he was using NumPy, which is a library exposed in Python, but that uses C. So you have to think the same for Solidity and Cairo.
You can write Cairo using Kakarot. Uh sorry, you can write Solidity using Kakarot, but yet you can actually also write modules in Cairo that are extremely efficient for ZK and then call them from using Solidity. So it's another way to see it is like ZK optimized Yule. It's good for teams that want to keep EVM network effect but also slowly transition into something that is very future proof, which is uh intermediary ZK VM. And this is also what we're saying. Uh we're seeing in the market as well.
Who knows Tyco here? They started by implementing their ZK EVM using Halo 2, but then now they went to mainnet and actually pivoted, and they ended up not going with Halo 2 and going with uh risk zero, if I'm not mistaken. So this is this shift from circuit-based, uh hard to maintain, quite performant but very specialized, hard to audit, hard to maintain, to something that is high level, so Rust, uh, and you can prove Rust using RIS0. For Kakao, it's different in Scairo, but it's exactly the same mental model. You go from something that is very low level, so something that is assembler, to something that is more common to Rust.
So this is the shift for writing infra. You no longer to write ZK infra using assembler code, you can now write ZK infra using Rust or Cairo. And for us, this enables us to be very, very fast. What do you get actually for a user or for a dev means that now on Starknet or any Starknet based chain, so app chains, you now get a dual VM runtime. So you can write Solidity, you can write Cairo, and then you get this like very clear trade-off space. If you want to land on Starknet very fast, you have an EVM code base without changing any line of code, it's completely EVM compatible. You just deploy, and then slowly, slowly you find that some things are 10x too expensive, and you write them in Cairo to optimize.
If you don't want to touch Cairo, you just directly deploy as Solid Z and it will just work at like on par performance with other other uh ZK rollups in the market. Okay, so you can ship one feature per week. You have ZK infra that's very high level, so you're very maintainable. Your code code base is 10x less lines of code. So you want to ship every month because you're a startup, but then you create fragmentation and you lose all the benefits of EVM. And then this is how you need probably like new ways to coordinate between rollups to make sure the breaking the EVM is not too costly. There's this tension between innovation and standardization.
So I argue that if we can have the same process that uh we have on L1, which is EIPs, uh, so Ethermia improvement proposal based on somewhat of a democracy, at least between core devs, in roll-ups, we could have less fragmentation and we would preserve the network effects. If we can't preserve the network effects, you might as well go for Solana VM or MoveVM or SVM or Kero VM directly because they're just better optimized for the future, especially Kero VM, because it everything that it computes is able to be proven with a SARC, and as we know, um because we are fans of Italic, who has tweeted like a few months ago, in 10 years everything will be ZK. It's just better for composability and scaling.
Okay, so yeah, historically, as I told you, EVMs uh follow L1 for updates. So you have uh I pictured in the top all the uh client teams of consensus engine as well as execution engine, and they basically argue about the vision. There's a vision right for the network of Ethereum with the values, but they are the ones that are like empowered to vote but also to propose changes that make that transform the vision which is diffused in the air into precise specialized specifications that will change the protocol. You have to think who knows that Ethereum L1 switched to blobs.
Okay, so Ethereum L1, not so long ago, switched to blobs for data availability. This is one example of a big update that had to go through lots of governance, took more than two years, I think maybe a bit less. But there are problems to solve. Call data is too expensive, how do we solve them? Oh, we could go with the new design for it for four. Okay, debate L1 hard fork, rollups catch up. But what if we could reverse this and say, I have a new idea, I'm gonna try it on my roll-up, and then it might land on L1. So and I think Etherm might really use it.
So I have one example, I have a few examples, but this is one example. So there is um there are such things called precompiles on L1 on in Solidity or in EVM bytecode, and um they're supposed to be able to enable you to do things that are very expensive if you were to write them in Solidity, but they're actually uh escape hatch of the EVM, they're written in C, C, Go, whatever. And then such as an example is big two compression function. And so there was a debate to include it, but then since since so you took a lot of time to include it, um and it was called a thousand times, which is almost never, and no one uses these functions, so much so that now they want to remove them. So imagine how painful it is to do top-down governance, think of new features to do, take one year to implement them, only to find out no one wants them.
It if you were in uh Y combinator meeting, you would get fired probably. So this is the longest EIP uh that got merged, is uh T store T load. Who knows about T store T load? Okay, so it took 5.5 years to go from specification to mainnet. Uh good job, Moody and Alexei, for being so patient. But now it enables like lots of uh cost savings for uh like uniswap like protocols, but still this is quite long. And another example is EIP3074. It was uh actually took four years to be scheduled for inclusion, but then there was pushback from the community, so it was actually killed. So that's another example of not so ideal.
Uh like the community is learning, but I'm arguing that if we could like try out EIPs on rollups, you would probably avoid all these problems. So that's kind of a reversal of the system. You like roll ups kind of unite to define standards, they test it against their own community. Rollups are extremely agile because they're not on L1, so they don't have to maintain the decentralization aspect and robustness aspect of the Ethereum network. They're kind of like small startups that try to innovate, and then the thing that sticks go goes back to L1. So I argue that you could design RIPs.
They already exist, I didn't invent it. So who knows about RIPs, rollup improvement proposals? Okay. And there's just this idea that you don't have to get consensus on L1 or go for governance, you implement them on L2, and then if they stick, people actually use them, you bring them back to L1. And such a good example of this is RIP 7212, which is the face ID signer precompile. So now you can use on most rollups your iPhone to sign transactions directly as a pre-compile, not on L1 yet, but then it's uh being um considered for inclusion on L1 because everyone loves it. Or at least enough people, like not everyone.
And then I argue that I claim that rollups can limit fragmentation through governance. There is this tension also in rollups that they don't have an incentive to go to govern together on L1, you just can't not govern together because you have this, you have responsibility for the network, like the etwas or Ethereum. But rollups they are competing with each other to claim the most TVL or mind share of devs. So if you have the new killer feature, for sure you're not gonna spend one year in an office arguing with another rollup to like ship it or not. Um but still, some pre-compiles or like uh standards actually make sense because if every rollup just fragments over time, everyone is shipping improvements, um, you will just uh like chip away all the advantages of being on Ethereum. So, such good examples are pre-compiles, so face ID, gas repricing, or just new innovations, such as to say there is no longer this idea that it's either Ketchack or nothing, it's every rollop has a primary hash and you could use it.
Other examples could be new storage layout, this is done by scroll today, and new content type. And then this idea slowly brewing in people's minds that Ethereum is going to transition into the world settlement layer. Initially it was the world computer, but then no computer can have the world compute. So you use ZK to compress the compute, and you just use L1 to verify the integrity of the compute, not do the compute. All right, so a bit of a shill moment. Kakarot aims to lead this innovation, at least because it's very hard to do updates in the ZK world that are fast, but if you use a high-level language for your infra, you're actually as agile as a DAP. So if you use assembler and circuits, you cannot update every month.
If you use high-level languages such as Cairo, it looks like Rust, you're going to be able to ship, and the code base is going to be extremely maintainable. And a bit of a vision for the future, I'm very bullish on this. We're working with Starkware, so we are building on the shoulders of giants. We didn't have to reinvent the wheel. They are building Cairo, the Cairo stack, the Starknet chain, as well as the prover technology, and they just announced their prover second generation, which is 1000x improvement, and it's by far on benchmarks the most performant in the industry. So what you would get out of this is very fast integrity verification, like a green check that everything went well, as well as sub cent cost.
And right now on StarkNet chains, like the costs are actually the same as base, which is quite good. Considering base is optimistic and Starknet chains are uh ZK. So you already have very good performance, but then 1000X will actually just solve all the problems of the Ethereum ecosystem in terms of prover technology. Okay. So yeah. For example, before EIP 3074 got killed, we implemented it in two weeks, which is the same approximately duration that it takes for uh someone to write Golang and implement this AIP, but our implementation was ZK enabled. So yeah, my claim.
Um we'll have to verify it because for example, Arbitrom stylists whom I mentioned are in testnet, and then um roll up uh improvement proposal. We're just at the third one, so we have time. EIPs have hundreds of them, so we'll see in the next years.
Related talks
- ZK-EVM
- Kakarot zkEVM: Introducing the Modular zkEVM Written in Cairo
- zkSync 2.0 update, Exciting Ethereum things and more - The Daily Gwei Refuel #411 - Ethereum Updates
- zkEVM #04 - Devconnect AMS'22
- Are OP Rollups More Expensive than ZK Rollups?
- zkEVM Vs EVM: Full Equivalence? by Ignasi Ramos | Devcon Bogotá
- IRL Workshop: Build on Ethereum, Hanoi Day 2
- Exploring Blockchain Scaling Solutions
- Lightning Talk: Native Rollups by Luca Donno, L2BEAT