WO2023070925A1 - Sharding method for blockchain transaction pool, system, storage medium and computer system - Google Patents

Sharding method for blockchain transaction pool, system, storage medium and computer system Download PDF

Info

Publication number
WO2023070925A1
WO2023070925A1 PCT/CN2021/141181 CN2021141181W WO2023070925A1 WO 2023070925 A1 WO2023070925 A1 WO 2023070925A1 CN 2021141181 W CN2021141181 W CN 2021141181W WO 2023070925 A1 WO2023070925 A1 WO 2023070925A1
Authority
WO
WIPO (PCT)
Prior art keywords
transaction
transaction pool
pool
standard
blockchain
Prior art date
Application number
PCT/CN2021/141181
Other languages
French (fr)
Chinese (zh)
Inventor
杨征
姚昱旻
王云丽
尹海波
谭林
冯斌
Original Assignee
湖南天河国云科技有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 湖南天河国云科技有限公司 filed Critical 湖南天河国云科技有限公司
Publication of WO2023070925A1 publication Critical patent/WO2023070925A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION 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/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3827Use of message hashing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION 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
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3236Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions

Abstract

The present invention relates to a sharding method for a blockchain transaction pool, a system, a storage medium and a computer system. Using the principle of ​​divide and conquer, an improvement to sharding a structure of a transaction pool is proposed. A single complete large blockchain transaction pool is sharded into multiple small standard transaction pools, so as to permit subsequent calls to process transactions or participate in other processes of the blockchain system. The present invention causes read-write lock competition of a thread for the transaction pool to be controlled within a limited small standard transaction pool. During a lock or unlock operation of the read-write lock, there is no need to lock or unlock the entire large blockchain transaction pool, preventing congestion problems between multiple operations, which can effectively reduce the frequency of conflicts and increase transaction throughput, thereby increasing the overall processing efficiency of the transaction pool and further increasing the overall performance of the blockchain system.

Description

