数字货币交易所开发源码丨数字货币交易所系统开发(详细及逻辑)

资讯 2024-06-22 阅读:57 评论:0
Solo? 算法简介? SOLO是单节点无共识投票过程的“共识算法”。SOLO is the “consensus algorithm” of the single-node non-consensus voting process....
美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

Solo?

  1. 算法简介?

SOLO是单节点无共识投票过程的“共识算法”。

SOLO is the “consensus algorithm” of the single-node non-consensus voting process.

  1. 算法用途?

快速部署单节点运行,降低试用门槛;

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.

  1. 如何使用算法?

部署一个长安链节点,将链配置的共识算法进行如下修改,清除数据启动即可:

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.

  1. 算法用途?

不考虑恶意节点的多节点环境;

The multi-node environment of malicious nodes is not considered;

需要支持高TPS的环境。

A high TPS environment needs to be supported.

  1. 共识接口说明?

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
}

  1. Raft共识与核心引擎交互图?

流程图如下:
Raft共识与核心引擎交互图

The flowchart is as follows:
Raft Consensus and Core Engine Interactive Chart

  1. 如何使用算法?

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?

  1. 算法简述?

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

  1. 与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.

  1. 与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.

美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址
文字格式和图片示例

注册有任何问题请添加 微信:MVIP619 拉你进入群

弹窗与图片大小一致 文章转载注明

分享:

扫一扫在手机阅读、分享本文

发表评论
平台列表
美化布局示例

欧易(OKX)

  全球官网 大陆官网

币安(Binance)

  官网

火币(HTX)

  官网

Gate.io

  官网

Bitget

  官网

deepcoin

  官网
热门文章
  • 区块链社区有哪些?区块链社区是什么?

    区块链社区有哪些?区块链社区是什么?
    展开全文...
  • 0.00006694个比特币等于多少人民币/美金

    0.00006694个比特币等于多少人民币/美金
    0.00006694比特币等于多少人民币?根据比特币对人民币的最新汇率,0.00006694比特币等于4.53424784美元/32.5436 16人民币。比特币(BTC)美元(USDT)人民币(CNY)0.000066944.53424784【比特币密码】32.82795436 16比特币对人民币的最新汇率为:490408.64 CNY(1比特币=490408.64人民币)(1美元=7.24人民币)(0.00006694USDT=0.0004846456 CNY)汇率更新时...
  • 0.00015693个比特币等于多少人民币/美金

    0.00015693个比特币等于多少人民币/美金
    0.000 15693比特币等于多少人民币?根据比特币对人民币的最新汇率,0.000 15693比特币等于10.6 1678529美元/76.86554996人民币。比特币(BTC)【比特币价格翻倍】美元(USDT)人民币(CNY)0.000/克洛克-0/5693【数字货币矿机】10.6 167852976.8655254996比特币对人民币的最新汇率为:489,807.72 CNY(1比特币= 489,807.72人民币)(1美元=7.24人民币)(0.00015693 U...
  • 0.00003374个比特币等于多少人民币/美金

    0.00003374个比特币等于多少人民币/美金
    0.00003374比特币等于多少人民币?根据比特币对人民币的最新汇率,0.00003374比特币等于2.2826 1222美元/16.5261124728人民币。比特币(BTC)美元(USDT)人民币(CNY)0.00003374克洛克-0/22216.5261124728比特币对人民币的最新汇率为:489807.72 CNY(1比特币=489807.72人民币)(1美元=7.24人民币)(0.00003374USDT=0.0002442776 CNY)。汇率更新于2024...
  • 2018-5-31币圈简报

    2018-5-31币圈简报
    一、要闻资讯类I. KEY INFORMATION CATEGORY1、央视:数字货币在京揭牌成立!中国或为此突变!1. View: Digital currency is established in Kyoto! China or mutated for it!中国数字货币来了˂a href="https://mp.weixin.qq.com/s/69fxKCf8GKSCscS4lT8WCA" Target="_blank"rel="noformlow"" Chinese...
标签列表