Viewpoint 丨 Ethereum 2.0 technology sharing

On January 11th at 20:00, BlockMania AMA Live Issue 41 and BlockMania "201 Technology AMA" Phase 3 continued. The theme of this issue is " Ethereum 2.0 Technology Sharing" . This event is hosted by the well-known technology community Comunion, BlockMania Co-organized, sharing guests as the author of "In-depth Understanding of Ethereum", Wang Xin, the technology leader of Star Chain Technology.

The following is a review of this AMA

Ethereum's road to development

This is a roadmap for Ethereum in 2019. We see that from the end of 2013, Vitalik Buterin, the founder of Ethereum, released the first white paper of Ethereum and started the project. It has been unknowingly gone through 6 years.

From July 24, 2014, Ethereum has conducted a 42-day pre-sale of Ethereum. By September, Ethereum had raised a total of 31,531 Bitcoins through pre-sale. According to the then Bitcoin price, Ethereum successfully raised more than 18 million U.S. dollars. According to CoinTelegraph, Ethereum “is one of the most successful One will be written into the annals of history. "

By July 30, 2015, the Ethereum Frontier Network was released. Developers started developing decentralized applications on the Frontier network, and miners began to join the network for mining. The miners themselves receive token rewards through mining, on the other hand, they also increase the computing power of the entire network and reduce the risk of being attacked by hackers.

Frontier is the first milestone in the development of Ethereum. Although it is positioned as a beta version in the eyes of developers, its performance in stability and performance far exceeds anyone's expectations, thereby attracting more development. Join the ranks of building an Ethereum ecology.

On March 14, 2016 (π day), Homestead, the second major version of the Ethereum platform, was released, and it was also the first official version released by Ethereum.

On September 18, 2017, the Ethereum development team began testing the first phase of the Metropolis version: the Byzantine fork. On October 16, 2017, the mainnet successfully completed the Byzantine fork at block 4,370,000.

The hard fork will provide flexible parameters for developers of smart contracts; at the same time, it prepares for the introduction of technologies such as zkSnarks zero-knowledge proof in later metropolis upgrades; delays the detonation of the difficulty bomb and delays the ice age by 1 year; Significantly reduced, so the transaction speed of the Ethereum platform will be significantly increased, and the corresponding miners' mining revenue will be reduced from 5 Ethereum to 3 per block.

In June 2019, the " Fort Constantinople" hard fork was completed at a height of 7080000 blocks, and the upgrade includes five improvements:

1) Introduce a fairer pricing method for changes in data storage;

2) Benefit smart contract developers;

3) Better specific scalability solutions based on state channels and off-chain transactions;

4) As more things are transferred to the second layer;

5) Reduce the block mining reward from 3 ETH to 2 ETH, and delay the difficulty bomb of Ethereum for 12 months.

Just last month, Ethereum officially completed the "Istanbul" fork , which includes six Ethereum Improvement Proposals (EIPs). The main problems solved are: Denial of Service (DDoS) attack resilience, reducing Gas costs, and increasing Equihash proof of work.

We see that Ethereum, as the representative of blockchain 2.0 technology, continues to develop and innovate and has become one of the top star projects in the industry.

This picture shows that the scale of Ethereum's project assets is steadily ranking second, far exceeding other cryptocurrency projects. This has a very close relationship with the height of Ethereum technology. The developers behind Ethereum are also very geeky.

Ethereum core technology

Back to the technical level, we can see that the technical architecture of Ethereum is also a layered architecture. From top to bottom, they are the application layer, the contract layer, and the protocol layer. The protocol layer contains basic components such as EVM virtual machine, block management, KV database, consensus algorithm, and P2P network.

The smart contract is the most core technology of Ethereum . Its implementation is based on the EVM virtual machine inside Ethereum. The smart contract can complete any code logic to support a variety of business processes. Ethereum uses the solidity language to write smart contracts.

Smart contracts build Ethereum's rich DApp ecosystem, make the blockchain more landing, integrate more with all walks of life, and more easily integrate with the Internet of Things, big data, artificial intelligence, cloud computing and other technologies.

This is also the biggest charm of Ethereum different from Bitcoin, that is, the blockchain 1.0 system.

Enterprise Ethereum

Everyone knows that Ethereum is a public chain project, so what does it have to do with our daily lives and our developers?