区块链交易池的分片方法、系统、存储介质和计算机系统Fragmentation method, system, storage medium and computer system of blockchain transaction pool 技术领域technical field
本发明涉及区块链技术领域,特别是涉及一种交易池的分片技术。The invention relates to the technical field of block chains, in particular to a fragmentation technology of a transaction pool.
背景技术Background technique
区块链系统的交易是指发给区块链系统的一段请求数据,可用于部署智能合约,调用智能合约接口,维护智能合约的生命周期,以及管理资产和价值交换。交易主要由发送者、接受者、交易数据和交易签名四部分组成,是区块链系统各种应用的基础。The transaction of the blockchain system refers to a piece of request data sent to the blockchain system, which can be used to deploy smart contracts, call smart contract interfaces, maintain the life cycle of smart contracts, and manage assets and value exchanges. The transaction is mainly composed of four parts: sender, receiver, transaction data and transaction signature, which is the basis of various applications of the blockchain system.
以用户发起的交易为例,首先,用户需要用自己的私钥给自己创建的交易签名,然后把签名后的交易发送到区块链上,接着由区块链系统的多个节点完成共识处理,随后执行交易相关的智能合约代码,生成交易指定的状态数据,最后,由记账节点将交易打包到新发布区块里,和状态数据一起落盘存储。至此,该交易被区块链系统确认,而被确认的交易被认为同时具备了一致性和事务性。Taking the transaction initiated by the user as an example, first, the user needs to use his own private key to sign the transaction created by himself, and then send the signed transaction to the blockchain, and then complete the consensus processing by multiple nodes of the blockchain system , and then execute the smart contract code related to the transaction to generate the status data specified by the transaction. Finally, the accounting node packs the transaction into the newly released block and stores it together with the status data. So far, the transaction has been confirmed by the blockchain system, and the confirmed transaction is considered to have both consistency and transactionality.
区块链交易池(TxPool交易缓冲池),用来暂存未被加入到区块的交易(包括本节点创建的交易和其他节点广播过来的交易)。一方面,需要检验所有提交交易的合法性,另一方面,然后从中选择合法交易交由区块链系统的共识机制确认,并需要缓存所有待处理的合法交易。交易池作为区块链系统的核心部件,在交易发出到上链的整个生命周期里都有交易池的参与,因此,交易池的性能直接影响区块链系统性能。The blockchain transaction pool (TxPool transaction buffer pool) is used to temporarily store transactions that have not been added to the block (including transactions created by this node and transactions broadcast by other nodes). On the one hand, it is necessary to check the legitimacy of all submitted transactions; on the other hand, select legal transactions from them to be confirmed by the consensus mechanism of the blockchain system, and all pending legal transactions need to be cached. As the core component of the blockchain system, the transaction pool participates in the entire life cycle from transaction issuance to on-chain. Therefore, the performance of the transaction pool directly affects the performance of the blockchain system.
如图1所示(以太坊的交易池),区块链交易池的资源调度存在于每条交易从发出到上链的全生命周期里(包括:RPC线程,Sync线程,Channel线程,Verify线程和打包线程等)。例如,网络接收到一个待打包的交易,需要获取交易池的写锁(独占模式锁住),然后将交易写入交易池中,共识模块打包过程需要获取交易池读锁(共享模式锁住),从中提取交易进行执行,当交易执行完并获得区块后,获取写锁(独占模式锁住),从交易池中删除已打包交易。但是, 现有方法在该过程,对交易池整体频繁使用读写锁,导致交易池的锁竞争成为系统“热点”,制约了区块链系统的整体性能的进一步提升。尤其是,制约区块链系统交易吞吐率的提升(transaction-per-second,TPS每秒处理的交易的次数)随着用户量和交易量的增加,低TPS已经不能满足需求,成为制约区块链系统性能提升的瓶颈。As shown in Figure 1 (Ethereum’s transaction pool), the resource scheduling of the blockchain transaction pool exists in the entire life cycle of each transaction from issuance to on-chain (including: RPC thread, Sync thread, Channel thread, Verify thread and packaged threads, etc). For example, when the network receives a transaction to be packaged, it needs to obtain the write lock of the transaction pool (locked in exclusive mode), and then write the transaction into the transaction pool. The packaging process of the consensus module needs to obtain the read lock of the transaction pool (locked in shared mode) , extract the transaction from it for execution, when the transaction is executed and the block is obtained, obtain the write lock (locked in exclusive mode), and delete the packaged transaction from the transaction pool. However, the existing methods frequently use read-write locks on the transaction pool as a whole during this process, causing the lock competition in the transaction pool to become a "hot spot" in the system, which restricts the further improvement of the overall performance of the blockchain system. In particular, it restricts the improvement of the transaction throughput rate of the blockchain system (transaction-per-second, the number of transactions processed by TPS per second). With the increase in the number of users and transaction volume, low TPS can no longer meet the demand and become a restrictive block. The bottleneck of chain system performance improvement.
为了提升TPS,业界提出了不同的交易池优化方案。公开号为CN110599136A的专利,提供了一种区块链交易池流量管控的方法,通过获取区块链节点对应的用户集合,以及所述区块链节点对应的交易池的最大缓存容量,为所述用户集合中的每个用户分别配置与所述交易池关联的流量阈值,用以提供交易池的整体利用率。FISCO BCOS对交易池性能的优化采用拆分且并行执行交易验证任务、交易异步通知策略来优化交易流水线处理效率。In order to improve TPS, the industry has proposed different transaction pool optimization schemes. The patent with the publication number CN110599136A provides a method for controlling the flow of a blockchain transaction pool. By obtaining the user set corresponding to the blockchain node and the maximum cache capacity of the transaction pool corresponding to the blockchain node, the Each user in the user set is respectively configured with a traffic threshold associated with the transaction pool to provide an overall utilization rate of the transaction pool. FISCO BCOS optimizes the performance of the transaction pool by splitting and executing transaction verification tasks in parallel and asynchronous transaction notification strategies to optimize the efficiency of transaction pipeline processing.
现有区块链交易池进行读操作或写操作都是通过线程实现的,线程作为独立运行和调度的基本单位。现有的区块链系统有且仅有一个完整的交易池,通过读写锁进行调度,为了保持数据的一致性,每个操作都需要对交易池整体进行加锁或解锁,由于使用大量的锁导致多个操作之间产生堵塞。The existing blockchain transaction pool performs read or write operations through threads, and threads are the basic unit of independent operation and scheduling. The existing blockchain system has one and only one complete transaction pool, which is scheduled through read-write locks. In order to maintain data consistency, each operation needs to lock or unlock the transaction pool as a whole. Due to the use of a large number of Locks cause blocking between multiple operations.
因此,如何优化区块链交易池,避免频繁读写锁,进而提升区块链系统的整体性能,是目前区块链技术领域亟待解决的技术问题。Therefore, how to optimize the blockchain transaction pool, avoid frequent read-write locks, and improve the overall performance of the blockchain system is a technical problem that needs to be solved urgently in the field of blockchain technology.
发明内容Contents of the invention
为解决上述技术问题,本发明提供一种区块链交易池的分片方法,包括:In order to solve the above-mentioned technical problems, the present invention provides a fragmentation method of a blockchain transaction pool, including:
确定需要划分的标准交易池S i的数量X;其中X为正整数;2≤i≤X; Determine the quantity X of the standard transaction pool S i that needs to be divided; where X is a positive integer; 2≤i≤X;
为每个所述标准交易池S i,匹配一一对应的唯一标识; For each of the standard transaction pools S i , match a one-to-one unique identifier;
将每个所述标准交易池S i的唯一标识,作哈希运算,将每个所述标准交易池S i的唯一标识映射至哈希环上的点A i,以将区块链交易池,划分为X个标准交易池S iThe unique identifier of each standard transaction pool S i is hashed, and the unique identifier of each standard transaction pool S i is mapped to a point A i on the hash ring, so that the blockchain transaction pool , divided into X standard transaction pools S i .
进一步地,所述X等于N/3的取整数;所述N为区块链CPU的核心数量。Further, the X is equal to an integer of N/3; the N is the number of cores of the blockchain CPU.
进一步地,所述X的大小由CPU的核心数量、内存容量和网络带宽决定。Further, the size of X is determined by the number of CPU cores, memory capacity and network bandwidth.
进一步地,所述唯一标识为索引ID i;其中,ID i=Prefix+i;所述Prefix代表 所述标准交易池S i的前缀;i代表所述标准交易池S i的序号。 Further, the unique identifier is an index ID i ; wherein, ID i =Prefix+i; the Prefix represents the prefix of the standard transaction pool S i ; i represents the serial number of the standard transaction pool S i .
进一步地,所述前缀,为CPU节点的主机名或IP地址或物理地址MAC。Further, the prefix is the host name or IP address or physical address MAC of the CPU node.
进一步地,所述哈希运算,为MurmurHash。Further, the hash operation is MurmurHash.
另一方面,本发明还提供了一种区块链交易池的分片系统,包括:On the other hand, the present invention also provides a sharding system of a blockchain transaction pool, including:
数量确定单元,用于确定需要划分的标准交易池S i的数量X;其中X为正整数;2≤i≤X; Quantity determination unit, used to determine the quantity X of the standard transaction pool S i that needs to be divided; where X is a positive integer; 2≤i≤X;
标识匹配单元,与所述数量确定单元连接,用于为每个所述标准交易池S i,匹配一一对应的唯一标识; An identifier matching unit, connected to the quantity determination unit, for matching a one-to-one unique identifier for each of the standard transaction pools S i ;
映射分块单元,与所述标识匹配单元连接,用于将每个所述标准交易池S i的唯一标识,作哈希运算,将每个所述标准交易池S i的唯一标识映射至哈希环上的点A i,以将区块链交易池,划分为X个标准交易池S iThe mapping block unit is connected with the identification matching unit, and is used to perform a hash operation on the unique identification of each standard transaction pool S i , and map the unique identification of each standard transaction pool S i to the hash Point A i on the Greek ring to divide the blockchain transaction pool into X standard transaction pools S i .
进一步地,所述分片系统,用于执行权利要求1-5任意一项所述的分片方法。Further, the sharding system is configured to implement the sharding method according to any one of claims 1-5.
另一方面,本发明还提供了一种计算机可读存储介质,其上存储有用于执行上述任意的分片方法的计算机程序。In another aspect, the present invention also provides a computer-readable storage medium, on which is stored a computer program for executing any of the sharding methods described above.
另一方面,本发明还提供了一种计算机系统,包括上述计算机可读存储介质和一个或多个处理器;On the other hand, the present invention also provides a computer system, including the above-mentioned computer-readable storage medium and one or more processors;
所述处理器,被配置为运行所述计算机程序。The processor is configured to run the computer program.
本发明提供的区块链交易池的分片方法、系统、计算机可读存储介质和计算机系统,采用分治法的思想,提出对交易池结构的分片改进,将单个完整的大的区块链交易池,分片划分为若干小的标准交易池,以供后续调用处理交易或参与区块链系统的其它进程。使得线程对交易池的读写锁竞争控制在限定的小标准交易池范围内,在读写锁的加锁或解锁操作中,无需对整个大的区块链交易池进行读写锁的加锁或解锁操作,避免了多个操作之间的拥塞问题,能有效降低冲突的频率,提升交易吞吐率,从而提升交易池整体的处理效率、进而提升区块链系统的整体性能。The sharding method, system, computer-readable storage medium and computer system of the block chain transaction pool provided by the present invention adopt the idea of divide-and-conquer, propose an improvement to the sharding of the transaction pool structure, and separate a single complete large block Chain transaction pool, shards are divided into several small standard transaction pools for subsequent calls to process transactions or participate in other processes of the blockchain system. Make the thread's read-write lock competition control of the transaction pool within the limited small standard transaction pool. In the lock or unlock operation of the read-write lock, there is no need to lock the read-write lock for the entire large blockchain transaction pool. Or unlocking operation, avoiding the congestion problem between multiple operations, can effectively reduce the frequency of conflicts, improve the transaction throughput rate, thereby improving the overall processing efficiency of the transaction pool, thereby improving the overall performance of the blockchain system.
附图说明Description of drawings
图1为以太坊的交易池示意图;Figure 1 is a schematic diagram of the transaction pool of Ethereum;
图2为本发明区块链交易的处理方法的一个实施例的流程图;Fig. 2 is the flowchart of an embodiment of the processing method of block chain transaction of the present invention;
图3为本发明的标注交易池的划分示意图;Fig. 3 is a schematic diagram of division of the marked transaction pool of the present invention;
图4为本发明的区块链交易的处理方法的步骤S1的流程图;Fig. 4 is the flow chart of step S1 of the processing method of block chain transaction of the present invention;
图5为区块链交易池划分为4个标准交易池,映射至哈希环的示意图;Figure 5 is a schematic diagram of the blockchain transaction pool divided into 4 standard transaction pools and mapped to the hash ring;
图6为本发明的区块链交易的处理方法的步骤S2的流程图;Fig. 6 is the flow chart of step S2 of the processing method of block chain transaction of the present invention;
图7-8为本发明的标准交易池与交易在哈希环上的位置的两种示意图;Figures 7-8 are two schematic diagrams of the standard transaction pool and the position of transactions on the hash ring in the present invention;
图9为本发明的区块链交易的处理方法的步骤S23的流程图;FIG. 9 is a flowchart of step S23 of the processing method of blockchain transactions of the present invention;
图10为本发明的区块链交易的处理方法的步骤S23b的一个实施例的流程图;FIG. 10 is a flowchart of an embodiment of step S23b of the method for processing blockchain transactions of the present invention;
图11为本发明的区块链交易的处理方法的步骤S23b的另一个实施例的流程图;FIG. 11 is a flow chart of another embodiment of step S23b of the method for processing blockchain transactions of the present invention;
图12为本发明的区块链交易的处理方法的步骤S0的流程图;Fig. 12 is a flowchart of step S0 of the processing method of blockchain transactions of the present invention;
图13为本发明的区块链交易的处理方法的步骤S01的一个实施例的流程图;FIG. 13 is a flowchart of an embodiment of step S01 of the method for processing blockchain transactions of the present invention;
图14为本发明的区块链交易的处理方法的步骤S01的另一个实施例的流程图;FIG. 14 is a flow chart of another embodiment of step S01 of the method for processing blockchain transactions of the present invention;
图15为本发明的区块链交易的处理系统的一个实施例的结构框图。Fig. 15 is a structural block diagram of an embodiment of the blockchain transaction processing system of the present invention.
具体实施方式Detailed ways
如图2所示,给出了本发明区块链交易的处理方法的一个具体实施例,包括:分片步骤S1和调用步骤S2。As shown in Fig. 2, a specific embodiment of the method for processing blockchain transactions of the present invention is given, including: fragmentation step S1 and calling step S2.
S1:将一个区块链交易池Pool,划分为X个标准交易池(SubPool i,后续简称为S i);其中,X为正整数;2≤i≤X。具体的,(如图3所示),分片交易池系统,可选但仅限于包括一个区块链交易池(分片交易池)和若干个标准交易池等实体构成。各实体在两层交易池系统中所扮演的角色与拥有的功能具体介绍如下:1、分片交易池:该池接口和普通交易池接口相同,通过增加一个交易分片处理中间层,隔离交易池上层业务逻辑,实现与普通交易池无差异化的访问方式。分片交易池具备两个关键组件:(1)交易池分片装置,该装置可选 但不仅限于采用一种基于一致性哈希环的交易池分片算法实现,由于交易哈希具备较好离散性,交易池交易具备较好的平衡性,可实现交易较均匀的分布在各标准交易池;(2)交易池交易合并装置,该装置主要是对分片交易池进行交易排序获取时需要用到,主要实现一个先进先出的排序方法。在公有链模式下,合并装置还需要基于最大收益率对交易进行排序。另外,该装置构建一个全局的交易优先队列,用于实现对不同标准交易池的交易排序方法。2、标准交易池:X个标准交易池一致,满足区块链常规交易处理的所有流程,与具体区块链采用的网络模块和共识算法相关,包括对单独标准交易池的写入、交易排序、读取、删除几个标准接口。 S1: Divide a blockchain transaction pool Pool into X standard transaction pools (SubPool i , hereinafter referred to as S i ); where X is a positive integer; 2≤i≤X. Specifically, (as shown in Figure 3), the shard transaction pool system is optional but limited to include a blockchain transaction pool (shard transaction pool) and several standard transaction pools and other entities. The roles and functions of each entity in the two-tier transaction pool system are introduced in detail as follows: 1. Fragmented transaction pool: The interface of this pool is the same as that of a common transaction pool. By adding a transaction shard to process the middle layer, transactions are isolated The business logic on the upper layer of the pool realizes an access method that is indistinguishable from ordinary transaction pools. The sharded transaction pool has two key components: (1) The transaction pool sharding device, which is optional but not limited to a transaction pool sharding algorithm based on a consistent hash ring. Since the transaction hash has a better Discrete, the transactions in the transaction pool have a better balance, which can achieve a more even distribution of transactions in each standard transaction pool; (2) transaction pool transaction merging device, which is mainly required for transaction sorting and acquisition of shard transaction pools Used to implement a first-in-first-out sorting method. In the public chain mode, the merger device also needs to sort the transactions based on the maximum yield. In addition, the device constructs a global transaction priority queue, which is used to realize the transaction sorting method for different standard transaction pools. 2. Standard transaction pool: The X standard transaction pools are consistent and meet all the procedures of the regular transaction processing of the block chain, which is related to the network module and consensus algorithm adopted by the specific block chain, including writing to a separate standard transaction pool and ordering transactions , Read, delete several standard interfaces.
S2:根据当前交易的特征值,调用上述标准交易池中的1至X-1个,完成当前交易。S2: According to the characteristic value of the current transaction, call 1 to X-1 in the above standard transaction pool to complete the current transaction.
在该实施例中,本发明的区块链交易的处理方法,采用分治法的思想,提出对交易池结构的分片改进,将单个完整的大的区块链交易池,分片划分为若干小的标准交易池,根据当前交易的特征值调用适合的小标准交易池处理完成,将线程对交易池的读写锁竞争控制在限定的小标准交易池范围内,在读写锁的加锁或解锁操作中,无需对整个大的区块链交易池进行读写锁的加锁或解锁操作,避免了多个操作之间的拥塞问题,能有效降低冲突的频率,提升交易吞吐率,从而提升交易池整体的处理效率、进而提升区块链系统的整体性能。In this embodiment, the block chain transaction processing method of the present invention adopts the idea of divide and conquer, proposes an improvement to the fragmentation of the transaction pool structure, and divides a single complete large block chain transaction pool into fragments For several small standard transaction pools, call the appropriate small standard transaction pool according to the characteristic value of the current transaction to complete the processing, and control the thread's read-write lock competition for the transaction pool within the limited small standard transaction pool. In the lock or unlock operation, there is no need to lock or unlock the entire large blockchain transaction pool, which avoids the congestion problem between multiple operations, effectively reduces the frequency of conflicts, and improves transaction throughput. Thereby improving the overall processing efficiency of the transaction pool, thereby improving the overall performance of the blockchain system.
具体的,如图4所示,步骤S1中,分片步骤可选但不仅限于包括:Specifically, as shown in Figure 4, in step S1, the fragmentation step is optional but not limited to include:
S11:确定将原本完整的区块链交易池,划分为若干标准交易池的数量X。具体的,该数量X为经验值,可选但不仅限于由本领域技术人员根据节点自身CPU的核心数量N,即并行处理能力,而预先自由设定,优选为等于N/3的取整数。更为具体的,该数量X,可预先设置,通过输入设备直接输入;或根据当前情况计算得到。更为具体的,该数量X,可选但不仅限于由CPU的核心数量、内存大小及网络带宽决定。示例的,以当前区块链系统中,CPU的核心数量为N个、内存大小为M G、带宽为L兆为例,X可选但不仅限于等于K 1×N+K 2×M+K 3×L。其中,K 1、K 2、K 3为各影响因素的影响因子。具体各影响因子的数值,可选但不仅限于由本领域技术人员根据该区块链系统的应用场景 而自由设定。示例的,在区块链系统应用于运算优先考虑的业务场景下,以影响因子K 1为重,在区块链系统应用于缓存优先考虑的业务场景下,以影响因子K 2为重,在区块链系统应用于网络吞吐优先考虑的业务场景下,以影响因子K 3为重。 S11: Determine the number X of dividing the original complete blockchain transaction pool into several standard transaction pools. Specifically, the number X is an empirical value, which can be optionally but not limited to be set freely in advance by those skilled in the art according to the core number N of the node's own CPU, that is, the parallel processing capability, preferably an integer equal to N/3. More specifically, the quantity X can be preset and directly input through the input device; or can be calculated according to the current situation. More specifically, the number X is optional but not limited to being determined by the number of CPU cores, memory size, and network bandwidth. For example, in the current blockchain system, the number of CPU cores is N, the memory size is M G, and the bandwidth is L megabytes. X is optional but not limited to K 1 ×N+K 2 ×M+K 3 ×L. Among them, K 1 , K 2 , and K 3 are the influencing factors of each influencing factor. The specific value of each influencing factor can be optional but not limited to be freely set by those skilled in the art according to the application scenario of the blockchain system. For example, in the business scenario where the blockchain system is applied to computing priority, the impact factor K 1 is the most important, and when the blockchain system is applied to the cache priority business scenario, the impact factor K 2 is the most important. When the blockchain system is applied to business scenarios where network throughput is prioritized, the impact factor K 3 is the most important.
S12:为划分的每个标准交易池S i(2≤i≤X),匹配一一对应的唯一标识。具体的,可选但不仅限于为X个标准交易池的每个标准交易池S i创建类似于身份证名片一样的索引ID i,作为对应标准交易池的唯一标识。更为具体的,该索引ID i可选但不仅限于以Prefix+i表示(即:ID i=Prefix+i)。其中,Prefix代表交易池前缀,可选但不仅限于为节点的主机名或节点的IP地址或物理地址MAC;i代表第i个标准交易池,为X个标准交易池所标记的序号。 S12: For each divided standard transaction pool S i (2≤i≤X), match a one-to-one unique identifier. Specifically, it is optional but not limited to create an index ID i similar to an ID card for each standard transaction pool S i of the X standard transaction pools, as the unique identifier of the corresponding standard transaction pool. More specifically, the index ID i may be optionally but not limited to be represented by Prefix+i (ie: ID i =Prefix+i). Among them, Prefix represents the prefix of the transaction pool, which is optional but not limited to the host name of the node or the IP address or physical address MAC of the node; i represents the i-th standard transaction pool, and is the serial number marked by the X standard transaction pool.
S13:将每个标准交易池的唯一标识,作哈希运算,以将每个标准交易池S i的唯一标识(可选但不仅限于为索引ID i)映射至哈希环上的点A i(如图5所示,为划分为4个标准交易池的示意图,A 1-A 4分别映射为S 1-S 4)。具体的,以该唯一标识为索引ID i为例,计算Hash(IDi),将匹配于X个标准交易池的所有唯一标识,一一映射到哈希环上。具体的,可选但不仅限于将所有标准交易池S 1,..,S i,..,S x的索引ID 1,..,ID i,..,ID x依次作为一致性哈希操作函数Hash的输入,经过Hash(IDi),映射到[0,2 32-1]数值空间上,把输出结果的区间首尾相连,形成一个顺时针增长的哈希环,如图5所示(4个标准交易池划分完成后,形成的哈希环示意图)。更为具体的,期间运用的哈希运算Hash可选但不仅限于为MurmurHash。 S13: Perform a hash operation on the unique identifier of each standard transaction pool to map the unique identifier of each standard transaction pool S i (optional but not limited to index ID i ) to point A i on the hash ring (As shown in Figure 5, it is a schematic diagram of four standard transaction pools, A 1 -A 4 are respectively mapped to S 1 -S 4 ). Specifically, taking the unique identifier as index ID i as an example, Hash(IDi) is calculated, and all unique identifiers matching X standard transaction pools are mapped to the hash ring one by one. Specifically, it is optional but not limited to use the index ID 1 , .., ID i , .., ID x of all standard transaction pools S 1 , .., S i , .., S x as consistent hash operations in sequence The input of the function Hash is mapped to the [0,2 32 -1] numerical space through Hash(IDi), and the intervals of the output results are connected end to end to form a clockwise-growing hash ring, as shown in Figure 5 (4 Schematic diagram of the hash ring formed after the division of standard transaction pools). More specifically, the hash operation Hash used during the period is optional but not limited to MurmurHash.
在该实施例中,给出了步骤S1的一个具体实施方式,即如何将一个完整的大区块链交易池Pool分块划分为多个小标准交易池S i。其基于一致性哈希环,把标准交易池通过一致性哈希算法全部映射到[0,2 32-1]的数值空间上,再将这个数值空间首尾相连形成哈希环,不仅解决了标准交易池的一一对应问题,避免造成混乱和误差;还由于哈希算法具备较好的离散性,使得标准交易池具备较好的平衡性,可使后续交易较均匀的散落分布在各标准交易池中。值得注意的,该分片步骤是如何将大的区块链交易池划分为小标准交易池的完整技术方案,其可选但不仅限于应用于后续调用中完成交易处理过程,还可应用于区块链系 统的其它进程中,解决其它需要全局调用区块链交易池,以全局锁的技术问题,更为具体的,该标准交易池也并非交易池的最小划分,划分的标准交易池还可按此方法进行进一步细分,划分为更小的标准交易池。 In this embodiment, a specific implementation of step S1 is given, that is, how to divide a complete large blockchain transaction pool Pool into multiple small standard transaction pools S i . Based on the consistent hash ring, it maps all the standard transaction pools to the numerical space of [0,2 32 -1] through the consistent hash algorithm, and then connects this numerical space end to end to form a hash ring, which not only solves the problem of standard The one-to-one correspondence of the transaction pool avoids confusion and errors; and because the hash algorithm has better discreteness, the standard transaction pool has a better balance, which can make subsequent transactions more evenly distributed among standard transactions in the pool. It is worth noting that this sharding step is a complete technical solution for how to divide a large blockchain transaction pool into small standard transaction pools. It is optional but not limited to be used in subsequent calls to complete the transaction processing process, and can also be applied to regional In other processes of the blockchain system, solve other technical problems that require global calls to the blockchain transaction pool to lock globally. More specifically, the standard transaction pool is not the smallest division of the transaction pool, and the divided standard transaction pool can also be This method is further subdivided into smaller pools of standard transactions.
更为具体的,如图6所示,步骤S2,可选但不仅限于,包括:More specifically, as shown in Figure 6, step S2 is optional but not limited to, including:
S21:生成当前交易(Transaction j,简称为T j)的特征值。具体的,可选但不仅限于采用当前交易T j的Nonce值或者当前交易T j本身的哈希值作为特征值。具体的,本领域技术人员可选但不仅限于通过本地的通用唯一识别码生成器为新进候选交易,即当前交易生成Nonce值。值得注意的,与每个标准交易池一样,该Nonce值、哈希值对于每个新进候选交易而言,也是具有唯一标识的,其能应用于后续哈希运算,以将每个当前交易T j,都映射到哈希环上的固定一点。 S21: Generate feature values of the current transaction (Transaction j , T j for short). Specifically, it is optional but not limited to adopting the Nonce value of the current transaction T j or the hash value of the current transaction T j itself as the characteristic value. Specifically, those skilled in the art may optionally, but not limited to, use a local UUID generator to generate a Nonce value for the new candidate transaction, that is, the current transaction. It is worth noting that, like each standard transaction pool, the Nonce value and hash value also have a unique identifier for each new candidate transaction, which can be applied to subsequent hash operations to convert each current transaction T j , are all mapped to a fixed point on the hash ring.
S22:将当前交易T j的特征值,即上述确定的Nonce值或哈希值,作哈希运算,以将当前交易T j映射至哈希环上的点B jS22: Perform a hash operation on the characteristic value of the current transaction T j , that is, the above-mentioned determined Nonce value or hash value, so as to map the current transaction T j to the point B j on the hash ring.
S23:根据点A i和B j的位置,对当前交易T j,调用标准交易池S i,完成当前交易。 S23: According to the positions of points A i and B j , call the standard transaction pool S i for the current transaction T j to complete the current transaction.
为便于理解本发明,在详细讲述如何调用标准交易池S i之前,先以图5为例,做个示例性约定,本领域技术人员可以理解的,在哈希值与标准交易池的映射表中,通过查表可以确定从点A 1-A 2这段圆弧上的所有哈希值(0-2 32×1/4]所对应的交易都优先调用A 2所对应标准交易池S 2;从点A 2-A 3这段圆弧上的所有哈希值(2 32×1/4‐2 32×1/2]所对应的交易都优先调用A 3所对应标准交易池S 3;从点A 3-A 4这段圆弧上的所有哈希值(2 32×1/2‐2 32×3/4]所对应的交易都优先调用A 4所对应标准交易池S 4;从点A 4-A 1这段圆弧上的所有哈希值(2 32×3/4‐2 32-1]所对应的交易都优先调用A 1所对应标准交易池S 1In order to facilitate the understanding of the present invention, before describing in detail how to call the standard transaction pool S i , first take Figure 5 as an example to make an exemplary agreement. Those skilled in the art can understand that the mapping table between the hash value and the standard transaction pool In , by looking up the table, it can be determined that all transactions corresponding to the hash value (0-2 32 ×1/4] on the arc from point A 1 to A 2 will preferentially call the standard transaction pool S 2 corresponding to A 2 ; All transactions corresponding to the hash value (2 32 × 1/4‐2 32 × 1/2] on the arc from point A 2 -A 3 will first call the standard transaction pool S 3 corresponding to A 3 ; All transactions corresponding to the hash value (2 32 × 1/2‐2 32 × 3/4] on the arc from point A 3 -A 4 will first call the standard transaction pool S 4 corresponding to A 4 ; All transactions corresponding to the hash value (2 32 ×3/4‐2 32 -1] on the arc of point A 4 -A 1 will first call the standard transaction pool S 1 corresponding to A 1 .
具体的,若点A i和B j重合,如图7所示,即该当前交易T j在哈希环上的位置B j恰好与某个标准交易池S i的位置A i重合(这种情况是很少的,因为哈希环上包括2 32-1个密密麻麻的点,均可对应某个交易,而标准交易池S i的数量没这么多,只是哈希环上均布的零散点),即落入标准交易池S i的管辖范围,则该当前交易T j优先于调用该标准交易池S i完成交易。如图7所示,在标准交易池S 1-S 4 的四个点位A 1-A 4中,当前交易T j在哈希环上的位置B j与标准交易池S 2重合,即落入标准交易池S 2的管辖范围,优先考虑调用该标准交易池S 2完成交易。更为具体的,可选但不仅限于还需要考虑该标准交易池S i的交易数量是否超过设定阈值,若超过则需等待或者调用其相邻的两个标准交易池S i+1、S i-1(即如图5示例的,调用S 1或S 3),若未超过则直接调用标准交易池S i(S 2)完成交易。当然,更为具体的,还需要考虑S i+1、S i-1交易数量是否超过设定阈值,若超过则需等待,直至S i、S i+1、S i-1中的1至X-1个的交易数量未超过设定阈值,则选其完成当前交易T j。具体的S i、S i+1、S i-1的优先级及判断标准,可由本领域技术人员根据实际需求而任意设定。 Specifically, if points A i and B j coincide, as shown in Figure 7, that is, the position B j of the current transaction T j on the hash ring happens to coincide with the position A i of a certain standard transaction pool S i (this The situation is very rare, because the hash ring includes 2 32 -1 densely packed points, all of which can correspond to a certain transaction, while the number of standard transaction pool S i is not so many, just scattered points evenly distributed on the hash ring ), that is, falls under the jurisdiction of the standard transaction pool S i , then the current transaction T j has priority over calling the standard transaction pool S i to complete the transaction. As shown in Figure 7, in the four points A 1 -A 4 of the standard transaction pool S 1 -S 4 , the position B j of the current transaction T j on the hash ring coincides with the standard transaction pool S 2 , that is, Into the jurisdiction of the standard transaction pool S2 , priority is given to calling the standard transaction pool S2 to complete the transaction. More specifically, optional but not limited to, it is also necessary to consider whether the number of transactions in the standard transaction pool S i exceeds the set threshold. If it exceeds, it needs to wait or call its two adjacent standard transaction pools S i+1 , S i-1 (that is, calling S 1 or S 3 as shown in Figure 5 ), if not exceeded, directly call the standard transaction pool S i (S 2 ) to complete the transaction. Of course , more specifically, it is also necessary to consider whether the number of transactions of S i+1 and S i-1 exceeds the set threshold. If the number of X-1 transactions does not exceed the set threshold, it will be selected to complete the current transaction T j . The specific priorities and judgment criteria of S i , S i+1 , and S i-1 can be set arbitrarily by those skilled in the art according to actual needs.
若点A i和B j不重合,如图8所示,即该当前交易T j在哈希环上的位置B j没有与任何一个标准交易池S i的位置A i重合(这种情况更常见,因为2 32数量相当庞大,如上所述的恰巧重合的机会相当少),而是位于哈希环的相邻两个标准交易池(S i与S i-1)所组成的一段弧上(这段弧上散落了很多个哈希值),即落入该两个标准交易池的共同管辖范围,此时可以选择标准交易池S i和标准交易池S i-1中的任意一个来完成当前交易。具体选用哪个标准交易池可查找哈希值与标准交易池的映射表确定。 If the points A i and B j do not coincide, as shown in Figure 8, that is, the position B j of the current transaction T j on the hash ring does not coincide with the position A i of any standard transaction pool S i (this situation is more Common, because the number of 2 32 is quite large, and the chance of coincidence as mentioned above is quite small), but it is located on an arc formed by two adjacent standard transaction pools (S i and S i-1 ) of the hash ring (There are a lot of hash values scattered on this arc), that is, it falls into the common jurisdiction of the two standard transaction pools. At this time, you can choose any one of the standard transaction pool S i and the standard transaction pool S i-1 to Complete the current transaction. Which standard transaction pool to choose can be determined by looking up the mapping table between the hash value and the standard transaction pool.
如图8所示的,当前交易T j在哈希环上的位置B j没有与任何一个标准交易池S i的位置重合,而是位于A 3和A 2所组成的一段弧上。那么我们通过查表,可以优选A 3、A 2所对应的S 3和S 2中的任何一个来完成当前交易。当然,同样的要考虑,这两个标准交易池S 3和S 2的交易数量是否超过设定阈值。具体的,可选但不仅限于优先考虑顺时针方向上离B j距离最近的A i所对应的S i(如图8所示的A 3),作为完成当前交易的首选交易池,若该标准交易池S i的交易数量未超过设定阈值,则调用S i,若超过,则考虑逆时针方向上离B j距离最近的A i-1所对应的S i-1(如图8所示的A 2),作为完成当前交易的二选交易池,若该标准交易池S i-1的交易数量未超过设定阈值,则调用S i-1,若超过则等待,再次判断S i,直到S i和S i-1中有一个的交易数量未超过设定阈值时,调用其一。 As shown in Figure 8, the position B j of the current transaction T j on the hash ring does not coincide with the position of any standard transaction pool S i , but is located on an arc formed by A 3 and A 2 . Then we can choose any one of S 3 and S 2 corresponding to A 3 and A 2 to complete the current transaction by looking up the table. Of course, it is also necessary to consider whether the number of transactions in the two standard transaction pools S3 and S2 exceeds the set threshold. Specifically, it is optional but not limited to give priority to the S i corresponding to the A i closest to B j in the clockwise direction (A 3 as shown in Figure 8), as the preferred transaction pool for completing the current transaction, if the standard If the number of transactions in the transaction pool S i does not exceed the set threshold, call S i , if it exceeds, consider the S i-1 corresponding to the A i-1 closest to B j in the counterclockwise direction (as shown in Figure 8 A 2 ), as the secondary transaction pool for completing the current transaction, if the number of transactions in the standard transaction pool S i-1 does not exceed the set threshold, call S i-1 , if it exceeds, wait, and judge S i again, Until the transaction quantity of one of S i and S i-1 does not exceed the set threshold, call one of them.
具体的,如图9所示,上述S23,可选但不仅限于包括:Specifically, as shown in Figure 9, the above S23 may optionally include, but is not limited to:
S23a:判断点B j的位置是否与某个标准交易池S i对应的点A i的位置重合; S23a: Judging whether the position of point B j coincides with the position of point A i corresponding to a certain standard trading pool S i ;
S23b:若重合,则调用点A i所对应的标准交易池S i,完成当前交易; S23b: If they overlap, call the standard transaction pool S i corresponding to point A i to complete the current transaction;
S23c:若不重合,则调用与点B j顺时针方向最近的点A i所对应的标准交易池S i或与点B j逆时针方向最近的点A i-1所对应的标准交易池S i-1,完成当前交易。 S23c: If there is no coincidence, call the standard transaction pool S i corresponding to the point A i closest to point B j in the clockwise direction or the standard transaction pool S corresponding to the point A i-1 closest to point B j in the counterclockwise direction i-1 , complete the current transaction.
在该实施例中,给出了本发明处理方法,在处理当前交易时,如何在X个标准交易池中,均衡调用某个标准交易池S i来完成当前交易的具体实施例。通过重合和不重合的两种判断,综合考虑两种情况,分别对待,能够将每个当前交易T j,离散分配至X个标准交易池S i,进一步确保在读写锁的加锁或解锁操作中,无需对整个大的区块链交易池进行读写锁的加锁或解锁操作,避免了多个操作之间的拥塞问题,能有效降低冲突的频率,提升交易吞吐率,从而提升交易池整体的处理效率、进而提升区块链系统的整体性能。值得注意的,该调用步骤是如何在X个标准交易池Si中有选择性的调用合适标准交易池的完整技术方案,其可选但不仅限于应用于前序分片步骤中完成交易处理过程,还可应用于本发明分治思想下的其它分片方法中,解决其它需要全局调用区块链交易池,以全局锁的技术问题。 In this embodiment, the processing method of the present invention is given. When processing the current transaction, how to call a certain standard transaction pool S i in a balanced manner among X standard transaction pools to complete the current transaction. Through the two judgments of coincidence and non-coincidence, considering the two situations comprehensively and treating them separately, each current transaction T j can be discretely allocated to X standard transaction pools S i , to further ensure the locking or unlocking of read-write locks During operation, there is no need to lock or unlock the read-write lock for the entire large blockchain transaction pool, avoiding the congestion problem between multiple operations, effectively reducing the frequency of conflicts, improving transaction throughput, and thus improving transaction The overall processing efficiency of the pool improves the overall performance of the blockchain system. It is worth noting that this call step is a complete technical solution for how to selectively call the appropriate standard transaction pool in the X standard transaction pools Si, which can be optionally but not limited to be applied to the previous sharding step to complete the transaction processing process. It can also be applied to other sharding methods under the divide-and-conquer idea of the present invention to solve other technical problems that require a global call to the blockchain transaction pool to lock globally.
优选的,为避免S23b某个标准交易池S i的处理数量达到设定上限,造成系统崩盘或紊乱,本领域技术人员可选但不仅限于在判断位置重合之后,及调用标准交易池S i之前,还插入一个判断该标准交易池S i的交易数量是否达到设定阈值的步骤。具体的,如图10所示,步骤S23b,还可选但不仅限于包括: Preferably, in order to prevent the processing quantity of a certain standard transaction pool S i from reaching the set upper limit in S23b, causing system crash or disorder, those skilled in the art can choose, but not limited to, after judging that the position overlaps, and before calling the standard transaction pool S i , a step of judging whether the transaction quantity of the standard transaction pool S i reaches a set threshold is also inserted. Specifically, as shown in Figure 10, step S23b may also optionally include, but is not limited to:
S23b1:若重合,则判断标准交易池S i的交易数量是否超过设定阈值; S23b1: If they overlap, judge whether the transaction quantity of the standard transaction pool S i exceeds the set threshold;
S23b2:若未超过设定阈值,则调用标准交易池S i,完成当前交易; S23b2: If the set threshold is not exceeded, call the standard transaction pool S i to complete the current transaction;
S23b3:若超过设定阈值,则等待,并返回S23b1再判断,直到标准交易池S i的交易数量未超过设定阈值,完成当前交易。 S23b3: If it exceeds the set threshold, wait, and return to S23b1 to judge again, until the transaction quantity of the standard transaction pool S i does not exceed the set threshold, the current transaction is completed.
类似的,为避免S23c某个标准交易池S i的处理数量达到设定上限,造成系统崩盘或紊乱,本领域技术人员可选但不仅限于在S i的处理数量达到设定上限时,考虑S i-1或其它可选的标准交易池,具体调用优先级及考虑哪些个标准交易池,可由本领域技术人员根据实际情况而自由设定。优选的,考虑S i或S i-1。更为优选的,在判断位置重合之后,及调用标准交易池S i或S i-1之前,还插入一个判断该标准交易池S i或S i-1的交易数量是否达到设定阈值的步骤。具体的,如图 10所示,步骤S23c,还可选但不仅限于包括: Similarly, in order to avoid S23c when the processing quantity of a certain standard transaction pool S i reaches the set upper limit, causing system crash or disorder, those skilled in the art can choose but not limited to when the processing quantity of S i reaches the set upper limit, consider S i-1 or other optional standard transaction pools, the specific calling priority and which standard transaction pools are considered can be freely set by those skilled in the art according to the actual situation. Preferably, S i or S i-1 is considered. More preferably, after judging that the positions overlap, and before calling the standard transaction pool S i or S i-1 , a step of judging whether the transaction quantity of the standard transaction pool S i or S i-1 reaches the set threshold is also inserted . Specifically, as shown in FIG. 10, step S23c may also optionally include, but is not limited to:
S23c1:若不重合,则判断与点B j顺时针方向最近的点A i所对应的标准交易池S i的交易数量,是否超过设定阈值; S23c1: If they do not overlap, determine whether the transaction quantity of the standard transaction pool S i corresponding to the point A i closest to point B j in the clockwise direction exceeds the set threshold;
S23c2:若未超过设定阈值,则调用标准交易池S i,完成当前交易; S23c2: If the set threshold is not exceeded, call the standard transaction pool S i to complete the current transaction;
S23c3:若超过设定阈值,则判断与点B j逆时针方向最近的点A i-1所对应的标准交易池S i-1的交易数量,是否超过设定阈值; S23c3: If it exceeds the set threshold, judge whether the transaction quantity of the standard transaction pool S i-1 corresponding to the point A i-1 closest to point B j in the counterclockwise direction exceeds the set threshold;
S23c4:若未超过设定阈值,则调用标准交易池S i-1,完成当前交易; S23c4: If the set threshold is not exceeded, call the standard transaction pool S i-1 to complete the current transaction;
S23c5:若超过设定阈值,则等待,并返回步骤S23c1,直到标准交易池S i、S i-1的其中一个的交易数量未超过设定阈值,则调用其完成当前交易。值得注意的,上述调用的标准交易池的具体哪个或哪几个,以及调用优先级别,仅给出上述示例,但并不以此具体实施例为限,本领域技术人员可根据实际需求,如交易数量的设定阈值大小、等待时间要求等任意设定。示例的,可仅调用标准交易池S i,也可调用S i、S i-1的甚至是涉及到S i+1、S i+2、S i-2均可,其先判断顺时针再判断逆时针,还是先判断逆时针再判断顺时针等优先顺序也均不受限。 S23c5: If it exceeds the set threshold, wait and return to step S23c1 until the transaction quantity of one of the standard transaction pools S i and S i-1 does not exceed the set threshold, then call it to complete the current transaction. It is worth noting that which one or several of the standard transaction pools to call above, as well as the call priority level, only give the above example, but not limited to this specific embodiment, those skilled in the art can according to actual needs, such as Arbitrary settings such as the threshold size of the transaction quantity and the waiting time requirement. For example, you can only call the standard transaction pool S i , you can also call S i , S i-1 or even involve S i+1 , S i+2 , and S i-2 . It is judged clockwise first and then There is no restriction on whether to judge counterclockwise, or whether to judge counterclockwise first and then judge clockwise.
更为优选的,为减轻标准交易池S i的负担,并减少用户等待的时间,如图11所示,步骤S23b,在另一个实施例中,还可选但不仅限于包括: More preferably, in order to reduce the burden on the standard transaction pool S i and reduce the waiting time for users, as shown in Figure 11, step S23b, in another embodiment, may also optionally but not limited to include:
S23b1’:若重合,则判断标准交易池S i的交易数量是否超过设定阈值; S23b1': If they overlap, judge whether the transaction quantity of the standard transaction pool S i exceeds the set threshold;
S23b2’:若未超过设定阈值,则调用标准交易池S i,完成当前交易; S23b2': If the set threshold is not exceeded, call the standard transaction pool S i to complete the current transaction;
S23b3’:若超过设定阈值,则判断与点B j顺时针方向最近的点A i+1所对应的标准交易池S i+1的交易数量,是否超过设定阈值; S23b3': If it exceeds the set threshold, judge whether the transaction quantity of the standard transaction pool S i +1 corresponding to the point A i+1 closest to point B j in the clockwise direction exceeds the set threshold;
S23b4’:若未超过设定阈值,则调用标准交易池S i+1,完成当前交易; S23b4': If the set threshold is not exceeded, call the standard transaction pool S i+1 to complete the current transaction;
S23b5’:若超过设定阈值,则判断与点B j逆时针方向最近的点A i-1所对应的标准交易池S i-1的交易数量,是否超过设定阈值; S23b5': If it exceeds the set threshold, judge whether the transaction quantity of the standard transaction pool S i -1 corresponding to the point A i-1 closest to point B j in the counterclockwise direction exceeds the set threshold;
S23b6’:若未超过设定阈值,则调用标准交易池S i-1,完成当前交易; S23b6': If the set threshold is not exceeded, call the standard transaction pool S i-1 to complete the current transaction;
S23b7’:若超过设定阈值,则等待,并返回步骤S23b1’,直到标准交易池S i、S i+1、S i-1的其中一个的交易数量未超过设定阈值,则调用其完成当前交易。值得注意的,上述调用的标准交易池的具体哪个或哪几个,以及调用优先级别,仅给出上述示例,但并不以此具体实施例为限,本领域技术人员可根据实际需 求,如交易数量的设定阈值大小、等待时间要求等任意设定。示例的,可仅调用标准交易池S i,也可调用S i、S i+1、S i-1的任意两两或三个的组合,甚至是涉及到S i+2、S i-2均可,其先判断顺时针再判断逆时针,还是先判断逆时针再判断顺时针等优先顺序也均不受限。 S23b7': If it exceeds the set threshold, wait and return to step S23b1' until the transaction quantity of one of the standard transaction pools S i , S i+1 , and S i-1 does not exceed the set threshold, then call it to complete current transaction. It is worth noting that which one or several of the standard transaction pools to call above, as well as the call priority level, only give the above example, but not limited to this specific embodiment, those skilled in the art can according to actual needs, such as Arbitrary settings such as the threshold size of the transaction quantity and the waiting time requirement. For example, only the standard transaction pool S i can be called, or any combination of two or three of S i , S i+1 , and S i-1 can be called, even involving S i+2 , S i-2 Either way, the order of priority, such as judging clockwise first and then counterclockwise, or judging counterclockwise first and then clockwise, is not limited.
更为优选的,如图12所示,为避免对无效交易进行判断再处理,浪费运行空间和内存,节约运行时间,本发明区块链交易的处理方法,还可选但不仅限于包括步骤S0:包括:More preferably, as shown in Figure 12, in order to avoid judging and reprocessing invalid transactions, wasting running space and memory, and saving running time, the method for processing blockchain transactions in the present invention may also optionally, but not limited to, include step S0 :include:
S01:判断当前交易T j是否为有效交易; S01: Determine whether the current transaction T j is a valid transaction;
S02:若当前交易T j为有效交易,则进行后续调用完成步骤; S02: If the current transaction T j is a valid transaction, perform subsequent calls to complete the steps;
S03:若当前交易T j不为有效交易(为无效交易),则不进行后续调用完成步骤。 S03: If the current transaction T j is not a valid transaction (is an invalid transaction), do not perform subsequent calls to complete the step.
具体的,该判定当前交易是否为有效交易的步骤S01-S03,可选但不仅限于设置在步骤S1或S2之前或之中,只要是调用标准交易池完成当前交易之前,均可。Specifically, the steps S01-S03 of judging whether the current transaction is a valid transaction are optional but not limited to being set before or during step S1 or S2, as long as it is before calling the standard transaction pool to complete the current transaction.
具体的,如图13所示,步骤S01,可选但不仅限于,包括:Specifically, as shown in Figure 13, step S01 is optional but not limited to, including:
S01a:判断当前交易T j是否合法; S01a: Determine whether the current transaction T j is legal;
S01b:若不合法,则判定当前交易T j,不为有效交易(无效交易),舍弃; S01b: If it is illegal, determine that the current transaction T j is not a valid transaction (invalid transaction), and discard it;
S01c:若合法,则判定当前交易T j,为有效交易,执行后续步骤。 S01c: If it is legal, determine that the current transaction T j is a valid transaction, and execute the next steps.
优选的,如图14所示,在另一个实施例中,步骤S01,可选但不仅限于,包括:Preferably, as shown in FIG. 14, in another embodiment, step S01, optionally but not limited to, includes:
S01a’:判断当前交易T j是否合法; S01a': Determine whether the current transaction T j is legal;
S01b’:若不合法,则判定当前交易T j不为有效交易; S01b': If it is illegal, determine that the current transaction T j is not a valid transaction;
S01c’:若合法,则继续判断当前交易T j是否为重复交易; S01c': If it is legal, continue to judge whether the current transaction T j is a repeated transaction;
S01d’:若为重复交易,则判定当前交易T j不为有效交易; S01d': If it is a repeated transaction, it is determined that the current transaction T j is not a valid transaction;
S01e’:若不为重复交易,则判定当前交易T j为有效交易。 S01e': If it is not a repeated transaction, determine that the current transaction T j is a valid transaction.
值得注意的,该判定当前交易T j是否有效的步骤,可选但不仅限于包括判定其是否为合法交易和重复交易。本领域技术人员可以理解的,可选合法交易和重复交易的其一判定,或者二者综合,或者涉及更多判定该交易是否为有效 交易的评判指标。另外,其判定顺序以及标准均可由本领域技术人员根据实际要求而任意设定。 It should be noted that the step of judging whether the current transaction T j is valid may optionally but not limited to include judging whether it is a legal transaction or a repeated transaction. Those skilled in the art can understand that one of the judgments of legal transactions and repeated transactions can be selected, or a combination of the two, or involve more evaluation indicators for judging whether the transaction is a valid transaction. In addition, the determination sequence and criteria can be arbitrarily set by those skilled in the art according to actual requirements.
另一方面,如图15所示,本发明基于上述处理方法,还提供一种区块链交易的处理系统,包括:On the other hand, as shown in Figure 15, the present invention also provides a blockchain transaction processing system based on the above processing method, including:
分片模块100,用于将区块链交易池,划分为X个标准交易池S i;其中X为正整数;2≤i≤X; The fragmentation module 100 is used to divide the blockchain transaction pool into X standard transaction pools S i ; where X is a positive integer; 2≤i≤X;
调用模块200,与分片模块100连接,用于根据当前交易T j的特征值,调用标准交易池S i中的1至X-1个,完成当前交易T jThe calling module 200 is connected with the sharding module 100, and is used to call 1 to X-1 of the standard transaction pool S i according to the characteristic value of the current transaction T j to complete the current transaction T j .
具体的,分片模块100,可选但不仅限于包括:Specifically, the fragmentation module 100 may optionally include, but is not limited to:
数量确定单元110,用于确定标准交易池S i的数量X; A quantity determination unit 110, configured to determine the quantity X of the standard transaction pool S i ;
标识匹配单元120,与数量确定单元110连接,用于为每个标准交易池S i,匹配一一对应的唯一标识; The identification matching unit 120 is connected with the quantity determination unit 110, and is used for matching a one-to-one unique identification for each standard transaction pool S i ;
映射分块单元130,与标识匹配单元120连接,用于将每个标准交易池S i的唯一标识,作哈希运算,将每个标准交易池S i的唯一标识映射至哈希环上的点A i,以将区块链交易池,划分为X个标准交易池S iThe mapping block unit 130 is connected with the identification matching unit 120, and is used for hashing the unique identification of each standard transaction pool S i , and mapping the unique identification of each standard transaction pool S i to the hash ring. Point A i to divide the blockchain transaction pool into X standard transaction pools S i .
更为具体的,调用模块200,可选但不仅限于包括:More specifically, calling module 200 may optionally but not be limited to include:
特征值生成单元210,用于生成当前交易T j的特征值; A feature value generating unit 210, configured to generate a feature value of the current transaction T j ;
映射定点单元220,与特征值生成单元210连接,用于将当前交易T j的Nonce值,作哈希运算,将当前交易T j映射至哈希环上的点B jThe mapping fixed-point unit 220 is connected with the characteristic value generating unit 210, and is used for performing a hash operation on the Nonce value of the current transaction T j , and mapping the current transaction T j to the point B j on the hash ring;
判断调用单元230,与映射分块单元130和映射定点单元220连接,用于根据点A i和B j的位置,对当前交易T j,调用标准交易池S i中的1至X-1个,完成当前交易T jThe judgment call unit 230 is connected with the mapping block unit 130 and the mapping fixed-point unit 220, and is used to call 1 to X-1 in the standard transaction pool S i for the current transaction T j according to the positions of points A i and B j , to complete the current transaction T j .
需要说明的,上述模块和单元,为本发明区块链交易的处理系统的功能性划分,并不对其结构、单元模块作实质意义上的割裂,可选但不仅限于通过整块CPU单元或处理器执行完成。It should be noted that the above-mentioned modules and units are functional divisions of the processing system of the blockchain transaction of the present invention, and do not substantially separate its structure and unit modules. The execution of the device is completed.
另一方面,本发明还提供一种计算机可读存储介质,其上存储有执行上述任意的处理方法和/或分片方法和/或调用方法的计算机程序。On the other hand, the present invention also provides a computer-readable storage medium, on which is stored a computer program for executing any of the above-mentioned processing methods and/or slicing methods and/or calling methods.
另一方面,本发明还提供一种计算机系统,包括上述任意的计算机可读存 储介质和一个或多个处理器,该处理器被配置为执行上述计算机程序。On the other hand, the present invention also provides a computer system, including any of the above-mentioned computer-readable storage media and one or more processors, the processors are configured to execute the above-mentioned computer program.
上述区块链交易的处理系统、计算机可读存储介质、计算机系统和上述处理方法一致,其技术特征的组合、技术作用和有益效果在此不再赘述,以上所述实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。The processing system, computer-readable storage medium, and computer system of the above-mentioned blockchain transaction are consistent with the above-mentioned processing method, and the combination, technical function and beneficial effect of its technical features will not be repeated here. The technical features of the above-mentioned embodiments can be Arbitrary combinations are made. To simplify the description, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered within the scope of this specification.
以上所述实施例仅表达了本发明的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本发明构思的前提下,还可以做出若干变形和改进,这些都属于本发明的保护范围。因此,本发明专利的保护范围应以所附权利要求为准。The above-mentioned embodiments only express several implementation modes of the present invention, and the descriptions thereof are relatively specific and detailed, but should not be construed as limiting the patent scope of the invention. It should be pointed out that those skilled in the art can make several modifications and improvements without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent for the present invention should be based on the appended claims.

