in

Concurrency and parallelism in smart contracts: Why is Ethereum so slow?

Ethereum is slow-extremely slow. Recently, I did a simple USDC approval transaction, and it took about 3 hours to verify. Here is a more enlightening statistic: Ethereum publishes a block every 10-20 seconds on average. Each block contains less than 350 transactions. All of this roughly translates to 30 transactions per second. When criticizing the slowness of Ethereum, Visa’s 2000 tps is often mentioned. Maybe this is an unfair comparison, because Ethereum is still in the development stage. However, it seems unlikely that Ethereum will dominate digital finance in the short term.

1634090674033153

Ethereum’s low throughput is a fundamental problem. Ethereum is an account-based blockchain: the state of the ledger is defined as a key-value mapping from an account address to a piece of data. A simple ETH transaction (value transfer) can increase or decrease the ETH balance data of the account. Similarly, more complex transactions (contract calls) will change the data of the specified account. In this case, the Ethereum transaction is a conversion function of the global ledger state. This is what makes it possible for the Ethereum Virtual Machine (EVM) Turing to complete and allow smart contracts; Ethereum smart contracts are essentially an interactive account data.

Now let us see how the EVM processes or verifies these transactions. It is unreasonable to process all transactions in parallel. By design, all transactions try to change the entire global state. If transactions are run in parallel, the EVM will be biased towards race conditions: two programs (transactions in this case) try to increase the uint variable in parallel. Because the two programs access the variable at the same time, the variable is only incremented once instead of twice. In order to solve such concurrency bugs, Ethereum chose to process transactions one by one. In other words, EVM is a single-threaded state machine. Therefore, Ethereum implements Concurrency (concurrency) instead of Parallelism (parallelism).

Ethereum is similar to a ticket queue with only one teller, and its processing time is inconsistent. The people in line are the transactions waiting to be verified, and the only teller is the virtual machine. When we consider gas costs, things become more complicated. Now, anyone can jump in the queue for an extra fee. The long queue means that those who cannot spend money to get a better position will have to wait too much time to process their tickets.

Ethereum’s low throughput is a problem, especially from the perspective of web3.0. Ethereum has indeed become the medium of all web applications. If its current throughput continues, trivial tasks like liking a post on Reddit may take more than two hours to process. We live in an era where speed is everything, and Ethereum is too slow.

You may ask, why not selectively apply concurrency? In more detail, why not apply concurrency to conflicting transactions—for example, transferring value to the same account—and process the remaining transactions in parallel. Unfortunately, Saraph and Herlihy have shown us that the speedup achieved is modest at best.

Many solutions have been proposed to accelerate Ethereum and improve its scalability. The recent EIP-1559-the London hard fork-does not directly affect the transaction speed of Ethereum, but theoretically it should stabilize the peak of large-scale transactions by reducing the number of potential blocks that ordinary users must wait before transaction processing. Volatility. Then there is the rollup of L2, which should directly affect the throughput of Ethereum without destroying the precious trustlessness of the blockchain.

At the same time, other blockchains that simulate general-purpose virtual machines are also under active development. Some have successfully achieved parallelism, with promised throughput much higher than Ethereum’s 30 tps. Pay special attention to  Algorand , Solana,  and  Cardano , and their unique approach to parallelization in smart contracts.

What do you think?

0 points
Upvote Downvote

Coinbase NFT experience whitelist application process description

YouTube deleted and restored the channel of Bitcoin bull Anthony Pompliano