From POW to Casper to experience the evolution of the Ethereum consensus mechanism

in #pow6 years ago

Foreword
The blockchain originated in Bitcoin and was developed in Ethereum. Want to have a systematic understanding of the blockchain, it is best to know the principles of Bitcoin and Ethereum, which is why I wrote from Bitcoin and Ethereum.

For the blockchain project, the consensus mechanism is its fundamental value. The consensus is the basis of the application of the blockchain, which refers to how the participants collaborate in this system. Therefore, this article hopes to summarize the consensus mechanism of Bitcoin and Ethereum to help you better understand the value of the blockchain.

Text
Many people first encounter bitcoin and see something that is surrounded by greed and deception, full of violent and scandals.

But when someone tries to blow up the bubble and explore the source, they will be impressed by the "consensus" built by Bitcoin. It feels like walking into a fully automated factory, and every node that handles things works according to established rules.

Broadly speaking, consensus is a social collaboration method that can be applied in different fields to improve efficiency. It is the most essential difference between bitcoin and bubble events such as “Tulip Bubble” and “The Mississippi Bubble”.

On the other hand, the bitcoin consensus is not perfect. Since Nakamoto's intention is to create a "money", so he chose Consistency and Partition tolerance, weakened Availability, in principle CAP (referring in a distributed system, Consistency, Availability, Partition tolerance, the three can not be at the same time under the framework, so that Bitcoin consensus encountered a problem when expanding the application.
pow1英文.png

Based on this, some people try to study different consensus mechanisms to make up for the lack of application of Bitcoin.

The Ethereum community is one of the most famous people who are trying to introduce the proof of interest POS into Ethereum and name the plan Casper.

This article will revolve around the Bitcoin workload proof POW and the Ethereum Equity Proof Program Casper.

Bitcoin workload proof POW
At first, Nakamoto wanted to create a currency that was agreed upon in advance, and once released, no one could control it. This will prevent someone from taking advantage of the self-interest, by controlling the circulation of money, and disguising the interests of the people in disguise.

In order to achieve the goal. First, Nakamoto has set the total amount of bitcoin at 21 million, and uses a dynamic function to specify a certain amount every 10 minutes. These 21 million coins will be fully circulated in 2140.

Second, Bitcoin transaction records are not controlled by any data center, but use peer-to-peer technology (P2P) to allow users to transfer funds directly, just as if they were using WeChat to transfer files.

In order to maintain the normal operation of the system, Satoshi Nakamoto rewards the newly generated bitcoin and transfer fee to the bookkeeping participant (miner, also known as the node). The working people are rewarded so that someone willingly work for the system.

In order not to make mistakes, Nakamoto needs to adopt a set of operating rules to make the system meet the following principles:

  1. The results are consistent. The transaction records of the entire network recorded by each node are consistent.
  2. Cannot be changed. No one can change the transaction history.
  3. Effective. The currency system works efficiently.
  4. Sustainable. The currency system can continue to run.

The rule to ensure the normal operation of the system is the consensus mechanism.

How does the Bitcoin consensus mechanism work?

When User A transfers to User B, the Bitcoin client of the node (including AB itself) will receive this information.

At the same time, all participants will use the computing device (mining machine) to calculate a “hash problem” every 10 minutes within the client. The time and difficulty of this puzzle is controlled by dynamic functions to ensure a 10-minute interval.

This process is called proof of work (POW).

The node that first calculates the correct result will review whether the transaction information is true according to the code, and package the transfer information including the AB user for a certain period of time, package it together to confirm (packaged into "block"), and the current "block" ", connect to the previous "block", generate a "blockchain", and synchronize (broadcast) to all bitcoin nodes across the network.

At this time, the transfer transaction of A to B is judged to be valid.pow2 英文.png

The billing node receives the newly generated bitcoin and transfer fees as a reward and begins a new round of hash puzzle calculations.

In addition, the results of the bookkeeping are based on the “longest chain”. If two participants complete the workload proof at the same time and pack the blocks, they will start the “race”. Whoever is the first to create a new block will prevail.

The Workload Proof Mechanism (POW) makes each node participating in the accounting unique. The calculation result will be broadcasted to the whole network and subject to the longest chain. This ensures that the transaction records of the whole network node are consistent.