Claims (10)

  1. 一种区块链交易池的分片方法,其特征在于,包括:A fragmentation method of a blockchain transaction pool, characterized in that it comprises:
    确定需要划分的标准交易池S i的数量X;其中X为正整数;2≤i≤X; Determine the quantity X of the standard transaction pool S i that needs to be divided; where X is a positive integer; 2≤i≤X;
    为每个所述标准交易池S i,匹配一一对应的唯一标识; For each of the standard transaction pools S i , match a one-to-one unique identifier;
    将每个所述标准交易池S i的唯一标识,作哈希运算,将每个所述标准交易池S i的唯一标识映射至哈希环上的点A i,以将区块链交易池,划分为X个标准交易池S iThe unique identifier of each standard transaction pool S i is hashed, and the unique identifier of each standard transaction pool S i is mapped to a point A i on the hash ring, so that the blockchain transaction pool , divided into X standard transaction pools S i .
  2. 根据权利要求1所述的分片方法,其特征在于,所述X等于N/3的取整数;所述N为区块链CPU的核心数量。The sharding method according to claim 1, wherein said X is equal to an integer of N/3; said N is the number of cores of the block chain CPU.
  3. 根据权利要求1所述的分片方法,其特征在于,所述X的大小由CPU的核心数量、内存容量和网络带宽决定。The fragmentation method according to claim 1, wherein the size of X is determined by the number of CPU cores, memory capacity and network bandwidth.
  4. 根据权利要求1所述的分片方法,其特征在于,所述唯一标识为索引ID i;其中,ID i=Prefix+i;所述Prefix代表所述标准交易池S i的前缀;i代表所述标准交易池S i的序号。 The sharding method according to claim 1, wherein the unique identifier is an index ID i ; wherein, ID i = Prefix+i; the Prefix represents the prefix of the standard transaction pool S i ; i represents all Describe the serial number of the standard transaction pool S i .
  5. 根据权利要求4所述的分片方法,其特征在于,所述前缀,为CPU节点的主机名或IP地址或物理地址MAC。The fragmentation method according to claim 4, wherein the prefix is a host name or an IP address or a physical address MAC of a CPU node.
  6. 根据权利要求1-5任意一项所述的分片方法,其特征在于,所述哈希运算,为MurmurHash。The fragmentation method according to any one of claims 1-5, wherein the hash operation is MurmurHash.
  7. 一种区块链交易池的分片系统,其特征在于,包括:A sharding system of a blockchain transaction pool, characterized in that it includes:
    数量确定单元,用于确定需要划分的标准交易池S i的数量X;其中X为正整数;2≤i≤X; Quantity determination unit, used to determine the quantity X of the standard transaction pool S i that needs to be divided; where X is a positive integer; 2≤i≤X;
    标识匹配单元,与所述数量确定单元连接,用于为每个所述标准交易池S i,匹配一一对应的唯一标识; An identifier matching unit, connected to the quantity determination unit, for matching a one-to-one unique identifier for each of the standard transaction pools S i ;
    映射分块单元,与所述标识匹配单元连接,用于将每个所述标准交易池S i的唯一标识,作哈希运算,将每个所述标准交易池S i的唯一标识映射至哈希环上的点A i,以将区块链交易池,划分为X个标准交易池S iThe mapping block unit is connected with the identification matching unit, and is used to perform a hash operation on the unique identification of each standard transaction pool S i , and map the unique identification of each standard transaction pool S i to the hash Point A i on the Greek ring to divide the blockchain transaction pool into X standard transaction pools S i .
  8. 根据权利要求7所述的分片系统,其特征在于,所述分片系统,用于执行权利要求1-6任意一项所述的分片方法。The fragmentation system according to claim 7, wherein the fragmentation system is configured to implement the fragmentation method according to any one of claims 1-6.
  9. 一种计算机可读存储介质,其特征在于,其上存储有用于执行权利要求 1-6任意一项所述的区块链交易池的分片方法的计算机程序。A computer-readable storage medium, characterized in that a computer program for executing the fragmentation method of the block chain transaction pool described in any one of claims 1-6 is stored thereon.
  10. 一种计算机系统,其特征在于,包括权利要求9所述的计算机可读存储介质和一个或多个处理器;A computer system, comprising the computer-readable storage medium and one or more processors according to claim 9;
    所述处理器,被配置为运行所述计算机程序。The processor is configured to run the computer program.
