Original title: "History Repeating Itself? Detailed explanation of Ethereum 2.0 and hard fork"
Original author: Spinach Spinach, Buidler DAO
Ethereum 2.0 has been upgraded since Vitalik Buterin released "Next Generation Smart Contracts and Decentralized Applications" in 2013 Platform”—Ethereum white paper has been hotly discussed since the Ethereum white paper. After several bounced tickets, Ethereum is finally about to usher in a historic “The Merge” upgrade. The Ethereum mainnet will be merged with the Ethereum beacon chain. Merge and complete the transition from the POW workload proof mechanism to the POS equity proof mechanism, but "The Merge" is just the beginning, Ethereum will also usher in "The Surge", "The Verge", "The Purge" and "The Splurge" and other upgrades introduce fragmentation chains and optimize data structures, and the client becomes the final version.

"You can be an apple that is on the defensive after it is developed, but Absolutely can’t be a self-proclaimed Nokia”. The transformation of the consensus mechanism is a test that Ethereum must go through on the way to become a real “world computer”. Although the future of Ethereum after the upgrade is full of unknowns, Ethereum has taken a step forward in the block A historic step in chain development!
*This article is for personal analysis only and does not constitute any Investment opinions, if there is any incorrect content, you are welcome to point it out
01/ Why should Ethereum upgrade?
Energy consumption
Scalability
Security issues
Public chain competition
02/ What important upgrades will Ethereum 2.0 bring?
Ether Fang's "Coordinator"—Beacon Chain
Ethereum's "Data Warehouse"—Shard Chain
How does the POS proof-of-stake mechanism work?
03/ What is the punishment mechanism of Ethereum under the proof-of-stake mechanism?
What are the punishment mechanisms?
How to detect that the node is doing evil?
04/ History repeating itself? What will happen when the Ethereum 2.0 upgrade faces a hard fork?
What is the difference between the current hard fork and the past ETC fork?
Will there be multiple hard forks in the Ethereum 2.0 upgrade?
Can Miner defuse the difficulty bomb? Why does the difficulty bomb make miners more prone to disagreement?
Ethereum under the POW proof-of-work mechanism is facing the problems of high energy consumption, low scalability, increasingly concentrated computing power threatening the network, and high-performance public chains constantly eroding the market. Dominance in the chain
The POS mechanism beacon chain that is running parallel to the current POW mechanism main chain will merge with the main chain after the upgrade of "The Merge" And replace the POW mechanism as the new consensus mechanism of the main chain
The fragmentation technology can put the data of Ethereum on 64 fragmentation chains for processing, greatly The TPS processing speed is greatly improved, and the hardware requirements for sharding nodes are very low, and it is even possible to run nodes on personal notebooks and mobile phones, making network nodes more decentralized
Under the proof-of-stake mechanism of POS, the beacon chain will randomly assign verification nodes to be responsible for proposing blocks according to the age of the currency, and only two-thirds of the network nodes can pass the verification vote before the block can be produced. In extreme cases, the protocol will An emergency state will be activated to solve the situation where blocks cannot be generated
Ethereum under the POS equity proof mechanism has two sets of penalty mechanisms: penalties for abnormal node operation (Penalties) and Nodes will face Slashing for doing evil, Slashing penalties are more serious, and the maximum loss of all rights and interests will be expelled from the agreement, while penalties (Penalties) are just fines
Verification nodes need to run additional Slasher nodes to detect malicious behaviors on the network. There is no profit in running Slasher nodes. /p>
The hard fork faced by the Ethereum 2.0 upgrade is different from the ETC fork. A large number of non-replicable assets such as centralized stable coins will make the Ethereum The forked chain of POW is in chaos, and the infrastructure ecology on the chain may also fail to operate normally due to the lack of operation of the POW chain oracle machine, and the issuer of the centralized stable currency has a decisive influence on the future of the fork
There will not be only one forked chain of Ethereum POW. Difficulty bombs and other factors may cause divergence among Miners, resulting in multiple POW forked chains, and eventually a large The ending of some forked chains may die with time
p>
The most criticized of the POW proof-of-work mechanism is its energy consumption problem. A large amount of computing power is wasted in the competition for the right to generate blocks. This means that with the continuous growth of the Ethereum ecosystem, there will be a large amount of electricity wasted, the figure below shows the estimated annual energy consumption of various industries in TWh/yr (retrieved in June 2022), the total energy consumption of Ethereum is about 112 TWh/year which is already higher than the annual total energy of Netflix The energy consumption of Ethereum under the POS proof-of-work mechanism is 99.5% lower than that of the POW proof-of-work mechanism, which makes Ethereum more environmentally friendly and more sustainable.

