Solo?
- 算法简介?
SOLO是单节点无共识投票过程的“共识算法”。
SOLO is the “consensus algorithm” of the single-node non-consensus voting process.
- 算法用途?
快速部署单节点运行,降低试用门槛;
Rapid deployment of single nodes and lowering of test thresholds;
供开发人员进行除网络和共识模块的全流程测试。
Provides developers with full-process testing for the removal of the network and consensus modules.
- 如何使用算法?
部署一个长安链节点,将链配置的共识算法进行如下修改,清除数据启动即可:
Deployment of a long-chain node to modify the agreed algorithm for chain configuration as follows, so that the clean-up data can be activated:
consensus:
# 共识类型(0-SOLO,1-TBFT,3-Maxbft,4-RAFT,10-POW)
type: 0
Raft?
4 算法简介?
Raft算法是目前使用最广泛的非拜占庭容错类共识算法。 Raft算法主要依靠投票机制和日志复制机制来实现节点间的共识。节点通过投票选出一个leader,由leader负责处理所有请求,再将请求以日志的方式复制到其他节点。
Consensus:
# Consensus type (0-SOLO, 1-TBFT, 3-Maxbft, 4-RAF, 10-POW)
type: 0
Raft? >br>4 algorithms are currently the most widely used non-Byzant tolerance misconsensus algorithms. Raft algorithms rely mainly on voting mechanisms and log reproduction mechanisms to achieve consensus among nodes.
- 算法用途?
不考虑恶意节点的多节点环境;
The multi-node environment of malicious nodes is not considered;
需要支持高TPS的环境。
A high TPS environment needs to be supported.
- 共识接口说明?
Raft 实现了长安链的ConsensusEngine接口。 Start 方法用来初始化Raft内部状态及启动Raft实例。 Stop 方法用来停止Raft实例。
Raft has achieved a long-chain ConsensusEngine interface. The Start method is used to initialize the internal state of Raft and to activate the Raft example. The Stop method is used to stop the Raft example.
type ConsensusEngine interface {
// Init starts the consensus engine.
Start() error
// Stop stops the consensus engine.
Stop() error
}
- Raft共识与核心引擎交互图?
流程图如下:
Raft共识与核心引擎交互图
The flowchart is as follows:
Raft Consensus and Core Engine Interactive Chart
- 如何使用算法?
Raft共识建议配置节点数为2n+1(n>=0),将链配置(参见配置模块,链配置章节)的共识算法进行如下修改,清除数据启动即可:
The Raft Consensus recommends that the number of nodes be configured at 2n+1 (n> = 0) and that the following changes be made to the consensus algorithm for chain configuration (see configuration module, chain configuration section) to remove data startup:
consensus:
# 共识类型(0-SOLO,1-TBFT,3-HOTSTUFF,4-RAFT,5-DPoS,10-POW)
type: 4
nodes:
Consensus:
# Consensus Type (0-SOLO, 1-TBFT, 3-HOTSTUFF, 4-RAFT, 5-DPOS, 10-POW)
TBFT?
- 算法简述?
TBFT 是一种拜占庭容错的共识算法,可以在拜占庭节点数小于总数1/3的情况下,保证系统的安全运行。 TBFT 的每轮共识可以分为5个步骤:
TBFT is a consensus algorithm for Byzantine misbehaviour that can guarantee the safe operation of the system if the number of Byzantine nodes is less than one third of the total. TBFT's consensus can be divided into five steps per round:
NewRound: 共识投票的准备阶段,会初始化共识相关状态;
NewRound: The preparatory stage for the consensus vote will initialize the consensus-related status;
Proposal: 提案阶段,leader节点会打包区块,并广播给follwer节点;
Proposal: During the proposal phase, the leader node will be packed and broadcast to the follwer node;
Prevote: 预投票阶段,follower节点在收到proposal并验证proposal合法后,广播自己的prevote投票到其他节点;
Prevote: During the pre-vote phase, following receipt of the proposal and verification of the proposal legality of the flolower node, broadcast its own prevote vote to the other node;
Precommit: 预提交阶段,节点收到 >2/3 针对proposal的prevote投票后,广播自己的precommit投票到其他节点;
Precommittee: Pre-submission stage, node received & gt; 2/3 after voting on proposal prevote, broadcast its own precommittee vote to other nodes;
Commit: 提交阶段,节点收到 >2/3 针对proposal的precommit投票后,提交proposal中的区块到账本。
Committee: At the submission stage, node & gt; 2/3 after voting on the proposal precommittee, submit the section in the proposal to the account book.
其中共识投票是指其中的Proposal,Prevote,Precommit三个阶段。 阶段图示如下:
共识算法-tbft算法阶段图
The consensus vote refers to the three phases of Proposal, Prevote, Precommittee. The stage chart is as follows:
Consensus Algorithm-tbft Algorithm
流程图如下:
共识算法-tbft流程图
Flowchart as follows:
Consensus algorithm-tbft flowchart
- 与PBFT的区别?
TBFT基于Tendermint算法,与PBFT的最大区别在于:PBFT有一个固定的leader节点打包交易,当leader节点故障的时候会 使用view-change子协议更换leader;而在TBFT中,leader是轮换的,每提交n个块(可以配置)leader会轮换成下一个节点。 因此,TBFT比PBFT有更好的公平性。
The biggest difference between TBFT, which is based on the Tendermint algorithm, and PBFT is that PBFT has a fixed leader node packaged and uses the view-change sub-agreement to replace Leader when the point fails; while in TBFT, leader is rotated, with each n block (which can be configured) rotated to the next node. Therefore, TBFT is more equitable than PBFT.
TBFT实现了随机性交易的剔除,当一个交易具有随机性执行结果的时候(该交易在不同节点执行结果不一致,比如说该交易调用合约时获取一个时间戳或者产生一个随机值),TBFT可以通过共识对该交易进行剔除,从而保证链的稳定性和正确性。从节点在收到提案进行验证的时候对这种随机性的交易的读写集进行判断,如果读写集不一致,则会在发起prevote投票的时候,加上对该交易进行剔除的投票。当收集到f+1个对该交易的剔除投票,则会调用核心引擎对该交易进行剔除。
TBFT has achieved the elimination of random transactions. When a transaction has a random execution result (when the transaction is executed inconsistently at different nodes, for example, when the transaction calls for a time stamp or a random value), TBFT can exclude the transaction by consensus, thereby ensuring the stability and correctness of the chain. When the proposal is verified from the node, a reading and writing set of such random transactions is judged, and if the book is not consistent, a vote on the transaction is added when the prevote vote is launched. When f+1 votes are collected, the transaction is screened out by the core engine.
- 与msgbus交互流程?
Raft共识与核心引擎交互图
ProposaState: TBFT发送给核心引擎本节点在当前高度是否是leader节点,核心引擎判断是否需要打包区块
Proposal: 核心引擎打包区块并发送给TBFT
Verify: 当本节点收到主节点发来的区块后,向核心引擎验证区块读写集等信息
VerifyResult: 核心引擎返回给TBFT Verify的结果,当区块合法时,本节点将会投票给区块
Commit: TBFT完成共识后,向核心引擎发送提交区块的信号,核心引擎提交区块到账本
BlockInfo: 核心引擎告知TBFT已提交区块的高度等信息,TBFT进入下一个高度
Raft Consensus and Core Engine Interactive Chart
ProposaState: TBFT sends this node to the core engine to determine whether or not the core engine is the leader node at its current altitude, and the core engine determines whether it needs to wrap blocks
Proposal: Core engine wraps blocks and sends TBFT
Verify: When this node receives blocks from the main node, the core node certifies the content of blocks such as the reading and writing set of blocks
VerifyResult: The core engine returns to the outcome of TBFT Verify, and when the blocks are legal, this node will vote to the core node
Commit: TBFT completes the consensus by sending a signal to the core engine to submit blocks to the account
BlockInfo: The core engine informs TBFT that it has submitted information, etc.
注册有任何问题请添加 微信:MVIP619 拉你进入群
打开微信扫一扫
添加客服
进入交流群
发表评论