Blockchain sharding method, system, device and storage medium based on directed acyclic graph in cold chain logistics
By employing consortium blockchains and directed acyclic graph sharding technology in cold chain logistics, the efficiency bottleneck and slow consensus mechanism of traditional single-chain blockchains in cold chain logistics have been solved, enabling high-concurrency transaction processing and rapid data synchronization, thereby improving the data processing capabilities of cold chain logistics.
Patent Information
- Application Number
- CN202410236365.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-01
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2044-03-01
AI Technical Summary
Traditional single-chain blockchain technology suffers from efficiency bottlenecks and slow consensus mechanisms in cold chain logistics, resulting in low data synchronization and initialization efficiency and insufficient transaction throughput.
By adopting the Directed Acyclic Graph (DAG) blockchain sharding technology based on consortium blockchains, cold chain transportation companies are sharded by IP region to form a sharded blockchain. Merkle tree and cross-shard Merkle tree structures are used, combined with a global snapshot synchronization mechanism to achieve parallel transaction processing and high throughput.
It improves the block generation speed and transaction processing capacity of the blockchain network, increases the transaction processing speed per unit time, solves the efficiency bottleneck and slow consensus mechanism of single-chain blockchain, and achieves high concurrency characteristics.
Smart Images

Figure CN118069748B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain technology, and in particular to a blockchain sharding method, system, device and storage medium based on a directed acyclic graph in cold chain logistics. Background Art
[0002] In essence, blockchain technology is a distributed, decentralized database system. Unlike traditional centralized databases, it does not have a central authority, but is maintained and managed by a network of many nodes. These nodes are equal, and no node can control the entire system, nor can any node unilaterally change data records. Therefore, each participant in the blockchain network needs to be responsible for his or her own behavior, which also means that the transaction data of the participants is non-repudiable, thereby achieving non-repudiation of transactions. In the blockchain, a variety of encryption algorithms are used to protect the security of account information and privacy in each node. The more common encryption algorithms use public and private keys to encrypt and decrypt information, which can ensure the security of information. This encryption method is also called asymmetric encryption. In addition, the blockchain also uses a consensus mechanism to ensure the reliability of transaction records. Only when a consensus is reached on a transaction on multiple nodes will the transaction be recognized and recorded in the blockchain, thereby ensuring the authenticity and validity of the transaction record.
[0003] Compared with the traditional Internet, the biggest difference of blockchain is its ability to transmit information. When blockchain is regarded as a means of storing information, it has the characteristics of distributed data storage and data transaction consensus across the entire network compared to traditional centralized databases, which greatly reduces the possibility of data loss and ensures that data is difficult to tamper with. Blockchain technology has strong scalability. It can be used in combination with various traditional disciplines to develop different application frameworks, improve the data and algorithms of the entire system, and raise credibility to a higher level.
[0004] According to the existing patent documents, the blockchain technology used in the cold chain logistics transportation process mainly uses blockchain technology based on the public chain, which is also a truly decentralized blockchain principle and method. This method uses a decentralized distributed accounting system, in which all participating nodes do not need to trust each other, and all maintain the same ledger through a unique consensus rule. Unlike the B / S-based business system, all nodes in the blockchain are independent and each backs up a complete copy of the chain data history record information. At the same time, all transaction data will be re-verified by all nodes, forming a new peer-to-peer (p2p) network structure.
[0005] The main consensus mechanism of the public chain is the Proof of Work (POW) mechanism, which is typically used in the generation mechanism of Bitcoin. The core of this algorithm is that after each node in the blockchain conducts transactions with other nodes, its transaction records must be recorded and stored by all nodes in the network. In order to ensure fairness among all nodes in the competition, the POW mechanism introduces the concept of risk-return ratio in economics. All nodes need to calculate a hash algorithm of a certain difficulty to prove their workload measurement before they can obtain the right to hang on the chain of the new block. Each node also needs to calculate the cumulative computing power of the longest chain before it can obtain this right. This is not applicable to the current timeliness and energy saving and efficiency improvement of the Internet of Things.
[0006] Another consensus mechanism is the Byzantine Fault Tolerance (BFT) mechanism based on the Byzantine Generals' Problem. The most widely used one is the Practical Byzantine Fault Tolerance (PBFT) mechanism. All nodes need to complete the negotiation process, which is divided into three stages: pre-preparation, preparation, and confirmation. By introducing a view concept, the transaction initiating node is set as the main (proposing) node, and the negotiation process between all nodes is completed under the same view. Obviously, with the surge in the number of nodes, the complexity of communication between nodes will surge, and the communication efficiency will be greatly reduced, which is also not suitable for the needs of the Internet of Things.
[0007] The above-mentioned POW mechanism and BFT mechanism both belong to the single-chain blockchain structure. Due to the characteristics of the single-chain structure, this type of ledger is prone to performance bottlenecks. The single-chain blockchain ledger uses a single-chain sequence to sort the transactions that occur. When the block size, consensus protocol, and network load are fixed, the scale of consensus messages in the system increases at O(n) with the transaction throughput. When the transactions sent exceed the system load, a large number of transactions will accumulate, causing a large number of transactions to wait for encapsulation into blocks, indirectly reducing the performance of the blockchain. Therefore, the single-chain blockchain ledger structure has become an important bottleneck for improving the performance of the alliance chain system. Summary of the invention
[0008] In view of this, an embodiment of the present disclosure provides a blockchain sharding method based on a directed acyclic graph in cold chain logistics, which at least partially solves the problems existing in the prior art.
[0009] In a first aspect, an embodiment of the present disclosure provides a blockchain sharding method based on a directed acyclic graph in cold chain logistics, the method comprising the following steps:
[0010] Form a private chain according to the alliance chain model;
[0011] Each cold chain transportation enterprise that has obtained CA certification constitutes a node of the private chain, and the nodes are regionally sharded according to different IP regional geographical locations; wherein the nodes in the same IP segment area form a regional single chain structure, which is called a sharded blockchain;
[0012] The internal consensus period of the consortium chain DAG shard block includes: dividing the Merkle tree root node of each node into an intra-shard Merkle tree and a cross-shard Merkle tree; when a transaction occurs between two nodes in the same shard blockchain, it is recorded in the intra-shard Merkle tree of the node; when a transaction occurs between two nodes in different shard blockchains, it is recorded in the cross-shard Merkle tree of the node; forming a global snapshot of the entire chain ledger at the current moment and storing it in the regulatory agency server;
[0013] The shard blockchain multi-chain snapshot synchronization period includes: each shard blockchain synchronizes the intra-shard transaction and cross-shard transaction change ledgers with the global snapshot through polling, and updates the global snapshot;
[0014] The shard block global snapshot synchronization period includes: broadcasting the global snapshot to each shard blockchain of the entire blockchain. After receiving the broadcast, each shard blockchain updates the Merkle tree ledger of its own block, thereby achieving consensus on the entire blockchain.
[0015] According to a specific implementation of the embodiment of the present disclosure, the method further includes:
[0016] When a new node is added to each shard blockchain, the hash value of the previous block in this area is obtained, and the consensus algorithm of this area is completed.
[0017] According to a specific implementation method of an embodiment of the present disclosure, nodes are put on the chain, nodes are traded, global snapshots are updated, global snapshots are synchronized, and concurrent execution is allowed.
[0018] According to a specific implementation of the embodiment of the present disclosure, when in the internal consensus period of the alliance chain DAG shard block, chain uploading, intra-shard consensus processing, intra-shard transactions, and cross-shard transactions are allowed. At this time, the node ledger state and the global ledger state may not be completely consistent;
[0019] When the sharded blockchain is in the multi-chain snapshot synchronization period, the chain, intra-shard consensus processing, intra-shard transactions, and cross-shard transactions are suspended, waiting for each shard to synchronize the intra-shard and cross-shard transaction change ledgers with the global snapshot through polling;
[0020] When the shard block global snapshot synchronization period is in progress, chain uploading, intra-shard consensus processing, intra-shard transactions, and cross-shard transactions are suspended, waiting for the shard block global snapshot synchronization to be completed.
[0021] According to a specific implementation method of an embodiment of the present disclosure, the participating units of the authentication system of the private chain include: transportation companies, supervisory agencies and operating agencies involved in cold chain transportation supervision.
[0022] In a second aspect, the embodiment of the present disclosure provides a blockchain sharding system based on a directed acyclic graph in cold chain logistics, the system comprising:
[0023] A blockchain module, configured to form a private chain in accordance with a consortium chain model; and,
[0024] Each cold chain transportation enterprise that has obtained CA certification constitutes a node of the private chain, and the nodes are regionally sharded according to different IP regional geographical locations; wherein the nodes in the same IP segment area form a regional single chain structure, which is called a sharded blockchain;
[0025] The consensus module is configured for the internal consensus period of the consortium chain DAG shard block, including: dividing the Merkle tree root node of each node into an intra-shard Merkle tree and a cross-shard Merkle tree; when a transaction occurs between two nodes in the same shard blockchain, it is recorded in the intra-shard Merkle tree of the node; when a transaction occurs between two nodes in different shard blockchains, it is recorded in the cross-shard Merkle tree of the node; forming a global snapshot of the entire chain ledger at the current moment and storing it in the regulatory agency server;
[0026] The shard blockchain multi-chain snapshot synchronization period includes: each shard blockchain synchronizes the intra-shard transaction and cross-shard transaction change ledgers with the global snapshot through polling, and updates the global snapshot; and
[0027] The shard block global snapshot synchronization period includes: broadcasting the global snapshot to each shard blockchain of the entire blockchain. After receiving the broadcast, each shard blockchain updates the Merkle tree ledger of its own block, thereby achieving consensus on the entire blockchain.
[0028] In a third aspect, an embodiment of the present disclosure further provides an electronic device, the electronic device comprising:
[0029] at least one processor; and,
[0030] a memory communicatively connected to the at least one processor; wherein,
[0031] The memory stores instructions that can be executed by the at least one processor. When the instructions are executed by the at least one processor, the at least one processor implements the blockchain sharding method based on a directed acyclic graph in cold chain logistics as described in any one of the first aspect or any one of the implementations of the first aspect.
[0032] In a fourth aspect, an embodiment of the present disclosure further provides a non-transitory computer-readable storage medium, which stores computer instructions, and when the computer instructions are executed by at least one processor, the at least one processor executes the blockchain sharding method based on a directed acyclic graph in cold chain logistics in the aforementioned first aspect or any implementation of the first aspect.
[0033] In a fifth aspect, an embodiment of the present disclosure further provides a computer program product, comprising a computer program stored on a non-transitory computer-readable storage medium, wherein the computer program comprises program instructions, and when the program instructions are executed by a computer, the computer executes the blockchain sharding method based on a directed acyclic graph in cold chain logistics in the aforementioned first aspect or any implementation of the first aspect.
[0034] The blockchain sharding method based on directed acyclic graph in cold chain logistics in the disclosed embodiment, on the basis of traditional single-chain blockchain and public chain, adopts sharding block technology and DAG (Directed Acyclic Graph) blockchain ledger structure and consensus mechanism by establishing a consortium chain, forming a network structure that allows forking, thereby accelerating the block generation speed of the blockchain network and not being affected by the block broadcasting speed, so that the overall consortium chain is changed from the traditional serial ledger structure to a parallel ledger structure, forming the high concurrency characteristics of the DAG ledger consensus mechanism, and thus can improve the traditional serial ledger accounting processing speed, greatly improving the TPS (Transactions Per Second) of the network node accounting speed per unit time. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] The above is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0036] Figure 1 A flowchart of a blockchain sharding method based on a directed acyclic graph in cold chain logistics provided by an embodiment of the present disclosure;
[0037] Figure 2 A flowchart of a blockchain sharding method based on a directed acyclic graph in cold chain logistics provided by an embodiment of the present disclosure;
[0038] Figure 3 A schematic diagram of node characteristics of a directed acyclic graph sharding blockchain sharding processing technology based on a consortium chain provided in an embodiment of the present disclosure;
[0039] Figure 4A schematic diagram of ledger features of a directed acyclic graph sharding blockchain sharding processing technology based on a consortium chain provided in an embodiment of the present disclosure;
[0040] Figure 5 A schematic diagram of the structure of a blockchain sharding system based on a directed acyclic graph in cold chain logistics provided by an embodiment of the present disclosure; and
[0041] Figure 6 A schematic diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0042] The embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.
[0043] The following describes the embodiments of the present disclosure through specific examples, and those skilled in the art can easily understand other advantages and effects of the present disclosure from the contents disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all of the embodiments. The present disclosure can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present disclosure. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present disclosure.
[0044] It should be noted that various aspects of the embodiments within the scope of the appended claims are described below. It should be apparent that the aspects described herein may be embodied in a wide variety of forms, and any specific structure and / or function described herein is merely illustrative. Based on the present disclosure, it should be understood by those skilled in the art that an aspect described herein may be implemented independently of any other aspect, and two or more of these aspects may be combined in various ways. For example, any number of aspects described herein may be used to implement a device and / or practice a method. In addition, other structures and / or functionalities other than one or more of the aspects described herein may be used to implement this device and / or practice this method.
[0045] Additionally, in the following description, specific details are provided to facilitate a thorough understanding of the examples. However, it will be understood by those skilled in the art that the aspects described may be practiced without these specific details.
[0046] At present, a large number of modern information means and technologies are used in cold chain logistics to solve the digital management problems of temperature, humidity, temperature control, vehicle trajectory, and electronic bills in the logistics process. At the same time, a variety of communication means are used to collect data information content, and database technology and big data technology are combined to explore and analyze existing data. However, the main means is still to manage cold chain logistics information through a centralized data management model and implement supervision by enterprises and regulatory departments, and improve the intelligence level of cold chain logistics. However, in this type of centralized data solution, the management process is completed independently by cold chain logistics companies, and regulatory units only obtain enterprise data content through third-party interfaces, resulting in "trust issues" as the core problem:
[0047] 1. Data trust issues in the cold chain transportation process, such as data tampering and data falsification;
[0048] 2. Trust issues in operational data during cold chain transportation, such as falsifying sensor temperature, shutting down refrigerants, and creating pseudo full-process cold chains by OD point refrigeration in order to save costs;
[0049] 3. Trust issues in cold chain data storage. The ownership of data belongs to logistics companies, which makes it difficult for government regulatory authorities and third-party testing agencies to conduct convenient cold chain traceability management.
[0050] 4. Cold chain data islands emerge. From the perspective of the entire cold chain transportation industry chain, the transportation process data is owned by scattered cold chain transportation companies, and it is difficult to analyze the entire transportation process of a specific cold chain case from the perspective of a transportation company;
[0051] 5. The responsibility for production safety cannot be determined. Especially for multimodal transport and drop-and-hook container cold chain transport, once there are production problems in the transportation of cold chain goods, food, and medicine, it is difficult to determine the responsibility.
[0052] The safety of cold chain transportation is related to the health of the people and social trust. Blockchain technology can realize the traceability of the upstream and downstream supply chains of cold chain transportation products, which is of great significance in solving the safety problems of cold chain products. The decentralization and cryptographic basis of blockchain can build a secure database and network system for the entire supply chain, effectively prevent the forgery and tampering of information, provide reference and guidance for practical applications, enrich the cold chain logistics traceability system based on blockchain technology, and have strong theoretical innovation. At the same time, the decentralized, tamper-proof, open, transparent and multi-party consensus characteristics of blockchain fully make up for the isolated defects of the cold chain transportation Internet of Things: its decentralized and multi-centralized characteristics can not only effectively reduce the high operation and maintenance costs of the centralized architecture, but also avoid the manipulation caused by the monopoly of giants in the data network; the asymmetric encryption used by blockchain can not only effectively protect data privacy, but also effectively confirm data ownership, realize network identity authority management, and identify malicious nodes through multi-party consensus: blockchain relies on its chain structure to build traceable, tamper-proof, open and transparent electronic evidence, and uses multi-party consensus to ensure the accuracy, consistency and integrity of Internet of Things data; the distributed architecture and subject equality characteristics of blockchain not only help to weaken the security performance impact of centralized servers, but also help to break the shackles of information islands in the Internet of Things and promote horizontal data flow and multi-party collaboration.
[0053] The efficiency problem of traditional single-chain blockchain technology has become a bottleneck in the development of blockchain. Specifically, the single blockchain is too large, resulting in very low efficiency in data synchronization initialization. On the other hand, the consensus mechanism of the single-chain blockchain is slow. Typical single-chain consensus mechanism algorithms such as POW (Proof OfWork) require on-chain nodes to calculate the hash of the packaged blocks. If the hash value does not meet the difficulty value requirements, the random number is changed and the hash value is recalculated until the calculated hash value is less than the difficulty value to complete the consensus process. The difficulty increases with the extension of the public chain.
[0054] Based on the traditional single-chain blockchain and public chain, the present invention establishes a consortium chain, adopts the sharding block technology and the DAG (Directed Acyclic Graph) blockchain ledger structure and consensus mechanism, and forms a network structure that allows forking, thereby accelerating the block generation speed of the blockchain network and is not affected by the block broadcast speed. The overall consortium chain is changed from a traditional serial ledger structure to a parallel ledger structure, forming a high concurrency feature of the DAG ledger consensus mechanism, which can improve the traditional serial ledger accounting processing speed and greatly improve the TPS (Transactions Per Second) of the network node accounting speed per unit time.
[0055] Through the directed acyclic graph sharding blockchain sharding processing technology based on the alliance chain, the efficiency bottleneck problem of the traditional single-chain blockchain technology is solved, the problem of very low data synchronization initialization efficiency caused by the large size of the single blockchain is solved, and the problem of the slow consensus mechanism of the single-chain blockchain is solved.
[0056] Consortium chain is a blockchain structure proposed in contrast to public chain. In essence, consortium chain does not belong to public chain, but is a partially private chain, which does not fully realize the idea of decentralization. In the process of cold chain transportation, in order to facilitate accurate supervision, management and traceability of enterprises, government regulatory agencies and cold chain logistics stakeholders, different cold chain transportation participants have different roles in the business, usually several business data providers plus 1-2 regulators. Therefore, consortium chain is more suitable for cold chain transportation business. From a technical perspective, consortium chain has the following advantages:
[0057] 1) In terms of access method, unlike the public chain which has no restrictions on access, the alliance chain access mechanism must be authorized by the alliance chain to obtain CA certification and PKI digital certificate before access can be made.
[0058] 2) The alliance chain uses an asymmetric encryption algorithm for transactions, which is conducive to the speed of transactions.
[0059] 3) At the consensus algorithm level, the business consensus of the alliance chain can be completely separated from the data consensus. The authenticity of the business data can be generated by a single party and endorsed by multiple parties to achieve cross-verification. In terms of data consensus, the alliance chain can adopt any consensus algorithm according to business needs.
[0060] 4) In terms of performance, the consortium chain must achieve a high throughput, and 4000TPS is generally considered to be the most basic requirement.
[0061] The blockchain's sharding technology draws on the architectural design of distributed databases, that is, splitting and processing from large data tables separately, or storing them separately according to server addresses, or cutting the two-dimensional table into tuple rows and attribute columns and storing them in different servers.
[0062] Sharding in a sharded blockchain refers to dividing the original single-chain structure into several sharded blockchains according to the node area network address or the transaction process. Taking network address sharding as an example, the original single-chain structure can be divided into several independent network area shards. Transactions within a shard are directly established through independent consensus within the shard, and transactions between shards are pushed to the alliance chain nodes for recording in the form of a public ledger. Regardless of whether it is a transaction within a shard or a cross-shard transaction, it is broadcast to the entire chain through the polling mechanism of the public ledger, and a full network consensus is formed by updating the node ledger. In this way, the single-chain structure can realize parallel processing of multi-sharded blockchains through sharding technology transformation, thereby solving the scalability problem of the blockchain single-chain structure system, realizing that the single-shard structure is smaller than the overall single-chain structure, and greatly reducing the scale of the consensus algorithm between blockchain nodes. In view of the binary value characteristics of the block hash value Merkle tree root node calculation, the overall network communication cost will be reduced (O) 2 , thereby achieving high throughput of parallel transaction processing.
[0063] Directed Acyclic Graph (DAG) technology is essentially a consensus ledger data structure of blockchain. Its technical feature is that each block or transaction in the DAG-based ledger structure can reference multiple predecessor nodes and can be referenced by multiple successor nodes at the same time. Based on this feature, multiple transactions can be confirmed simultaneously in one round of consensus in DAG. At present, there are three types of technical structures for DAG ledger structure. The structure that is more suitable for alliance chain sharding technology is the ledger structure based on parallel chains. Its characteristics are that network nodes or accounts each maintain a chain blockchain. When transactions occur between nodes or accounts, the DAG ledger based on parallel chains is made between each account through mutual references between nodes. This algorithm simplifies the DAG ledger structure through mutual references between independent single chains, and simplifies the difficulty of consensus protocol design. It has higher throughput and lower transaction confirmation delay, and the information on the chain is more difficult to be tampered with.
[0064] Figure 1 A schematic diagram of the process of a blockchain sharding method based on a directed acyclic graph in cold chain logistics provided in an embodiment of the present disclosure.
[0065] Figure 2 For Figure 1 Corresponding flowchart of the blockchain sharding method based on directed acyclic graph in cold chain logistics.
[0066] like Figure 1 As shown, at step S110, a private chain is formed according to the alliance chain model.
[0067] More specifically, the process proceeds to step S120.
[0068] In step S120, each cold chain transportation enterprise that obtains CA certification constitutes a node of the private chain, and the nodes are regionally sharded according to the geographical locations of different IP regions; wherein the nodes in the same IP segment area form a regional single chain structure, which is called a sharded blockchain.
[0069] In the embodiment of the present invention, the participating units of the authentication system of the private chain include: transportation enterprises, supervisory agencies and operating agencies involved in the supervision of cold chain transportation.
[0070] More specifically, in the certification system of the private chain, the transport enterprises, supervisory agencies and operating agencies involved in the supervision of cold chain transport are organized into a unified alliance chain participating unit; the transport enterprises realize the full process management of the cold chain transport process of their enterprises through the alliance chain to realize the credibility of the transportation link; the supervisory agency is the management extension of the government regulatory agency, and can realize the trusted supervision of the whole process of the chain transport enterprises through the alliance chain, and the evidence collection after the problem has credibility, while reducing the social management cost; the operating agency is an independent third-party technical agency, responsible for the platform operation and maintenance technology management, and is only responsible for the construction and implementation of the alliance chain. The data is tamper-proof and is not affected by third parties. Among them, the cold chain transport enterprises that obtain CA certification constitute a node alone, and are regionally sharded according to the geographical location of different IP regions. Nodes in the same IP segment area form a regional single chain structure, which is called a sharded blockchain. When adding a new node to each sharded blockchain, it only needs to obtain the hash value of the previous block in this area and complete the consensus algorithm in this area. Since the total number of nodes in the sharded blockchain is relatively small, the chain speed is faster than that of the public blockchain.
[0071] Next, go to step S130.
[0072] At step S130, the internal consensus period of the alliance chain DAG shard block includes: dividing the Merkle tree root node of each node into an intra-shard Merkle tree and a cross-shard Merkle tree; when a transaction occurs between two nodes in the same shard blockchain, it will be recorded in the intra-shard Merkle tree of the node; when a transaction occurs between two nodes in different shard blockchains, it will be recorded in the cross-shard Merkle tree of the node; the whole chain ledger forms a global snapshot at the current moment and is stored in the regulatory agency server.
[0073] In the embodiment of the present invention, when in the internal consensus period of the alliance chain DAG shard block, chain-up, intra-shard consensus processing, intra-shard transactions, and cross-shard transactions are allowed. At this time, the node ledger state may not be completely consistent with the global ledger state.
[0074] Next, go to step S140.
[0075] At step S140, the shard blockchain multi-chain snapshot synchronization period includes: each shard blockchain synchronizes the intra-shard transaction and cross-shard transaction change ledger with the global snapshot through polling, and updates the global snapshot.
[0076] In an embodiment of the present invention, when the sharded blockchain multi-chain snapshot synchronization period is in progress, the chain uploading, intra-shard consensus processing, intra-shard transactions, and cross-shard transactions are suspended, waiting for each shard to synchronize the intra-shard and cross-shard transaction change ledgers with the global snapshot through polling.
[0077] Next, go to step S150.
[0078] At step S150, the shard block global snapshot synchronization period includes: broadcasting the global snapshot to each shard blockchain of the entire blockchain, and after each shard blockchain receives the broadcast, it updates the Merkle tree ledger of its own block, thereby achieving consensus on the entire blockchain.
[0079] In an embodiment of the present invention, when the shard block global snapshot synchronization period is in progress, chain uploading, intra-shard consensus processing, intra-shard transactions, and cross-shard transactions are suspended, waiting for the shard block global snapshot synchronization to be completed.
[0080] In an embodiment of the present invention, the method further includes: when a new node is added to each shard blockchain, the hash value of the previous block in the area is obtained, and the consensus algorithm of the area is completed.
[0081] In the embodiment of the present invention, node chaining, node transactions, global snapshot updates, global snapshot synchronization, and concurrent execution are allowed.
[0082] like Figure 3 As shown in the figure, in order to realize the overall characteristic concept of blockchain sharding processing technology based on the directed acyclic graph of the alliance chain, it is necessary to improve the merkle root of the traditional blockchain node. The node composition of the traditional blockchain is as follows Figure 3 As shown in Figure (a), the traditional block node is divided into the block header part and the block body part. The alliance chain DAG shard blockchain node is composed of Figure 3 (b) is shown. The consortium chain block header mainly includes the version number, the hash value of the previous block, the timestamp, the random number, the public key, and the Merkle root. The block body is the ledger information recorded through the Merkle tree. Among them, the version number, timestamp, random number, and Merkle root will be packaged as a whole to form the pre-hash value of the next node blockchain, thus forming an overall single-chain consortium chain. When a transaction occurs, it is recorded as m i transactions, each transaction is hashed to form the mth transaction of the kth node. i Transaction hash value R i, after the merkle binary number is hashed in sequence to form the final merkle root node calculation hash value. The merkle root node hash value can be used as the transaction data ledger information of this node, and can also be used as the basis for the traceability calculation of the global consensus ledger.
[0083] The consortium chain DAG shard blockchain nodes are divided into two categories according to intra-shard transactions and cross-shard transactions. When the block body is an intra-shard transaction, the calculation mode of the merkle tree of its transaction is consistent with the calculation of the traditional block connection point merkle tree, and will eventually be recorded in the intra-shard merkle tree root node calculation hash value merkle-A; if it is a cross-shard transaction type, the hash calculation will complete the calculation of the transaction value of different shard nodes, and finally store it in the cross-shard merkle tree root node calculation hash value merkle-B. The state value parameter K is added to the DAG shard blockchain node s , mainly used to identify which stage the current block is in the overall alliance chain. If it is the internal consensus period of the alliance chain DAG shard block, K s =0, then on-chain, intra-shard consensus processing, intra-shard transactions, and cross-shard transactions are allowed. At this time, the node ledger state may not be completely consistent with the global ledger state. If it is the shard blockchain multi-chain snapshot synchronization period, K s =1, it is necessary to suspend the chain, intra-shard consensus processing, intra-shard transactions, and cross-shard transactions, and wait for each shard to synchronize the intra-shard and cross-shard transaction change ledgers with the global snapshot through polling; if it is the shard block global snapshot synchronization period, K s =2, the chain, intra-shard consensus processing, intra-shard transactions, and cross-shard transactions are still suspended, waiting for the global snapshot synchronization of the shard blocks to be completed. Therefore, the state value K s It is the overall control threshold of the sharded blockchain consensus mechanism.
[0084] In traditional blockchains, newly released blocks will be added to the original longest chain, and the chain that all nodes consider to be the longest will be used as the standard, spreading indefinitely. In DAG, new blocks will be added to a shard blockchain according to the registered IP network area, which is consistent with the single chain structure. However, in the transaction process, especially in the cross-shard transaction process, any transaction behavior may occur in multiple shard blocks in the two-dimensional space. Due to the directionality of the nodes in the shard, each node will point to the fixed direction of the longest chain of the shard. At the same time, the transaction of the node may also be carried out with any cross-shard node in the two-dimensional space. The structure of this data structure is a directed acyclic graph structure.
[0085] like Figure 4As shown in the figure, if it is an intra-shard transaction of a sharded blockchain, the intra-shard transaction causes the shard state to generate a change pointing to the previous round of shard state snapshots of the shard, which is used to represent the state transfer of intra-shard transactions. The intra-shard state transfers organized in chronological order constitute a parallel state snapshot chain. Then the intra-shard transaction directly records only one snapshot of this shard area. k ~s i (snapshot k represents the kth shard blockchain, s i represents the i-th snapshot in the k-th shard blockchain, and each snapshot represents a poll), specifically recorded in snapshot k ~s i The merkle tree root node in the shard calculates the hash value merkle-A.
[0086] like Figure 4 As shown in the figure, if it is a cross-shard transaction of DAG blockchain, each state snapshot is derived from the change of its predecessor state, and the submission and execution of the transaction will lead to the change of the state snapshot. Cross-shard transactions enable the receiving shard (transaction deduction party) to generate a pointer to the sending shard (transaction peer addition party) to represent the state transfer of cross-shard transactions. The existence of cross-shard transactions connects the state snapshots of different shards to form a global state snapshot ledger based on DAG parallel chains. For example, Figure 4 As shown, snapshot 3 ~s i+3 The snapshot indicates that in the i+3th poll in the 3rd shardchain3, the snapshot 1 ~s i+1 、snapshot 2 ~s i+2 The second snapshot is updated, which also means that in the i+3th polling, the snapshots of the corresponding shards in the i+1th and i+2th polling are referenced, resulting in changes in the current snapshot3~si+3 snapshots due to cross-shard transactions. 1 ~s i+1 The snapshot records the transaction between the nodes in the first shard and the third shard. This transaction information is recorded in the snapshot 1 ~s i+1 The merkle tree root node calculates the hash value merkle-B; similarly, snapshot 2 ~s i+2 The snapshot records the transaction between the nodes in the second and third shards. This transaction information is recorded in the snapshot. 2 ~s i+2The merkle tree root node calculates the hash value merkle-B. 3 ~s i+3 Updating the above two snapshots means that the ledger information of the last cross-shard transaction in the global ledger is synchronized in the third shard, and finally the consistency of the shard ledger is achieved.
[0087] The blockchain sharding method based on directed acyclic graph in cold chain logistics proposed in the present invention solves the efficiency bottleneck problem of traditional single-chain blockchain technology through directed acyclic graph sharding blockchain sharding processing technology based on alliance chain, solves the problem of very low data synchronization initialization efficiency caused by the large size of single blockchain, and solves the problem of slow consensus mechanism of single-chain blockchain.
[0088] Based on the traditional single-chain blockchain and public chain, the present invention establishes a consortium chain, adopts the sharding block technology and the DAG (Directed Acyclic Graph) blockchain ledger structure and consensus mechanism, and forms a network structure that allows forking, thereby accelerating the block generation speed of the blockchain network and is not affected by the block broadcast speed. The overall consortium chain is changed from a traditional serial ledger structure to a parallel ledger structure, forming a high concurrency feature of the DAG ledger consensus mechanism, which can improve the traditional serial ledger accounting processing speed and greatly improve the TPS (Transactions Per Second) of the network node accounting speed per unit time.
[0089] Figure 5 The blockchain sharding system 500 based on a directed acyclic graph in cold chain logistics provided by the present invention is shown, including a blockchain module 510 and a consensus module 520.
[0090] The blockchain module 510 is used to form a private chain according to the alliance chain model; and,
[0091] Each cold chain transportation enterprise that has obtained CA certification constitutes a node of the private chain, and the nodes are regionally sharded according to different IP regional geographical locations; wherein the nodes in the same IP segment area form a regional single chain structure, which is called a sharded blockchain;
[0092] The consensus module 520 is used for the internal consensus period of the consortium chain DAG shard block, including: dividing the Merkle tree root node of each node into an intra-shard Merkle tree and a cross-shard Merkle tree; when a transaction occurs between two nodes in the same shard blockchain, it is recorded in the intra-shard Merkle tree of the node; when a transaction occurs between two nodes in different shard blockchains, it is recorded in the cross-shard Merkle tree of the node; the whole chain ledger is formed into a global snapshot at the current moment and stored in the regulatory agency server;
[0093] The shard blockchain multi-chain snapshot synchronization period includes: each shard blockchain synchronizes the intra-shard transaction and cross-shard transaction change ledgers with the global snapshot through polling, and updates the global snapshot; and
[0094] The shard block global snapshot synchronization period includes: broadcasting the global snapshot to each shard blockchain of the entire blockchain. After receiving the broadcast, each shard blockchain updates the Merkle tree ledger of its own block, thereby achieving consensus on the entire blockchain.
[0095] See also Figure 6 The embodiment of the present disclosure further provides an electronic device 60, the electronic device comprising:
[0096] at least one processor; and,
[0097] a memory communicatively connected to the at least one processor; wherein,
[0098] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the blockchain sharding method based on directed acyclic graph in cold chain logistics in the aforementioned method embodiment.
[0099] The embodiments of the present disclosure also provide a non-transitory computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable the computer to execute the blockchain sharding method based on directed acyclic graph in cold chain logistics in the aforementioned method embodiment.
[0100] The embodiments of the present disclosure also provide a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer executes the blockchain sharding method based on a directed acyclic graph in cold chain logistics in the aforementioned method embodiment.
[0101] Reference below Figure 6, which shows a schematic diagram of the structure of an electronic device 60 suitable for implementing the embodiment of the present disclosure. The electronic device in the embodiment of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle terminals (such as vehicle navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0102] like Figure 6 As shown, the electronic device 60 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic device 60 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0103] Typically, the following devices may be connected to the I / O interface 605: input devices 606 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; output devices 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; storage devices 608 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 609. The communication device 609 may allow the electronic device 60 to communicate with other devices wirelessly or by wire to exchange data. Although the electronic device 60 with various devices is shown in the figure, it should be understood that it is not required to implement or have all the devices shown. More or fewer devices may be implemented or have alternatively.
[0104] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device 609, or installed from a storage device 608, or installed from a ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0105] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0106] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0107] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: obtains at least two Internet Protocol addresses; sends a node evaluation request including the at least two Internet Protocol addresses to a node evaluation device, wherein the node evaluation device selects an Internet Protocol address from the at least two Internet Protocol addresses and returns it; receives the Internet Protocol address returned by the node evaluation device; wherein the obtained Internet Protocol address indicates an edge node in a content distribution network.
[0108] Alternatively, the computer-readable medium carries one or more programs, and when the one or more programs are executed by the electronic device, the electronic device: receives a node evaluation request including at least two Internet Protocol addresses; selects an Internet Protocol address from the at least two Internet Protocol addresses; and returns the selected Internet Protocol address; wherein the received Internet Protocol address indicates an edge node in a content distribution network.
[0109] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0110] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0111] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware. The name of a unit does not limit the unit itself in some cases. For example, the first acquisition unit may also be described as a "unit for acquiring at least two Internet Protocol addresses".
[0112] It should be understood that various parts of the present disclosure may be implemented in hardware, software, firmware, or a combination thereof.
[0113] The above is only a specific implementation of the present disclosure, but the protection scope of the present disclosure is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed in the present disclosure should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A blockchain sharding method based on directed acyclic graph in cold chain logistics. It is characterized in that The method comprises the following steps: Form a private chain according to the alliance chain model; Each cold chain transportation enterprise that has obtained CA certification constitutes a node of the private chain, and the nodes are regionally sharded according to different IP regional geographical locations; wherein the nodes in the same IP segment area form a regional single chain structure, which is called a sharded blockchain; The internal consensus period of the consortium chain DAG shard block includes: dividing the Merkle tree root node of each node into an intra-shard Merkle tree and a cross-shard Merkle tree; when a transaction occurs between two nodes in the same shard blockchain, it is recorded in the intra-shard Merkle tree of the node; when a transaction occurs between two nodes in different shard blockchains, it is recorded in the cross-shard Merkle tree of the node; forming a global snapshot of the entire chain ledger at the current moment and storing it in the regulatory agency server; The shard blockchain multi-chain snapshot synchronization period includes: each shard blockchain synchronizes the intra-shard transaction and cross-shard transaction change ledgers with the global snapshot through polling, and updates the global snapshot; The shard block global snapshot synchronization period includes: broadcasting the global snapshot to each shard blockchain of the entire blockchain, and each shard blockchain updates the Merkle tree ledger of its own block after receiving the broadcast, thereby achieving consensus of the entire blockchain; When the consortium chain DAG shard block is in the internal consensus period, uploading to the chain, intra-shard consensus processing, intra-shard transactions, and cross-shard transactions are allowed. At this time, the node ledger state may not be completely consistent with the global ledger state; When the sharded blockchain is in the multi-chain snapshot synchronization period, the chain, intra-shard consensus processing, intra-shard transactions, and cross-shard transactions are suspended, waiting for each shard to synchronize the intra-shard and cross-shard transaction change ledgers with the global snapshot through polling; When the shard block global snapshot synchronization period is in progress, chain uploading, intra-shard consensus processing, intra-shard transactions, and cross-shard transactions are suspended, waiting for the shard block global snapshot synchronization to be completed.
2. According to the blockchain sharding method based on directed acyclic graph in cold chain logistics according to claim 1, It is characterized in that The method further comprises: When a new node is added to each shard blockchain, the hash value of the previous block in this area is obtained, and the consensus algorithm of this area is completed.
3. According to the blockchain sharding method based on directed acyclic graph in cold chain logistics according to claim 1, It is characterized in that Node on-chain, node transaction, global snapshot update, global snapshot synchronization, and concurrent execution are allowed.
4. According to claim 1, the blockchain sharding method based on directed acyclic graph in cold chain logistics, It is characterized in that Participants in the private chain certification system include: transportation companies, supervisory agencies and operating agencies involved in cold chain transportation supervision.
5. A blockchain sharding system based on directed acyclic graph in cold chain logistics, It is characterized in that The system comprises: A blockchain module, configured to form a private chain in accordance with a consortium chain model; and, Each cold chain transportation enterprise that has obtained CA certification constitutes a node of the private chain, and the nodes are regionally sharded according to different IP regional geographical locations; wherein the nodes in the same IP segment area form a regional single chain structure, which is called a sharded blockchain; The consensus module is configured for the internal consensus period of the consortium chain DAG shard block, including: dividing the Merkle tree root node of each node into an intra-shard Merkle tree and a cross-shard Merkle tree; when a transaction occurs between two nodes in the same shard blockchain, it is recorded in the intra-shard Merkle tree of the node; when a transaction occurs between two nodes in different shard blockchains, it is recorded in the cross-shard Merkle tree of the node; forming a global snapshot of the entire chain ledger at the current moment and storing it in the regulatory agency server; The shard blockchain multi-chain snapshot synchronization period includes: each shard blockchain synchronizes the intra-shard transaction and cross-shard transaction change ledgers with the global snapshot through polling, and updates the global snapshot; and The shard block global snapshot synchronization period includes: broadcasting the global snapshot to each shard blockchain of the entire blockchain, and each shard blockchain updates the Merkle tree ledger of its own block after receiving the broadcast, thereby achieving consensus of the entire blockchain; When the alliance chain DAG shard block is in the internal consensus period, uploading to the chain, intra-shard consensus processing, intra-shard transactions, and cross-shard transactions are allowed. At this time, the node ledger status may not be completely consistent with the global ledger status; When the sharded blockchain is in the multi-chain snapshot synchronization period, the chain, intra-shard consensus processing, intra-shard transactions, and cross-shard transactions are suspended, waiting for each shard to synchronize the intra-shard and cross-shard transaction change ledgers with the global snapshot through polling; When the shard block global snapshot synchronization period is in progress, chain uploading, intra-shard consensus processing, intra-shard transactions, and cross-shard transactions are suspended, waiting for the shard block global snapshot synchronization to be completed.
6. An electronic device, It is characterized in that The electronic device includes: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor. When the instructions are executed by the at least one processor, the at least one processor executes the blockchain sharding method based on a directed acyclic graph in cold chain logistics as described in any one of claims 1 to 4.
7. A non-transitory computer-readable storage medium, It is characterized in that The non-transitory computer-readable storage medium stores computer instructions, which, when executed by at least one processor, cause the at least one processor to execute the blockchain sharding method based on a directed acyclic graph in cold chain logistics as described in any one of claims 1 to 4.
8. A computer program product, It is characterized in that The computer program product includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer executes the blockchain sharding method based on a directed acyclic graph in cold chain logistics as described in any one of claims 1 to 4.
