Blockchain Basics: Decrypting The Misunderstandings Of Mining And Consensus

admin 232 0

As a "traditional software" developer, I feel that the learning curve for learning blockchain development is quite steep. For example, I often misunderstand seemingly simple concepts. I recommend that beginners read less articles like this one. I also cannot guarantee that my current understanding is completely accurate. The purpose of writing this article is to bring out my own notes for everyone to discuss.

As a "traditional software" developer, I feel that the learning curve for learning blockchain development is quite steep. For example, I often misunderstand seemingly simple concepts. I recommend that beginners read less articles like this one. I also cannot guarantee that my current understanding is completely accurate. The purpose of writing this article is to bring out my own notes for everyone to discuss.

Beginners should first try to read some relevant classic materials: such as white papers or official documents, relevant protocol documents, BIP documents, or classic works such as "". Those who are capable recommend reading the code and notes, and even some email records or chat records of developers, such as dev log;

With these foundations, you can look at other people's interpretations and related papers with questions. This reduces the possibility of being misled by wrong ideas. Misunderstanding the basic concepts of the blockchain world can be even more fatal because they are all real gold. , too many accidents occur because a few lines of code introduce fatal vulnerabilities, or are based on or developed products that are not fully understood;

Blockchain technology has introduced a lot of new vocabulary, such as POW POS, etc. This article will first talk about the relatively high-frequency POW/POS and consensus algorithms, and first quote two paragraphs:

1>What is the consensus:

is a form of that and each x. ""Prove that this can be used as,close to the data. --

2> Emin Gunn Sirer

POS/POW itself is not a consensus:

1. Guessing Game-Mining Mechanism Solved POS is a different mining mechanism. Essentially, they are different guessing games but with similar rules. They all need to construct a block so that its hash value is less than a certain target value, which is the so-called dynamic adjustment of the difficulty value;

POW is to guess a random nonce value when constructing a block to meet the above conditions. When all nonces are invalid, the block content can be adjusted and fine-tuned. The greater the computing power, the greater the opportunity. That's the amount of work.prove

;

POS is to find a UTXO to construct, and the hash value is smaller than the weight difficulty value corresponding to the UTXO.When the node controls

The more UTXOs there are, or to be precise, the bigger the stakes, the better the chances of finding it. This is proof of stake;

It can be seen that the so-called POW POS only has different requirements for generating blocks. The guessing game is played round by round. One block is generated each round. After each round of block generation, it will be broadcast and published to the blockchain network. All nodes will select the winning block of this round based on the consensus algorithm and connect it to the prompt of the current blockchain, so I call POW POS a ticket to reach consensus or a ticket to become a candidate.

#POW applet example:

#POSv3 explained in detail:

2. Voting Procedure-Consensus Algorithm

POW POS is just a ticket to becoming a candidate. Which block is the winner of the round is decided by a majority of voters. Their voting rules are the consensus algorithm itself. Voters are nodes in the network. Of course, we are talking about full nodes here, and the voting work roughly includes (there is no detailed process here, it is completely a high-level overview):

1) Forwarding: The process of verifying and forwarding the received information can be regarded as one of the verification steps of voting. If a candidate block contains illegal content, the candidate block will be lost. gain legitimacy;

2) Full block and best chain: More detailed verification of the received block (block level and level verification) to find the longest chain. Of course, the actual process is dynamic, and the current longest chain may not be the final longest. chain,

