CatcherVC Research: In-depth interpretation of Optimism expansion plan
星球君的朋友们
2022-04-07 03:00
本文约8961字,阅读全文需要约36分钟
How should Optimism move toward decentralization and fulfill the vision of the "fraud proof" mechanism and multi-Squeencer rotation?

secondary title

The focus of this article

  • For the sake of security and decentralization, the gas limit and block generation time of ETH blocks cannot be greatly changed;

  • The essence of Layer 2 expansion is to create a chain with higher TPS, and hang the information of this chain on Ethereum;

  • The market value-added space of Optimism is huge, its TPS upper limit can reach 1600, but the actual utilization rate of throughput is less than one thousandth, and the future development potential is huge;

  • Since the peer nodes are not open, after Optimism’s local Sequencer generates a block, it takes even one hour to verify its correctness, which is too long;

  • The current Optimism and Arbitrum are both officially run block nodes, which have serious centralization problems, and their foundation lies more in the "credibility" of the project party than in "procedural justice" itself;

  • foreword

foreword

As the merger of ETH officially enters the process, Layer2 and Rollup have gradually become prominent in the blockchain industry. At its origin, the purpose of Layer 2 is to increase the number of transactions per second (TPS) processed by the system and reduce Gas fees. The former is the core point of the entire Layer2 expansion, and the latter is the key to improving the Layer2 interactive experience.

According to its definition, TPS = the number of transactions processed within a period of time / time-consuming, applied in the blockchain field, if ignoring forks or block reorganizations, it can be roughly regarded as TPS = the average number of transactions contained in each block Number ÷ block time. For ordinary public chains, improving TPS is faced with the problem of block expansion and block generation time. At the same time, the actual value of TPS also involves the Gas mechanism adopted by the public chain, whether it is ETH, BSC or Polygon. .

However, increasing the gas capacity of blocks or shortening the block generation time will destroy security. The root cause is that the expansion of Ethereum must face the problem of "impossible triangle". How to improve efficiency while ensuring security and decentralization is always a problem On paper, in the unresolved stage.

In this regard, Layer 2, represented by Optimism and Arbitrum, has risen rapidly with the banner of high efficiency and low gas, which is quite eye-catching. While relying on sophisticated narratives to attract capital from all walks of life, and relying on ultra-low Gas to harvest a large number of users, its inherent centralization problems have become increasingly clear, causing more and more attention and doubts.

secondary title

Gas Mechanism of Ethereum

One of the key factors determining the efficiency of Ethereum is the Gas mechanism it uses. In the Ethereum system, Gas is a form of measurement that reflects the complexity of different operations. Just like a car needs gasoline to run, transactions on Ethereum will consume Gas. For the simplest transfer of ETH tokens, the Gas consumption is 21,000. Other types of operations, such as ordinary ERC-20 token transfers, or more complex contract interactions, can generate tens of thousands or even hundreds of thousands of Gas consumption.

A single block of Ethereum has a Gas upper limit, which limits the total amount of Gas that can be consumed by all transaction instructions in a block. This is like a refrigerator that cannot be filled when it is full. On the eve of the implementation of EIP-1559 last year, the upper limit of Gas in a single block was about 15 million, which roughly accommodated a maximum of 714 ETH token transfers. If the average block generation period of 13 seconds is put into the TPS calculation formula, EIP— The theoretical TPS upper limit of Ethereum before 1559 was 55.

However, in reality, many transactions are contract interactions with high Gas consumption, which will greatly occupy the Gas capacity of the block. The actual average TPS of Ethereum is reduced to 20, and the congestion is unbearable, which makes a large number of potential transaction needs be squeezed out of the chain. Since the handling fee of a single transaction = Gas Used × Gas Price, and Gas Used is determined by the system, it can be regarded as a constant. After the user initiates a transaction, he has to pay a higher Gas Price than others to be the first to be responded by the system. In the end, the gap between supply and demand caused by the characteristics of the system created high handling fees, causing countless people to complain.

In the final analysis, ETH is essentially an auction platform for trading permissions, Gas Price is the bid of the bidder, and the ownership of trading permissions is reached by the supply and demand sides through the bidding mechanism. This design is in line with the free market principle of the blockchain, but it has planted the seeds of involution.

Throughout the history of Ethereum, whenever there are hot events such as "Crypto Kitty" and "5.19" to stimulate transaction demand, there will be a fierce Gas War phenomenon on the ETH chain. Whoever pays the higher Gas Price will have the transaction on the chain first , The fierce price war has caused the Gas Price to rise, and users who cannot pay the high handling fee are turned away. This makes Ethereum a veritable "noble chain", which has caused countless disputes, and also made EIP-1559 once the most popular in the eyes of many people. The "savior".

