WO2020011154A1 - 区块链透明分片方法、装置及系统 - Google Patents
区块链透明分片方法、装置及系统 Download PDFInfo
- Publication number
- WO2020011154A1 WO2020011154A1 PCT/CN2019/095226 CN2019095226W WO2020011154A1 WO 2020011154 A1 WO2020011154 A1 WO 2020011154A1 CN 2019095226 W CN2019095226 W CN 2019095226W WO 2020011154 A1 WO2020011154 A1 WO 2020011154A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- shard
- node
- transaction data
- sharding
- blockchain
- Prior art date
Links
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/08—Payment architectures
- G06Q20/10—Payment architectures specially adapted for electronic funds transfer [EFT] systems; specially adapted for home banking systems
- G06Q20/102—Bill distribution or payments
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1001—Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1097—Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/52—Network services specially adapted for the location of the user terminal
Definitions
- the present invention relates to the technical field of blockchain, and in particular, to a method, a device, and a system for transparently slicing a blockchain.
- a fragment can be regarded as a sub-chain.
- the fragment is attached to the main chain, between the fragment and the fragment. They are independent of each other in business, and the transactions are in separate spaces.
- a sharding architecture is a structure that can significantly increase network throughput. Each shard has its own consensus node, which makes the computing truly parallel.
- nodes can choose which shards to join.
- the release and invocation of smart contracts need to determine the node address of the target shard. This solution will lead to the number of nodes in the shard, the number of smart contracts,
- the transaction load is uneven, on the other hand, it is inconvenient for users to issue and call contracts.
- the purpose of the present invention is to provide a method and a system for transparently sharding a blockchain, so that nodes and contracts are evenly distributed in different shards, which can effectively improve the use efficiency of users and solve the problems of imbalanced transaction load.
- the method for transparent sharding of a blockchain specifically includes: obtaining information of multiple shard nodes serving the blockchain, and performing a consistent hash algorithm according to the shard node information Obtain the corresponding relationship between the shard node and the shard; according to the corresponding relationship between the shard node and the shard and the shard node, construct a ReDiR (Recursive) corresponding to the shard on a DHT (distributed hash table) network.
- Distributed (Rendezvous) tree obtain the shard nodes that process transaction data according to the ReDiR tree.
- An embodiment of the present invention provides a method for transparent sharding of a blockchain.
- the method includes: obtaining contract address information of transaction data, and obtaining transaction data and shards through a consistent hash algorithm according to the contract address information. A corresponding relationship; obtaining a shard node in the corresponding shard according to the corresponding relationship between the transaction data and the shard; and sending the transaction data to the shard node.
- An embodiment of the present invention also provides a transparent blockchain sharding device, the device includes a relationship determination module, a construction module, and a query module; the relationship determination module is configured to obtain a plurality of shard nodes serving the blockchain The corresponding relationship between the shard node and the shard by a consistent hash algorithm according to the shard node information; the building module is configured to: A ReDiR tree corresponding to the segment is constructed on the DHT network; the query module is configured to obtain a segment node for processing transaction data according to the ReDiR tree.
- An embodiment of the present invention also provides a transparent blockchain sharding device.
- the device includes a contract processing module, a relationship query module, and a sending module.
- the contract processing module is used to obtain contract address information of transaction data.
- the contract address information obtains a correspondence relationship between transaction data and fragments through a consistent hash algorithm;
- the relationship query module is configured to obtain a fragment node in the corresponding fragment according to the correspondence relationship between the transaction data and the fragment;
- the sending module is configured to send the transaction data to the sharding node.
- the invention also provides a blockchain transparent sharding system, the system includes a construction unit and a processing unit; the construction unit is used to obtain information about multiple shard nodes serving the blockchain, and according to the shard nodes The information obtains the correspondence between the shard nodes and the shards through a consistent hash algorithm; and according to the corresponding relationship between the shard nodes and the shards and the shard nodes, a ReDiR tree corresponding to the shards is constructed on the DHT network.
- the processing unit is configured to obtain the contract address information of the transaction data, and obtain a correspondence relationship between the transaction data and the fragment through a consistent hash algorithm according to the contract address information; and according to the correspondence between the transaction data and the fragment Relationship, obtain a shard node in the corresponding shard; and send the transaction data to the shard node.
- the present invention also provides an electronic device including a memory, a processor, and a computer program stored on the memory and executable on the processor.
- the processor executes the computer program, the method for transparently sharding a blockchain described above is implemented. A step of.
- the present invention also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above-mentioned transparent blockchain fragmentation method are implemented.
- the beneficial technical effect of the present invention is: determining the correspondence between the contract and the shard, and the correspondence between the shard node and the shard by using a consistent hash algorithm; so that the nodes and the contract are evenly distributed in different shards.
- contract deployers and callers do not have to specify target fragments and node addresses, and transactions can be transparently routed to the corresponding fragments.
- FIG. 1 is a schematic flowchart of a blockchain transparent sharding method according to an embodiment of the present invention
- FIG. 2 is a schematic diagram of blockchain fragmentation provided by an embodiment of the present invention.
- FIG. 3 is a schematic diagram of a blockchain shard and a relationship between shard nodes according to an embodiment of the present invention
- FIG. 4 is a schematic diagram of a ReDiR tree structure according to an embodiment of the present invention.
- FIG. 5 is a schematic flowchart of a blockchain transparent sharding method according to an embodiment of the present invention.
- FIG. 6 is a schematic diagram of a relationship between a blockchain fragment and transaction data contract address information provided by an embodiment of the present invention
- FIG. 7 is a schematic structural diagram of a blockchain transparent sharding system according to an embodiment of the present invention.
- FIG. 8 is a schematic structural diagram of a blockchain transparent sharding device according to an embodiment of the present invention.
- FIG. 9 is a schematic structural diagram of a blockchain transparent sharding device according to an embodiment of the present invention.
- FIG. 10 is a schematic structural diagram of a blockchain transparent sharding device according to an embodiment of the present invention.
- FIG. 11 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
- a method for transparent sharding of a blockchain specifically includes: S101 obtains information of multiple shard nodes serving a blockchain, and passes consistency according to the shard node information.
- the hash algorithm obtains the corresponding relationship between the shard node and the shard;
- S102 constructs a ReDiR tree corresponding to the shard on the DHT network according to the corresponding relationship between the shard node and the shard and the shard node;
- S103 The ReDiR tree described above obtains shard nodes that process transaction data.
- the contract deployer and caller do not need to specify the target fragment and node address, and directly obtain the required fragment node on the ReDiR tree;
- the foregoing embodiment enables the balanced distribution of the shard nodes and effectively improves the parallel computing efficiency.
- the number of shards N is determined at the beginning of the creation of the blockchain, and each shard is numbered from 1 to N, that is, the shard ID, and the consistency of the shard information is constructed according to the shard ID.
- Sexual hash ring as shown in Figure 2 below; at this time, the node serving the shard is called the shard node; according to the node node's number information nodeid, a consistent hash algorithm can determine the shard node and the shard Correspondence, please refer to Figure 3 for details.
- constructing a ReDiR tree corresponding to the shard on the DHT network further includes: adding the shard node to the ReDiR tree After that, the service location information is obtained according to the spatial location of the shard node in the ReDiR tree; the service location information is bound to the shard node information and released to the DHT network.
- the service location information includes hierarchical location information in the ReDiR tree and number information of the shard node; wherein the addition of the shard node to the ReDiR tree further includes: adding the shard node's The number information is compared with a predetermined threshold, and hierarchical position information of the shard node in the ReDiR tree is obtained according to a comparison result.
- all the nodes of each shard construct a ReDiR tree on the DHT network; when the shard node joins the DHT network, it will publish its own address information on the ReDiR tree corresponding to the shard. , That is, publishing services.
- l may be 2
- namespace the shard ID
- the nodeid value is the current maximum and minimum value of space I (l, nodeid) or the boundary value of space I (l, nodeid), which needs to be stored to level + 1 layer; the nodeid value is the only value in the current space or The lower boundary value needs to be stored to the level-1 layer.
- An embodiment of the present invention further provides a method for transparently sharding a blockchain.
- the method includes: S501 obtains contract address information of transaction data, and passes the contract address information according to the contract address information.
- the consistent hash algorithm obtains the correspondence between the transaction data and the shards; S502 obtains the shard nodes in the corresponding shards according to the correspondence between the transaction data and the shards; S503 sends the transaction data to the shards node.
- the segment where the contract is located that is, the target segment of the transaction is determined by a consistent hash algorithm mainly according to the contract address of the transaction; for details, refer to FIG. 6.
- the above-mentioned method for transparently sharding a blockchain further includes: constructing a ReDiR tree corresponding to the shard on a DHT network through the shard nodes in the shard; according to the transaction data The corresponding relationship with the shards is obtained from the ReDiR tree of the corresponding shards.
- obtaining the shard node in the corresponding shard further includes: according to the account address of the user who currently operates the transaction data and the ReDiR tree of the corresponding shard.
- the segment node's address information is calculated to obtain the logical distance between the two, and the segment node that processes the transaction data is obtained according to the logical distance.
- the logical distance between the account address of the user currently operating the transaction data and the address information of the segment node in the ReDiR tree of the corresponding segment is calculated, and the transaction data is obtained and processed according to the logical distance.
- the fragmentation node further includes: generating resource address information in the ReDiR tree according to the account address of the user currently operating the transaction data; and querying the address information of the fragmentation node in the ReDiR tree according to the resource address information; Adjusting the resource address information according to the query result.
- step S502 according to the corresponding relationship between the transaction data and the shard, obtaining the shard node in the corresponding shard further includes: according to the contract address information of the transaction data and The address information of the segment nodes in the ReDiR tree corresponding to the segment is calculated to obtain a logical distance between the two, and a segment node that processes the transaction data is obtained according to the logical distance.
- obtaining the shard node for processing the transaction data according to the logical distance includes: obtaining the logical distance through an exclusive-OR operation, and selecting a shard node with the smallest logical distance as a shard node for processing the transaction data.
- the target fragment after the target fragment is determined, it is necessary to find the fragment node in the ReDiR tree where the fragment is located.
- Users use their account address or contract address information to find the shard node closest to their logical distance.
- the logical distance refers to the result of an exclusive OR operation performed on the account address or contract address information and the fragment node address information.
- first select the specified level l may be 2) as the starting level, and find the user account address or contract address information (address) in the ReDiR tree where the fragment is located (namespace is the fragment ID) at the spatial level.
- an embodiment of the present invention further provides a blockchain transparent sharding device.
- the device includes a relationship determination module, a construction module, and a query module.
- the relationship determination module is configured to obtain services for a block. Information of multiple shard nodes of the chain, and obtain a correspondence relationship between shard nodes and shards through a consistent hashing algorithm according to the shard node information;
- the building module is configured to:
- the sharding node constructs a ReDiR tree corresponding to the shard on a DHT network;
- the query module is configured to obtain a sharding node for processing transaction data according to the ReDiR tree.
- the building module further includes, after the sharding node joins the ReDiR tree, obtaining service location information according to the spatial location of the sharding node in the ReDiR tree; and combining the service location information with the segmentation node.
- the slice node information is bound and published to the DHT network.
- another embodiment of the present invention further provides a blockchain transparent sharding device, the device includes a contract processing module, a relationship query module, and a sending module; the contract processing module is used to obtain transaction data The corresponding contract address information is obtained by a consistent hashing algorithm according to the contract address information, and the correspondence between the transaction data and the shards is obtained; the relationship query module is used to determine the correspondence between the transaction data and the shards according to the corresponding relationship between the transaction data and the shards.
- a shard node is obtained in the shard; the sending module is configured to send the transaction data to the shard node.
- the device may further include a generation module for constructing a ReDiR tree corresponding to the shard on the DHT network through the shard nodes in the shard; according to the transaction data and the shard The corresponding relationship of the slices is obtained from the ReDiR tree of the corresponding slice.
- the relationship query module further includes a distance calculation module, and the distance calculation module is configured to be based on an account address of a user who currently operates the transaction data or a contract of the transaction data.
- One of the address information and the address information of the fragment node in the ReDiR tree of the corresponding fragment are calculated to obtain a logical distance between the two, and a fragment node that processes the transaction data is obtained according to the logical distance.
- FIG. 7 another embodiment of the present invention further provides a blockchain transparent sharding system.
- the system includes a construction unit 701 and a processing unit 702.
- the construction unit is configured to obtain a service for the blockchain.
- a plurality of shard node information and obtain a correspondence relationship between the shard node and the shard through a consistent hashing algorithm according to the shard node information; and according to the shard node and shard correspondence relationship and the shard node, in A ReDiR tree corresponding to the shard is constructed on the DHT network;
- the processing unit is configured to obtain contract address information of transaction data, and obtain a correspondence between the transaction data and the shard by a consistent hash algorithm according to the contract address information A relationship; and obtaining a shard node in the corresponding shard according to the corresponding relationship between the transaction data and the shard; and sending the transaction data to the shard node.
- the processing unit may further include an account calculation module, where the account calculation module is configured to: according to the account address of the user currently operating the transaction data and the address of the fragment node in the ReDiR tree of the corresponding fragment Information is calculated to obtain a logical distance between the two, and a shard node that processes the transaction data is obtained according to the logical distance.
- the processing unit may further include a contract calculation module, which is configured to calculate according to the contract address information of the transaction data and the address information of the shard node in the ReDiR tree of the corresponding shard. A logical distance between the two is obtained, and a shard node that processes the transaction data is obtained according to the logical distance.
- a contract calculation module configured to calculate according to the contract address information of the transaction data and the address information of the shard node in the ReDiR tree of the corresponding shard. A logical distance between the two is obtained, and a shard node that processes the transaction data is obtained according to the logical distance.
- the construction unit may further include a publishing module, which is used for the shard node to obtain services according to the spatial location of the shard node in the ReDiR tree after joining the ReDiR tree.
- Location information binding the service location information with the fragment node information and publishing it to the DHT network.
- the blockchain transparent sharding method and system determine the corresponding relationship between the contract and the shard, and the corresponding relationship between the shard node and the shard by using a consistent hash algorithm; so that the nodes and the contract are evenly distributed in different shards. In the film.
- contract deployers and callers do not have to specify target fragments and node addresses, and transactions can be transparently routed to the corresponding fragments.
- An embodiment of the present application also provides a specific implementation of an electronic device capable of implementing all the steps in the method for transparently sharding a blockchain in the above embodiment.
- the electronic device specifically includes the following content:
- the electronic device may be a desktop computer, a tablet computer, a mobile terminal, etc., and this embodiment is not limited thereto.
- the electronic device can be implemented by referring to the embodiment of the method for blockchain transparent sharding and the embodiment of the blockchain transparent sharding device. The content is incorporated herein, and the duplicates are not repeated here. More details.
- FIG. 11 is a schematic block diagram of a system configuration of an electronic device 600 according to an embodiment of the present application.
- the electronic device 600 may include a central processing unit 100 and a memory 140; the memory 140 is coupled to the central processing unit 100. It is worth noting that this figure is exemplary; other types of structures can also be used to supplement or replace the structure to implement telecommunication functions or other functions.
- the blockchain transparent sharding method may be integrated into the central processing unit 100.
- the central processing unit 100 may be configured to perform the following control: obtain information of a plurality of shard nodes serving the blockchain, and obtain a correspondence between the shard nodes and the shards through a consistent hash algorithm according to the shard node information. Relationship; according to the corresponding relationship between the shard node and the shard and the shard node, a ReDiR tree corresponding to the shard is constructed on the DHT network; and a shard node that processes transaction data is obtained according to the ReDiR tree.
- constructing a ReDiR tree corresponding to the shard on the DHT network may include: after the shard node joins the ReDiR tree, The slice node obtains service location information from the spatial location in the ReDiR tree; and binds the service location information to the slice node information and publishes the service location information to the DHT network.
- the service location information includes hierarchical location information in the ReDiR tree and numbering information of the fragmentation nodes.
- the addition of the sharding node to the ReDiR tree further includes: comparing the numbering information of the sharding node with a predetermined threshold, and obtaining hierarchical position information of the sharding node in the ReDiR tree according to the comparison result.
- the central processor 100 may be further configured to perform the following control: obtain contract address information of transaction data, and obtain a correspondence relationship between transaction data and fragments by a consistent hash algorithm according to the contract address information; according to the transaction data Corresponding relationship with the shards, obtain shard nodes in the corresponding shards; and send the transaction data to the shard nodes.
- the transaction data and the shards before obtaining the shard nodes in the corresponding shards, it further includes: constructing the corresponding shards on the DHT network through the shard nodes in the shards.
- ReDiR tree according to the corresponding relationship between the transaction data and the shard, obtain a shard node in the ReDiR tree of the corresponding shard.
- obtaining the shard node in the corresponding shard further includes: according to the account address of the user who currently operates the transaction data and the shard node in the ReDiR tree of the corresponding shard.
- the address information is calculated to obtain a logical distance between the two, and a slice node that processes the transaction data is obtained according to the logical distance.
- the logical distance between the account address of the user currently operating the transaction data and the address information of the segment node in the ReDiR tree of the corresponding segment is calculated, and the transaction data is obtained and processed according to the logical distance.
- the fragmentation node further includes: generating resource address information in the ReDiR tree according to the account address of the user currently operating the transaction data; and querying the address information of the fragmentation node in the ReDiR tree according to the resource address information; Adjusting the resource address information according to the query result.
- obtaining the shard node in the corresponding shard further includes: according to the contract address information of the transaction data and the address of the shard node in the ReDiR tree of the corresponding shard. Information is calculated to obtain a logical distance between the two, and a shard node that processes the transaction data is obtained according to the logical distance.
- obtaining the shard node for processing the transaction data according to the logical distance includes: obtaining the logical distance through an exclusive-OR operation, and selecting a shard node with the smallest logical distance as a shard node for processing the transaction data.
- the embodiment of the present application provides an electronic device, which uses a consistent hash algorithm to determine the correspondence between a contract and a shard, and the correspondence between a shard node and a shard; so that nodes and contracts are evenly distributed in different In the shard.
- the contract deployer and caller do not have to specify target fragments and node addresses, and transactions can be routed transparently to the corresponding fragments.
- the blockchain transparent sharding device may be configured separately from the central processing unit 100.
- the blockchain transparent sharding device may be configured as a chip connected to the central processing unit 100 and controlled by the central processing unit. To achieve transparent sharding of the blockchain.
- the electronic device 600 may further include a communication module 110, an input unit 120, an audio processor 130, a display 160, and a power source 170. It is worth noting that the electronic device 600 does not necessarily include all the components shown in FIG. 11; in addition, the electronic device 600 may further include components not shown in FIG. 11, and reference may be made to the prior art.
- the central processing unit 100 is sometimes referred to as a controller or an operation control, and may include a microprocessor or other processor devices and / or logic devices.
- the central processing unit 100 receives input and controls each of the electronic devices 600. Operation of parts.
- the memory 140 may be, for example, one or more of a buffer, a flash memory, a hard drive, a removable medium, a volatile memory, a non-volatile memory, or other suitable devices.
- the above-mentioned failure-related information can be stored, and in addition, a program for executing the related information can be stored.
- the central processing unit 100 may execute the program stored in the memory 140 to implement information storage or processing.
- the input unit 120 provides input to the central processing unit 100.
- the input unit 120 is, for example, a key input or a touch input device.
- the power source 170 is used to provide power to the electronic device 600.
- the display 160 is used for displaying display objects such as images and characters.
- the display may be, for example, an LCD display, but is not limited thereto.
- the memory 140 may be a solid-state memory, such as a read-only memory (ROM), a random access memory (RAM), a SIM card, and the like. It may also be a memory that holds information even when power is off, can be selectively erased, and is provided with more data. An example of this memory is sometimes called EPROM or the like.
- the memory 140 may also be some other type of device.
- the memory 140 includes a buffer memory 141 (sometimes referred to as a buffer).
- the memory 140 may include an application / function storage section 142 for storing application programs and function programs or a flow for performing operations of the electronic device 600 through the central processing unit 100.
- the memory 140 may further include a data storage section 143 for storing data.
- the driver storage section 144 of the memory 140 may include various driver programs for the communication function of the electronic device and / or for performing other functions of the electronic device (such as a messaging application, an address book application, etc.).
- the communication module 110 is a transmitter / receiver 110 that transmits and receives signals via the antenna 111.
- a communication module (transmitter / receiver) 110 is coupled to the central processing unit 100 to provide input signals and receive output signals, which may be the same as the case of a conventional mobile communication terminal.
- multiple communication modules 110 may be provided in the same electronic device, such as a cellular network module, a Bluetooth module, and / or a wireless local area network module.
- the communication module (transmitter / receiver) 110 is also coupled to the speaker 131 and the microphone 132 via the audio processor 130 to provide audio output via the speaker 131 and to receive audio input from the microphone 132, thereby realizing general telecommunication functions.
- the audio processor 130 may include any suitable buffers, decoders, amplifiers, and the like.
- the audio processor is also coupled to the central processing unit 100, thereby enabling recording on the unit through the microphone 132, and enabling sounds stored on the unit to be played through the speaker 131.
- An embodiment of the present application further provides a computer-readable storage medium capable of implementing all the steps in the method for transparently sharding a blockchain in the foregoing embodiment.
- the computer-readable storage medium stores a computer program, and the computer program is When the processor executes, all steps of the blockchain transparent sharding method in the above embodiment are implemented. For example, when the processor executes the computer program, the following steps are implemented:
- the fragment node constructing a ReDiR tree corresponding to the fragment on the DHT network; obtaining a fragment node for processing transaction data according to the ReDiR tree; or obtaining contract address information of transaction data according to the contract address
- the information obtains the correspondence between the transaction data and the shards through a consistent hash algorithm; according to the correspondence between the transaction data and the shards, obtains the shard node in the corresponding shard; and sends the transaction data to the shards Nodes, etc.
- the embodiments of the present application provide a computer-readable storage medium, which uses a consistent hash algorithm to determine the correspondence between a contract and a shard, and the correspondence between a shard node and a shard; so that the nodes and the contract are balanced Distributed in different shards.
- contract deployers and callers do not have to specify target fragments and node addresses, and transactions can be transparently routed to the corresponding fragments.
- the embodiments of the present invention may be provided as a method, a system, or a computer program product. Therefore, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
- computer-usable storage media including, but not limited to, disk storage, CD-ROM, optical storage, etc.
- These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to work in a specific manner such that the instructions stored in the computer-readable memory produce a manufactured article including an instruction device, the instructions
- the device implements the functions specified in one or more flowcharts and / or one or more blocks of the block diagram.
- These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of steps can be performed on the computer or other programmable device to produce a computer-implemented process, which can be executed on the computer or other programmable device.
- the instructions provide steps for implementing the functions specified in one or more flowcharts and / or one or more blocks of the block diagrams.
Landscapes
- Business, Economics & Management (AREA)
- Engineering & Computer Science (AREA)
- Accounting & Taxation (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Finance (AREA)
- Development Economics (AREA)
- Economics (AREA)
- Strategic Management (AREA)
- Physics & Mathematics (AREA)
- General Business, Economics & Management (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Computer And Data Communications (AREA)
Abstract
一种区块链透明分片方法、装置及系统,所述方法包含:获取服务于区块链的多个分片节点信息,根据所述分片节点信息通过一致性哈希算法获得分片节点与分片的对应关系;根据分片节点与分片的对应关系和所述分片节点,于DHT网络上构建与所述分片对应的ReDiR树;获取交易数据的合约位址信息,根据所述合约位址信息通过一致性哈希算法获得交易数据与分片的对应关系;根据所述交易数据与分片的对应关系,于对应分片中获得分片节点;将所述交易数据发送至所述分片节点。
Description
本发明涉及区块链技术领域,尤其涉及一种区块链透明分片方法、装置及系统。
目前经典架构的区块链网络都遇到了极大的性能瓶颈,例如所熟知比特币和以太坊,尽管绝大多数交易之间并无关联性,但是所有的交易都串行执行,而且网络上的所有全节点都需要执行所有的交易,这就造成了极大的计算资源的浪费。
为了解决并行计算的问题,需要对区块链进行垂直切分,切分出多个分片,一个分片可以被看做一个子链,分片依附于主链,分片与分片之间在业务上相互独立,交易处于各自独立的空间中。分片架构是一种可显著提高网络吞吐量的架构,每个分片都有自己的共识节点,使得计算得以真正并行化。
但是分片给用户也带来更高的使用复杂性,节点和智能合约如何均衡分配到分片也是需要解决的问题。
在以太坊的分片架构中,节点可自主选择加入哪个分片,智能合约的发布及调用需要确定目标分片的节点地址,这种方案一方面会导致分片中节点数量、智能合约数量、交易负载不均衡,另一方面用户发布及调用合约使用不方便。
发明内容
本发明目的在于提供一种区块链透明分片方法及系统使节点和合约均衡分布在不同的分片中,有效提高用户的使用效率和解决交易负载不均衡等问题。
为达上述目的,本发明一实施例所提供的区块链透明分片方法具体包含:获取服务于区块链的多个分片节点信息,根据所述分片节点信息通过一致性哈希算法获得分片节点与分片的对应关系;根据分片节点与分片的对应关系和所述分片节点,于DHT(分布式哈希表)网络上构建与所述分片对应的ReDiR(Recursive Distributed Rendezvous)树;根据所述ReDiR树获得处理交易数据的分片节点。
本发明一实施例提供一种区块链透明分片方法,所述方法包含:获取交易数据的合约位址信息,根据所述合约位址信息通过一致性哈希算法获得交易数据与分片的对应关系;根据所述交易数据与分片的对应关系,于对应分片中获得分片节点;将所述交易数据发送至所述分片节点。
本发明一实施例还提供一种区块链透明分片装置,所述装置包含关系确定模块、构建模块和查询模块;所述关系确定模块用于获取服务于区块链的多个分片节点信息,根据所述分片节点信息通过一致性哈希算法获得分片节点与分片的对应关系;所述构建模块用于根据分片节点与分片的对应关系和所述分片节点,于DHT网络上构建与所述分片对应的ReDiR树;所述查询模块用于根据所述ReDiR树获得处理交易数据的分片节点。
本发明一实施例还提供一种区块链透明分片装置,所述装置包含合约处理模块、关系查询模块和发送模块;所述合约处理模块用于获取交易数据的合约位址信息,根据所述合约位址信息通过一致性哈希算法获得交易数据与分片的对应关系;所述关系查询模块用于根据所述交易数据与分片的对应关系,于对应分片中获得分片节点;所述发送模块用于将所述交易数据发送至所述分片节点。
本发明还提供一种区块链透明分片系统,所述系统包含构建单元和处理单元;所述构建单元用于获取服务于区块链的多个分片节点信息,根据所述分片节点信息通过一致性哈希算法获得分片节点与分片的对应关系;以及根据分片节点与分片的对应关系和所述分片节点,于DHT网络上构建与所述分片对应的ReDiR树;所述处理单元用于获取交易数据的合约位址信息,根据所述合约位址信息通过一致性哈希算法获得交易数据与分片的对应关系;以及根据所述交易数据与分片的对应关系,于对应分片中获得分片节点;将所述交易数据发送至所述分片节点。
本发明还提供一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现上述的区块链透明分片方法的步骤。
本发明还提供一种计算机可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现上述的区块链透明分片方法的步骤。
本发明的有益技术效果在于:通过使用一致哈希算法确定合约和分片的对应关系,以及分片节点和分片的对应关系;使得节点和合约均衡分布在不同的分片中。其次基于DHT网络的ReDiR(Recursive Distributed Rendezvous)服务发现机制,使得合约部署者和调用者不必指定目标分片和节点地址,交易可以透明路由到相应的分片。
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本 发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1为本发明一实施例所提供的区块链透明分片方法流程示意图;
图2为本发明一实施例所提供的区块链分片示意图;
图3为本发明一实施例所提供的区块链分片及分片节点关系示意图;
图4为本发明一实施例所提供的ReDiR树结构示意图;
图5为本发明一实施例所提供的区块链透明分片方法流程示意图;
图6为本发明一实施例所提供的区块链分片及交易数据合约地址信息关系示意图;
图7为本发明一实施例所提供的区块链透明分片系统结构示意图;
图8为本发明一实施例所提供的区块链透明分片装置结构示意图;
图9为本发明一实施例所提供的区块链透明分片装置结构示意图;
图10为本发明一实施例所提供的区块链透明分片装置结构示意图;
图11为本发明一实施例所提供的电子设备的结构示意图。
为使本发明实施例的目的、技术方案和优点更加清楚明白,下面结合实施例和附图,对本发明做进一步详细说明。在此,本发明的示意性实施例及其说明用于解释本发明,但并不作为对本发明的限定。
在本说明书的描述中,参考术语“一实施例”、“一具体实施例”、“例如”等的描述意指结合该实施例或示例描述的具体特征、结构、材料或者特点包含于本申请的至少一个实施例或示例中。在本说明书中,对上述术语的示意性表述不一定指的是相同的实施例或示例。而且,描述的具体特征、结构、材料或者特点可以在任何的一个或多个实施例或示例中以合适的方式结合。各实施例中涉及的步骤顺序用于示意性说明本申请的实施,其中的步骤顺序不作限定,可根据需要作适当调整。
请参考图1所示,本发明一实施例所提供的区块链透明分片方法具体包含:S101获取服务于区块链的多个分片节点信息,根据所述分片节点信息通过一致性哈希算法获得分片节点与分片的对应关系;S102根据分片节点与分片的对应关系和所述分片节点,于DHT网络上构建与所述分片对应的ReDiR树;S103根据所述ReDiR树获得处理交易数据的分片节点。以此,利用DHT网络的ReDiR(Recursive Distributed Rendezvous)服务发现机制,使得合约部署者和调用者不必指定目标分片和节点地址,直接于所述ReDiR 树上获取到需要的分片节点;同时利用上述实施例,使得各分片节点均衡分布,有效提高并行化计算效率。
在上述步骤S101中,区块链在创建之初就确定了分片的数量N,对每个分片从1到N进行编号,即分片ID,并根据分片ID构造分片信息的一致性hash环,如下图2所示;此时,服务于分片的节点称为分片节点;根据分片节点的编号信息nodeid,通过一致性哈希算法即可确定分片节点和分片的对应关系,具体请参考图3所示。
在上述步骤S102中的根据分片节点与分片的对应关系和所述分片节点,于DHT网络上构建与所述分片对应的ReDiR树还包含:所述分片节点加入所述ReDiR树后,根据分片节点于所述ReDiR树中所处空间位置获得服务位置信息;将所述服务位置信息与所述分片节点信息绑定后发布至所述DHT网络中。具体的,所述服务位置信息包含所述ReDiR树中的层级位置信息及所述分片节点的编号信息;其中,所述分片节点加入所述ReDiR树还包含:将所述分片节点的编号信息与预定阈值比较,根据比较结果获得所述分片节点在所述ReDiR树中的层级位置信息。实际工作中,请参考图4所示,每个分片的所有节点在DHT网络上构建成一颗ReDiR树;分片节点在加入DHT网络时会在分片对应的ReDiR树上发布自己的地址信息,即发布服务。分片节点在发布服务时,选取指定层级l(可为2)作为起始Level,找到自身nodeid在分片所在的ReDiR树(namespace为分片ID)l层的空间位置I(l,nodeid),生成服务ID(ID=namespace+level+nodeid),将服务ID与节点信息一起发布到空间位置I(l,nodeid)中。同时根据nodeid判断需不需要向其他Level发送存储请求。依据的条件有:nodeid值是空间I(l,nodeid)当前最大、最小值或空间I(l,nodeid)边界值,需要向level+1层进行存储;nodeid值是当前空间的唯一值或者是低一层的边界值则需要向level-1层进行存储。
在区块链上,跟合约相关的交易有两种类型:a)合约部署交易;b)合约调用交易。两种类型的交易的最大区别在于合约地址,部署交易中的合约地址根据合约代码Hash生成,调用交易中的合约地址为调用者指定的合约地址。除此之外,两种类型的交易在网络上的发送和传播等并无区别。为此,请参考图5所示,本发明一实施例还提供一种区块链透明分片方法,所述方法包含:S501获取交易数据的合约位址信息,根据所述合约位址信息通过一致性哈希算法获得交易数据与分片的对应关系;S502根据所述交易数据与分片的对应关系,于对应分片中获得分片节点;S503将所述交易数据发送至所述分片节点。在该实施例中,主要根据交易的合约地址,通过一致性哈希算法来确定合约所在的分片,即交易的目标分片;具体可参考图6所示。
在本发明一实施例中,上述区块链透明分片方法还包含:通过所述分片中的分片节点,于DHT网络上构建与所述分片对应的ReDiR树;根据所述交易数据与分片的对应关系,于对应分片的ReDiR树中获得分片节点。
在上述步骤S502中的根据所述交易数据与分片的对应关系,于对应分片中获得分片节点还包含:根据当前操作所述交易数据的用户的账户地址与对应分片的ReDiR树中分片节点的位址信息计算获得两者之间的逻辑距离,根据所述逻辑距离获得处理所述交易数据的分片节点。其中,根据当前操作所述交易数据的用户的账户地址与对应分片的ReDiR树中分片节点的位址信息计算获得两者之间的逻辑距离,根据所述逻辑距离获得处理所述交易数据的分片节点还包含:根据当前操作所述交易数据的用户的账户地址于所述ReDiR树中生成资源地址信息;根据所述资源地址信息查询所述ReDiR树中分片节点的位址信息;根据查询结果调整所述资源地址信息。
在本发明另一实施例中,在上述步骤S502中的根据所述交易数据与分片的对应关系,于对应分片中获得分片节点还包含:根据所述交易数据的合约位址信息与对应分片的ReDiR树中分片节点的位址信息计算获得两者之间的逻辑距离,根据所述逻辑距离获得处理所述交易数据的分片节点。其中,根据所述逻辑距离获得处理所述交易数据的分片节点包含:通过异或运算获得所述逻辑距离,选择所述逻辑距离最小的分片节点作为处理所述交易数据的分片节点。
在上述实施例中,目标分片确定后,需要在分片所在的ReDiR树查找分片节点。用户使用自己的账户地址或合约位址信息来查找跟自己逻辑距离最近的分片节点。这里逻辑距离是指账户地址或合约位址信息与分片节点的位址信息做异或运算的结果。实际工作中,首先选取指定层级l(可为2)作为起始Level,找到用户账户地址或合约位址信息(address)在分片所在的ReDiR树(namespace为分片ID)l层的空间位置I(l,address),生成资源ID(ID=namespace+level+address)。利用资源ID向指定的空间I(l,address)查询。当在l层级没有找到资源,则需要根据address判断需不需要向其他Level发送查询请求。依据的条件有:如果查询结果没有后继结点,说明可能存在于更高的level中,使得level+1向上继续查找;有后继值说明可能存在于更低的level中,使得level-1向下继续查找;如果address为空间I(l,address)的边界值,则整个网络中不存在,停止查询。
请参考图8所示,本发明一实施例还提供一种区块链透明分片装置,所述装置包含关系确定模块、构建模块和查询模块;所述关系确定模块用于获取服务于区块链的多个 分片节点信息,根据所述分片节点信息通过一致性哈希算法获得分片节点与分片的对应关系;所述构建模块用于根据分片节点与分片的对应关系和所述分片节点,于DHT网络上构建与所述分片对应的ReDiR树;所述查询模块用于根据所述ReDiR树获得处理交易数据的分片节点。其中,所述构建模块还包含在所述分片节点加入所述ReDiR树后,根据分片节点于所述ReDiR树中所处空间位置获得服务位置信息;将所述服务位置信息与所述分片节点信息绑定后发布至所述DHT网络中。
请参考图9所示,本发明另一实施例还提供一种区块链透明分片装置,所述装置包含合约处理模块、关系查询模块和发送模块;所述合约处理模块用于获取交易数据的合约位址信息,根据所述合约位址信息通过一致性哈希算法获得交易数据与分片的对应关系;所述关系查询模块用于根据所述交易数据与分片的对应关系,于对应分片中获得分片节点;所述发送模块用于将所述交易数据发送至所述分片节点。其中,所述装置还可包含生成模块,所述生成模块用于通过所述分片中的分片节点,于DHT网络上构建与所述分片对应的ReDiR树;根据所述交易数据与分片的对应关系,于对应分片的ReDiR树中获得分片节点。
请参考图10所示,在上述实施例中,所述关系查询模块还包含距离计算模块,所述距离计算模块用于根据当前操作所述交易数据的用户的账户地址或所述交易数据的合约位址信息中一个,与对应分片的ReDiR树中分片节点的位址信息计算获得两者之间的逻辑距离,根据所述逻辑距离获得处理所述交易数据的分片节点。
请参考图7所示,本发明另一实施例还提供一种区块链透明分片系统,所述系统包含构建单元701和处理单元702;所述构建单元用于获取服务于区块链的多个分片节点信息,根据所述分片节点信息通过一致性哈希算法获得分片节点与分片的对应关系;以及根据分片节点与分片的对应关系和所述分片节点,于DHT网络上构建与所述分片对应的ReDiR树;所述处理单元用于获取交易数据的合约位址信息,根据所述合约位址信息通过一致性哈希算法获得交易数据与分片的对应关系;以及根据所述交易数据与分片的对应关系,于对应分片中获得分片节点;将所述交易数据发送至所述分片节点。
在上述实施例中,所述处理单元还可包含账户计算模块,所述账户计算模块用于根据当前操作所述交易数据的用户的账户地址与对应分片的ReDiR树中分片节点的位址信息计算获得两者之间的逻辑距离,根据所述逻辑距离获得处理所述交易数据的分片节点。
在上述实施例中,所述处理单元还可包含合约计算模块,所述合约计算模块用于根据所述交易数据的合约位址信息与对应分片的ReDiR树中分片节点的位址信息计算获得两者之间的逻辑距离,根据所述逻辑距离获得处理所述交易数据的分片节点。
在上述实施例中,所述构建单元还可包含发布模块,所述发布模块用于所述分片节点加入所述ReDiR树后,根据分片节点于所述ReDiR树中所处空间位置获得服务位置信息;将所述服务位置信息与所述分片节点信息绑定后发布至所述DHT网络中。
本发明所提供的区块链透明分片方法及系统通过使用一致哈希算法确定合约和分片的对应关系,以及分片节点和分片的对应关系;使得节点和合约均衡分布在不同的分片中。其次基于DHT网络的ReDiR(Recursive Distributed Rendezvous)服务发现机制,使得合约部署者和调用者不必指定目标分片和节点地址,交易可以透明路由到相应的分片。
本申请的实施例还提供能够实现上述实施例中的区块链透明分片方法中全部步骤的一种电子设备的具体实施方式,所述电子设备具体包括如下内容:
处理器(processor)、存储器(memory)、通信接口(Communications Interface)和总线;其中,所述处理器、存储器、通信接口通过所述总线完成相互间的通信;所述通信接口用于实现相关设备之间的信息传输;该电子设备可以是台式计算机、平板电脑及移动终端等,本实施例不限于此。在本实施例中,该电子设备可以参照实施例用于区块链透明分片方法的实施例及区块链透明分片装置的实施例进行实施,其内容被合并于此,重复之处不再赘述。
图11为本申请实施例的电子设备600的系统构成的示意框图。如图11所示,该电子设备600可以包括中央处理器100和存储器140;存储器140耦合到中央处理器100。值得注意的是,该图是示例性的;还可以使用其他类型的结构,来补充或代替该结构,以实现电信功能或其他功能。
一实施例中,区块链透明分片方法可以被集成到中央处理器100中。其中,中央处理器100可以被配置为进行如下控制:获取服务于区块链的多个分片节点信息,根据所述分片节点信息通过一致性哈希算法获得分片节点与分片的对应关系;根据分片节点与分片的对应关系和所述分片节点,于DHT网络上构建与所述分片对应的ReDiR树;根据所述ReDiR树获得处理交易数据的分片节点。
其中,根据分片节点与分片的对应关系和所述分片节点,于DHT网络上构建与所述分片对应的ReDiR树可包含:所述分片节点加入所述ReDiR树后,根据分片节点于所述 ReDiR树中所处空间位置获得服务位置信息;将所述服务位置信息与所述分片节点信息绑定后发布至所述DHT网络中。
其中,所述服务位置信息包含所述ReDiR树中的层级位置信息及所述分片节点的编号信息。
其中,所述分片节点加入所述ReDiR树还包含:将所述分片节点的编号信息与预定阈值比较,根据比较结果获得所述分片节点在所述ReDiR树中的层级位置信息。
中央处理器100还可以被配置为进行如下控制:获取交易数据的合约位址信息,根据所述合约位址信息通过一致性哈希算法获得交易数据与分片的对应关系;根据所述交易数据与分片的对应关系,于对应分片中获得分片节点;将所述交易数据发送至所述分片节点。
其中,根据所述交易数据与分片的对应关系,于对应分片中获得分片节点之前还包含:通过所述分片中的分片节点,于DHT网络上构建与所述分片对应的ReDiR树;根据所述交易数据与分片的对应关系,于对应分片的ReDiR树中获得分片节点。
其中,根据所述交易数据与分片的对应关系,于对应分片中获得分片节点还包含:根据当前操作所述交易数据的用户的账户地址与对应分片的ReDiR树中分片节点的位址信息计算获得两者之间的逻辑距离,根据所述逻辑距离获得处理所述交易数据的分片节点。
其中,根据当前操作所述交易数据的用户的账户地址与对应分片的ReDiR树中分片节点的位址信息计算获得两者之间的逻辑距离,根据所述逻辑距离获得处理所述交易数据的分片节点还包含:根据当前操作所述交易数据的用户的账户地址于所述ReDiR树中生成资源地址信息;根据所述资源地址信息查询所述ReDiR树中分片节点的位址信息;根据查询结果调整所述资源地址信息。
其中,根据所述交易数据与分片的对应关系,于对应分片中获得分片节点还包含:根据所述交易数据的合约位址信息与对应分片的ReDiR树中分片节点的位址信息计算获得两者之间的逻辑距离,根据所述逻辑距离获得处理所述交易数据的分片节点。
其中,根据所述逻辑距离获得处理所述交易数据的分片节点包含:通过异或运算获得所述逻辑距离,选择所述逻辑距离最小的分片节点作为处理所述交易数据的分片节点。
从上述描述可知,本申请的实施例提供一种电子设备,通过使用一致哈希算法确定合约和分片的对应关系,以及分片节点和分片的对应关系;使得节点和合约均衡分布在不同的分片中。其次基于DHT网络的ReDiR(Recursive Distributed Rendezvous)服务发 现机制,使得合约部署者和调用者不必指定目标分片和节点地址,交易可以透明路由到相应的分片。
在另一个实施方式中,区块链透明分片装置可以与中央处理器100分开配置,例如可以将区块链透明分片装置配置为与中央处理器100连接的芯片,通过中央处理器的控制来实现区块链透明分片操作。
如图11所示,该电子设备600还可以包括:通信模块110、输入单元120、音频处理器130、显示器160、电源170。值得注意的是,电子设备600也并不是必须要包括图11中所示的所有部件;此外,电子设备600还可以包括图11中没有示出的部件,可以参考现有技术。
如图11所示,中央处理器100有时也称为控制器或操作控件,可以包括微处理器或其他处理器装置和/或逻辑装置,该中央处理器100接收输入并控制电子设备600的各个部件的操作。
其中,存储器140,例如可以是缓存器、闪存、硬驱、可移动介质、易失性存储器、非易失性存储器或其它合适装置中的一种或更多种。可储存上述与失败有关的信息,此外还可存储执行有关信息的程序。并且中央处理器100可执行该存储器140存储的该程序,以实现信息存储或处理等。
输入单元120向中央处理器100提供输入。该输入单元120例如为按键或触摸输入装置。电源170用于向电子设备600提供电力。显示器160用于进行图像和文字等显示对象的显示。该显示器例如可为LCD显示器,但并不限于此。
该存储器140可以是固态存储器,例如,只读存储器(ROM)、随机存取存储器(RAM)、SIM卡等。还可以是这样的存储器,其即使在断电时也保存信息,可被选择性地擦除且设有更多数据,该存储器的示例有时被称为EPROM等。存储器140还可以是某种其它类型的装置。存储器140包括缓冲存储器141(有时被称为缓冲器)。存储器140可以包括应用/功能存储部142,该应用/功能存储部142用于存储应用程序和功能程序或用于通过中央处理器100执行电子设备600的操作的流程。
存储器140还可以包括数据存储部143,该数据存储部143用于存储数据。存储器140的驱动程序存储部144可以包括电子设备的用于通信功能和/或用于执行电子设备的其他功能(如消息传送应用、通讯录应用等)的各种驱动程序。
通信模块110即为经由天线111发送和接收信号的发送机/接收机110。通信模块(发送机/接收机)110耦合到中央处理器100,以提供输入信号和接收输出信号,这可 以和常规移动通信终端的情况相同。
基于不同的通信技术,在同一电子设备中,可以设置有多个通信模块110,如蜂窝网络模块、蓝牙模块和/或无线局域网模块等。通信模块(发送机/接收机)110还经由音频处理器130耦合到扬声器131和麦克风132,以经由扬声器131提供音频输出,并接收来自麦克风132的音频输入,从而实现通常的电信功能。音频处理器130可以包括任何合适的缓冲器、解码器、放大器等。另外,音频处理器还耦合到中央处理器100,从而使得可以通过麦克风132能够在本机上录音,且使得可以通过扬声器131来播放本机上存储的声音。
本申请的实施例还提供能够实现上述实施例中的区块链透明分片方法中全部步骤的一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,该计算机程序被处理器执行时实现上述实施例中的区块链透明分片方法的全部步骤,例如,所述处理器执行所述计算机程序时实现下述步骤:
获取服务于区块链的多个分片节点信息,根据所述分片节点信息通过一致性哈希算法获得分片节点与分片的对应关系;根据分片节点与分片的对应关系和所述分片节点,于DHT网络上构建与所述分片对应的ReDiR树;根据所述ReDiR树获得处理交易数据的分片节点;或获取交易数据的合约位址信息,根据所述合约位址信息通过一致性哈希算法获得交易数据与分片的对应关系;根据所述交易数据与分片的对应关系,于对应分片中获得分片节点;将所述交易数据发送至所述分片节点等。
从上述描述可知,本申请的实施例提供一种计算机可读存储介质,通过使用一致哈希算法确定合约和分片的对应关系,以及分片节点和分片的对应关系;使得节点和合约均衡分布在不同的分片中。其次基于DHT网络的ReDiR(Recursive Distributed Rendezvous)服务发现机制,使得合约部署者和调用者不必指定目标分片和节点地址,交易可以透明路由到相应的分片。
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一 流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
本发明中应用了具体实施例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的方法及其核心思想;同时,对于本领域的一般技术人员,依据本发明的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本发明的限制。
Claims (21)
- 一种区块链透明分片方法,其特征在于,所述方法包含:获取服务于区块链的多个分片节点信息,根据所述分片节点信息通过一致性哈希算法获得分片节点与分片的对应关系;根据分片节点与分片的对应关系和所述分片节点,于DHT网络上构建与所述分片对应的ReDiR树;根据所述ReDiR树获得处理交易数据的分片节点。
- 根据权利要求1所述的区块链透明分片方法,其特征在于,根据分片节点与分片的对应关系和所述分片节点,于DHT网络上构建与所述分片对应的ReDiR树还包含:所述分片节点加入所述ReDiR树后,根据分片节点于所述ReDiR树中所处空间位置获得服务位置信息;将所述服务位置信息与所述分片节点信息绑定后发布至所述DHT网络中。
- 根据权利要求2所述的区块链透明分片方法,其特征在于,所述服务位置信息包含所述ReDiR树中的层级位置信息及所述分片节点的编号信息。
- 根据权利要求3所述的区块链透明分片方法,其特征在于,所述分片节点加入所述ReDiR树还包含:将所述分片节点的编号信息与预定阈值比较,根据比较结果获得所述分片节点在所述ReDiR树中的层级位置信息。
- 一种区块链透明分片方法,其特征在于,所述方法包含:获取交易数据的合约位址信息,根据所述合约位址信息通过一致性哈希算法获得交易数据与分片的对应关系;根据所述交易数据与分片的对应关系,于对应分片中获得分片节点;将所述交易数据发送至所述分片节点。
- 根据权利要求5所述的区块链透明分片方法,其特征在于,根据所述交易数据与分片的对应关系,于对应分片中获得分片节点之前还包含:通过所述分片中的分片节点,于DHT网络上构建与所述分片对应的ReDiR树;根据所述交易数据与分片的对应关系,于对应分片的ReDiR树中获得分片节点。
- 根据权利要求6所述的区块链透明分片方法,其特征在于,根据所述交易数据与分片的对应关系,于对应分片中获得分片节点还包含:根据当前操作所述交易数据的用户的账户地址与对应分片的ReDiR树中分片节点的位址信息计算获得两者之间的逻辑距离,根据所述逻辑距离获得处理所述交易数据的分片节点。
- 根据权利要求7所述的区块链透明分片方法,其特征在于,根据当前操作所述交易数据的用户的账户地址与对应分片的ReDiR树中分片节点的位址信息计算获得两者之间的逻辑距离,根据所述逻辑距离获得处理所述交易数据的分片节点还包含:根据当前操作所述交易数据的用户的账户地址于所述ReDiR树中生成资源地址信息;根据所述资源地址信息查询所述ReDiR树中分片节点的位址信息;根据查询结果调整所述资源地址信息。
- 根据权利要求6所述的区块链透明分片方法,其特征在于,根据所述交易数据与分片的对应关系,于对应分片中获得分片节点还包含:根据所述交易数据的合约位址信息与对应分片的ReDiR树中分片节点的位址信息计算获得两者之间的逻辑距离,根据所述逻辑距离获得处理所述交易数据的分片节点。
- 根据权利要求7至9中任一项所述的区块链透明分片方法,其特征在于,根据所述逻辑距离获得处理所述交易数据的分片节点包含:通过异或运算获得所述逻辑距离,选择所述逻辑距离最小的分片节点作为处理所述交易数据的分片节点。
- 一种区块链透明分片装置,其特征在于,所述装置包含关系确定模块、构建模块和查询模块;所述关系确定模块用于获取服务于区块链的多个分片节点信息,根据所述分片节点信息通过一致性哈希算法获得分片节点与分片的对应关系;所述构建模块用于根据分片节点与分片的对应关系和所述分片节点,于DHT网络上构建与所述分片对应的ReDiR树;所述查询模块用于根据所述ReDiR树获得处理交易数据的分片节点。
- 根据权利要求11所述的区块链透明分片装置,其特征在于,所述构建模块还包含在所述分片节点加入所述ReDiR树后,根据分片节点于所述ReDiR树中所处空间位置获得服务位置信息;将所述服务位置信息与所述分片节点信息绑定后发布至所述DHT网络中。
- 一种区块链透明分片装置,其特征在于,所述装置包含合约处理模块、关系查询模块和发送模块;所述合约处理模块用于获取交易数据的合约位址信息,根据所述合约位址信息通过一致性哈希算法获得交易数据与分片的对应关系;所述关系查询模块用于根据所述交易数据与分片的对应关系,于对应分片中获得分片节点;所述发送模块用于将所述交易数据发送至所述分片节点。
- 根据权利要求13所述的区块链透明分片装置,其特征在于,所述装置还包含生成模块,所述生成模块用于通过所述分片中的分片节点,于DHT网络上构建与所述分片对应的ReDiR树;根据所述交易数据与分片的对应关系,于对应分片的ReDiR树中获得分片节点。
- 根据权利要求14所述的区块链透明分片装置,其特征在于,所述关系查询模块还包含距离计算模块,所述距离计算模块用于根据当前操作所述交易数据的用户的账户地址或所述交易数据的合约位址信息中一个,与对应分片的ReDiR树中分片节点的位址信息计算获得两者之间的逻辑距离,根据所述逻辑距离获得处理所述交易数据的分片节点。
- 一种区块链透明分片系统,其特征在于,所述系统包含构建单元和处理单元;所述构建单元用于获取服务于区块链的多个分片节点信息,根据所述分片节点信息通过一致性哈希算法获得分片节点与分片的对应关系;以及根据分片节点与分片的对应关系和所述分片节点,于DHT网络上构建与所述分片对应的ReDiR树;所述处理单元用于获取交易数据的合约位址信息,根据所述合约位址信息通过一致性哈希算法获得交易数据与分片的对应关系;以及根据所述交易数据与分片的对应关系,于对应分片中获得分片节点;将所述交易数据发送至所述分片节点。
- 根据权利要求16所述的区块链透明分片系统,其特征在于,所述处理单元还包含账户计算模块,所述账户计算模块用于根据当前操作所述交易数据的用户的账户地址与对应分片的ReDiR树中分片节点的位址信息计算获得两者之间的逻辑距离,根据所述逻辑距离获得处理所述交易数据的分片节点。
- 根据权利要求16所述的区块链透明分片系统,其特征在于,所述处理单元还包含合约计算模块,所述合约计算模块用于根据所述交易数据的合约位址信息与对应分片的ReDiR树中分片节点的位址信息计算获得两者之间的逻辑距离,根据所述逻辑距离获得处理所述交易数据的分片节点。
- 根据权利要求16所述的区块链透明分片系统,其特征在于,所述构建单元还包含发布模块,所述发布模块用于所述分片节点加入所述ReDiR树后,根据分片节点于所述ReDiR树中所处空间位置获得服务位置信息;将所述服务位置信息与所述分片节点信息绑定后发布至所述DHT网络中。
- 一种电子设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计 算机程序,其特征在于,所述处理器执行所述计算机程序时实现权利要求1至10中任一项所述的区块链透明分片方法的步骤。
- 一种计算机可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现权利要求1至10中任一项所述的区块链透明分片方法的步骤。
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810743807.2 | 2018-07-09 | ||
CN201810743807.2A CN109146447B (zh) | 2018-07-09 | 2018-07-09 | 区块链透明分片方法、装置及系统 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2020011154A1 true WO2020011154A1 (zh) | 2020-01-16 |
Family
ID=64799967
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2019/095226 WO2020011154A1 (zh) | 2018-07-09 | 2019-07-09 | 区块链透明分片方法、装置及系统 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN109146447B (zh) |
WO (1) | WO2020011154A1 (zh) |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111680327A (zh) * | 2020-06-10 | 2020-09-18 | 中国银行股份有限公司 | 基于区块链的客户信息整合方法、装置、设备及存储介质 |
CN112688870A (zh) * | 2020-12-28 | 2021-04-20 | 杭州趣链科技有限公司 | 一种路由方法、路由装置及节点设备 |
CN113656508A (zh) * | 2021-08-26 | 2021-11-16 | 支付宝(杭州)信息技术有限公司 | 区块链系统中执行交易的方法及装置 |
CN114140115A (zh) * | 2021-10-28 | 2022-03-04 | 湖南天河国云科技有限公司 | 区块链交易池的分片方法、系统、存储介质和计算机系统 |
CN115834087A (zh) * | 2023-02-21 | 2023-03-21 | 中国科学院合肥物质科学研究院 | 基于层叠网络的区块链分片方法、系统、设备及存储介质 |
CN116012164A (zh) * | 2023-03-17 | 2023-04-25 | 安徽中科晶格技术有限公司 | 基于虚拟账户的区块链跨分片交易方法 |
Families Citing this family (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109146447B (zh) * | 2018-07-09 | 2022-07-05 | 矩阵元技术(深圳)有限公司 | 区块链透明分片方法、装置及系统 |
CN110753026B (zh) * | 2019-02-27 | 2020-10-30 | 北京嘀嘀无限科技发展有限公司 | 一种基于区块链的分片方法及装置 |
CN111026511B (zh) * | 2019-11-20 | 2023-08-08 | 中国科学院计算技术研究所 | 基于事务数据分区-链间融合的区块链并行系统及方法 |
CN110958324B (zh) * | 2019-12-12 | 2023-12-19 | 度小满科技(北京)有限公司 | 一种区块链网络的数据处理方法及装置 |
CN111083052B (zh) * | 2019-12-19 | 2022-01-28 | 度小满科技(北京)有限公司 | 一种基于有序平衡二叉树的分片方法及装置 |
CN111221910A (zh) * | 2019-12-31 | 2020-06-02 | 杭州趣链科技有限公司 | 一种提升区块链读写性能的分片存储方法 |
CN111694809B (zh) * | 2020-06-11 | 2021-05-04 | 杭州云链趣链数字科技有限公司 | 基于区块链的文件过滤方法、装置和计算机设备 |
CN112039860B (zh) * | 2020-08-18 | 2021-04-06 | 上海简苏网络科技有限公司 | 一种在联盟链中实现联合共识分片的方法和装置 |
CN112866025B (zh) * | 2021-01-14 | 2022-10-11 | 公安部第三研究所 | 一种智能合约的分片处理方法 |
CN113411376A (zh) * | 2021-05-12 | 2021-09-17 | 精英数智科技股份有限公司 | 基于区块链分片存储的传感器数据处理方法及装置 |
CN115550251B (zh) * | 2022-12-01 | 2023-03-10 | 杭州蚂蚁酷爱科技有限公司 | 区块链网络、节点集合的维护方法及装置 |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106682984A (zh) * | 2016-10-27 | 2017-05-17 | 上海亿账通区块链科技有限公司 | 基于区块链的交易事务处理方法及系统 |
CN107770154A (zh) * | 2017-09-22 | 2018-03-06 | 中国科学院信息工程研究所 | 基于云存储的区块链可靠数据存储方法、终端及系统 |
CN108243250A (zh) * | 2018-01-05 | 2018-07-03 | 无锡井通网络科技有限公司 | 一种基于分布式网络的分片快速选择方法 |
CN109146447A (zh) * | 2018-07-09 | 2019-01-04 | 矩阵元技术(深圳)有限公司 | 区块链透明分片方法、装置及系统 |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP5666719B2 (ja) * | 2010-12-20 | 2015-02-12 | テレフオンアクチーボラゲット エル エム エリクソン(パブル) | ピアツーピア・ネットワークにおける検索 |
EP2671368A1 (en) * | 2011-01-31 | 2013-12-11 | Telefonaktiebolaget L M Ericsson (PUBL) | Adaptive service discovery in structured peer-to-peer overlay networks and method |
CN106899680B (zh) * | 2017-03-09 | 2019-07-30 | 深圳壹账通智能科技有限公司 | 多区块链的分片处理方法和装置 |
-
2018
- 2018-07-09 CN CN201810743807.2A patent/CN109146447B/zh active Active
-
2019
- 2019-07-09 WO PCT/CN2019/095226 patent/WO2020011154A1/zh active Application Filing
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106682984A (zh) * | 2016-10-27 | 2017-05-17 | 上海亿账通区块链科技有限公司 | 基于区块链的交易事务处理方法及系统 |
CN107770154A (zh) * | 2017-09-22 | 2018-03-06 | 中国科学院信息工程研究所 | 基于云存储的区块链可靠数据存储方法、终端及系统 |
CN108243250A (zh) * | 2018-01-05 | 2018-07-03 | 无锡井通网络科技有限公司 | 一种基于分布式网络的分片快速选择方法 |
CN109146447A (zh) * | 2018-07-09 | 2019-01-04 | 矩阵元技术(深圳)有限公司 | 区块链透明分片方法、装置及系统 |
Non-Patent Citations (1)
Title |
---|
RHEA, S. ET AL.: "OpenDHT: A Public DHT Service and Its Uses", ACM SIGCOMM COMPUTER COMMUNICATION REVIEW, 26 August 2005 (2005-08-26), pages 73 - 84, XP058144779 * |
Cited By (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111680327A (zh) * | 2020-06-10 | 2020-09-18 | 中国银行股份有限公司 | 基于区块链的客户信息整合方法、装置、设备及存储介质 |
CN111680327B (zh) * | 2020-06-10 | 2024-02-23 | 中国银行股份有限公司 | 基于区块链的客户信息整合方法、装置、设备及存储介质 |
CN112688870A (zh) * | 2020-12-28 | 2021-04-20 | 杭州趣链科技有限公司 | 一种路由方法、路由装置及节点设备 |
CN112688870B (zh) * | 2020-12-28 | 2022-11-04 | 杭州趣链科技有限公司 | 一种路由方法、路由装置及节点设备 |
CN113656508A (zh) * | 2021-08-26 | 2021-11-16 | 支付宝(杭州)信息技术有限公司 | 区块链系统中执行交易的方法及装置 |
CN114140115A (zh) * | 2021-10-28 | 2022-03-04 | 湖南天河国云科技有限公司 | 区块链交易池的分片方法、系统、存储介质和计算机系统 |
CN115834087A (zh) * | 2023-02-21 | 2023-03-21 | 中国科学院合肥物质科学研究院 | 基于层叠网络的区块链分片方法、系统、设备及存储介质 |
CN115834087B (zh) * | 2023-02-21 | 2023-06-06 | 中国科学院合肥物质科学研究院 | 基于层叠网络的区块链分片方法、系统、设备及存储介质 |
CN116012164A (zh) * | 2023-03-17 | 2023-04-25 | 安徽中科晶格技术有限公司 | 基于虚拟账户的区块链跨分片交易方法 |
Also Published As
Publication number | Publication date |
---|---|
CN109146447A (zh) | 2019-01-04 |
CN109146447B (zh) | 2022-07-05 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2020011154A1 (zh) | 区块链透明分片方法、装置及系统 | |
US11762703B2 (en) | Multi-region request-driven code execution system | |
CN115516831B (zh) | Sd-wan集线器和辐条的自动配设 | |
US10372499B1 (en) | Efficient region selection system for executing request-driven code | |
CA2964461C (en) | Composite partition functions | |
US9712612B2 (en) | Method for improving mobile network performance via ad-hoc peer-to-peer request partitioning | |
CN110730478B (zh) | 切片关联方法、装置、端到端切片编排器及存储介质 | |
CN111460504B (zh) | 业务处理方法、装置、节点设备及存储介质 | |
CN115208812B (zh) | 业务处理方法及装置、设备、计算机可读存储介质 | |
WO2020011011A1 (zh) | P2p网络中的消息广播方法及系统 | |
US10129358B2 (en) | Partitioned serialized caching and delivery of large files | |
JP2017117204A (ja) | プロセッサ、再構成可能回路の制御方法及びプログラム | |
US11075987B1 (en) | Load estimating content delivery network | |
CN110727738B (zh) | 基于数据分片的全局路由系统、电子设备及存储介质 | |
CN112905338B (zh) | 计算资源自动分配方法及装置 | |
CN111666589A (zh) | 区块链分布式的风险数据共享系统及方法 | |
US9860171B2 (en) | Large scale message routing in a distributed network | |
CN107342929B (zh) | 一种新消息通知的发送方法、装置及系统 | |
CN112437449A (zh) | 联合资源分配方法及区域编排器 | |
CN106550025A (zh) | 一种移动云计算系统的数据处理方法及装置 | |
CN114710496A (zh) | 一种多节点负载均衡方法及装置 | |
US10778660B1 (en) | Managing multiple producer consumer—systems with non-identical idempotency keys | |
US8880729B2 (en) | Method and apparatus for routing requests for service using BGP community attributes | |
US9882835B2 (en) | Programming method and apparatus for core routing and switching system | |
CN104618421A (zh) | 存储资源分配方法及装置 |
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: 19834446 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 19834446 Country of ref document: EP Kind code of ref document: A1 |