There will continue to be soft forks, blocks, and even reorganizations, usually six confirmations (generally speaking, as long as the world's network does not experience large-scale and long-term paralysis, so-called deep reorganizations are unlikely to occur unless is malicious at a distance);

In the blockchain network, here we mainly talk about the public chain represented by I. Each client, whether it is an ordinary mobile wallet or a mining machine node, has its own role in this network. For an ordinary mobile wallet (hot wallet), its main task is to broadcast and relay transaction information, while the purpose of the mining node is to earn rewards and handling fees, so the miner node works hard to generate candidate blocks. These miner nodes may be running different official versions, some are modified unofficial versions, and some are even malicious hacker nodes, so the consensus algorithm is the basis for these good nodes and bad nodes to cooperate without trusting each other, that is, To achieve what is called;

The essence of consensus is to solve the Byzantine Generals Problem. The consensus algorithm is a Byzantine fault-tolerant algorithm (here is a general term, not specifically BFT or PBFT). The purpose of POW POS is to increase the cost of evil nodes or traitor nodes. In fact, for POW, the cost of doing evil is indeed very high, especially for the Bitcoin network, but for POS, there are many low-cost ways to do evil, which will be mentioned in the next 3 chapters;

A common consensus algorithm is the Satoshi Nakamoto consensus algorithm, which consists of a series of consensus rules based on the longest chain principle. For details see:

Other consensus algorithms include PBFT (both adopted), see detailed explanation

Simply put, when a client sends a request, nodes (similar to voter representatives) send preamble information to other nodes, and nodes that receive the information respond to the information. When each node receives an ack from other nodes, all nodes send the information. , when enough information is received, reply to the end;

So here we also want to mention the so-called DPOS algorithm

DPOS is divided into two parts: a set of blocks and. Make sure you lose the most if you don't.

--

@/dpos---this--white paper

As mentioned above, the DPOS algorithm has two parts, 'D': selecting the block producer, and 'POS': generating the block, so DPOS itself is not a consensus, because the consensus is only reached after the block is generated. occurs between these blocks;

Personal opinion: The main difference between DPOS and POS is that POS is a ticket for most people to participate in the consensus, while DPOS is a ticket for a small number of selected people to participate in the consensus, so for EOS it still needs to be achieved according to the longest chain principle . Consensus, the potential problem here is that individual wealthy nodes with a large number of coins may do whatever they want, so EOS proposes to introduce the BFT consensus model. If you are interested, you can read this article "DPOS BFT-Fault"

If you are asking what will happen if some nodes do not adhere to the consensus or modify the consensus, the answer is that a fork will occur, but if there are not enough nodes to support and join your new consensus, your forked chain will have nothing. It makes sense, so the consensus is the consensus of the majority of people. The consensus of a few people only makes sense on public chains based on DPOS or some alliance chains.

3. Attack vectors

Understand this, you will have a relatively clearer understanding of some complete problems or security incidents, such as

1) Certain attack methods are economically feasible for many POS public chains, but are not economically feasible for POW public chains like Bitcoin.

For example, the main reason for long distance and critical situations is that the cost of producing blocks on POW is very high, not to mention deliberately choosing the wrong branch, the cost is even greater, while POS does not have this problem, and there is no cost to produce blocks. As long as there are certain shares, sometimes you can even buy the shares, then construct an attack, and then sell the shares. The cost is just the handling fee. Don’t misunderstand Stake and think that Stake is not needed. Meaning miners or should I say mining on multiple branches at the same time. Due to the lower cost of producing blocks, multi-branch mining can increase the chances of receiving rewards. Being in danger will eventually lead to a double-spend attack;

The solution is to improve the consensus algorithm, such as setting (also already adopted), node punishment for unclear nodes,

There are specific algorithms. If you are interested, take a closer look at Ethereum.

2) Similarly, the same -first node synchronization (that is, the attack method of exhausting memory and disk space) will occur on POS, and POW can circumvent this problem

Simply put, this attack method uses nodes to synchronize forked branch blocks. If reorg does not occur, that is, the branch node is not the longest node, full (full verification of double flowers, signatures, etc.) will not be performed. , consumes memory (sending) or disk (sending blocks)

——About PoS

You can read qtum's response to the study:

Re: “Fake Stake” on Chain-Based Proof of Stake

As can be seen from the above two examples, any small changes or vulnerabilities in the consensus algorithm may introduce multiple attack vectors. We can learn a lot about how we think from them. Here are links to vulnerabilities that have occurred throughout Bitcoin history:

You can learn to analyze and report both DOS and COST vulnerabilities caused by a single line of code.

CVE-2018-17144 Vulnerability Research and Analysis

4. More ideas. Although I am just a blockchain technology enthusiast and have no opportunity to participate in public chain development, my continuous and in-depth understanding will also help my development capabilities. Developing a decentralized global mindset is extremely useful. For the challenge, colleagues who are familiar with distributed development or multi-threaded development may have an easier time picking up than me. Of course, in addition to technical thinking, many places also need to combine economic incentive mechanisms. For example, this article proposes the idea of ​​miner nodes. Verification Dilemma:

If you do a complete verification (including execution verification), it will take a certain amount of time. The advantage is that illegal transactions are excluded. If you skip verification, you will get more time than other miners, but the danger is that it may contain illegal transactions. transactions, thus wasting computing power and paying the price. This paper is interesting. It feels a bit like demonstrating the contradiction between the 1 mining mechanism and the 2 consensus algorithm I mentioned earlier. Full compliance, driven by mining interests. Consensus rules are still selectively followed.If you are interested, you can learn about the solution proposed by the author "THE 'S"

标签: #Mining #Blockchain

  • 评论列表

留言评论