How can we make good use of the technical resources of Ethereum, apply it to our own projects, or do some traditional industry innovation? This has been the biggest problem that plagues industry practitioners.

Probably the most successful application is still around the financial ecology of digital assets, such as exchanges. But beyond asset trading, people's exploration has not stopped.

As early as 2017, the Ethereum Alliance was established by more than 20 global top financial institutions and technology companies such as JP Morgan Chase, the Chicago Board of Trade Group, New York Mellon Bank, Thomson Reuters, Microsoft, Intel, and Accenture.

This is the protocol stack of the enterprise Ethereum. We see a lot more than the Ethereum public chain. It also leans more towards an enterprise architecture and is more in line with the definition of the alliance chain. In terms of privacy protection, cross-chain communication and consensus algorithms Improved and optimized.

Technology improvement direction

I also had some exchanges with the enterprise Ethereum EEA in 2017, and participated in the telephone discussion conference organized by them. However, because the alliance is a loose organization and lacks clear development goals and cooperation mechanisms, there has been no substantial progress to this day.

In their own words, there is too much politics in the organization. In fact, this alliance is mainly based on the contribution of JP Morgan Chase. They launched the Quorum technology framework, which is a better prototype of Ethereum in enterprise applications.

The BaaS platform of the Ant Blockchain and Microsoft Cloud both support the Quorum framework.

Well, now the blockchain technology has also encountered a bottleneck, which is why the concept of Ethereum 2.0 was proposed.

The main optimizations focus on three directions: performance, privacy, and fees.

Ethereum 2.0

ETH 2.0 will be implemented in three phases:

Phase 0

Beacon chain, involving the core part, network, signature scheme and randomness. It runs on the Sapphire testnet created by Prysm Labs. If you have Goerli ETH, you can join the testnet and pledge gETH.

Phase 1

It is a protocol implementation for 64 independent running shard chains. Each shard can run a state of the network. For example, you can put Maker on one shard, other DeFi applications on another shard, Eth1 chain on another shard, Crypto Kitties on another shard, and so on …

Phase 2

Support execution engine to realize the trading and account model of the entire space. The execution engine minimizes the complexity of the system.

I don't know if there will be more follow-up stages. Although researchers hope to see more Eth2.0 shard chain development plans, all this is still in the early stages of development.

This is a layered framework of Ethereum 2.0. The main change is the addition of Beacon Chain and Shard Chain. Shard translates into shards. Similar to a distributed operating system, transactions within different shards can be processed in parallel.

After a period of open discussion, Ethereum's 2.0 technology has gradually begun to converge: the number of shards has been reduced from 1024 to 64, and the size of shard blocks has increased from (target value 16, upper limit 64) kB to (target value 128 , The upper limit is 512) kB. The total capacity of the slice is 1.3-2.7 MB / s, and the specific value depends on the slot time .

If needed, the number of shards and block size can increase over time, such as eventually reaching 1024 shards in 10 years, and 1 MB blocks.

Many simplifications have been implemented at the L1 and L2 layers:

1) Less shard chain logic required;

2) Because the "native" cross-shard communication can be completed in one time slot, there is no need to accelerate the cross-shard communication through Layer-2;

3) There is no need to facilitate decentralized exchanges to facilitate payment of cross-segment transaction fees;

4) The execution environment can be further simplified;

5) No need to mix serialization and hashing again.

Of course, this also introduces some problems:

1) The overhead of the beacon chain is greater;

2) The generation time of shard blocks is longer;

3) The demand for "bursting" bandwidth is higher, but the demand for "average" bandwidth is lower.

TPS has always been an important bottleneck for blockchains. We know that Bitcoin and Ethereum both use PoW consensus algorithms, and TPS is about 10.

Zk-rollup technology was introduced in the recent Ethereum 2.0 research, which can theoretically increase transactions to 3000TPS.

Close to the performance of a centralized system, everyone knows that the Visa network currently has an average TPS of 2000.

This is a comparison of Ethereum theoretical performance using zk-rollup technology

Each batch (a batch is a zkRollup block) contains 2048 (simple Ethereum) transactions and a zk proof. However, thanks to the implementation of the two proposals, EIP 1108 and EIP 2028, the gas cost of transactions and proofs has now changed: 8.125 bytes per transaction.

Currently each transaction only takes 16 gas / byte, so the gas cost of each transaction is 8.125 * 16 = 130 gas. Since there are 2048 transactions per batch, the transaction cost per batch is 130 * 2048 = 266,240 gas.

If 15 batches are inserted into the Ethereum block, since each batch can hold 2048 transactions, this means that we can make each block package 15 * 2048 = 30,720 transactions.

30,720 transactions / 15 seconds = 2048 transactions per second.

Of course, there are still some practical problems to be solved in the above knowledge theory derivation: Each zkRollup batch needs a short encryption certificate (zk-SNARK) to prove the integrity of the transactions in the batch. It turns out that the computation to generate this proof is very expensive. This is the main bottleneck in reaching the theoretical throughput limit.

Currently using one CPU and three GPUs, it takes several minutes to generate such a proof. Although performance can be significantly improved through parallel computing, reducing proof time from minutes to seconds while maintaining reasonable costs remains an important challenge.

Finally, let's talk about zero-knowledge proof, which is used to protect data privacy on the blockchain, which is very suitable for electronic medical record (HDR) scenarios in the medical industry.

Understanding zero-knowledge proofs, you can review the stories of Alibaba and the Forty Thieves:

When the robber tortured Alibaba for the spell that opened the stone gate in the cave, he said to the robber: "You are pointing away from me with a bow and arrow, and when you raise your right hand, I read the spell to open the stone gate and raise the left I said a spell and shut the stone door. If I can't do it or run away, shoot me with a bow and arrow. "

Alibaba proved that he knew the spell, and did not reveal the specific content of the spell.

zk-SNARKs, Zk-STARKs and BulletProofs (bullet proofs) are the three main technologies for zero-knowledge proofs for blockchain privacy technology. In comparison:

1. Bulletproofs and Zk-STARKs do not require trusted settings, and zk-SNARKs require trusted settings; zk-STARKs: Performed through the interaction between the prover and the verifier, using an effective mathematical method to make the verifier By verifying each step, you are finally convinced that the prover really knows some information or has a certain right.

Its characteristics are: fast proof and fast verification, but large proof SNARK means that the two parties do not need to interact, and the prover can issue it unilaterally, and there is no need to repeatedly pass information between the two parties. Its characteristics are: slow proof, fast verification, small proof volume.

2. Proof speed comparison: Zk-STARKs> zk-SNARKs> Bulletproofs

3. File size: zk-SNARKs <Bulletproofs <Zk-STARKs

In a word: Zk-STARKs are too big, bulletproofs are too slow, the advantage is that no pre-installation is needed, and zk-SNARKs are optimal.

There are already quite mature third-party libraries that can be used for the development and research of zero-knowledge proofs.

This area is also a hot topic for academic research, and many new breakthroughs related to zk-SNARK structure have been announced in recent months. The new discovery is that the infamous "trusted settings" are currently redundant, meaning that universal computing can be used. However, it is difficult to find understandable information about these new constructs.

The new zero-knowledge proof construction solves the limitations of the setup process, which means that arbitrary code like smart contracts can be run as zk-SNARKs. There are usually two approaches:

Transparent setting: The setting process creates a reference string, which is public, but does not produce toxic waste. This is similar to how zk-STARK works. Fractal, Halo, and SuperSonic-CG all use transparent settings. The disadvantage of this method is that the proof size is usually large. Factal and zk-STARK proved to be as large as 250kB, which is impractical for blockchain applications.

The Fractal team told me that they are working to reduce the size of the proof. Halo and SuperSonic have proven sizes of 10kB or less. (Note: zk-STARK is the name of a specific zero-knowledge proof, similar to Groth16 or Fractal)

General settings: The setup process creates a structured reference string that produces toxic waste, but the creation is no longer limited to a single circuit. Instead, a reference string can be used with an unlimited number (with a certain upper limit) of any circuit. Examples are Marlin, SuperSonic-RSA, and Plonk.