But from the facts, the core function of EIP-1559, which has attracted much attention last year and made a substantial adjustment to the Gas mechanism of the block, is to make the floating range of Gas Price more controllable, and reduce the inflation rate and sell-off of ETH. Instead of directly lowering the Gas Price or banning the Gas bidding mechanism.

image description

image

(It can be seen that Gas Price has risen continuously for 4 blocks)

image description

image

(The central axis of the chart is the second day of the London Hard Fork)

Since EIP-1559 does not really change the gas content of the block, the TPS of Ethereum has not been improved, and the handling fee remains high, and a large number of potential users are still stranded outside the Ethereum system.

According to relevant data, the current ETH has nearly 200 million independent addresses, and the number of transactions processed per day is only more than 1 million; in contrast, BSC (BNB Chain), which has a lower gas fee, processes transactions per day The number is above 5 million, but the number of independent addresses is less than 150 million.secondary title

Block cycle

From another point of view, since TPS=the number of transactions contained in each block ÷ the block generation time, the block generation cycle is also the key to TPS. At the same time, several stages in the block generation cycle can map different components in the business logic of Ethereum, which is the key point of the Layer 2 expansion idea.

It should be emphasized that Ethereum is a system composed of a large number of server nodes, and its business logic includesExecution, consensus, multi-party storage3 parts. in,

  • [Execution] generally refers to the processing of transaction events and other instructions to obtain results;

  • [Consensus] means that all nodes agree on the execution result;

  • [Multi-party storage] means that multiple nodes store the same content and can be read by the outside world.

In some materials, [consensus] is also called [settlement], and [multi-party storage] is called [data availability]. These terms are essentially interoperable.

A block generation cycle consists of the following steps:

  • First, the mining pool nodes pass【Proof of Work】Pick a winner and let them do it【implement】The process of transaction, making a new block;

  • 【Proof of Work】Brute force exhaustion of random numbers is required, which consumes a lot of computing power. These tasks are completed by the mining machines in the mining pool, which takes a long time;

  • The winning mining pool node will grab a batch from the transaction events waiting to be uploaded according to the level of Gas Price【implement】, get the result, and then include the transaction information and the result into the new block;

  • Afterwards, the new block is propagated to all Ethereum nodes and the content is checked. Specifically, the node checking the block will read its content and execute the transaction inside again to see whether the data submitted by the block mining pool is correct. This is done【consensus】

  • Finally, if the new block passes the inspection, the nodes will include the new block, completing【Multiple Storage】

image description

image

(Ethereum node number and physical location classification)

In summary, a complete block generation cycle of Ethereum includes[Proof of Work] + [Execution] + [Consensus] + [Multiple Storage]4 stages. Among them, the [Proof of Work] and [Consensus] stages take the longest. Since there are more than 2,000 mining pools and full nodes in Ethereum, it will take a lot of communication time for these nodes to reach [consensus]; and [proof of work] is a flexible time-filling tool, and its original design is to let The block period is stable at about 15 seconds (the current block period is about 13 seconds).

image description

image

(Physical location distribution of Ethereum nodes)

If the block is forcibly expanded, the information gap between different nodes will also be exacerbated. For example, if the Gas capacity of the ETH block is increased by 10 times, the number of transactions contained in each block will increase by 10 times, and the information difference between different nodes will also increase by 10 times.

According to relevant information, until Ethereum completes the POS transformation, its block generation cycle will be stable at 13 seconds. After the transformation of POS, the block generation cycle will only be shortened by 1 second and stabilize at 12 seconds. In this way, the POS transformation will increase the TPS of Ethereum by 10% at most, which is like a drop in the bucket.

Currently, in the guaranteedUnchanged security and decentralizationThe premise,ETH's block Gas capacity and block generation time have basically reached the theoretical limitsecondary title

OP Rollup Expansion Solution

As mentioned above, due to comprehensive considerations, the block capacity and block generation cycle of Ethereum cannot be changed much. Its TPS is basically maintained below 20, and there has never been much improvement in the past two years.

image description

image

(average Gas upper limit of BSC block)

Layer 2 represented by Rollup adheres to different concepts. Although its essence is also a public chain outside of Ethereum, it is still largely dependent on the security of Ethereum. For example, OP Rollup (Optimistic Rollup) will compress and store the Layer 2 blockchain copy to the Ethereum mainnet, and at the same time:

  • Layer2's local block generation cycle only retains the stage of [executing] transactions;

  • [Proof of Work] is cancelled;

  • [Multi-party storage] function is transferred to the Ethereum network;

  • secondary title

Principles of Optimism

Taking the most typical Optimism in the OP Rollup scheme as an example, its four most important modules areSequencer (sequencer), Verifier (verifier), CTC (transaction chain), SCC (state chain). Among them, Sequencer and Verifier are Layer 2 nodes with hardware entities, which basically constitute the Layer 2 node network; CTC and SCC are contracts deployed on Ethereum, and these four modules form the core architecture of Optimism.