PCT/CN2021/141181 2021-10-28 2021-12-24 Sharding method for blockchain transaction pool, system, storage medium and computer system WO2023070925A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111259102.1A CN114140115B (en) 2021-10-28 2021-10-28 Block chain transaction pool fragmentation method, system, storage medium and computer system
CN202111259102.1 2021-10-28

Publications (1)

Publication Number Publication Date
WO2023070925A1 true WO2023070925A1 (en) 2023-05-04

Family

ID=80396180

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/141181 WO2023070925A1 (en) 2021-10-28 2021-12-24 Sharding method for blockchain transaction pool, system, storage medium and computer system

Country Status (2)

Country Link
CN (1) CN114140115B (en)
WO (1) WO2023070925A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114710486B (en) * 2022-03-09 2023-09-08 合肥工业大学 Method and system for monitoring fragmented single-point overheating in block chain system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106682984A (en) * 2016-10-27 2017-05-17 上海亿账通区块链科技有限公司 Block chain-based transaction business processing method and system
CN108243250A (en) * 2018-01-05 2018-07-03 无锡井通网络科技有限公司 A kind of fragment fast selecting method based on distributed network
CN109146447A (en) * 2018-07-09 2019-01-04 矩阵元技术(深圳)有限公司 The transparent sharding method of block chain, apparatus and system
CN111507695A (en) * 2020-04-17 2020-08-07 腾讯科技(深圳)有限公司 Data processing method, data processing device, node equipment and storage medium
CN113032370A (en) * 2021-03-30 2021-06-25 东北大学 Design method of partitioned block chain system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106682984A (en) * 2016-10-27 2017-05-17 上海亿账通区块链科技有限公司 Block chain-based transaction business processing method and system
CN108243250A (en) * 2018-01-05 2018-07-03 无锡井通网络科技有限公司 A kind of fragment fast selecting method based on distributed network
CN109146447A (en) * 2018-07-09 2019-01-04 矩阵元技术(深圳)有限公司 The transparent sharding method of block chain, apparatus and system
CN111507695A (en) * 2020-04-17 2020-08-07 腾讯科技(深圳)有限公司 Data processing method, data processing device, node equipment and storage medium
CN113032370A (en) * 2021-03-30 2021-06-25 东北大学 Design method of partitioned block chain system