In addition, at the time of billing, the node also checks the "unexpended balance" (UTXO) of all addresses associated with the transaction. For example, if you check if A has an unspent balance, you need to check if A has received an earlier transfer, and so on, until “creation transaction”.

In theory, as long as the “creation transaction” remains unchanged, the current unspent balance for each person is determined.

The creation transaction remains the same, coupled with the distributed storage of transaction records, making it impossible for anyone to change the transaction history.pow3 英文.png

Energy consumption and "the tragedy of the commons"

In fact, Bitcoin sacrifices usability to ensure system consistency and raises a number of issues.

First of all, bitcoin is not efficient.

On the one hand, subject to size restrictions, each "block" contains 4000 transaction data, converted by 10 minutes of generation time, equivalent to 6.67 transactions per second, and even the number of unconfirmed transactions in Bitcoin has reached 12,134. pen
This is unqualified for the currency.

On the other hand, the workload proof mechanism consumes a lot of unnecessary resources. Each time it is packaged into blocks, all nodes calculate the hash problem separately, and the node that is finally eligible for accounting is unique. The work done by the rest of the nodes is a waste.

In addition, in order to obtain the billing rights with greater probability, people have invented special mining machines to improve their computing power. The mining machine consumes a lot of electricity in the process of calculating the hash problem. According to statistics, the current global power consumption of Bitcoin mines exceeds 159 countries in the world such as the Czech Republic.

Second, bitcoin may not be sustainable, and a unique distribution mechanism may put Bitcoin in "the tragedy of the commons"

Due to Nakamoto's regulations, the new bitcoin reward is halved for every 210,000 blocks produced. By 2140, when Bitcoin was all dug out, the miners rewarded only the user transfer fee.

At the same time, don't forget that the size of the "block" is limited, so the amount of the fee is fixed.

Therefore, at some point in the future, when the bitcoin rewards obtained by the miners' bills are equal to the cost of mining machinery hardware and electric rent, a large number of miners will withdraw from the bitcoin system, and the computing power will be concentrated in the hands of a few people.

They can use the calculated power to extend the new "longest chain" in the previous block, thereby invalidating the other chain and retrieving the coins they have already paid. This will cause a devastating blow to the Bitcoin system.
pow4 英文 .png

In fact, the Bitcoin community has recognized the existence of problems. In recent years, they have discussed expanding the capacity of "blocks" or introducing solutions such as quarantine witnesses and lightning networks to increase the number of transactions per second (TPS). They even discussed whether to increase the total amount of issuance. But there has never been an agreement.

The good news is that although bitcoin payments are not as convenient as legal currency, countries such as the United States, Japan, Germany, Canada, Belarus, and Switzerland have accepted bitcoin payments and have recognized their legal status within a certain legal scope.
Some countries have also set up Bitcoin ATM machines.

In essence, as a currency, Bitcoin is moving towards its original intention. In contrast, the problems that Ethereum needs to solve are much more complicated.

Copy the following link to register for the HuobiPro account:
https://www.huobi.br.com/zh-cn/topic/invited/?invite_code=qazb3

Reference materials:
Ethereum Casper 101
https://medium.com/@jonchoi/ethereum-casper-101-7a851a4f1eb0

A Proof of Stake Design Philosophy
https://medium.com/@VitalikButerin/a-proof-of-stake-design-philosophy-506585978d51

Proof of Stake FAQs
https://github.com/ethereum/wiki/wiki/Proof-of-Stake-FAQs

Casper Proof of Stake compendium
https://github.com/ethereum/wiki/wiki/Casper-Proof-of-Stake-compendium

Proof of Stake: How I Learned to Love Weak Subjectivity
https://blog.ethereum.org/2014/11/25/proof-stake-learned-love-weak-subjectivity/

Critique of Buterin’s “A Proof of Stake Design Philosophy”
https://medium.com/@tuurdemeester/critique-of-buterins-a-proof-of-stake-design-philosophy-49fc9ebb36c6

Cryptocurrencies without Proof of Work
https://arxiv.org/pdf/1406.5694.pdf

casper_basics.pdf
https://github.com/ethereum/research/blob/master/papers/casper-basics/casper_basics.pdf

The Triangle of Harm
https://vitalik.ca/general/2017/07/16/triangle_of_harm.html

Casper Proof of Stake compendium
https://github.com/ethereum/wiki/wiki/Casper-Proof-of-Stake-compendium