76 total views
Take a look at the scalability challenges of Ethereum.
Written by: Remco Bloemen, 0x Technical Expert Compiler: Leo Young
If you recently used the DeFi products, it will be due to high transaction costs prohibitive. It is now normal to pay tens to hundreds of dollars in transaction fees for Ethereum transactions. At the current rate, only ” Whale ” transactions can be profitable. Forget about the noble goals of “banking-the-unbanked” (banking-the-unbanked) or “building a permissionless financial infrastructure that benefits the general public.” Ethernet Square turned into a paradise for the rich.
Small transaction fees can sometimes be as high as 10%
Behind the high transaction fees that block chain scalability issues. This problem is well known, and there is even a dedicated Wikipedia page. Scalability is the maximum limit of the current block chain development, in addition to long-time deterministic, prone to front running, cross chain interoperability issues.
We want to create a tokenized world where all values can flow freely, but the limitations of the blockchain are preventing us from achieving this mission. This is why 0x Labs specially set up a team of engineers to try to solve these limited problems. Through our research, we hope to explore the limitations of Ethernet Square this article, and how it affects DeFi users. In addition, this paper will address the next generation of simple block chain. In the future, we will also write articles to discuss different solutions to Layer 2 and demonstrate our strategy to meet DeFi needs.
First of all, it is necessary to explain that the size of Ethereum transactions is calculated in gas . Collect transactions in blocks, one block approximately every 13 seconds. The number of transactions contained in each block is limited, which is the ” gas limit “. Currently, each block has approximately 12 million gas transaction space. A pure ERC-20 token transfer requires approximately 50,000 gas. That is, each block can accommodate up to 240 pen transfer tokens, transfer of about 18 strokes per second. DeFi transfer often involves multi-pen token transfers and bookkeeping, resulting in transaction costs doubled, thereby limiting the throughput of the block. The “gas limit” and block time mean that the gas required for the transaction needs to be continuously provided.
First, let’s look at how gas supply and its use have grown in the history of Ethereum.
Ethernet Square on the block every day, about six thousand dug, worth billions gas trading space. Mainly due to the increase in the “gas limit”, the number of gas transactions has also changed and increased over time. At the same time, the total gas fee consumed by transactions will also increase as transactions on Ethereum increase and become larger.
Looking back at the gas supply (gray) and consumption (black) of the entire history of Ethereum, as shown below:
As can be seen from the above figure, Ethereum is an enterprise-level application, because office hours are the highest application
Byzantium (Byzantium), before Constantinople (Constantinople) and Muir Glacier (Muir Glacier) hard bifurcation, Ethernet Square gas supply has several starts to fall. These are all the effects of Ethereum’s ” difficulty bomb ” (also known as “Ice Age”).
In the ” Ice Age “, the block production time increased significantly, resulting in a decrease in the amount of blocks per day and a decrease in gas supply. Of course, this situation is very unpopular, hard to force the network to adjust the fork. The purpose of this is: to force hard forks to bring upgrades and improvements, and to prevent innovation stagnation. The Istanbul hard fork did not reset the “difficulty bomb”, so the Muir Glacier hard fork was quickly carried out. Berlin (Berlin) upcoming hard bifurcation consider changing this mechanism (EIP 2515).
Looking at the usage (black), Ethereum has always accounted for more than 60% of gas consumption since the ICO boom in 2017. After that, the “gas upper limit” was increased to four times a few times, and the gas usage increased proportionally after each increase of the upper limit. In the past few months, Ethereum usage has been stuck at 95%.
To understand why Ethernet Square amount of gas does not exceed 95%, we need to understand the concept of “empty block” (empty block) and “tertiary block” (ommer block) of.
“Empty Block” and “Uncle Block”
Ethernet Square on history, even if no matter how high demand, gas amount never exceeded the upper limit of 95%. Surprisingly, the remaining 5% is wasted in completely empty blocks. These empty blocks appear regularly, about one in every twenty blocks. There is a transaction that needs to be paid to enter the package into the block, why would anyone even empty the block? First look at the following data:
Empty blocks steady growth rate over time, is currently 5%. The empty block rate of all mining pools is equal, so it is not malicious miners who empty blocks. On the contrary, the real reason may be a block too fast. If the mining time is less than six seconds, the probability of obtaining an empty block will increase geometrically.
One explanation is that as soon as the miner obtains the new block header, it starts to dig the next block before the entire block is packaged. This kind of operation is called SPV mining in Bitcoin, allowing miners to start looking for the next block without completing a block verification, but can only add empty blocks. After the new block is fully packaged, you can add the next complete block and switch to mining.
Further evidence for this interpretation is that, if the same miners dug two blocks in quick succession, the empty block rate will be reduced by 25%.
Another way to empty a block is to process the new block while mining the previous block. This results in multiple blocks being mined at the same time. If such a situation occurs, Ethereum will select a backbone block and mark the other blocks as ” uncle blocks ” (ommer). Miners who dig “uncle blocks” can still get small rewards. The rate of occurrence of this situation is stable:
During the peak period of gas consumption in 2018, the rate of “uncle blocks” also reached a new high, but then the proportion fell to 5% of all mined blocks. This is consistent with the fact that miners may change the mining strategy at this time and cause the empty block rate to increase.
The damage of the empty block rate to the scalability of Ethereum is not immediately apparent, but it does have an impact. Since the EIP-100 proposal of the Byzantine upgrade, the difficulty adjustment maintains a certain ratio of backbone chain blocks to “uncle blocks”. Therefore, a high rate of “uncle blocks” means that the number of wasted “uncle blocks” increases and the number of blocks that increase in the main chain decreases. This is manifested as the daily block generation time is extended and the total daily gas volume is reduced. (Another reason for the extended block time is the “difficulty bomb”)
‘T block “or empty blocks are important health indicators Square Ethernet network. Any increase in any indicator means a decrease in the total gas used for transactions every day. “Uncle block” rate analysis is the main part of supporting EIP 2028 and 1559 studies (see 1, 2, 3). Surprisingly, the two empty block of EIP not mentioned, but there is a method defect study. Use logistic regression and other appropriate statistical methods to analyze the “uncle block” rate and empty block rate, so that a more rigorous analysis will be better.
There are ways to reduce the empty block rate and the “uncle block” rate. The presumed root cause is that the mining pool does not have the latest status available due to network and processing delays. A simple but less satisfactory solution is to allow more mining center of the pool, the latest state will be together.
A more decentralized solution is to create dedicated connections between mining pools like bloXroute . By “spy mining” (spy mining) inspired, you can make mine pond dug in advance to share your current block. Other mining pools will prepare subsequent blocks that may be mined. After the mining pool successfully digs its own blocks, it already knows which blocks can be mined in the future and switch immediately. Above the stack, improving node communication protocols and processing algorithms is also effective, and there is still room for improvement in these areas. Ultimately, reducing the empty block rate and the “uncle block” rate can increase the gas supply by up to 5% in a single day.
So there seems to be a 95% gas limit, but what if someone wants to use more than 95%?
What happens if the Ethereum gas limit reaches the top? Miners are free to choose a package deal (detailed follow-up), but in fact the miners by “high gas costs priority principle” package deal, such as the highest profits. This creates the phenomenon of the first price auction of available gas.
Gas prices have become a textbook template for ” perfect inelastic supply. ” As the network usage rate exceeds 80% and rises to 95%, the gas price increases significantly. Any increase in potential demand will only increase the price until the price drives off demand and falls back to the same level.
The only way to let the price drop is to increase gas supply or reduce demand, and the recent increase in gas cap is not sufficient to reduce gas prices.
At first glance, the increased interest in Ethereum will only push up the price, but will not cause the increase in usage. In fact, the use of high-value expel low-value use, reduce expensive class of non-homogeneity of game tokens (NFT) transaction, DeFi more large deals.
Proposal EIP 1559 is intended to make gas supply more elastic in the short term. During peak demand periods, block capacity can be increased (up to 20 million gas). This helps keep the peak gas price stable and can pack transactions faster. But this does not change the long-term supply problems inelastic.
According to the proposal EIP-1559, there is still a fixed gas issuance rate for a long time, which means that the gas price will continue to rise until the demand is small enough. EIP-1559 still encourage priority package deal to pay a premium in the same block (assuming that mine pool to continue according to the original order to dig blocks). This means that the front running, gas bidding situation and miners profit still exists.
The number in the figure represents the lowest price that can be packaged and traded in the next block. The more you are willing to wait a long time, gas prices will be lower. Historical data shows that if you are willing to wait two minutes or more, the price will be very low. EIP-1559 helps reduce premiums and facilitates faster processing of transactions.
Therefore, the gas ceiling will increase the gas price. How can we increase the ceiling?
Gas upper limit
The mining pool determines the upper limit of gas. Here is a brief overview of miners and mining pools works: Almost all the miners will gather together to count Resources. The miners will not run the risk of long-term gain is not alone go to the next block, but to gather resources and a stable income. The mining pool verifies the computing power contributed by each miner, and then continues to dig the next block, which promotes the development of the mining pool. Large mining pools will eventually mine a larger share of blocks.
Let’s take a look at the development of the share of the Ethereum mining pool:
Xinghuo, Ethermine and Yuchi won the main blocks.
In addition to hard bifurcation, the mine pool operators have an important responsibility of governance: they can set an Ethernet Square gas cap. Unlike block generation time and gas price (new feature), the upper gas limit is determined by each block. New gas is limited to the upper limit of 0.1% on a block, each block can only make a slight float ( “Yellow Book” Formula 47). If the three mining pools unanimously agree to rapidly compound interest and roll unilaterally, the upper gas limit can be doubled or halved in two and a half hours. If the disagreement, gas cap is the weighted average of the size of the mine pool.
At present, due to the lack of detailed information about the actual operation of miners, we will use a simple method: voting system . […] I hope that in the future we can soft fork into a more accurate algorithm.
Ethereum design principles (first joined in March 2015)
In the early days of Ethereum, the way miners set the gas limit was the ” solution to fill the gap. ” Many “filling solutions” are good enough to become backup parameters. EIP 1559 proposes a different mechanism, which is currently under discussion during the Berlin fork. Prior to this, mineral pool operators can control as OPEC oil production as control gas supply.
Ethermine mining pool operator
Two recent unanimous decision of mine pool to enhance gas production by 25%, quite controversial. The goal was to ease the pressure of high transaction fees by increasing gas supply. What we have seen so far is that transaction demand has grown faster than the gas ceiling. This causes the price to slow down temporarily, and eventually rise.
Ethernet will increase the gas cap Square, a huge security risk. As mentioned above, the upper gas limit will increase the “uncle block” rate and the empty block rate. Under normal transaction load, this increase is small. But for security issues, we don’t care about normal behavior, only unfavorable behavior in bad situations. Perez and Livshits (2019) studied this terrible situation, the result is under the same gas costs, transaction during bad times slower than normal trading. It takes ninety second blocks to fill up the transaction. This causes the synchronization of nodes to lag, and the mining pool digs “uncle blocks” and empty blocks. As of the release of this manuscript, the problem has been alleviated, but not enough to avoid it. This led to the two main node developers Péter Szilágyi and Alexey Akhunov criticizing the decision to increase the gas limit.
Therefore, the upper gas limit drives up the gas price. It seems that we should not blindly increase the gas limit. What should I do? Perhaps the gas cost required for transactions can be reduced?
The gas cost of the transaction is mainly composed of the EVM running cost . The transaction is composed of many EVM operations, and the cost of each operation is determined by EIP and hard fork. In the past few hard forks, the gas cost of some operations has increased (EIPs 150, 160, 1884), and some decreased (EIPs 1108, 2028, 2200). Berlin planned hard bifurcation is also considering changing some of the gas cost for a particular operation.
All changes aim is to make the cost more accurately the true costs of response operations. This means that as computers and algorithms become faster, computational operating costs will decrease.
The storage operating costs vary. The cost of storage and retrieval depends on the size of the state on the chain, and the state of Ethereum continues to increase. Improving storage devices or databases will not offset the increase in state size.
This means that storage is still a high cost for DeFi applications. It takes 20,000 gas to create a new balance, and 5,000 gas to modify the existing balance. The balance must be modified at least twice for transfers, and at least four times for remittances. The state fees required for DeFi transactions are higher. It seems that there is no simple way to reduce the amount of related storage. When there is demand, storage fees will rise. On the bright side, the Layer 2 scaling solution is biased towards lightweight storage and high computational load, which seems to have more advantages.
Finally, as the gas limit increases, the same security concerns will appear: bad situations will have a big impact. The average cost of a local optimization of gas cost to achieve the current operation is very dangerous.
This makes it clear why the scalability issue of Ethereum is so difficult. Before giving a solution, we need to mention another limitation of Ethereum that hurts DeFi users.
Block packagers follow the consensus rules. Consensus rules guarantee important freedoms such as transaction selection and sequencing. For ordinary token transfers, there is no big problem. But for DeFi transactions such as exchanges, preemptive transactions have high economic value. If the target transaction is attacked on both sides, more complicated profit-making behaviors will occur. Daian et al. (2019) called “miners profit” (miner extractable value).
It seems that mining pools will not maliciously use their transaction ordering freedom, but they can still use it for profit. It is possible for the mining pool to use Geth to sort transactions by gas price (see 1, 2). This will generate a gas price auction, with the highest bidding transaction first. This can cause adverse effects, anyone can be the first transaction through the high bid. Competing traders continue to bid to increase the gas price until the trading profit completely offsets the gas fee. Currently, all profit will fall into a transaction fee miners pocket.
In other cases, the next transaction will be valuable, such as the first liquidation position after the price oracle is updated. This is called ” back-running “, and the result is that miners benefit.
Large spreads, price deviation, high transaction fees and more failure, end-users will DeFi damaged, miners profit. To have a better DeFi experience, this problem must be solved. To solve this problem, it is necessary to restrict the freedom of transaction sorting, such as requiring the transaction with the lowest gas price in a block to be prioritized.
Now fully understand the limitations of Ethernet Square, and how it affects DeFi. Of course all star teams dedicated to scalability will eventually solve this problem, right.
Strengthen the bottom, focus on the second floor
There are many outstanding teams working on different scalability solutions. There are two solutions: Layer 1 and Layer 2 . Layer 1 target solution is to build more scalable Ethernet Square, Layer 2 solution is to build more scalable infrastructure on the basis of Ethernet Square on.
The most obvious problem from the beginning: to enhance the performance of existing Ethernet Square – this is Eth1x do. Improve the performance of the Ethereum client, there can still be many improvements. Unfortunately, Eth1x has hardly received any support it deserves, and all progress is slow.
To understand what performance Eth1x can achieve, you can first take a look at Solana . Solona’s throughput can reach more than a thousand times that of Ethereum, and there is room for improvement. The main disadvantage of this approach is that hardware to run full node demanding.
Most other solutions have three things in common:
- Use WebAssembly as a virtual machine, minimal state architecture, and most importantly sharding. All transactions on Ethereum are currently executed in sequence. Transaction sequencing is undoubtedly the key to blockchain. The disadvantage of this model is that it is difficult to process in parallel, so the scalability problem cannot be easily solved by investing more resources. This is what the next generation blockchain Eth2.0 will solve.
- By changing the transaction execution method, transactions can be processed in parallel. The blockchain is divided into multiple loosely connected domains, which is called ” sharding ” processing procedures, to achieve this solution. The transactions within a shard are still arranged in order, but the shards are asynchronous. This allows all shards to run in parallel, expanding the network according to the number of shards.
- The domain used for separation does not necessarily match the shard. The same shard can have multiple domains, and even domains can be migrated to achieve load balancing. For an in-depth understanding of sharding technology, readers please browse the ” Night Shadow ” paper of the Near Protocol.
Where the main chain of the next-generation blockchain is divided into domains and when divided into domains depends on the situation. It can be considered as a second generation block chain from the fine-grained (numerous fine domain) to a coarse-grained (a few large domains) spectrum.
The two projects each occupy both sides of the granularity spectrum: Dfinity is at the fine-grained end, each agent has its own domain, and each agent interaction is asynchronous. The Near protocol is slightly more granular, and each contract has its own domain. Boca is coarse-grained end, it is the entire domain is fragmentation, a condition called “parallel chain” is more accurate. Analyzing Ether Square 2.0 DApp developer from premature angle. Eth1EE (Eth1 execution environment on Eth2) will be coarse-grained, with boundaries consistent with shards, and the current Ethereum will become a shard. Advantage of fine-grained solution is transparent; contract between calls, whether or not cross tile boundaries, can look the same. This in turn allows contracts to be moved between shards to easily balance the load.
The disadvantage is that longer cross-domain transaction is atomic, but rather become parallel, wherein the portion irrevocable. In Dfinity and Near, it is shown that the call between the contracts is async , and the contract is returned to wait for await. All transactions that occur during await will be written to the chain. Later other people’s transactions can be superimposed. All previous transactions cannot be cancelled at this time. After await is finally confirmed, the success or failure instruction of the contract call can be returned. There are multiple proposals to avoid this situation and allow a certain amount of atomization across shards, but this also has disadvantages. Embracing deatomization seems to be a natural consequence.
For DeFi, asynchronous transferFrom calls pose a big challenge. Imagine a simple transaction between two parties. Alice and Bob want to trade with ETH and DAI. The basic contract should be:
But now I need to deal with errors. If the first transaction fails, we can stop the transaction. If the second transaction fails, 1 ETH needs to be returned to Alice. The problem is, Bob may have already spent that 1 ETH at this time. One way to solve this problem is hosting.
That’s it, no one will lose. But now Bob will have the exclusive right to free choice of Alice’s transaction. Alice’s tokens are in custody, no other transactions will be made, and there is no guarantee that the transaction with Bob will be successful. Solving this problem can punish violators. However, DeFi transactions are very expensive , and it is difficult to determine how much punishment is appropriate. Solving this problem can require all parties in the market to deposit funds in custody in a deposit contract at the beginning. And this becomes a centralized state, and there is no need for sharding at all.
Another thing to note is how complicated these concurrency issues can be. Real trading, there are sequences of filling the state needs to be updated (fill-state of the order) , which make the agreement more complicated. Compared with concurrency vulnerabilities, the reentry attack vulnerabilities that plagued Ethereum 1.0 are not surprising. Concurrency vulnerabilities are uncertain and will not occur during testing. From the above simple transactions, we can see that to solve this problem, we need to rethink the infrastructure, and the only reliable way is to overthrow it.
Transaction is the foundation of DeFi construction and a series of processing procedures. We already know how the exchange trading book poses a challenge. The automatic market maker exchange is relatively simple, because there is an escrow reserve, but the reserve balance forms a bottleneck that prevents parallelism. Even for the fastest traditional exchange, settlement is not parallel (although there will be redundancy), and the sorting is done on a single matching engine. To learn more about the working principles of traditional exchanges, Brian Nigito’s presentation is great.
This does not mean that these problems are unsolvable. The simplest solution is to deploy a separate agreement all these instances of each tile, so arbitrageurs to keep synchronized with each other. It may be possible to obtain a single synchronized shard with sufficient performance to include all DeFi transactions, so that there is no need to worry about concurrency issues.
This article delves into the limitations of Ethereum’s expansion of DeFi applications. As mentioned above, this problem is complicated and cannot be solved overnight. Later, we will write another article to discuss Layer 2 specific solutions and demonstrate 0x’s own strategy.
1. Daniel Perez & Benjamin Livshits (2019). “Broken Metre: Attacking Resource Metering in EVM.”
2. Daian et al. (2019). “Flash Boys 2.0: Frontrunning, Transaction Reordering, and Consensus Instability in Decentralized Exchanges.”
3. Brian Nigito (2017). “How to Build an Exchange.”
4. Danny Ryan (2020). “The State of Eth2, June 2020.”
5. Scott Shapiro & William Villanueva (2020). “ETH 2 Phase 2 WIKI.”
6. Near Protocol sharding design