Also Published As

Publication number Publication date
CN114140115B (en) 2022-09-06
CN114140115A (en) 2022-03-04

Similar Documents

Publication Publication Date Title
US9154442B2 (en) Concurrent linked-list traversal for real-time hash processing in multi-core, multi-thread network processors
US8321385B2 (en) Hash processing in a network communications processor architecture
US8539199B2 (en) Hash processing in a network communications processor architecture
WO2017133623A1 (en) Data stream processing method, apparatus, and system
CN109983449B (en) Data processing method and storage system
EP3493084B1 (en) Method for processing data in bloom filter and bloom filter
WO2023070924A1 (en) Blockchain transaction processing method and system
US7765405B2 (en) Receive side scaling with cryptographically secure hashing
CN111989705A (en) Priority in licensed block chains
US20100232448A1 (en) Scalable Interface for Connecting Multiple Computer Systems Which Performs Parallel MPI Header Matching
US7779164B2 (en) Asymmetrical data processing partition
WO2020082576A1 (en) Device and method for processing block transaction, and storage medium
JP2016535337A (en) Efficient packet processing model in network environment and system and method for supporting optimized buffer utilization for packet processing
WO2011123991A1 (en) Memory access method for parallel computing
US8762595B1 (en) Method for sharing interfaces among multiple domain environments with enhanced hooks for exclusiveness
US11487478B2 (en) Memory system and method of controlling nonvolatile memory
WO2019080232A1 (en) Task information transmission method and apparatus in workflow system, and computer device
WO2023070925A1 (en) Sharding method for blockchain transaction pool, system, storage medium and computer system
US20160334996A1 (en) In-flash immutable object processing
CN116455559A (en) Implementation method and device of soft and hard collaboration high-speed password equipment and electronic equipment
CN110162395B (en) Memory allocation method and device
CN110445580B (en) Data transmission method and device, storage medium, and electronic device
WO2023029982A1 (en) Method and system for memory allocation
WO2023098050A1 (en) Remote data access method and apparatus
WO2014177080A1 (en) Method and device for processing resource object storage

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21962266

Country of ref document: EP

Kind code of ref document: A1