data Source: ethereum.org
With the continuous improvement of the Ethereum ecology and the increasing number of users, the demand for user interaction is constantly increasing. Ethereum needs the ability to handle more transactions. Ethereum under the current POW workload proof mechanism The TPS processing speed is only 15-17 transactions per second. When the number of Ethereum interactions increases sharply, network congestion will occur, resulting in "gas wars", making interactions extremely expensive and confirming transactions extremely slow. In the "312" black swan During the event, MakerDAO once had "zero-yuan purchases" due to the skyrocketing GAS fee. In 2017, the CryptoKitties explosion caused network congestion in Ethereum, and even the GAS fee reached the highest average GAS price in Ethereum history of 939.59 Gwei. Extremely expensive, no one wants to interact with such an expensive gas fee.

Data source: etherscan
As of August 4, 2022, the average price of Ethereum gas fees at this time is only 18 Gwei, which is 52.2 times different from 939.59 Gwei.

Data source: etherscan
Ethereum under the proof-of-work mechanism of POW is not enough to support a large number of interactive requests. As one of the biggest obstacles of the "world computer", the upgrade of Ethereum 2.0 can solve this problem very well. After the shard chain starts to go online, combined with Layer 2's Rollups technology, the theoretical upper limit of TPS can reach 100,000 transactions per second. Compared with the TPS processing speed of the POW proof-of-work mechanism, it can be said that it is very different.
For Ethereum with POW proof-of-work mechanism, the existence of Mining Pool makes the computing power of Ethereum tend to be centralized and poses a threat to the overall network security of Ethereum. The attack cost under the POW mechanism is reflected in the equipment and computing power. In terms of stacking, when someone or a collective masters more than 51% of the computing power, they can launch a "51% attack" on Ethereum, and the protocol itself cannot effectively suppress this situation. The cost of launching an attack after the mechanism is changed to purchasing a large amount of ETH for pledge. While investing assets, the protocol can also confiscate assets to nodes that launch malicious attacks. This kind of punishment cannot be realized under the operation of the proof-of-work mechanism.
The security model will change after the upgrade of Ethereum, because of the introduction of shard chains. The beacon chain will randomly assign validators to different shards - this makes it nearly impossible for validators to collude by attacking a specific shard and thus attack the network. In the blockchain of proof-of-work mode, the protocol cannot control and distribute Miner, so sharding cannot obtain such high security in the POW mechanism, which makes Ethereum under the POS mechanism more secure.
After the shard chain goes online, people can use laptops and mobile phones to run the shard chain Clients, which encourage more people to become validators, increasing the decentralization of the network and reducing the attack surface.

Image source: ethereum.org< p>
Public chain as a district The most important infrastructure in the blockchain field has always been the focus of the market. As the leading public chain, Ethereum has been constantly facing challenges from many emerging high-performance public chains known as "Ethereum Killers". Erosion, from the highest market share of nearly 97% in 2021 to the current market share of 59.05%, the competition between public chains has entered a fierce stage, and Ethereum under the POW workload proof mechanism has gradually been unable to adapt to the needs of the times Therefore, what Ethereum can do is to upgrade and expand to maintain the dominance of Ethereum in the era of multiple public chains.

