CN114723444A - A Data Sharding Method for Parallel Voting Consensus - Google Patents
A Data Sharding Method for Parallel Voting Consensus Download PDFInfo
- Publication number
- CN114723444A CN114723444A CN202210072749.1A CN202210072749A CN114723444A CN 114723444 A CN114723444 A CN 114723444A CN 202210072749 A CN202210072749 A CN 202210072749A CN 114723444 A CN114723444 A CN 114723444A
- Authority
- CN
- China
- Prior art keywords
- data
- node
- block group
- block
- nodes
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 31
- 238000013467 fragmentation Methods 0.000 claims abstract description 20
- 238000006062 fragmentation reaction Methods 0.000 claims abstract description 20
- 239000012634 fragment Substances 0.000 claims abstract description 18
- 238000012795 verification Methods 0.000 claims description 6
- 230000007423 decrease Effects 0.000 claims description 4
- 238000012545 processing Methods 0.000 claims description 4
- 238000012544 monitoring process Methods 0.000 claims description 3
- 238000011084 recovery Methods 0.000 claims description 3
- 238000005457 optimization Methods 0.000 abstract description 4
- 230000006872 improvement Effects 0.000 abstract description 3
- 230000011218 segmentation Effects 0.000 abstract description 3
- 230000008569 process Effects 0.000 description 6
- 238000005516 engineering process Methods 0.000 description 5
- 230000007246 mechanism Effects 0.000 description 5
- 238000013500 data storage Methods 0.000 description 4
- 230000008901 benefit Effects 0.000 description 3
- 238000012546 transfer Methods 0.000 description 3
- 238000009825 accumulation Methods 0.000 description 2
- 230000006399 behavior Effects 0.000 description 2
- 238000004364 calculation method Methods 0.000 description 2
- 238000013461 design Methods 0.000 description 2
- 238000010586 diagram Methods 0.000 description 2
- 230000002452 interceptive effect Effects 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 238000013144 data compression Methods 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000018109 developmental process Effects 0.000 description 1
- 239000011159 matrix material Substances 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000008520 organization Effects 0.000 description 1
- 230000009466 transformation Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q20/00—Payment architectures, schemes or protocols
- G06Q20/38—Payment protocols; Details thereof
- G06Q20/382—Payment protocols; Details thereof insuring higher security of transaction
- G06Q20/3827—Use of message hashing
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q20/00—Payment architectures, schemes or protocols
- G06Q20/38—Payment protocols; Details thereof
- G06Q20/382—Payment protocols; Details thereof insuring higher security of transaction
- G06Q20/3829—Payment protocols; Details thereof insuring higher security of transaction involving key management
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q20/00—Payment architectures, schemes or protocols
- G06Q20/38—Payment protocols; Details thereof
- G06Q20/40—Authorisation, e.g. identification of payer or payee, verification of customer or shop credentials; Review and approval of payers, e.g. check credit lines or negative lists
- G06Q20/405—Establishing or using transaction specific rules
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D30/00—Reducing energy consumption in communication networks
- Y02D30/50—Reducing energy consumption in communication networks in wire-line communication networks, e.g. low power modes or reduced link rate
Landscapes
- Business, Economics & Management (AREA)
- Accounting & Taxation (AREA)
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Finance (AREA)
- Strategic Management (AREA)
- Computer Security & Cryptography (AREA)
- General Business, Economics & Management (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Development Economics (AREA)
- Economics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
Description
技术领域technical field
本发明属于区块链技术改进领域,尤其涉及一种用于并行投票共识的数据分片方法。The invention belongs to the field of block chain technology improvement, and in particular relates to a data fragmentation method for parallel voting consensus.
背景技术Background technique
随着全球信息技术领域的科技革命和产业变革,互联网逐渐由“信息互联网”向“价值互联网”发展。在“信息互联网”时代,网络上的信息公开透明,但也因可以随意篡改而变得不可信,需要第三方机构提供信任担保。一旦提供信任的第三方平台倒闭,其所提供的信任便化为泡沫。为了解决互联网发展过程中产生的信任问题,区块链技术应运而生。With the technological revolution and industrial transformation in the global information technology field, the Internet has gradually developed from the "information Internet" to the "value Internet". In the era of "Information Internet", the information on the Internet is open and transparent, but it is also untrustworthy because it can be tampered with at will, requiring a third-party organization to provide trust guarantees. Once the third-party platform that provides trust collapses, the trust provided by it will become a bubble. In order to solve the trust problem arising from the development of the Internet, blockchain technology came into being.
区块链技术是分布式数据存储系统、点对点传输、共识机制、加密算法等技术的集成应用模式,能够在互联网上实现传统互联网无法实现的信任和价值传递。其基于密码学原理而非信用的特征,使得任何达成一致的双方直接交易,从而不需要第三方中介的参与。另一方面,区块链中几乎不存在单点故障,链上的数据存储在全球无数台机器节点上,使得数据“稳定”、“可信”且“不可篡改”,这重新赋予了网络上的数据一种可以被信任的价值。Blockchain technology is an integrated application mode of distributed data storage system, point-to-point transmission, consensus mechanism, encryption algorithm and other technologies, which can realize trust and value transfer on the Internet that cannot be achieved by traditional Internet. It is based on the principle of cryptography rather than the characteristics of credit, so that any two parties who reach an agreement can directly trade without the participation of a third-party intermediary. On the other hand, there is almost no single point of failure in the blockchain, and the data on the chain is stored on countless machine nodes around the world, making the data "stable", "trustworthy" and "immutable", which re-empowers the network data a value that can be trusted.
区块链每个节点在本地存储完整区块链的复制,因此节点可独立完成交易查找、账户余额计算等工作。然而,随着虚拟货币区块链包含的数据量不断增加,区块链体积不断增大。例如,截至2019年12月,虚拟货币区块链约占存储空间260GB。虚拟货币区块链体积过大演变为可伸缩性问题,导致空白节点同步时间增长。同时,繁重的存储负担会增加维护全节点的成本。Each node of the blockchain stores a copy of the complete blockchain locally, so nodes can independently complete transactions such as transaction lookup and account balance calculation. However, as the amount of data contained in the virtual currency blockchain continues to increase, the size of the blockchain continues to increase. For example, as of December 2019, the virtual currency blockchain occupies about 260GB of storage space. The excessive size of the virtual currency blockchain has evolved into a scalability problem, resulting in an increase in the synchronization time of blank nodes. At the same time, the heavy storage burden increases the cost of maintaining a full node.
本方案设计了一种面向并行投票共识的交互式区块组体分片方案,并利用纠删码保证完整数据可以随时恢复,同时采用了一种结合布隆过滤器的冷热数据缓存策略来保证交易快速定位和区块组数据的快速查询。This scheme designs an interactive block group sharding scheme for parallel voting consensus, and uses erasure codes to ensure that complete data can be recovered at any time. It ensures fast transaction location and fast query of block group data.
2008年,Nakamoto提出虚拟货币。在虚拟货币区块链系统中,用户可以上传自身的交易,交易的实质是将一个账户中的虚拟货币转移到另外账户中,一个交易可能存在多个输入和多个输出。合法交易被打包放到区块中,区块最大为1MB。区块包括区块头和区块体两部分,区块头主要包括指向上个区块的哈希值、交易默克尔树树根值、时间戳和随机数等,区块体主要包括产生的交易。In 2008, Nakamoto proposed virtual currency. In the virtual currency blockchain system, users can upload their own transactions. The essence of the transaction is to transfer the virtual currency in one account to another account. A transaction may have multiple inputs and multiple outputs. Legal transactions are packaged into blocks with a maximum size of 1MB. A block consists of a block header and a block body. The block header mainly includes the hash value pointing to the previous block, the root value of the transaction Merkle tree, a timestamp and a random number, etc. The block body mainly includes the generated transaction. .
虚拟货币中包括全节点和轻节点两种节点。轻节点又叫做SPV (SimplifiedPayment Verification)节点,它不存储区块链交易数据,只具有钱包功能,可以减轻存储压力。全节点存储全部的区块数据,可以用于验证交易,为其他节点提供数据,具有完备的节点功能。针对存储资源较少的设备,虚拟货币白皮书中介绍SPV节点在初始化同步过程中只下载区块头,然后根据自身需要从全节点请求数据。这种节点所需的存储大小只与区块高度成线性关系,与区块大小无关。每个区块头80B,一年仅4.2MB 的空间,极大地减轻了存储压力。The virtual currency includes both full nodes and light nodes. Light nodes are also called SPV (Simplified Payment Verification) nodes. They do not store blockchain transaction data, but only have a wallet function, which can reduce storage pressure. The full node stores all block data, which can be used to verify transactions, provide data for other nodes, and have complete node functions. For devices with less storage resources, the virtual currency white paper introduces that the SPV node only downloads the block header during the initialization synchronization process, and then requests data from the full node according to its own needs. The storage size required for such a node is only linearly related to the block height, independent of the block size. Each block header is 80B, and the space is only 4.2MB a year, which greatly reduces the storage pressure.
虚拟货币轻节点的主要优点在于,第一,大幅缩小了节点的存储空间,为存储能力比较弱的客户端加入网络提供了可能;第二,轻节点依赖于全节点,可以快速准确地进行支付校验,不需要下载全部的支付数据。The main advantages of virtual currency light nodes are that, first, the storage space of nodes is greatly reduced, making it possible for clients with weak storage capabilities to join the network; second, light nodes rely on full nodes and can make payments quickly and accurately For verification, there is no need to download all payment data.
上述轻节点方案也存在着一定的缺陷。首先,随着数据量的增加,轻节点增多,全节点个数减少,区块链系统的去中心化程度减弱,数据安全性、稳定性下降;轻节点减少了数据存储,但是增大了网络带宽压力,在数据存储和数据共享方面对系统没有贡献。The above-mentioned light node scheme also has certain defects. First of all, as the amount of data increases, the number of light nodes increases, the number of full nodes decreases, the degree of decentralization of the blockchain system is weakened, and the security and stability of data decreases; light nodes reduce data storage, but increase the size of the network. Bandwidth pressure, does not contribute to the system in terms of data storage and data sharing.
支付通道(Payment Channels)是运行在虚拟货币网络上的二层结构,允许参与的双方直接建立彼此间点对点的支付渠道。参与方可以安全地维护和更新彼此间私有账本,这样他们在通道内的交易就不需要写入区块链。需要指出的是,交易过程中,支付通道的中间状态也可以随时写入虚拟货币账本。支付通道避免了直接在虚拟货币上进行交易,因此可以显著提高容量、可扩张性、交易吞吐量。通道内的交易处理速率仅受参与方的网络带宽限制,而不需要考虑虚拟货币网络的拥堵情况。支付通道的另一个优势是它们不需要虚拟货币矿工的直接服务,因此可以以极低的的交易费进行,可以经济地执行虚拟货币用户间的微额支付。Payment Channels is a two-layer structure running on the virtual currency network, allowing both parties involved to directly establish peer-to-peer payment channels between each other. Participants can securely maintain and update each other's private ledger so that their transactions within the channel do not need to be written to the blockchain. It should be pointed out that during the transaction process, the intermediate state of the payment channel can also be written into the virtual currency ledger at any time. The payment channel avoids transacting directly on the virtual currency, so it can significantly increase capacity, scalability, transaction throughput. The transaction processing rate within the channel is only limited by the network bandwidth of the participants, regardless of the congestion of the virtual currency network. Another advantage of payment channels is that they do not require direct services from virtual currency miners, so they can be performed with extremely low transaction fees, and micropayments between virtual currency users can be performed economically.
闪电网络,是由Joseph Poon与Thaddeus Dryja首次提出的,也是目前发展前景最好、影响力最大的支付通道。闪电网络允许参与的用户执行虚拟货币链下支付,依靠惩罚机制促进用户的诚实行为。如果一个节点广播恶意交易,那么诚实的参与者就可以合法地索取相关闪电网络内的所有资金,这有力地保证了多个参与方,在公平、公正的情况下进行交易。Lightning Network, first proposed by Joseph Poon and Thaddeus Dryja, is currently the most promising and influential payment channel. The Lightning Network allows participating users to perform virtual currency off-chain payments, relying on punishment mechanisms to promote honest behavior of users. If a node broadcasts a malicious transaction, then honest participants can legally claim all funds within the relevant Lightning Network, which strongly guarantees that multiple parties can conduct transactions in a fair and just manner.
这种方式的主要优点在于,第一,大幅减小了因小额交易引起的节点存储空间;第二,加快了虚拟货币的处理速度,避免小交易拖慢整体性能。The main advantages of this method are that, firstly, it greatly reduces the node storage space caused by small transactions; secondly, it speeds up the processing speed of virtual currency and prevents small transactions from slowing down the overall performance.
上述方案也存在着一定的缺陷。首先,本方案依赖于双方的可信,否则有可能资产的丢失,因此仅适合于小额交易;同时,本方案仅仅适用于转账一种交易类型,不具有普适性,并且也没有从根本上减少节点的数据存储量。The above scheme also has certain drawbacks. First of all, this scheme relies on the trustworthiness of both parties, otherwise assets may be lost, so it is only suitable for small-value transactions; at the same time, this scheme is only suitable for transfer of one type of transaction, which is not universal, and does not fundamentally Reduce the amount of data storage on the node.
发明内容SUMMARY OF THE INVENTION
本发明的目的在于提供一种用于并行投票共识的数据分片方法,旨在解决如何在不影响数据安全性的前提下进行区块数据压缩以提高阶段系统可拓展性的核心技术问题。The purpose of the present invention is to provide a data sharding method for parallel voting consensus, which aims to solve the core technical problem of how to perform block data compression to improve the scalability of the stage system without affecting the data security.
本发明是这样实现的,一种用于并行投票共识的数据分片方法,所述用于并行投票共识的数据分片方法包括以下步骤:The present invention is implemented as follows: a data sharding method for parallel voting consensus, the data sharding method for parallel voting consensus includes the following steps:
S1、当前周期的主节点负责监控从上一次分片后区块组的体积;S1. The master node of the current cycle is responsible for monitoring the volume of the block group after the last fragmentation;
S2、判断监控的区块主体的体积是否大于存储因子M,当体积和大于 M时,则发起一条<split,l,r,signature>交易到网络中,当体积和小于M时,则继续执行S2;S2. Determine whether the volume of the monitored block body is greater than the storage factor M. When the volume sum is greater than M, initiate a <split,l,r,signature> transaction to the network, and when the volume sum is less than M, continue to execute S2;
S3、节点i接收到split交易后,需要先等待获取从l到r范围内的所有区块组;S3. After node i receives the split transaction, it needs to wait to obtain all block groups in the range from l to r;
S4、节点独立获取对应的分片编码并广播一条交易 S4. The node independently obtains the corresponding fragment code and broadcast a transaction
S5、当系统中的n个节点都明确进行了回复后,节点可以独立的将l 到r范围内的区块组体删除并只保留 S5. After the n nodes in the system have clearly responded, the nodes can independently delete the block groups in the range from l to r and keep only
其中,其中l是本次分片开始的区块组序号,r是本次分片结束的区块组序号。Among them, l is the serial number of the block group at the beginning of this fragmentation, and r is the serial number of the block group at the end of this fragmentation.
本发明的进一步技术方案是:所述步骤S4中计算的哈希值是确保每个节点都拥有数据片的摘要信息,以用于获取数据片时进行正确性验证。A further technical solution of the present invention is: in the step S4, calculating The hash value is to ensure that each node has the summary information of the data piece, which is used for correctness verification when obtaining the data piece.
本发明的进一步技术方案是:数据分片保存后,当节点i需要恢复高度为h的区块组体数据时,它向全网广播一条<query,h,i,signature>查询请求,处于存活状态的节点收到请求后将回复对应的分片,节点i收集到任意的n-2f-1个块后执行即可获取到需要的数据。A further technical solution of the present invention is: after data fragmentation is saved, when node i needs to restore the block group data with height h, it broadcasts a query request <query,h,i,signature> to the whole network, and is still alive After receiving the request, the node in the state will reply to the corresponding shard, and node i will execute it after collecting any n-2f-1 blocks. The required data can be obtained.
本发明的进一步技术方案是:节点在计算分片时任需保存每个分片的摘要,在获取到其他节点的分片时进行摘要比较。A further technical solution of the present invention is that: a node needs to save the digest of each fragment when calculating fragments, and compares the digests when obtaining fragments of other nodes.
本发明的进一步技术方案是:分片后数据查询根据时间线将区块组划分为hot、warm、cold三个状态区间,在每个状态区间使用不同的缓存策略。A further technical solution of the present invention is: data query after fragmentation divides the block group into three state intervals of hot, warm and cold according to the time line, and uses different caching strategies in each state interval.
本发明的进一步技术方案是:所述hot状态区间中保存的是最新的区块组集合被查询是高频的,应该被保存在每个节点上,以用于减少大规模数据片获取时的网络带宽和处理压力,定义Hot状态区间的长度为Lh,最新的区块高度为hmax,高度在(hmax-Lh,hmax]的区块组位于该状态区间。A further technical solution of the present invention is: the latest block group set stored in the hot state interval is frequently queried, and should be stored on each node, so as to reduce the cost of large-scale data slice acquisition. The network bandwidth and processing pressure define the length of the Hot state interval as L h , the height of the latest block is h max , and the block group whose height is (h max -L h , h max ] is located in this state interval.
本发明的进一步技术方案是:所述Warm状态区间中保存的是较新的区块组,用于区块组正确性检验的区块组请求,被使用的频率不高,区块组不必保存在每个节点上,仅保存在nw个节点上,其中(1<=nw<=2f+1);当nw个节点均处于宕机状态时,区块组查询使用RSCode进行批量恢复;定义Warm空间的长度为Lw,高度在(hmax-Lh-Lw,hmax-Lh]的区块组位于该状态区间内。A further technical solution of the present invention is that: the Warm state interval saves newer block groups, and the block group request used for the correctness check of the block group is not used frequently, and the block group does not need to be saved On each node, it is only stored on n w nodes, where (1 <= n w <= 2f+1); when n w nodes are all down, block group query uses RSCode for batch recovery ; Define the length of the Warm space as L w , and the block group whose height is (h max -L h -L w , h max -L h ] is located in the state interval.
本发明的进一步技术方案是:在节点使用布隆过滤器记录每个区块组的交易存在信息,在交易查询时快速定位到交易所处的区块组信息,所述布隆过滤器长度增加降低误判率。A further technical solution of the present invention is: use a Bloom filter at the node to record the transaction existence information of each block group, quickly locate the block group information at the exchange during transaction query, and the length of the Bloom filter increases Reduce the false positive rate.
本发明的进一步技术方案是:所述Cold状态区间保存很旧的区块组且被查询几率非常低,在新节点加入网络会被频繁访问;Cold状态区间将多个区块组分片合并成为一个块并重新计算块哈希减少区块组分片产生摘要的存储空间,高度在[0,hmax-Lh-Lw]的区块组位于该状态区间内。A further technical solution of the present invention is: the Cold state interval saves very old block groups and the probability of being queried is very low, and will be frequently accessed when a new node joins the network; the Cold state interval merges multiple block group shards into a One block and recalculating the block hash reduces the storage space for the digest generated by the block group fragmentation, and the block group with a height of [0,h max -L h -L w ] is located in this state interval.
本发明的进一步技术方案是:在新节点刚加入网络需要全量获取所有的区块组时,新节点需校验的分片哈希量会减少。A further technical solution of the present invention is: when a new node just joins the network and needs to acquire all block groups in full, the hash amount of the shards to be verified by the new node will be reduced.
本发明的有益效果是:可以使得区块链节点只存储原始数据的一个分片,并且分片最少只占原始数据的比例等于系统中正常节点的数量。同时,对新旧区块组体进行时间线划分并采取不同的缓存策略以换取对区块组和交易的快速查询。The beneficial effect of the present invention is that the blockchain node can only store one fragment of the original data, and the fragment only accounts for at least the proportion of the original data equal to the number of normal nodes in the system. At the same time, the new and old block groups are divided into time lines and different caching strategies are adopted in exchange for fast query of block groups and transactions.
附图说明Description of drawings
图1是本发明实施例提供的用于并行投票共识的数据分片方法的流程图。FIG. 1 is a flowchart of a data sharding method for parallel voting consensus provided by an embodiment of the present invention.
图2是本发明实施例提供的区块组分片工作过程,以存在一个恶意节点的4个节点场景为例的示意图。FIG. 2 is a schematic diagram of a working process of block group sharding provided by an embodiment of the present invention, taking a scenario of four nodes with one malicious node as an example.
图3是本发明实施例提供的基于时间线的缓存模型示意图。FIG. 3 is a schematic diagram of a cache model based on a timeline provided by an embodiment of the present invention.
具体实施方式Detailed ways
如图1所示,本发明提供的用于并行投票共识的数据分片方法,其详述如下:As shown in Figure 1, the data fragmentation method for parallel voting consensus provided by the present invention is described in detail as follows:
在区块链网络中,区块链每个节点在本地完整的存储全部区块链的复制,因此节点可以独立的进行区块校验、交易查询等行为。然而,区块链是持续增加并且不能删除的账本数据,这对节点的存储能力产生了很大的挑战。例如,截止到2019年12月,虚拟货币区块链约占260GB。如何在不影响安全性的前提下进行区块数据压缩是提高阶段系统可拓展性的核心问题。In the blockchain network, each node of the blockchain stores a complete copy of the entire blockchain locally, so the nodes can independently perform block verification, transaction query and other behaviors. However, the blockchain is the ledger data that is continuously increasing and cannot be deleted, which poses a great challenge to the storage capacity of nodes. For example, as of December 2019, the virtual currency blockchain accounted for about 260GB. How to compress block data without compromising security is the core issue to improve the scalability of the stage system.
本发明提供一种用于并行投票共识数据分片的方法,提出在并行投票共识网络中利用纠删码进行区块组体的批量分割方法,每个节点只存储原本数据的一个小分片,并能够保证在任何时间点都可以恢复出原始数据;提出了区块组体数据的分片流程,根据存储累积量在各个节点交互式地启动分片,并可以在多组数据中并行启动分片,同时能够保证系统在启动分片的时间点是安全的;提出了结合布隆过滤器的冷热数据不同缓存策略实现区块组和交易的查找优化。The present invention provides a method for parallel voting consensus data sharding, and proposes a batch segmentation method of block grouping by using erasure codes in a parallel voting consensus network, each node only stores a small shard of the original data, And it can ensure that the original data can be recovered at any point in time; the sharding process of block group data is proposed, and the sharding can be started interactively at each node according to the storage accumulation, and the sharding can be started in parallel in multiple groups of data. At the same time, it can ensure that the system is safe at the time of starting the sharding. Different caching strategies of hot and cold data combined with Bloom filter are proposed to realize the search optimization of block groups and transactions.
基于纠删码的数据分片Data Fragmentation Based on Erasure Code
纠删码不需要全部的分片即可恢复出原来的全部数据,这个特性很适合存在恶意和故障节点的拜占庭环境。通常早期生成的区块组访问查询频率是极低的,但是每个节点仍然要存储全量的区块组交易数据。结合纠删码的存储方案可以让节点仅存储交易集合的一个分片,并当需要的时候可以实时恢复出完整的区块组交易信息。Erasure codes do not require all shards to recover all the original data. This feature is very suitable for Byzantine environments with malicious and faulty nodes. Usually the access query frequency of the block group generated in the early stage is extremely low, but each node still needs to store the full amount of block group transaction data. The storage scheme combined with erasure codes allows nodes to store only one shard of the transaction set, and can restore the complete block group transaction information in real time when needed.
Reed-Solomon纠删码可以用一个<k,m>二元组表示,原始的数据M 被分割成k个数据块,同时使用矩阵运算产生m个校验块。对于任意的d 个块,当d∈k∪m&d≥k时,原始数据可以被恢复。因此,RS Code在最多m个块丢失或者暂时无法获取下能保证原始数据的安全性。The Reed-Solomon erasure code can be represented by a <k,m> two-tuple, the original data M is divided into k data blocks, and the matrix operation is used to generate m check blocks. For any d blocks, the original data can be recovered when d∈k∪m&d≥k. Therefore, the RS Code can guarantee the security of the original data when at most m blocks are lost or temporarily unavailable.
对于存在f个恶意节点的并行投票共识网络中,系统中最多会出现2f 个节点不响应的情况。假设系统中有n个节点,任何时刻最少时有n-2f个活性节点,为了保证原始数据任何时刻都能被恢复,系统应该采用(n-2f,2f) 配置的RS编码。For a parallel voting consensus network with f malicious nodes, at most 2f nodes will not respond in the system. Assuming that there are n nodes in the system, and there are at least n-2f active nodes at any time, in order to ensure that the original data can be recovered at any time, the system should use the (n-2f, 2f) configuration of RS coding.
考虑到区块组头中的元数据是经常访问的,此算法仅对存储了交易的区块组体BGB进行分片,BGBj表示高度为j的区块组体。对于任意的区块组体,RS码编码共产生n个块其中包括n-2f个数据块以及 2f个检验块每个记账节点只存储一个块,并当必要的时候请求其他任意2f-1块即可恢复区块组体本身,这样每个节点理论上只需要保存原始数据的1/n-2f,也即系统理论下正常节点的数量。Considering that the metadata in the block group header is frequently accessed, this algorithm only shards the block group BGB that stores the transaction, and BGB j represents the block group with height j. For any block group, RS code encoding generates a total of n blocks which includes n-2f blocks of data and 2f check blocks Each accounting node only stores one block, and when necessary, requests any other 2f-1 block to restore the block group itself, so that each node theoretically only needs to save 1/n-2f of the original data, and also That is, the number of normal nodes under the system theory.
本方案使用交易来进行交互式分片,每个区块都产生一次分片交易代价是高昂的,取而代之是定期进行一次分片。在进行编码前,需要将每个区块组体等比例分成n-2f份,每个数据块是所有区块组体相同位置的集合。This scheme uses transactions for interactive sharding. It is expensive to generate a shard transaction for each block. Instead, sharding is performed regularly. Before encoding, each block group needs to be divided into n-2f parts in equal proportions, and each data block is a collection of all block groups in the same position.
为了使得分片和节点之间的对应关系尽量随机,记账节点i所存储分片的序号定义Split(l,r,i)表示对从l到r的区块组体进行RS编码,并保留记账节点i对应的块 表示使用任意n-2f个分片恢复出l-r范围内的区块组体。In order to make the correspondence between shards and nodes as random as possible, the sequence number of shards stored by accounting node i Defining Split(l,r,i) means performing RS encoding on the block group from l to r, and retaining the block corresponding to the accounting node i Indicates that a block group within the range of lr is recovered using any n-2f shards.
数据分片流程Data sharding process
在本方案中分片方案是基于交易驱动的,系统存在一个存储因子M,当某一个范围内的区块组体体积之和大于M,系统将启动对这些区块组体的分片。存储因子的存在避免频繁地进行分片,导致节点计算压力过高。In this scheme, the sharding scheme is driven by transactions. There is a storage factor M in the system. When the sum of the volume of the block groups in a certain range is greater than M, the system will start the sharding of these block groups. The existence of the storage factor avoids frequent sharding, resulting in excessive computational pressure on nodes.
当前周期的主节点负责监控从上一次分片后区块组体的体积,并当体积和大于M时发起一条<split,l,r,signature>交易到网络中,其中l是本次分片开始的区块组序号,r是本次分片结束的区块组序号。当前的主节点可能是恶意的并且故意不发起分片,因为恶意的节点存在上限f,系统最多会在f个共识周期后启动本次分片。分片的启动是并行的,主节点无需等待上次分片结束即可开始本次分片。The master node of the current cycle is responsible for monitoring the volume of the block group after the last fragmentation, and when the sum of the volume is greater than M, initiates a <split,l,r,signature> transaction to the network, where l is the current fragmentation The starting block group sequence number, and r is the block group sequence number at the end of this sharding. The current master node may be malicious and deliberately does not initiate sharding, because the malicious node has an upper limit f, and the system will start this sharding after at most f consensus cycles. The sharding is started in parallel, and the master node can start this sharding without waiting for the end of the previous sharding.
节点i接收到split交易后,需要先等待获取从l到r范围内的所有区块组。之后,节点独立获取对应的分片编码并广播一条交易计算的哈希值的目的是保证所有节点确实收到了对应的区块组并进行了相同的分片。当系统中的所有n个节点都明确进行了回复后,节点可以独立的将l到r范围内的区块组体删除并只保留 After node i receives the split transaction, it needs to wait to obtain all block groups in the range from l to r. After that, the node independently obtains the corresponding fragment code and broadcast a transaction calculate The purpose of the hash value is to ensure that all nodes have indeed received the corresponding block group and performed the same sharding. When all n nodes in the system have responded explicitly, the nodes can independently delete the block groups in the range from l to r and keep only
本方案使用了一个较强的同步假设,系统中宕机的f个节点最终会在某个时间启动并获取到所有的区块组以及执行分片。否则,假设系统中当前存活的2f+1个节点已经进行了分片计算并删除了对应的区块组体后,f 个宕机的节点恢复有效并且之前的2f+1中f个正常节点宕机,此时剩下的 f个恶意节点只要保持沉默,那么只有f个节点拥有区块组体块数据,这样就无法恢复之前的区块组体。我们认为这种强同步假设是合理的,因为节点最终会有效并且节点不需要同时在线,分片启动是并行的,这样可以很快弥补节点宕机造成的时间差。This scheme uses a strong synchronization assumption, and f nodes that are down in the system will eventually start at a certain time and acquire all block groups and execute sharding. Otherwise, it is assumed that the currently surviving 2f+1 nodes in the system have performed sharding calculations and deleted the corresponding block group, then the f downtime nodes are restored and the f normal nodes in the previous 2f+1 are down. At this time, as long as the remaining f malicious nodes remain silent, only f nodes have the block data of the block group, so that the previous block group cannot be recovered. We think this strong synchronization assumption is reasonable, because the nodes will eventually be valid and the nodes do not need to be online at the same time, and the shards are started in parallel, which can quickly compensate for the time difference caused by node downtime.
当节点i需要恢复高度为h的区块组体数据时,它向全网广播一条When node i needs to restore the block group data of height h, it broadcasts a message to the whole network
<query,h,i,signature>查询请求,处于存活状态的节点收到请求后将回复对应的分片,节点i收集到任意的n-2f-1个块后执行即可获取到需要的数据。考虑到节点有可能是恶意的因此它发送的分片有可能是被修改的,节点在计算分片时任需要保存每个分片的摘要,并当获取到其他节点的分片时进行摘要比较。<query,h,i,signature> query request, the node in the surviving state will reply to the corresponding fragment after receiving the request, node i will execute it after collecting any n-2f-1 blocks The required data can be obtained. Considering that the node may be malicious, the shards it sends may be modified, the node needs to save the digest of each shard when calculating shards, and compare the digests when obtaining shards of other nodes. .
数据查询优化Data query optimization
分片的设计对存储进行了优化的同时,引发了查询效率低的问题。如果系统每次查询都需要用一次RS码恢复数据,会对查询性能造成了极大的影响。本方案采用时间线将区块组划分为hot、warm、cold三个状态区间,并分别使用了不同的缓存策略。While the design of sharding optimizes storage, it leads to the problem of low query efficiency. If the system needs to use the RS code to restore data every time it is queried, it will have a great impact on the query performance. This scheme uses a timeline to divide the block group into three state intervals: hot, warm, and cold, and uses different caching strategies respectively.
在区块链网络中,查询请求通常包括区块组查询和交易查询两类。区块组查询是指通过指定高度来查询对应的区块组(包括区块组头和区块组体)信息。交易查询是指通过指定交易哈希来查询对应的交易的全部信息。交易查询通常利用数据库(例如MongoDB、LevelDB)提供的索引机制来快速查找对应的交易。分片机制需要额外的机制来快速确定交易对应的位置。In a blockchain network, query requests usually include block group queries and transaction queries. Block group query refers to querying the corresponding block group (including block group header and block group body) information by specifying a height. Transaction query refers to querying all the information of the corresponding transaction by specifying the transaction hash. Transaction queries usually use the indexing mechanism provided by databases (such as MongoDB and LevelDB) to quickly find corresponding transactions. The sharding mechanism requires additional mechanisms to quickly determine where transactions correspond.
根据程序访问的局部性原理,越新的区块组被访问到的概率越高,那么它们应该出现在每个节点上,而更为陈旧的区块组被访问的频次很低,仅当需要的时候恢复数据即可。According to the principle of locality of program access, the newer block groups have a higher probability of being accessed, so they should appear on every node, while the older block groups are accessed very infrequently, only when needed data can be restored.
Hot空间中保存的是最新的区块组集合,区块组查询和交易查询在这一范围内都是高频的。因此无论区块组有无被分片,它们都应该被缓存在每个节点上。定义Hot空间的长度为Lh,最新的区块高度为hmax,那么高度在(hmax-Lh,hmax]的区块组位于这一空间内。The hot space saves the latest block group set, and block group queries and transaction queries are high-frequency within this range. So whether blockgroups are sharded or not, they should be cached on every node. The length of the Hot space is defined as L h , and the height of the latest block is h max , then the block group whose height is (h max -L h , h max ] is located in this space.
Warm空间中保存的是较新的区块组,这一空间中更多是用于进行区块组正确性检验的区块组请求,区块组中的交易相对而言是过期的,因此被使用到的频率并不高。区块组不必保存在每个节点上,仅需要保存在n 个节点上,其中(1<=nw<=2f+1)。当nw个节点都处于宕机状态时,区块组查询使用RS Code进行批量恢复。定义Warm空间的长度为Lw,那么高度在(hmax-Lh-Lw,hmax-Lh]的区块组位于这一空间内。Newer block groups are stored in the Warm space. This space is more for block group requests for correctness verification of the block group. The transactions in the block group are relatively expired, so they are The frequency used is not high. The block group does not have to be stored on each node, but only needs to be stored on n nodes, where (1<= nw <=2f+1). When n w nodes are all down, block group query uses RS Code for batch recovery. The length of the Warm space is defined as L w , then the block group whose height is (h max -L h -L w ,h max -L h ] is located in this space.
交易分片后要能够快速定位到所处的区块组,首先节点使用布隆过滤器记录每个区块组的交易存在信息,当交易查询时可以快速定位到交易有可能所处的区块组信息。考虑到布隆过滤器存在假阳性问题,适当增加布隆过滤器长度可以降低误判率。After the transaction is fragmented, it is necessary to quickly locate the block group it is in. First, the node uses the Bloom filter to record the transaction existence information of each block group. When the transaction is queried, it can quickly locate the block where the transaction is likely to be located. group information. Considering the false positive problem of the Bloom filter, appropriately increasing the length of the Bloom filter can reduce the false positive rate.
Cold空间保存的是很旧的区块组,交易查询和区块查询的几率是非常低的,然而这些数据当新节点加入网络会被频繁访问到。Cold空间将多个区块组分片合并成为一个块并重新计算块哈希这减少了区块组分片产生的摘要的存储空间。当新节点刚加入网络需要全量获取所有的区块组时,新节点需要校验的分片哈希量也会减少。高度在[0,hmax-Lh-Lw]的区块组位于这一空间内。Cold space saves very old block groups, the probability of transaction query and block query is very low, but these data will be frequently accessed when new nodes join the network. Cold space merges multiple block group shards into a single block and recalculates the block hash. This reduces the storage space for digests produced by block group shards. When a new node has just joined the network and needs to obtain all block groups in full, the amount of shard hashes that the new node needs to verify will also decrease. Block groups with heights in [0,h max -L h -L w ] are located in this space.
此时,布隆过滤器记录每个分片的交易存在信息,减少交易查询时布隆过滤器的比较次数,从而实现交易的快速定位。同时,每个分片会随机冗余保存到nc个节点上,nc可以是一个可以等于0的比较小的值,并在nc个缓存都失效下使用检验块恢复数据。At this time, the Bloom filter records the transaction existence information of each shard, reducing the number of comparisons of the Bloom filter during transaction query, so as to realize the rapid positioning of transactions. At the same time, each shard will be randomly and redundantly saved to n c nodes, n c can be a relatively small value that can be equal to 0, and the data will be recovered using the check block when n c caches are invalid.
本发明技术方案可以使得区块链节点只存储原始数据的一个分片,并且分片最少只占原始数据的比例等于系统设定中正常节点的数量。同时,对新旧区块组体进行时间线划分并采取不同的缓存策略以换取对区块组和交易的快速查询。The technical solution of the present invention can make the blockchain node only store one fragment of the original data, and the fragment only accounts for at least the proportion of the original data equal to the number of normal nodes in the system setting. At the same time, the new and old block groups are divided into time lines and different caching strategies are adopted in exchange for fast query of block groups and transactions.
本方案提出在并行投票共识网络中利用纠删码进行区块组体的批量分割方法,将一组区块组体内的每个交易只存储到一个节点,每个节点只存储原本数据的一个小分片,并能够保证在任何时间点都可以恢复出原始数据。This scheme proposes a batch segmentation method of block groups using erasure codes in a parallel voting consensus network, and stores each transaction in a group of blocks in only one node, and each node only stores a small portion of the original data. Fragmentation, and can guarantee that the original data can be recovered at any point in time.
本方案提出了区块组体数据的分片流程,根据存储累积量在各个节点交互式地启动分片,并可以在多组数据中并行启动分片,同时能够保证系统在启动分片的时间点是安全的。This scheme proposes the sharding process of block group data, interactively starts sharding at each node according to the storage accumulation, and can start sharding in multiple groups of data in parallel, and can ensure that the system starts sharding at the same time. point is safe.
本方案提出了结合布隆过滤器的冷热数缓存策略实现在分片下对区块组和交易的查找优化。This scheme proposes a hot and cold number caching strategy combined with Bloom filters to optimize the search and optimization of block groups and transactions under sharding.
以上所述仅为本发明的较佳实施例而已,并不用以限制本发明,凡在本发明的精神和原则之内所作的任何修改、等同替换和改进等,均应包含在本发明的保护范围之内。The above descriptions are only preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present invention shall be included in the protection of the present invention. within the range.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210072749.1A CN114723444A (en) | 2022-01-21 | 2022-01-21 | A Data Sharding Method for Parallel Voting Consensus |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210072749.1A CN114723444A (en) | 2022-01-21 | 2022-01-21 | A Data Sharding Method for Parallel Voting Consensus |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114723444A true CN114723444A (en) | 2022-07-08 |
Family
ID=82236261
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210072749.1A Pending CN114723444A (en) | 2022-01-21 | 2022-01-21 | A Data Sharding Method for Parallel Voting Consensus |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114723444A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117473020A (en) * | 2023-12-27 | 2024-01-30 | 湖南天河国云科技有限公司 | Data access method, system, computer storage medium and terminal device |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20170272100A1 (en) * | 2016-03-15 | 2017-09-21 | Cloud Crowding Corp. | Distributed Storage System Data Management And Security |
CN108512908A (en) * | 2018-03-13 | 2018-09-07 | 山东超越数控电子股份有限公司 | A kind of cloud storage fault tolerant mechanism based on Ceph and the web-based management platform based on Ceph |
CN109345386A (en) * | 2018-08-31 | 2019-02-15 | 阿里巴巴集团控股有限公司 | Transaction common recognition processing method and processing device, electronic equipment based on block chain |
CN109871366A (en) * | 2019-01-17 | 2019-06-11 | 华东师范大学 | A method for storing and querying blockchain shards based on erasure codes |
CN112104482A (en) * | 2020-08-11 | 2020-12-18 | 佛山赛思禅科技有限公司 | Consensus method based on parallel voting |
CN112364209A (en) * | 2020-12-09 | 2021-02-12 | 杭州复杂美科技有限公司 | Distributed data storage method, data query method, device and storage medium |
-
2022
- 2022-01-21 CN CN202210072749.1A patent/CN114723444A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20170272100A1 (en) * | 2016-03-15 | 2017-09-21 | Cloud Crowding Corp. | Distributed Storage System Data Management And Security |
CN108512908A (en) * | 2018-03-13 | 2018-09-07 | 山东超越数控电子股份有限公司 | A kind of cloud storage fault tolerant mechanism based on Ceph and the web-based management platform based on Ceph |
CN109345386A (en) * | 2018-08-31 | 2019-02-15 | 阿里巴巴集团控股有限公司 | Transaction common recognition processing method and processing device, electronic equipment based on block chain |
CN109871366A (en) * | 2019-01-17 | 2019-06-11 | 华东师范大学 | A method for storing and querying blockchain shards based on erasure codes |
CN112104482A (en) * | 2020-08-11 | 2020-12-18 | 佛山赛思禅科技有限公司 | Consensus method based on parallel voting |
CN112364209A (en) * | 2020-12-09 | 2021-02-12 | 杭州复杂美科技有限公司 | Distributed data storage method, data query method, device and storage medium |
Non-Patent Citations (2)
Title |
---|
Z. WANG ET AL.: "A Data Lightweight Scheme for Parallel Proof of Vote Consensus", 《2021 IEEE INTERNATIONAL CONFERENCE ON BIG DATA (BIG DATA)》 * |
赵羽龙等: "区块链增强型轻量级节点模型", 《计算机应用》 * |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117473020A (en) * | 2023-12-27 | 2024-01-30 | 湖南天河国云科技有限公司 | Data access method, system, computer storage medium and terminal device |
CN117473020B (en) * | 2023-12-27 | 2024-03-22 | 湖南天河国云科技有限公司 | Data access method, system, computer storage medium and terminal device |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111611315B (en) | Financial big data-oriented multi-fork tree structure block chain integrated optimization storage method | |
CN110474986B (en) | A consensus method, device and system based on blockchain system | |
WO2021027529A1 (en) | Block processing method and device, block consensus method and device and block synchronization method and device | |
WO2023045620A1 (en) | Transaction data processing method and apparatus, computer device and storage medium | |
WO2019024780A1 (en) | Light-weight processing method for blockchain, and blockchain node and storage medium | |
CN114915404A (en) | Block chain data storage extension model construction method for Internet of things | |
CN112039837B (en) | Electronic evidence preservation method based on block chain and secret sharing | |
CN110535687A (en) | Cooperative caching method based on lightweight block chain in Internet of vehicles environment | |
CN108959563A (en) | A kind of expansible block chain query method and system of capacity | |
CN113826355A (en) | Short Transaction Identifier Collision Detection and Reconciliation | |
US11870883B2 (en) | Blockchain-based data management of distributed binary objects | |
CN114385756A (en) | Method and blockchain node for executing transactions in blockchain | |
CN114511319A (en) | Block chain consensus method | |
CN112951357A (en) | Block chain-based virtual medical resource transverse expansion method | |
CN114745102A (en) | A Lightweight and Scalable Blockchain System Based on Edge Computing | |
CN116055579A (en) | Multi-alliance chain crossing method | |
CN114723444A (en) | A Data Sharding Method for Parallel Voting Consensus | |
CN115021945B (en) | Block chain transaction processing method and system | |
Wang et al. | A data lightweight scheme for parallel proof of vote consensus | |
Papadopoulos et al. | Continuous authentication on relational streams | |
CN115904625A (en) | Cross-node multi-virtual machine memory management method, system, terminal and medium | |
CN118157870A (en) | Cross-geographic time series data hierarchical consensus system and method based on alliance blockchain | |
CN116910173A (en) | Block chain-oriented verifiable efficient query method | |
CN114791788B (en) | A blockchain-based data storage method and device | |
CN114461730B (en) | Self-adaptive block data compression method based on remainder system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20220708 |
|
RJ01 | Rejection of invention patent application after publication |