[区块链从原理到实现] - 区块链中的各种共识算法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/gx_1983/article/details/82824093

[区块链从原理到实现] - 区块链中的各种共识算法

本文将介绍区块链中常用的各种分布式共识算法,对其原理及典型实现做分析。
主要共识算法有:

  • POW
  • BFT
    • PBFT
    • IBFT
  • POS
    • POS
    • DPOS
  • RAFT
  • PAXOS

DPOS

DPOS Consensus Algorithm  - The Missing White Paper
DPOS共识算法 - 丢失的白皮书(此处说明在开发DPOS的时候是没有这个白皮书的,这个白皮书是后补充的,姑且算作白皮书。)

This is the missing white paper and analysis of delegated proof of stake (DPOS).  The goal of this paper is to provide an analysis of why DPOS works and what makes it robust. An early description of DPOS can be found at bitshares.org; however, that description also includes many aspects that are not part of the actual consensus process.
这篇文章是补充的白皮书及对DPOS的分析(DPOS:代理股权证明)。本文的目的是对DPOS为什么能够工作及其鲁棒性的分析。早期DPOS的描述可以在bitshares.org找到,但是在这个网站中的描述包含了许多不是实际共识算法的部分(也就是说此文章只是共识算法的描述,更纯粹。)

All blockchains are fundamentally a deterministic state machine acted upon by transactions. Consensus is the process of agreeing on a deterministic order of transactions and filtering invalid transactions. There are many different consensus algorithms that could produce equivalent ordering of transactions, but DPOS has proven robust, secure, and efficient by years of reliable operation on multiple blockchains.
所有的区块链从本质上来说都是通过交易来处理一个确定性状态机。共识就是对确定性的交易顺序及无效交易达成一致意见的一个过程。有多种不同的共识算法都能够达成一致的交易顺序,但是DPOS被认为是最鲁棒,安全及许多年在多个区块链上使用,被证明是高效的。

Like all consensus algorithms, the most harm the block producers can cause is censorship. All blocks must be valid according to the deterministic open source state machine logic.
就像所有共识算法一样,区块生产者能引起的最大的伤害就是censorship(审查)。通过确定性开源状态机逻辑,所有区块都必须是有效的。

Summary of DPOS Algorithm
DPOS算法摘要。
The DPOS algorithm is divided into two parts: electing a group of block producers and scheduling production. The election process makes sure that stakeholders are ultimately in control because stakeholders lose the most when the network does not operate smoothly. How people are elected has little impact on how consensus is achieved on a minute by minute basis. Therefore, this document will focus on how consensus is reached after the block producers have been chosen.
DPOS算法分为两部分:1.选举区块生产者;2.调度并产生区块。
选举过程确保了股票持有者对网络的最根本的控制,因为如果区块链网络不平顺的话,股票持有者的损失最大。
区块生产者如何被选举出来的对如何在一分钟内共识如何达成几乎没有影响,所以,本文章主要关注区块生产者本选举出来之后的共识过程,而并不关注区块生产者是如何被选举出来的。

To help explain this algorithm I want to assume 3 block producers, A, B, and C. Because consensus requires 2⁄3 + 1 to resolve all cases, this simplified model will assume that producer C is deemed the tie breaker. In the real world there would be 21 or more block producers. Like proof of work, the general rule is that longest chain wins. Any time an honest peer sees a valid strictly longer chain it will switch from its current fork to the longer one.
I will to show by example how DPOS operates under most conceivable network conditions. These examples should help you understand why DPOS is robust and hard to break.
为了有助于解释算法,我会假定有3个区块生产者A,B,C。共识需要2/3+1个来解决所有情况,这个简化模型会假设C永远是打破僵局的那个人。在真是世界中,应该有21个或者更多个区块生产者。就像POW一样,一般的规则是最长的链会赢。
重点:在任何时候,一个诚实的peer看到一个更长的链的时候,它就会从当前的分叉切换到所看到的最长的这个链。
我会用更多的例子来解释实际情况时各种网络情况下的处理过程。这些例子会帮助你理解为什么DPOS是鲁棒的及难以被破坏的。

Normal Operation
正常操作。
Under normal operation block producers take turns producing a block every 3 seconds. 
Assuming no one misses their turn then this will produce the longest possible chain. It is invalid for a block producer to produce a block at any other time slot than the one they are scheduled for.
正常操作的时候,区块生产者按照顺序每隔3秒产生一个快。假定每隔生产者在其该出块的时候都出块了,那么就会产生一个最长的链。
重点: DPOS中对于块生产者来说,在非其出块时间所出的块被视为是无效的。

Minority Fork
Up to 1⁄3 of the nodes can be malicious or malfunction and create a minority fork. In this case the minority fork will only produce one block every 9 seconds while the majority fork will produce 2 blocks every 9 seconds. Once again, the honest 2⁄3 majority will always be longer than the minority.

猜你喜欢

转载自blog.csdn.net/gx_1983/article/details/82824093