Home  >  Article  >  Web Front-end  >  Looking at the initial chain from the development process of blockchain

Looking at the initial chain from the development process of blockchain

坏嘻嘻
坏嘻嘻Original
2018-09-13 18:10:501666browse

This article mainly introduces the relevant knowledge of blockchain in 200 lines of code. It is very good and has reference value. Friends who need it can refer to it

Recently, the topic of blockchain has been speculated It’s very hot. People who understand technology pay attention to the chain, while those who don’t understand technology care about the currency price. In short, blockchain is a new decentralized economic organization model implemented by a series of technologies. In fact, blockchain technology appeared as early as 2007. With years of improvement and perfection, we have the btc, eth, eos, and true we see now. In short, blockchain is a new decentralized economic organization model implemented by a series of technologies. This article aims to conduct some research from the perspective of consensus algorithms of blockchains in different periods.

1 POW represented by btc: Proof of Work, proof of work.
Bitcoin uses the POW mechanism in the Block generation process. A Block Hash that meets the requirements consists of N leading zeros. The number of zeros depends on the difficulty value of the network. To obtain a reasonable Block Hash requires a lot of trial and error calculations, and the calculation time depends on the hashing speed of the machine. When a node provides a reasonable Block Hash value, it means that the node has indeed undergone a large number of attempted calculations. Of course, the absolute value of the number of calculations cannot be obtained, because finding a reasonable hash is a probabilistic event. When a node has n% of the computing power of the entire network, the node has a probability of n/100 to find the Block Hash.
Advantages: safe, resistant to forks, the POW consensus currency represented by Bitcoin has been in existence for 9 years, and its security has been tested by time.
Disadvantages: Waste of electricity, not energy-saving, a large amount of electricity and computing power are used to compete for Bitcoin’s accounting rights, without making any contribution to the real society. According to incomplete statistics, the electricity required for Bitcoin mining now exceeds the average level of 180 countries. It is precisely because of this that POS appeared

2: POS: Proof of Stake, proof of equity.
POS: Also known as proof of equity, it is similar to property stored in a bank. This model will allocate corresponding interest to you based on the amount and time you hold digital currency.
Operating mechanism: The nodes in the network put the digital currency in the node into the POS mechanism, and the identity is changed into a verifier. The POS mechanism randomly selects one of these verifiers as the generator of the block. Of course, this randomness and input The number of digital currencies is related. The probability of being selected is higher if you invest more coins than if you invest less, which is basically proportional to the quantity ratio. Of course, within a certain period of time, if the generator selected by POS does not generate a block, then the next validator will be selected again. As for the effective chain, this follows the longest chain principle of the blockchain. Since in the POS consensus mechanism, there are tokens as collateral, when the system finds that the node is suspected of committing evil, the mortgaged tokens can be destroyed. Therefore, in the POS consensus mechanism, the security of the system is not provided by the competition of hardware computing power outside the system, but by the hardware computing power competition outside the system. Is based on collateralized tokens as a guarantee of honest nodes.

3 PBFT: Practical Byzantine Fault Tolerance, practical Byzantine fault tolerance algorithm. See the previous introduction to the Byzantine Fault Tolerance algorithm.
PBFT is a state machine replica replication algorithm, that is, the service is modeled as a state machine, and the state machine replicates replicas on different nodes in the distributed system. Each copy of the state machine saves the state of the service and also implements the service's operations. The set of all replicas is represented by a capital letter R, and an integer from 0 to |R|-1 is used to represent each replica. For the convenience of description, assume |R|=3f 1, where f is the maximum number of replicas that may fail. Although more than 3f1 replicas can exist, the additional replicas do not improve reliability other than reducing performance.

Chulian is the world’s earliest hybrid consensus public chain, which is characterized by combining pbft and pow consensus. Use the former to ensure performance and the latter to ensure decentralization. To put it simply, it is based on POW, and then the PBFT backbone node is elected on this node. Personally, I feel that integrating two different consensus algorithms is a very innovative idea. First select the main node based on POW to avoid excessive centralization, similar to the EOS super node, and then operate it under several main nodes later. Although it seems to be contrary to decentralization, this is also the efficiency at this stage. , a better solution that takes into account both performance and decentralization.