Data source: Defillama
The Beacon Chain (Beacon Chain) is used by Ethereum to solve the consensus problem of POS proof of rights and coordination The block chain of the shard chain, which was launched on December 1, 2020, is currently running independently and parallel to the main chain of Ethereum. It allows ETH holders to pledge ETH to become a verification node to replace POW Miner. After the shard chain goes online, it connects with the shard chain and coordinates work to randomly assign verifiers to the shard chain to form a whole that can cooperate with each other. However, the beacon chain currently cannot handle accounts and smart contracts.
The most important thing about "The Merge" upgrade is to merge the beacon chain and the main chain, After the merger, the verification nodes on the beacon chain will replace all POW Miners and be responsible for the consensus mechanism of the entire Ethereum, and the main network will bring the ability to execute smart contracts to the POS equity certification system, providing all ETH holders and users Ensure a smooth transition.

Ethereum Shard Chain (Shard Chain) refers to creating multiple new chains/shard chains to process data on Ethereum at the same time, so as to reduce network congestion, increase TPS processing speed and reduce GAS fees. The slice chain does not have the right to process smart contracts, but becomes the "data warehouse" of Ethereum. The validators of the slice chain will be responsible for random coordination and distribution by the beacon chain. After the slice chain goes online, Ethereum will be divided into 64 shard chains run synchronously. In theory, with the Rollups technology of Layer 2, the TPS processing speed of Ethereum can reach 100,000 transactions per second, which greatly improves the throughput of the entire Ethereum and enables Ethereum to carry larger ecology and user volume, sharding technology will be launched in the next upgrade of "The Surge".
Scalability: The shard chain can handle more transactions than a single chain, and solve the problem of network congestion.
Decentralization: The shard chain is greatly The threshold of hardware requirements is lowered, so that everyone can run the shard chain client through a consumer-grade laptop or even a mobile phone.
Security: Trust The random allocation mechanism of the standard chain makes it impossible for attackers to gather their power on a shard chain, and as long as there is a bad block in one shard, it will be discarded once it is found, and the whole chain will avoid this bad block. p>

How does the shard chain connect with the beacon chain?
The link between the fragment chain and the beacon chain needs to rely on cross-linking ( crosslinks) to achieve, crosslinks (crosslinks) is to connect a beacon block and shard block and can be referenced, the shard block under the same block will accept the hash of the beacon block from the same block value, the hash value of the beacon block contains the hash values of all crosslinks received by the beacon block, and the beacon block in the next block will accept the crosslinks from the previous block Crosslinks of the shard blocks of the block and send the hash value of the beacon block of this block to the shard block of the same block, some beacon blocks may lose the reference of the shard block , but each shard block must be connected to a beacon block, so missed shard blocks can be crosslinked in the next beacon block.
Because the beacon chain currently only supports 64 fragments, a beacon block can at most It can accommodate 64 crosslinks. If there are 63 shard blocks in a block that are not proposed, then the next beacon block will have only 1 crosslink. The beacon chain is like the "cervical spine" of Ethereum, and all the shard chains are connected to the "cervical spine" of this "cervical spine" of Ethereum.

POS proof of rights is a consensus mechanism used by the blockchain to achieve distributed consensus. In the POW workload proof mechanism, Miner competes for the right to produce blocks through the accumulation of computing power In the POS proof-of-stake mechanism, Miner competes for the right to generate blocks through the amount of pledged ETH. Miner needs to pledge at least 32 ETH to become a verification node or pledge any number of ETH to participate in joint pledge to participate in Mining. When a user submits a transaction on a shard When , the verifier will be responsible for adding the transaction to the shard block, and the beacon chain will pseudo-randomly select the verifier through the algorithm to propose a new block.
p>
How does the POS equity proof mechanism verify and generate blocks?
To participate as a validator, a user must deposit 32 ETH into the deposit contract and run three separate pieces of software : Execution client, consensus client and verifier. When the verifier is selected to produce a block, the block needs two-thirds of the total active verifiers to confirm the signature before the block can be produced, so as to ensure the security of Ethereum Make the block "final", because it is impossible for two blocks to obtain the signatures of two-thirds of the total active verifiers at the same time. When a verifier is not selected to produce a block, they will participate in verifying another verifier block proposal and confirm that everything is in order.
About the block time, under the proof of work, the block time is determined by the mining difficulty decision, whereas in Proof of Stake, the speed is fixed. Proof of Stake The time of Ethereum is divided into slots (Slot) and cycles (Epoch), which determine the rhythm of consensus in the system, that is, a slot (Slot) is issued every 12 seconds, and each cycle (Epoch) contains 32 Slots, that is, a cycle is generated every 6.4 minutes. Each slot (Slot) can only create one valid block, and a validator is randomly selected in each slot (Slot) as the block proposer. This validator is responsible for creating a new shard block and sending it to other nodes on the network.
Also in each slot (Slot), the beacon chain will randomly select a "committee" composed of at least 128 validators to Each shard block is certified, and its vote is used to determine the validity of the proposed block. The number of "committees" validators is not fixed but changes with the change of the block. After each cycle , "committees" are disbanded and reformed by different, random participants, which helps to prevent bad participants in the committee from harming shards. In addition to validating votes, "committees" also need Responsible for trying to crosslink the shard block in the slot (Slot) where it is located to a specific beacon block on a certain beacon chain.