After the ceremony, the three constructed reference strings can be updated to improve safety: if the current toxic waste leaks, you only need to update the build process to protect the system again. (Some common zk-SNARKs, such as AuroraLight and Libra, use static non-upgradable common settings. We won't discuss these in this blog post).

The table shows the performance comparison of some zksnark algorithms. On the prover side, it takes O (n log n) time to create a proof for each zk-SNARK construct. The differences are mainly the size of the proof, the verification time, and the size of the reference string.

In summary, we have mainly examined three technical points of Ethereum 2.0: sharding, zkrollup, and zksnark.

More theoretical knowledge and algorithms are involved, and it takes time to understand. However, the focus is on what these algorithms can do and how to use them.

Q & A


Q1: Ethereum has completed the fork, so will it have any major impact on the follow-up?

Answer: The fork of Ethereum is a software upgrade. The upgrade direction of Ethereum is the direction that the Ethereum community hopes to develop, so with the upgrades, the network will be more secure, more efficient, and more in line with the idea of ​​community governance.

This fast iteration of our usual software development is a reason. The only difference is that Ethereum is a financial system that carries hundreds of billions of assets. The security of the assets and the continuity of services have not been affected in the least. That's why this project deserves attention.

Q2: Is it convenient to introduce the solidity language briefly?

A: solidity is an Ethereum-specific scripting language with a syntax very similar to javascript. It has most of the features of a high-level language. The most commonly used operation is to operate on Ethereum accounts and balances in the accounts.

solidity is very suitable for implementing digital assets, such as ERC20, ERC721, ERC777 are very common digital asset types.

The assets of the very lively coin circle projects were around ERC20, and the blockchain games represented by EtherCat used the ERC721 standard.

Q3: The iteration of the blockchain platform is affected by the public. It cannot be too fast or too aggressive. For example, there will be a fork problem. Does the teacher think that this problem can be solved in the future? On the software platform, the Matthew effect usually occurs, that is, the winner takes all. Now Ethereum is the first platform. Is there no chance for other platforms? Decentralization, which is the theory of DAO, seems to have infiltrated since Ethereum, but in fact the concentration of power will bring efficiency. How do you think about this?

A: First of all, make it clear that the success of a blockchain project depends not only on technology. V also wrote that the community is far more important than the code. Code is just a tool to implement community governance and rules.

In solving some basic problems, very advanced technology is not used. Rather, it is the smart contract and token mechanism in the blockchain, which is the core content of organizational improvement.

The iteration of the blockchain platform can now be said to meet many application scenarios. But Ethereum is serving global users, so the technology will be more difficult.

When we study blockchain, we still focus more on how to implement blockchain technology, transform an industry, or solve some core social problems, such as medical care and education.

Ethereum's DAO is a very good idea, and decentralization is also relative, that is, multi-centralization. The idea of ​​PoS is that the greater the stakeholder relationship, the greater the weight of voting. Not everyone can vote.

Q4: Teacher Wang, in the Ethereum ecosystem, what is the biggest opportunity for ordinary individual developers?

Answer: The future we face is a programmable society. There are a large number of business rules and logic that need to be converted into smart contracts. Artificial intelligence solves the problem of productivity. The blockchain can govern these productivity more effectively and fairly. When developers understand these principles, they can help implement these logics and contribute social value in a specific scenario.

Of course, there are many technical challenges at the bottom of the blockchain, but this is more suitable for students with a certain academic research foundation.

Technical participation suggestions are still in the direction of blockchain application. The bottom of the blockchain is not suitable for most people.

For example, it is a good idea to make a blockchain tool, similar to imtoken. For example: etherscan.

Q5: Are there any good suggestions for DApp direction?

A: Broadly speaking, I think there are several directions, one is financial, and the other is personal information. Finance is the transaction, investment, and value-added of digital assets, because this area is becoming more and more compliant, and supervision has come in. The privacy protection of personal information is more and more valued. Personal credit, health records, personal consumption portraits, and more need to restore sovereignty.

Comunion's DAO, which is a non-corporate, but organization beyond the company. Collisions of ideas from different backgrounds and angles can produce extraordinary results.

DAO's financial and personnel management are very much in need of tools such as DApps.

BlockMania is a blockchain consulting think tank designed to bring the deepest awareness and thinking of the blockchain industry to the industry and the public. Like the blockchain, we believe that each idea has the possibility to become a node that connects to other ideas, so we need to build a platform that connects ideas from points to lines and converges from lines into a network.

In the past year, a number of high-quality online AMA events have been organized around topics such as the blockchain market, technology, and applications. Welcome attention.