Cointime

Download App
iOS & Android

Long-term L1 execution layer proposal: replace the EVM with RISC-V

Cointime Official

This post proposes a radical idea for the future of the Ethereum execution layer, one that is equally as ambitious as the beam chain effort is for the consensus layer. It aims to greatly improve the efficiency of the Ethereum execution layer, resolving one of the primary scaling bottlenecks, and can also greatly improve the execution layer’s simplicity - in fact, it is perhaps the only way to do so.

The idea: replace the EVM with RISC-V as the virtual machine language that smart contracts are written in.

Important clarifications:

  • The concepts of accounts, cross-contract calls, storage, etc would stay exactly the same. These abstractions work fine and developers are used to them. Opcodes like SLOADSSTOREBALANCECALL, etc, would become RISC-V syscalls.
  • In such a world, smart contracts could be written in Rust, but I expect most developers would keep writing smart contracts in Solidity (or Vyper), which would adapt to add RISC-V as a backend. This is because smart contracts written in Rust are actually quite ugly, and Solidity and Vyper are much more readable. Potentially, devex would change very little and developers might barely notice the change at all.
  • Old-style EVM contracts will continue to work and will be fully two-way interoperable with new-style RISC-V contracts. There are a couple ways to do this, which I will get into later in this post.

One precedent for this is the Nervos CKB VM, which is basically RISC-V.

Why do this?

In the short term, the main bottlenecks to Ethereum L1 scalability are addressed with upcoming EIPs like block-level access listsdelayed execution and distributed history storage plus EIP-4444. In the medium term, we address further issues with statelessness and ZK-EVMs. In the long term, the primary limiting factors on Ethereum L1 scaling become:

  1. Stability of data availability sampling and history storage protocols
  2. Desire to keep block production a competitive market
  3. ZK-EVM proving capabilities

I will argue that replacing the ZK-EVM with RISC-V solves a key bottleneck in (2) and (3).

This is a table of the number of cycles that the Succinct ZK-EVM uses to prove different parts of the EVM execution layer:

download (6)800×359 154 KB

There are four parts that take up a significant amount of time: deserialize_inputsinitialize_witness_dbstate_root_computation and block_execution.

initialize_witness_db and state_root_computation both have to do with the state tree, and deserialize_inputs refers to the process of converting block and witness data into an internal representation; hence, realistically over 50% of it is proportional to witness sizes.

These parts can be heavily optimized by replacing the current keccak 16-ary Merkle patricia tree with a binary tree that uses a prover-friendly hash function. If we use Poseidon, we can prove 2 million hashes per second on a laptop (compared to ~15,000 hash/sec for keccak). There are also many options other than Poseidon. All in all, there are opportunities to massively reduce these components. As a bonus, we can get rid of accrue_logs_bloom by, well, getting rid of the bloom.

This leaves block_execution, which makes up roughly half of prover cycles spent today. If we want to 100x total prover efficiency, there’s no getting around the fact that we need to at least 50x EVM prover efficiency. One thing that we could do is to try to create implementations of the EVM that are much more efficient in terms of prover cycles. The other thing that we can do is to notice that ZK-EVM provers today already work by proving over implementations of the EVM compiled down to RISC-V, and give smart contract developers access to that RISC-V VM directly.

Some numbers suggest that in limited cases, this could give efficiency gains over 100x:

download (7)800×476 154 KB4a3981f5-7c49-4631-9c7c-3216b4c62466583×528 33.4 KB

In practice, I expect that the remaining prover time will become dominated by what today are precompiles. If we make RISC-V the primary VM, then the gas schedule will reflect proving times, and so there will be economic pressure to stop using more expensive precompiles; but even still the gains won’t be quite this impressive, but we have good reason to believe they will be very significant.

(Incidentally, the roughly 50/50 split between “EVM” and “other stuff” also appears in regular EVM execution, and we intuitively expect that the gains from removing EVM as “the middleman” should be similarly large)

Implementation details

There are a number of ways to implement this kind of proposal. The least disruptive is to support two VMs, and allow contracts to be written in either one. Both types of contracts would have access to the same types of facilities: persistent storage (SLOAD and SSTORE), the ability to hold ETH balances, the ability to make and receive calls, etc. EVM and RISC-V contracts would be free to call into each other; a the RISC-V perspective calling an EVM contract would appear from its perspective to be doing a syscall with some special parameters; the EVM contract receiving the message would interpret it as being a CALL.