By observing the blockchain browser of the beacon chain, we can see that the detailed information in the figure below shows that 99.8% of the active verifiers in this cycle (Epoch) are entitled to 13,150,835 ETH out of the total pledged amount of 13,177,296 ETH Vote to sign and produce blocks. The shard blocks in each slot (Slot) are produced by different verifiers and passed through the vote signature of more than two-thirds of the active verifiers.


Data source: beaconcha.in
How does the proof-of-stake mechanism select verification nodes to generate blocks?
The block of the POS equity proof mechanism is pseudo-random by the protocol Select a validator to be responsible for producing blocks according to the rights and interests. The probability of the validator being selected to produce blocks will increase with the number of pledged ETH and the growth of CoinAge. CoinAge is a POS equity proof mechanism. Parameters, the longer the Miner has not produced a block, the longer the coin age (CoinAge) and the greater the probability of being selected to produce a block, but when the Miner is selected to produce a block, the coin age (CoinAge) will return to zero and start accumulating again.
Assuming that the pledge annual rate of return is 10%, Pharaoh pledges At this time, Pharaoh’s currency age is 0, but Pharaoh has not been selected to generate blocks for 30 days. At this time, Pharaoh’s currency age is 30100=3000. If he chooses to produce a block, his coin age will be reset to zero and he will get 0.82ETH=3000*10%/365 according to the formula of block reward=coin age annual interest rate/365.
The general mechanism of block generation is as shown in the figure below. The currency age can only increase the probability of being selected. Seeing that nodes with more pledged ETH are more likely to be selected, resulting in the phenomenon that the richer the more dominant.

What if the beacon chain has been unable to produce blocks?
In Ethereum under the proof-of-stake mechanism of POS, a block needs to be approved by two-thirds of the verification nodes. Blocks can be generated to ensure the "finality" of the block. What if the beacon chain fails to pass two-thirds of the verification node votes and Ethereum stagnates?
When this extreme situation occurs, Ethereum will initiate an emergency state: Inactivity leak, which is triggered by four consecutive beacon chain When the period (Epoch) does not pass two-thirds of the verification nodes to verify the vote, it will enter the state of inactivity leak (Inactivity leak). The interests of the nodes participating in the verification voting exceed two-thirds of the total verification node rights to restore the normal operation of the beacon chain.
< /p>
In the POW workload proof mechanism, if the Miner modifies the blockchain data, it will only generate a small fork of its own that cannot be collectively Consensus recognition, in the end, it has to keep pace with the original blockchain. Although tampering with blockchain data without 51% computing power will not affect the blockchain, Miner will not be punished. However, in Ethereum under the POS proof-of-stake mechanism, the misbehavior of the verification node will be punished by the protocol, and the punishment can be roughly divided into two types: Penalties and Slashing.
< br>
The difference between Penalties and Slashing is that Penalties are due to the fact that the verification node has been inactive or generated Penalties caused by incorrect proofs, but penalties (Penalties) will only fine the balance of the verification node and will not expel the verification node from the protocol.