image

Sequencer is a centralized mining pool node responsible for producing blocks locally on Layer 2. Optimism abolishes the [Proof of Work] process, and the only Sequencer acts as a miner, and will not immediately let other nodes do [Consensus] verification, which saves a lot of time. The current Sequencer can finalize the block immediately after executing the transaction.The local block generation time is only 1 second, which improves TPS fundamentally.

However, Sequencer has a strong centralization feature. It actually creates a side chain independent of Ethereum. If there is no [consensus] and [multi-party storage] process, it will inevitably lack security. To solve this problem,Optimism states in its early documentation that a Sequencer must stake a certain amount of assets and:

  • Every few minutes, the Sequencer node will store the compressed version of the local block to the ETH main network; these contents include a summary of transaction data and the state root StateRoot after the transaction occurs. This process is Rollup (packaging);

  • The summary of transaction data is stored in the CTC (transaction chain) contract on ETH, and the corresponding state root is stored in the SCC (state chain) contract. This will generate two transaction events. During this process, the Ethereum system is only responsible for [multi-party storage] content, and will not verify the correctness;

  • The Verifier (verifier) ​​of Layer 2 will automatically read the content stored by Sequencer in Ethereum and review it. This step is similar to Ethereum's [consensus].

  • The current Optimism and Arbitrum are both run by the official Sequencer node, which has serious centralization problems.

image

CTC and SCC are contracts officially deployed by Optimism on Ethereum. The two record the summary of Layer 2 transaction data and the root hash value of the Layer 2 state tree after each transaction is executed in a Batch (batch) structure.From the outside, CTC and SCC are like two bill lists.