A more radical approach from a protocol perspective is to convert existing EVM contracts into contracts that call an EVM interpreter contract written in RISC-V that runs their existing EVM code. That is, if an EVM contract has code C, and the EVM interpreter lives at address X, then the contract is replaced with top-level logic that, when called from outside with call params D, calls X with (C, D), and then waits for the return value and forwards it. If the EVM interpreter itself calls the contract, asking to run a CALL or SLOAD/SSTORE, then the contract does so.

An intermediate route is to do the second option, but create an explicit protocol feature for it - basically, enshrine the concept of a “virtual machine interpreter”, and require its logic to be written in RISC-V. The EVM would be the first one, but there could be others (eg. Move might be a candidate).

A key benefit of the second and third proposal is that they greatly simplify the execution layer spec - indeed, this type of idea may be the only practical way to do that, given the great difficulty of even incremental simplifications like removing SELFDESTRUCT. Tinygrad has the hard rule of never going above 10000 lines of code; an optimal blockchain base layer should be able to fit well within those margins and go even smaller. The beam chain effort holds great promise for greatly simplifying the consensus layer of Ethereum. But for the execution layer to see similar gains, this kind of radical change may be the only viable path.

Comments

All Comments

Recommended for you

  • Changpeng Zhao: Binance Wallet now supports identifying malicious addresses; you will receive a warning if you transfer funds to them.

    Zhao Changpeng posted on Binance Plaza stating, "The cryptocurrency industry should be able to completely eradicate address poisoning attacks and protect users. All wallets should simply check whether the receiving address is a poisoned address and block the user.This is a blockchain query. Wallets should not even display these junk transactions anywhere. If the value of the transaction is very small, filter it out. Security alliances in the industry should maintain a real-time blacklist of these addresses so that wallets can check before sending transactions. Binance Wallet is already doing this. If a user tries to send to a malicious address, they will receive a warning.

  • Bitcoin spot ETFs saw a total net outflow of $189 million yesterday, marking the fourth consecutive day of net outflows.

     according to SoSoValue data, the total net outflow of Bitcoin spot ETFs is 189 million USD.The Bitcoin spot ETF with the largest single-day net outflow yesterday was Blackrock's ETF IBIT, with a single-day net outflow of 157 million USD. Currently, IBIT's total historical net inflow has reached 62.34 billion USD. The second is Fidelity's ETF FBTC, with a single-day net outflow of 15.2979 million USD. Currently, FBTC's total historical net inflow has reached 12.189 billion USD. As of the time of writing, the total net asset value of Bitcoin spot ETFs is 114.289 billion USD, with the ETF net asset ratio (market value as a proportion of Bitcoin's total market value) reaching 6.53%, and the cumulative historical net inflow has reached 57.076 billion USD.

  • BTC falls below $88,000

     market shows BTC fell below $88,000, currently at $87,997.85, 24-hour decline reaches 0.88%, market volatility is significant, please manage your risk accordingly.

  • The U.S. spot Ethereum ETF saw net inflows of $84.59 million yesterday.

     according to Trader T monitoring, the US spot Ethereum ETF had a net inflow of 84.59 million USD yesterday.

  • ETH breaks $3,000

     the market shows ETH breaking through $3000, currently at $3000.08, with a 24-hour decline of 0.38%. The market is highly volatile, please manage your risk accordingly.

  • Binance Wallet launches "secure auto-signature" service

     according to the official announcement, Binance Wallet has launched the "Secure Auto Sign" (SAS) service: it now supports mnemonic/private key wallets to trade on Binance Wallet (web version).

  • Circle minted 500 million USDC on the Solana network.

    according to Onchain Lens monitoring, Circle has minted 500 million USDC on the Solana network. Since October 11, Circle has issued a total of 18 billion USDC on the Solana network.

  • Sources familiar with the matter: JPMorgan Chase is considering offering cryptocurrency trading services to institutional clients.

    according to Bloomberg, as major global banks deepen their involvement in the cryptocurrency asset class, JPMorgan Chase is considering offering cryptocurrency trading services to its institutional clients. A knowledgeable source revealed that JPMorgan is evaluating what products and services its market division can offer to expand its business in the cryptocurrency field. The source stated that these products and services may include spot and derivatives trading.

  • Federal Reserve Governor Milan: We believe that the policy rate will eventually be lowered.

    Federal Reserve Board member Mylan stated that due to the US government shutdown, there were some anomalies in last week's inflation data; he believes that the US will not experience an economic recession in the near term, but if policies are not adjusted, the US will face an increasing risk of economic recession. We believe that policy interest rates will eventually be lowered.

  • BlackRock deposited 819.39 BTC, worth approximately $73.72 million, into Coinbase.

     according to Onchain Lens monitoring, BlackRock deposited 819.39 BTC into Coinbase, worth approximately 73.72 million USD.