Recently, the topic of blockchain has been very hot. Those who understand the technology will follow the chain, and those who do not understand the technology will follow the chain. Pay attention to currency prices. In short, blockchain is a new decentralized economic organization model implemented by a series of technologies. In fact, blockchain technology appeared as early as 2007. With years of improvement and perfection, we have the btc, eth, eos, and true we see now. In short, blockchain is a new decentralized economic organization model implemented by a series of technologies. This article aims to conduct some research from the perspective of consensus algorithms of blockchains in different periods.

1 POW represented by btc: Proof of Work, proof of work.
Bitcoin uses the POW mechanism in the Block generation process. A Block Hash that meets the requirements consists of N leading zeros. The number of zeros depends on the difficulty value of the network. To obtain a reasonable Block Hash requires a lot of trial and error calculations, and the calculation time depends on the hashing speed of the machine. When a node provides a reasonable Block Hash value, it means that the node has indeed undergone a large number of attempted calculations. Of course, the absolute value of the number of calculations cannot be obtained, because finding a reasonable hash is a probabilistic event. When a node has n% of the computing power of the entire network, the node has a probability of n/100 to find the Block Hash.
Advantages: safe, resistant to forks, the POW consensus currency represented by Bitcoin has been in existence for 9 years, and its security has been tested by time.
Disadvantages: Waste of electricity, not energy-saving, a large amount of electricity and computing power are used to compete for Bitcoin’s accounting rights, without making any contribution to the real society. According to incomplete statistics, the electricity required for Bitcoin mining now exceeds the average level of 180 countries. It is precisely because of this that POS appeared

2: POS: Proof of Stake, proof of equity.
POS: Also known as proof of equity, it is similar to property stored in a bank. This model will allocate corresponding interest to you based on the amount and time you hold digital currency.
Operating mechanism: The nodes in the network put the digital currency in the node into the POS mechanism, and the identity is changed into a verifier. The POS mechanism randomly selects one of these verifiers as the generator of the block. Of course, this randomness and input The number of digital currencies is related. The probability of being selected is higher if you invest more coins than if you invest less, which is basically proportional to the quantity ratio. Of course, within a certain period of time, if the generator selected by POS does not generate a block, then the next validator will be selected again. As for the effective chain, this follows the longest chain principle of the blockchain. Since in the POS consensus mechanism, there are tokens as collateral, when the system finds that the node is suspected of committing evil, the mortgaged tokens can be destroyed. Therefore, in the POS consensus mechanism, the security of the system is not provided by the competition of hardware computing power outside the system, but by the hardware computing power competition outside the system. Is based on collateralized tokens as a guarantee of honest nodes.

3 PBFT: Practical Byzantine Fault Tolerance, practical Byzantine fault tolerance algorithm. See the previous introduction to the Byzantine Fault Tolerance algorithm.
PBFT is a state machine replica replication algorithm, that is, the service is modeled as a state machine, and the state machine replicates replicas on different nodes in the distributed system. Each copy of the state machine saves the state of the service and also implements the service's operations. The set of all replicas is represented by a capital letter R, and an integer from 0 to |R|-1 is used to represent each replica. For the convenience of description, assume |R|=3f 1, where f is the maximum number of replicas that may fail. Although more than 3f1 replicas can exist, the additional replicas do not improve reliability other than reducing performance.

Chulian is the world’s earliest hybrid consensus public chain, which is characterized by combining pbft and pow consensus. Use the former to ensure performance and the latter to ensure decentralization. To put it simply, it is based on POW, and then the PBFT backbone node is elected on this node. Personally, I feel that integrating two different consensus algorithms is a very innovative idea. First select the main node based on POW to avoid excessive centralization, similar to the EOS super node, and then operate it under several main nodes later. Although it seems to be contrary to decentralization, this is also the efficiency at this stage. , a better solution that takes into account both performance and decentralization.

Related recommendations:

200 lines of code to implement blockchain Detailed explanation of blockchain examples

Bitcoin’s blockchain api friends who are familiar with it will give advice one time

The above is the detailed content of Looking at the initial chain from the development process of blockchain. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn