The author of this article is an original work of the Star Alliance
The concept of consensus mechanism
-
What is consensus mechanism
The “consensus mechanism” is to complete the verification and confirmation of transactions in a very short period of time through voting of special nodes in the blockchain system. If several nodes with unrelated interests can agree on a transaction, we can assume that the whole network can agree on it.
-
Why do we need consensus mechanisms
Blockchain is a decentralized distributed ledger in which each node maintains a ledger of all transactions on the chain. When a new transaction occurs on the chain, each node may receive this information at a different time. Some malicious nodes may publish incorrect information at this time. At this time, nodes need to verify the information received by all nodes, and finally publish the most correct information. The operation of this system requires the participation of all nodes, and the system will give rewards to nodes for their work. At this time, consensus mechanism is needed to determine under what rules nodes can get block rights and system rewards.
The consensus mechanism ensures that only real transactions are recorded on the blockchain and can effectively balance efficiency and security in the application of blockchain technology.
-
Objectives of the consensus mechanism
-
Consensus: Consensus mechanisms attempt to resolve one of the most complex issues surrounding distributed systems: the authenticity and accuracy of data. Unlike centralized systems, users don’t have to trust anyone in the system. The protocol rules embedded in the network ensure that the state of the common ledger is always updated by popular consensus.
-
Preventing double-spending attacks: The consensus mechanism prevents any user from making repeated purchases, a problem with digital currencies that existed before Bitcoin. A “double spend attack” is when a digital currency can be spent twice. The protocol rules embedded in the blockchain consensus mechanism ensure that only valid and genuine transactions are recorded in a public and transparent ledger. As miners’ computing power expands to protect trades (and networks), it becomes harder to double attack or change the index of trades.
-
Incentives: Creating a self-regulating trust-free system requires mobilizing participants in the network. Consensus mechanisms do this by incentivizing good behavior and, in some cases, punishing bad actors. The first consensus mechanism used by Bitcoin (proof-of-work) rewarded miners with Bitcoins for warranting and verifying each transaction. Any action against a network (through hacking or double-spending) requires a lot of computing power and money, resources that would be better spent working for the system (because their efforts will be rewarded) rather than against it.
-
Equity and equity: One of the important advantages of decentralization of blockchain is the allocation of licenses, so that anyone can participate on the same basis. The open source nature of public blockchains makes it possible for anyone to check and verify whether the underlying source code is fair to all participants in the network. If you want, you can easily set up a node and become a participant or even a miner. In short, consensus ensures that blockchains do not discriminate.
-
Fault tolerance: In the algorithmic world, fault tolerance is the ability of a distributed system to operate indefinitely in the face of threats or failures. Consensus mechanisms ensure that blockchains are fault-tolerant and therefore reliable and consistent.
-
There are several characteristics that an ideal consensus mechanism needs
features | instructions |
---|---|
Secret | The election was held in secret. |
Fair | Elections are fair, based on a set of rules, based on which probability works |
Single Leader | It is better to elect one leader each round |
Unpredictable | Can’t predict |
Verifiable | It’s very easy to verify |
Anti-attack | Be able to withstand attacks |
Efficient | Low resource consumption |
Three common consensus mechanisms
-
POW- Proof of work
POW, short for Proof of Work, is a requirement that must be met in a system to generate new blocks to be added to the blockchain. In the blockchain network constructed based on proof of work mechanism, nodes compete for billing rights by calculating the numerical solution of random hash hash, and the ability to obtain the correct numerical solution to generate blocks is the concrete performance of node computing power. By competing for billing rights (random values) through mathematical operations, the nodes with billing rights can broadcast the packaged blocks to the whole network and incorporate them into the blockchain, and the nodes will be rewarded for participating in the calculation
-
POS- Proof of interest
POS is proof of stake, which requires miners to have a certain amount of digital currency (which can be acquired through purchase) when creating blocks. The system calculates the age of coins according to the number of tokens in miners’ wallets and the storage time. The higher the age of coins, the higher the probability of obtaining packaged blocks, which is similar to storing assets in banks. The bank will allocate you a return based on how much and how long you hold your digital assets.
-
DPOS- Proof of agency interest
DPOS is Delegated Proof of Stake. In the blockchain system, users with money can vote to delegate nodes with the rights to package and verify new blocks. The packaged and verified transactions of the system rely on these nodes, and the nodes can vote to remove nodes that fail to perform their obligations. The standby node replaces the node.
-
A brief comparison of mechanic weaknesses
Consensus mechanism | describe | disadvantages |
---|---|---|
POW | Proof of work | Serious inefficiency; Excessive consumption of resources; High bifurcation probability |
POS | Interest in | Not easy to maintain consistency; The more coins a person holds, the more likely he or she is to get the right to account |
DPOS | Certificate of Authorized Equity | Low security; Goes against the idea of blockchain decentralization |
###Filecoin consensus mechanism –EC expected consensus
Filecoin’s consensus protocol strategy is to elect one or more miners each round to create a new block, and the likelihood of a miner winning the election is proportional to the miner’s current effective storage.
Filecoin converts the miner’s current stored data in the network to voting power of the Miner.
Filecoin has a collateral mechanism that forces participants to choose a chain, and by cleverly combining the collateral mechanism to penalize miners who dig multiple chains at once, convergence can be accelerated very quickly.
The implementation of the expected consensus is very simple, it does not require interaction, the nodes themselves can calculate whether they become the leader, and after the publication of others can be very easy to verify.
-
Algorithm description
The expected consensus mechanism can be described by the following formula. If, in a round of calculation, a miner can make the following formula true, he is qualified to produce blocks
The left part: H is the irreversible hash function (for example, SHA256), and L is the number of bits in binary of the value of H, ensuring that the value of the left part is between 0% and 100%.
H function inside the < t | | rand (t) > is a cut in the first round t uniform random number, this will only be revealed in the first round t;
Part on the right: the proportion of the effective computing force of the mining machine in the total effective computing force of the whole network
-
Disadvantages of the anticipatory consensus mechanism
The anticipatory consensus mechanism realizes the characteristics of fairness, confidentiality and public verifiability, but it is not perfect, and its biggest problem lies in the instability of generating blocks. In each cycle, one leader miner is expected to be elected, but in some cases more than one leader miner may be elected.
The proportion of empty block rounds in each cycle is as high as 36.78%, and the proportion of expected rounds with only one block is only 36.78%
-
Filecoin consensus mechanism improved – increased block output
Now that we understand this problem with the expected consensus mechanism, how can we improve against instability? A straightforward idea is to increase the amount of blocks produced; Filecoin introduced the constant BlocksPerEpoch, called E for short here. The expected number of blocks produced in each round is set to E, and the value of E is still under experiment and discussion. Here we make a simple calculation: when e=1, which is the original scheme, one block per round, the empty block rate exceeds 1/3; When e=2, it can be theoretically calculated that the probability of empty block turns will be reduced to 1/8 ~ 1/7. When e=3, the proportion of empty blocks will be reduced to 1/20
The method of increasing the amount of block output is very simple, but it can improve the stability of the network block output. This, in turn, results in more blocks on the chain, which also requires more synchronization and validation per node. You can’t have your cake and eat it too.
-
SSLE
Secret Single Leader Election, or Secret Single Leader Election, is the goal of many Consensus mechanisms, for which there are many studies, such as Algorand, Snow White, Stellar Consensus, Bar-fault Tolerance Consensus and Mergeable Consensus also include the expected Consensus mechanism introduced in this paper.