data Source: beaconcha.in
Slashing is a more serious punishment Mechanism, only verification nodes that attempt to attack the overall stability of the Ethereum network will be punished by Slashing. While facing a maximum loss of up to all equity fines, the malicious node will also be expelled from the protocol, usually slashed ( Slashing) is divided into:
As a proposer, two completely conflicting blocks are proposed in a slot (Slot) [if it is just a simple If you propose two identical blocks, you will not face slashing]
As a verification voter, in one slot (Slot) for two complete All conflicting blocks are verified and voted, which is called "double voting" [If you verify and vote on two identical blocks, you will not face reduction (Slashing)]
"Surround voting" out of order as validating voters in an attempt to counter history
If the malicious node is punished by Slashing, the node will be punished immediately and will not be verified. You can withdraw, the amount of punishment depends on the severity of the crime, and the maximum penalty is confiscation of all rights and interests.
The verification node itself will not detect the malicious behavior on the Ethereum network, but needs to run the beacon chain node at the same time Only by running a node called Slasher can it have the ability to capture criminal behaviors that can be confiscated in the Ethereum network. The Slasher node is equivalent to the "police" in the Ethereum network. In order to detect the malicious behavior of the node, Slasher will record the Attestation and proposal history for each validator, which are then cross-referenced with broadcast content to find evidence of malice, but running a Slasher node is not necessarily profitable as malpractice is uncommon and reporting rewards are not high , and running a Slasher node consumes a lot of disk space and is more energy-intensive, which means that allowing a Slasher node is completely altruistic, but in theory the entire Ethereum network only needs to have an honest, functioning Slasher node in operation You can find all the evil behavior.
When allowing Slaher's verification node to discover malicious behavior, the node will pack the evidence of the evil into In the slot (Slot) where the evil occurred and the Slashing penalty was initiated on the evil node, we can see in the example below that the 13209 node as a verification voter in the 4,289,592 slot (Slot) of the 134045 cycle (Epoch) is The two conflicting blocks were verified and voted, and the evidence of evil was packed into the next slot (Slot) of 4,289,593.

Data source: beaconcha.in< p>
The malicious node was reported by node 70929, and then the node 13209 was punished by Slashing At the same time as the fine, they will be expelled from the agreement in the 134051 cycle (Epoch) and will be subject to continuous fines for 36 consecutive days until the 142238 cycle (Epoch) to withdraw the balance.

Data source: beaconcha.in< p>
Node 70929 as the whistleblower received a reporting reward of about 0.89ETH.

A hot topic about the Ethereum 2.0 upgrade discussion must be inseparable Open the topic of Ethereum POW hard fork, so what is hard fork?
Hard fork is when the blockchain permanently diverges, After a major update of the blockchain system, nodes that have not been upgraded cannot verify the blocks produced by nodes that have been upgraded. At this time, a hard fork will occur, and two blockchains with the same ledger before a certain block will be split. Hard forks can also be initiated on their own initiative. The most classic case is the hard fork from Ethereum—Ethereum Classic. DAO was hacked and stolen about $50 million worth of ETH at the time, which caused a big blow to Ethereum. After that, Ethereum founder Vitalik Buterin decided to initiate a hard fork to roll back the blockchain to recover the losses suffered by Ethereum. , and then some people still stick to the stolen Ethereum and refuse to upgrade, making Ethereum split into Ethereum Classic and the current Ethereum.