(Note: The state tree is a database that records the address information on the chain. By obtaining the state tree root and transaction data summary, the Layer2 local block content can be pieced together. Generally speaking, the Layer2 state root stored in the SCC contract is more Important, after obtaining the state root, combined with transaction data to calculate, you can know whether Sequencer has rewritten the balance of the user's address without authorization.)

image

Layer2Verifier will automatically read the records in the two contracts of CTC and SCC, try to piece together the local block content of Sequencer, and verify it.

  • If the Verifier finds that there is a problem with the data submitted by the Sequencer, it can initiate a challenge (challenge) and submit the version that it thinks is correct. If the challenge is successful, the wrong data in the CTC and SCC can be rewritten and a certain amount of token rewards can be obtained;

  • If the Sequencer is successfully challenged and confirmed to be dishonest, it will be punished, and part of its pledged assets will be deducted; if the pledge balance is lower than the specified threshold, the Sequencer will be forcibly delisted and will no longer be eligible to generate blocks;

  • proof of fraudproof of fraud"Mechanism, which means that Verifier can disclose Sequencer's fraudulent behavior.

  • [Consensus] reached between Verifier and Sequencer has a serious lag. After a transaction is submitted, it will be executed by Sequencer immediately, but Verifier can obtain the state root and perform final verification of the result after 1 hour.

  • Optimism carried out an EVM equivalence upgrade in November 2021. Its Sequencer and Verifier clients banned the old version of the OVM virtual machine. The "fraud proof" program based on the old version of OVM cannot work, and the new version of the "fraud proof" program has not yet been released. .

According to the previous technical document, Optimism sets the challenge window to 7 days. If no Verifier initiates a challenge within 7 days, the content released by Sequencer will be finalized and cannot be rewritten.

In essence, Optimism is a cross-domain interactive system composed of software and hardware entities on Layer1 and Layer2. Its unique business logic is to construct a mapped version of Layer2 blocks on Ethereum.Due to the need to transfer information across domains, Optimism's Sequencer and Verifier need to run a copycat version of the Ethereum client Geth:L2gethsecondary title

Optimism's Gas mechanism and its details

On the issue of gas fees, since the Optimism business process has a step of storing data in Ethereum,Gas fee for each transaction = Layer1 part + Layer2 part, and other OP Rollup schemes such as Arbitrum and Metis are no different.

Among them, the Layer2 part mainly involves the cost of the Sequencer node executing the transaction. Since Sequencer's TPS upper limit is extremely high, and there are currently few Optimism users, its local Gas Price is ultra-low. The calculation formula is: L2 Gas Fee = L2 Gas Used × L2 Gas Price.

image

  • According to OP’s official disclosure, the Layer 2 part of a transaction only accounts for 0.4%, and the remaining 99.6% of Gas expenses come from the Layer 1 part. [1]

  • Turn this into a simple formula: 0.4% x execution fee + 99.6% x storage fee.

It is not difficult to see that the transaction execution fee has been greatly reduced.

So, the more complicated the execution steps of the transaction (options, etc.), the more you can save on Optimism. For example, the last option operation on Ethereum that cost $100 only cost about $1.5 on Optimism, which is only 1/60; ordinary transfers on Ethereum cost $3, and Optimism may cost $0.3, which is 1/10.

image description

image

(Optimism’s official explanation of the fee structure)

For a deeper understanding, you can observe the specific steps of Rollup (packaging) and storage:

  • Before storing a batch of transaction data in Ethereum, Sequencer will compress the content, then combine the batch of transactions into Batch (batch), and transmit it to the ETH network node.

  • Each Batch can contain hundreds of transaction data, just like a block. The time period for releasing batches is dynamically adjusted by Sequencer, and is currently about 3 to 10 minutes.

Therefore, the process of packaging and transmitting Batch must have a workload, which will consume a certain amount of computing resources, and the fixed overhead can make up for this part of the cost. Currently, the fixed overhead Gas per transaction on Optimism is 2100.Optimism officially stated that as the scale of users expands in the future and the number of transactions received by each Batch increases, the fixed overhead will be further reduced.

image description

image

(The data passed from Sequencer to CTC is a bunch of characters in the form of hexadecimal numbers)

image description

image

(The status root batch submitted by Optimism)

secondary title

What is the theoretical TPS upper limit of OPtimism?

To explore the theoretical TPS upper limit of Optimism, we should imagine a critical state:

  • Sequencer's local block generation speed is much higher than that of the Ethereum main network, so there is always an information gap between the original content of Layer 2 and the copy content of Layer 1. With the increase of Layer 2 users, the actual TPS surges, and the information gap △ between Layer 2 and Layer 1 can be enlarged;

  • When Optimism approaches its theoretical TPS upper limit, the information difference △ per second between Layer2 and Layer1 can be very large. Therefore, at this time, Optimism must submit data to the Ethereum mainnet as soon as possible, and synchronize the data at all costs;

  • In the end, the instructions initiated by the Sequencer occupy all the Gas in the Ethereum block, that is, all the resources available on the Ethereum are used by Optimism, and each Ethereum block contains the data submitted by the Sequencer;

  • image description

image

(The theoretical TPS upper limit of various Layer2 schemes calculated by the W3.Hitchhiker team)

To sum up, the TPS limit of Optimism is at least 16 times that of Ethereum. Considering that there are too few Optimism users at present, the actual TPS is even less than 3% of Ethereum, and its development space can reach up to 500 times the current one.

After sorting out the above contents, combined with the actual investigation, it is concluded that:

  • The Sequencer node itself creates a blockchain with extremely high TPS, which is the source of expansion. Although the efficiency is extremely high, due to its high degree of centralization, Sequencer may do evil or crash;

  • In order to enhance security, Optimism requires Sequencer to pledge certain assets, and requires Sequencer to disclose the key information of Layer 2 blocks on the ETH main network, and Verifier will automatically read and check the accuracy;

  • image description

image

(An option opening operation on Optimism only cost $1.2; it costs more than $100 on Ethereum)

  • The [consensus] reached between Verifier and Sequencer has a serious lag.image description

image

(The Sequencer of Optimism is uploaded to the state root batch of Layer1, and the cycle can reach 1 hour)

  • Incentives received by Verifier = token reward for successful challenge - node operating cost. It is an unpredictable event to issue a "fraud proof" and the challenge is successful, the probability is not high, so the incentives for Verifier are not strong, the number of such nodes is not easy to expand, and the consensus and security are still weaker than Ethereum.

As mentioned earlier, the most effective way to expand Verifier is to increase incentives or open the peer-to-peer network. For Optimism, which has not yet issued tokens and has not opened peer nodes, it is difficult to motivate validators through its own issued tokens like Metis.Therefore, the current Optimism is facing a lot of challenges in how to expand the scale of verification nodes and enhance the timeliness of verification.

  • It is worth noting that the Sequencer nodes of OP Rollup such as Optimism and Arbitrum are currently provided by the official, so whether the Sequencer penalty mechanism is effective is still controversial; at present, the security of Optimism and Arbitrum comes more from the "credit" of the project party. Rather than "procedural justice" itself;

  • epilogue

epilogue

Although Optimism is very popular today, showing great development prospects and value-added space, as mentioned above, it still faces the problem of excessive centralization.Gavin Wood once said: "True decentralization and security are more valuable than high efficiency.If users cannot be allowed to participate in network maintenance in a timely manner, the so-called Layer 2 will be no different from traditional financial platforms.

image

(Gavin Wood once said about the brief downtime of Solana last year: true decentralization and security are more valuable than high efficiency. If users cannot run the full nodes of the network themselves, then such a project will be no different from traditional banks)

This article understands the comparison of transaction costs of the four major Layer 2 solutions

references

星球君的朋友们
作者文库