Ethereum 2.0 upgrade is a complete change of the consensus mechanism. After the merger of "The Merge", the POS proof-of-work mechanism will directly replace the POW proof-of-work mechanism. POW Miner We are faced with the need to find other ways out. This change touches the interests of all POW Miners, which leads to the fact that Miners may collectively launch a hard fork. In fact, during the writing of this article, the Miner group has issued a statement to hard fork Once a POW Ethereum is issued, it is basically certain that Ethereum will undergo a hard fork again, so what will be the difference between this hard fork and the past?
< /p>
In fact, the hard fork caused by the upgrade of Ethereum 2.0 is quite different from the classic fork of Ethereum back then. First of all, Ethereum was still in its initial stage , does not have a very rich ecology, but after so many years of development, Ethereum has grown into a leader in the public chain, carrying the richest ecology and the largest amount of funds. If there is another hard fork in Ethereum, Since the historical ledgers of the hard forked chains are the same, there will be two non-replicable assets such as USDT, USDC and wBTC, and two protocols on Ethereum such as MakerDAO and AAVE. The extra centralized stablecoins such as USDT and USDC caused by the fork will eventually return to zero because they cannot be cashed into legal currency. At this time, the ecology on the Ethereum fork chain will become extremely chaotic. If there is no good solution, then The forked chain will become unprofitable and unable to operate. Vitalik Buterin, the founder of Ethereum, expressed his opinion at BUIDL Asia held in Seoul on August 3: "Centralized stablecoins can determine "controversial" The future of the hard fork", it can be seen that the issuer of the centralized stable currency played a decisive role in the hard fork.

Information source: cointelegraph.com
< /p>
There will not be only one hard fork in the Ethereum 2.0 upgrade, there may be many POW hard fork chains, but in the end these POW hard fork chains Whether it can survive is still unknown. For the Ethereum Foundation and developers, it is easy for the united front to reach a consensus on the main chain-POS beacon chain, but for the Miner group, due to decentralization, it is difficult for Miner The united front forms a community of interests, and the existence of the difficulty bomb (Difficulty Bomb) makes it easier for Miner groups to have differences of opinion. So what is the difficulty bomb (Difficulty Bomb)?
Difficulty Bomb is a Mining that can adjust the entire chain according to the block time The mechanism of difficulty value was proposed and written into the Ethereum code in 2015. The purpose is to artificially increase the difficulty of Mining so that POW Miner loses motivation and joins the POS beacon chain so that the POW mechanism can smoothly transition to the POS mechanism. When the difficulty After the bomb is activated, the difficulty of mining will increase exponentially, which will make the block reward of mining become lower and lower until there is no profit at all, causing all miners to withdraw from the POW chain. The difficulty bomb has been opened many times in history , but every time it was postponed by the Ethereum Foundation and the hard fork of the developers, it can be observed in the figure below that the block generation time of Ethereum showed a sharp upward trend after the difficulty bomb was turned on and returned to In normal time, the reason why the difficulty bomb has been postponed many times is that the upgrade of Ethereum 2.0 is like "changing tires on a high speed" and needs to be very cautious, so it is very slow. The Ethereum Foundation and developers are not ready for the upgrade. So delayed the difficulty bomb many times.

Data source: bitinfocharts.com< p>
In the latest difficulty bomb delay EIP-5133 proposal, the difficulty bomb was delayed until mid-September 2022.

Information source: eips.ethereum.org
Can Miner defuse the difficulty bomb? Why does the difficulty bomb make miners more prone to disagreement?
The difficulty bomb can be dismantled by Miner, as long as a new chain is hard forked before the difficulty bomb occurs and the time when the difficulty bomb occurs can be dismantled As a result, this may have some technical risks and additional resource consumption for the Miner group, and which block starts to fork before the difficulty bomb starts? When is the difficulty bomb delayed?
These issues may cause Miners to have differences of opinion, unable to unite the front, resulting in a variety of different Ethereum POW fork chains.

Although there may be multiple different POWs in Ethereum Hard fork, but the most critical problem to be solved is the non-replicable assets and ecological problems on the chain. The development team of the core protocol on Ethereum will follow the POS beacon chain with a high probability, and the infrastructure ecology left on the forked chain such as Protocols such as AAVE and MakerDAO may also become unable to operate normally due to the lack of oracle machines on the POW chain, and will eventually become worthless products of the old era. It is also a challenge to rebuild a new ecology on the POW fork chain. It is an extremely difficult and costly thing. In the end, the ending of the POW fork chain may disappear with time and become a memory in people's minds, but everything is possible. Let us wait and see how the hard fork of Ethereum will end!
Original link
a>
Welcome to join the official BlockBeats community:
Telegram Subscription Group: https://t.me/theblockbeats
Telegram Discussion Group: https://t.me/BlockBeats_App
Official Twitter Account: https://twitter.com/BlockBeatsAsia