A blockchain-based efficient traceability method for the whole life cycle of mass production
By using parallel transactions and node partitioning in the InMPT structure, the storage and retrieval pressure of full lifecycle traceability in large-scale manufacturing supply chains is solved, achieving efficient data retrieval and significantly improving traceability efficiency.
Patent Information
- Application Number
- CN202411264055.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-10
- Publication Date
- 2025-12-16
- Estimated Expiration
- 2044-09-10
AI Technical Summary
In large-scale manufacturing supply chains, there is enormous pressure to store and retrieve products throughout their entire lifecycle. Existing technologies are inefficient in both on-chain and off-chain modes and cannot effectively meet the high-frequency data retrieval needs.
The Index Merkle Patricia Trie (InMPT) structure is adopted to partition transactions and nodes in parallel. The hash value is used to search in parallel in the blockchain node group. The InMPT structure after transaction partitioning is constructed to realize parallel data retrieval and reduce retrieval time complexity.
It improves data retrieval efficiency and reduces retrieval time complexity from O(log(n)) to O(log(n/k)). It significantly improves source tracing efficiency under high-frequency retrieval requests, and improves retrieval efficiency by about 1233% compared with traditional methods.
Smart Images

Figure CN119128014B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of blockchains, in particular to a large-scale manufacturing full-life-cycle efficient traceability method based on blockchains. BACKGROUND
[0002] The supply chain of large-scale manufacturing industry is a complex system, including suppliers, manufacturers, distributors and customers, which cooperate to produce and circulate products. For supply chain management, product full-life-cycle traceability is crucial, that is, to retrieve the full-life-cycle data of the problem product from raw materials to sales. In recent years, blockchain has emerged as a promising full-life-cycle traceability technology. It has ideal characteristics such as decentralization, transparency and immutability, breaking down information silos and improving the speed of information exchange between supply chain stakeholders. Product data at each stage is stored as a transaction on the chain and retrieved during the traceability process. However, in the supply chain of large-scale manufacturing industry, the number of products is huge, each product goes through many stages, and the amount of data at each stage is large, resulting in a large amount of data and huge storage pressure for the overall transaction; at the same time, product full-life-cycle traceability requires one-by-one retrieval of multiple transaction data at each stage, combined with the large demand for full-life-cycle traceability, resulting in high frequency of data retrieval requests and huge retrieval pressure. In order to reduce the storage and retrieval pressure, an on-chain and off-chain mode is proposed. Therefore, an efficient on-chain and off-chain data retrieval method in full-life-cycle traceability is needed.
[0003] Chinese patent "CN112950227A based on blockchain information tracing system and method of cross-border supply chain of China-Europe land-sea fast line" provides a blockchain-based information tracing system and method of cross-border supply chain of China-Europe land-sea fast line, including a product tracing module and a query module, wherein the product tracing module includes a supply chain on-chain module and a supply chain off-chain module, thereby realizing the retrieval of traceability information, and on the other hand improving the reliability of traceability information. However, the complete transaction data is stored off-chain, and only the hash value of the transaction is stored on-chain for verification. During traceability, the data at each stage is retrieved from the data table or document with a large amount of data at different addresses off-chain, rather than directly retrieved on-chain. High communication requirements result in long time consumption and low overall efficiency.
[0004] The Chinese patent "CN113157733A A kind of efficient traceability query method for multi-chain data correlation" provides a kind of efficient traceability query method for multi-chain data correlation, its features include: identifying target transaction to be traced, finding all corresponding target chain based on cross-chain transaction data correlation, parallel sending query request, target chain is according to the key value of the target transaction and is inquired and the query result is returned, so as to effectively improve the traceability query efficiency and the scalability of entire system.But its technical scheme stores the antecedent transaction association information of each transaction on chain, when each transaction data is generated, it needs to retrieve its corresponding antecedent transaction information from all blocks with a large amount of data, and its efficiency is even lower than the method of storing only transaction hash value on chain.
[0005] The Chinese patent "CN117194518A Data query method for large-scale manufacturing full life cycle traceability based on block chain" provides a data query method for large-scale manufacturing full life cycle traceability based on block chain, which increases the index of the current stage and the index of the previous stage in the transaction structure, so that the key information of the transaction can be obtained without retrieving all transactions, improving the efficiency of retrieving transactions during traceability.But its technical scheme lacks the association between index information and off-chain data, and is not suitable for on-chain and off-chain mode. SUMMARY
[0006] In view of the deficiencies of the prior art, the purpose of the present application is to provide a large-scale manufacturing full life cycle efficient traceability method based on block chain, comprising:
[0007] Step 1: for the product to be traced in the manufacturing full life cycle, obtain the batch number of the product to be traced, and determine the last stage of the large-scale manufacturing full life cycle for the plurality of stages in the large-scale manufacturing full life cycle;
[0008] Step 2: taking the last stage of the large-scale manufacturing full life cycle as the current stage, and taking the batch number as the index of the current transaction;
[0009] Step 3: for the hash value of the index of each current transaction in the current stage, determine the target group number of the block chain for implementing the current retrieval request in the plurality of node groups of the block chain and the group number of the node group, and for each current transaction, through the nodes in the block chain node group corresponding to the target group number, according to the hash value of the index of the current transaction, obtain the hash value of the index of all transactions of the previous stage of the current stage in the pre-constructed InMPT structure after transaction division, wherein all block chain node groups corresponding to the target group number are executed in parallel when obtaining the hash value of the index of all transactions of the previous stage of the current stage;
[0010] The InMPT structure after transaction division, i.e., the Index Merkle Patricia Trie structure, includes index information of all transactions in all stages of the whole life cycle of manufacturing, the index information of the transactions includes key and value, the key is a hash value of an index of the transaction, the value includes an off-chain storage location of complete information of the transaction and hash values of indexes of all transactions of a previous stage corresponding to the transaction, the InMPT structure after transaction division adopts an MPT structure, the InMPT structure after transaction division includes a root node, a stage branch node, an expansion node, a branch node and a leaf node, the root node is connected with the stage branch node, one stage branch corresponds to one stage in the whole life cycle of manufacturing, the stage branch node is connected with the expansion node in a plurality of nodes including index information of all transactions of a corresponding stage, the plurality of nodes including index information of all transactions of the corresponding stage include the expansion node, the branch node and the leaf node;
[0011] Step 4: determining whether the current stage is the first stage in the whole life cycle of large-scale manufacturing, if the current stage is the first stage in the whole life cycle of large-scale manufacturing, the process ends, if the current stage is not the first stage in the whole life cycle of large-scale manufacturing, step 5 is performed;
[0012] Step 5: taking a previous stage of the current stage as a new current stage, taking a hash value of an index of each transaction of the previous stage as a hash value of an index of a current transaction, and returning to step 3.
[0013] Optionally, the InMPT structure after transaction division is constructed through the following steps:
[0014] Step A1: obtaining indexes of all transactions in all stages of the whole life cycle of large-scale manufacturing, for each index of the transactions, calculating the index through a hash algorithm to obtain a hash value of the index of the transaction, i.e., a key of the transaction, obtaining a hash value of a transaction index of a previous stage of the transaction and an off-chain storage location of complete information of the transaction to obtain a value of the transaction, the key of the transaction and the value of the transaction constitute index information of the transaction, and then obtaining index information of all transactions;
[0015] Step A2: According to the MPT structure and the index information of all transactions, an initial InMPT structure is constructed, which contains the index information of all transactions of all stages, and the initial InMPT structure includes one root node, multiple extension nodes, multiple branch nodes and multiple leaf nodes, for each transaction, the key of the index of the transaction is composed of the extension node of the transaction, the branch node of the transaction and the leaf node of the transaction, and the value of the transaction is stored in the leaf node of the transaction;
[0016] Step A3: According to the stages of the whole life cycle of mass production, stage branch nodes are set between the root node and the extension node in the initial InMPT structure, and the transaction index information in the initial InMPT structure is divided according to the stages, and then based on the stages corresponding to the stage branch nodes and the structure corresponding to the stages after the transaction index information in the initial InMPT structure is divided, the InMPT structure after the transaction is divided is obtained.
[0017] Optionally, step 3 specifically includes:
[0018] Step 3.1: For the index of each current transaction of the current stage, the hash value of each current index is obtained by hash algorithm calculation, and then the current search request is generated, and the current search request is sent to the blockchain, and after receiving the current search request, the target group number of the blockchain node group for implementing the current search request in the blockchain is calculated according to the hash value of the index of the transaction in the current search request in the pre-divided multiple node groups of the blockchain and the group number of the node group.
[0019] Step 3.2: For each current transaction, the leaf node corresponding to the hash value of the index of the current transaction is found in the pre-constructed InMPT structure after the transaction is divided according to the hash value of the index of the current transaction through the node in the target group number corresponding to the blockchain node group, and the hash value of the index of all transactions of the previous stage of the current stage is obtained in the value of the leaf node corresponding to the hash value of the index of the current transaction.
[0020] Optionally, the target group number of the blockchain node group for implementing the current search request in the blockchain is calculated according to the hash value of the index of the transaction in the current search request in step 3.1, which is specifically implemented by the following way:
[0021] The hash value of the index of the current transaction is divided by the total number of blockchain nodes, and then the modulo operation is performed to obtain the target group number of the blockchain node group for implementing the current search request corresponding to the hash value of the index of the current transaction, which is specifically implemented by the following formula:
[0022] R j =Ij modm(1)
[0023] wherein, I j represents the hash value of the index of the current transaction in the current search request j, m represents the total number of groups of the blockchain nodes, R j represents the target group number of the group of the blockchain nodes for implementing the current search request j.
[0024] Optionally, the pre-division of the plurality of groups of nodes of the blockchain and the group numbers of the groups of nodes is implemented through the following steps.
[0025] Step B1: determining the total number of groups of grouping for all nodes of the blockchain;
[0026] Step B2: dividing all nodes in the blockchain according to the total number of groups to determine the group number to which each node belongs, so as to obtain the plurality of groups of nodes of the blockchain and the group numbers of the groups of nodes.
[0027] Optionally, step B1 specifically comprises:
[0028] establishing a formula of the total number of groups, which is specifically represented by formula (2):
[0029]
[0030] wherein, m represents the total number of groups of the blockchain nodes; c represents the communication time of the nodes in each group of the blockchain with the nodes in other groups of the blockchain; o represents the time required for responding to the current data search request in the InMPT structure before the grouping of the blockchain nodes; T is an optimization target, which represents the time required for responding to the current search request when the total number of groups is m; s.t. is a constraint condition, N + is a positive integer, min m T minimizes T when the total number of groups is m;
[0031] deriving formula (2) to obtain:
[0032] dT / dm=c-o / m 2 (3)
[0033] setting the derivative to 0 to obtain
[0034]
[0035] Since m∈N + , the optimal solution of formula (2) is:
[0036]
[0037] Thus, the value of the total number of groups m of the groups of blockchain nodes is formula (5).
[0038] Optionally, step B2 specifically comprises:
[0039] The address of the node in the blockchain is obtained by a hash algorithm, the hash value is divided by the total number of groups, and a modulo operation is performed to obtain the group number to which the node in the blockchain is allocated, which is specifically realized by the following formula:
[0040] G i = Hash(Ad i )(mod m)(6)
[0041] Wherein, Ad i represents the address of node i, m represents the total number of groups of blockchain nodes, G i represents the group number of node i.
[0042] The beneficial effects produced by the above technical solutions are:
[0043] In the present application, the InMPT realizes that the leaf node corresponding to the previous stage transaction can be directly retrieved by the value of the leaf node corresponding to the current transaction, thereby avoiding retrieving the complete information of the transaction off-chain to obtain the index of the previous stage transaction; the transaction division realizes parallel data retrieval on different transaction branches of the InMPT, thereby reducing the retrieval time complexity from O(log(n)) to O(log(n / k)) and improving the retrieval efficiency when there is a large amount of transaction data; the node division realizes parallel data retrieval of different node groups, thereby improving the retrieval efficiency when the retrieval request frequency is high. Compared with the traditional on-chain and off-chain method of only storing transaction hash values on the chain, the data retrieval efficiency in the full life cycle traceability of the present application is improved by about 1233%. BRIEF DESCRIPTION OF DRAWINGS
[0044] Figure 1 It is a PRIMPT method flow diagram based on blockchain in large-scale manufacturing full life cycle traceability in an embodiment of the present application;
[0045] Figure 2 It is a structure diagram of an automobile supply chain in an embodiment of the present application;
[0046] Figure 3 It is an InMPT structure example diagram in an embodiment of the present application;
[0047] Figure 4 It is an InMPT structure example diagram after dividing transactions in an embodiment of the present application;
[0048] Figure 5 It is a full life cycle traceability flow example diagram of the PRIMPT method in an embodiment of the present application;
[0049] Figure 6 FIG. 1 is a schematic diagram of an InMPT structure and a traditional on-chain off-chain mode efficiency comparison for an embodiment of the present application;
[0050] Figure 7 FIG. 2 is a schematic diagram of an InMPT structure and a traditional on-chain off-chain mode efficiency comparison for a transaction division embodiment of the present application;
[0051] Figure 8 FIG. 3 is a schematic diagram of an InMPT structure and a traditional on-chain off-chain mode efficiency comparison for a node division embodiment of the present application. DETAILED DESCRIPTION
[0052] The specific embodiments of the present application will be further described in detail below with reference to the accompanying drawings and examples. The following examples are used to illustrate the present application, but are not used to limit the scope of the present application.
[0053] In view of the problems existing in the prior art, the present application provides a large-scale manufacturing full life cycle efficient traceability method based on a block chain. Specifically, the MPT structure is improved through an InMPT structure and a parallel retrieval mechanism (including transaction division and node division), so the method of the present application can also be called PRIMPT (Parallel Retrieve Index Merkle Patricia Trie), which can be understood as a parallel retrieval index MPT, and then combined with Figure 1 The present application can include the following steps:
[0054] Step 1: For a product to be traced in the manufacturing full life cycle, obtain the batch number of the product to be traced, and determine the last stage of the large-scale manufacturing full life cycle for a plurality of stages in the large-scale manufacturing full life cycle.
[0055] The large-scale manufacturing full life cycle can be an automobile supply chain, Figure 2 FIG. 1 is a schematic diagram of an InMPT structure and a traditional on-chain off-chain mode efficiency comparison for an embodiment of the present application;
[0056] The present application can include the following steps: Figure 2, all stages of the automobile supply chain in order include raw material storage, part production, part storage, part supply, stamping, welding, painting, assembly, automobile storage, automobile delivery and automobile sales, the last stage of the mass manufacturing full life cycle is automobile sales, and the final product of the automobile supply chain is an automobile, so the product to be traced in step 1 is the automobile with quality problems.
[0057] In specific implementation, the present application can take the batch number of the automobile with quality problems as an index, trace back from the automobile sales stage to the first stage of the automobile supply chain, that is, trace back to the raw material storage stage.
[0058] Step 2: taking the last stage of the mass manufacturing full life cycle as the current stage, and taking the batch number as the index of the current transaction;
[0059] Step 3: for the hash value of the index of each current transaction of the current stage, in the multiple node groups of the pre-divided blockchain and the group numbers of the node groups, determine the target group number of the blockchain for implementing the current retrieval request, for each current transaction, through the nodes in the node group corresponding to the target group number, according to the hash value of the index of the current transaction, in the pre-constructed InMPT structure after transaction division, obtain the hash values of the indexes of all transactions of the previous stage of the current stage, wherein all blockchain node groups corresponding to the target group numbers are executed in parallel when obtaining the hash values of the indexes of all transactions of the previous stage of the current stage.
[0060] The InMPT structure after transaction division, that is, the Index Merkle Patricia Trie structure, includes index information of all transactions of all stages in the manufacturing full life cycle, the index information of the transaction includes key and value, the key is the hash value of the index of the transaction, the value includes the off-chain storage location of the complete information of the transaction, and the hash values of the indexes of all transactions corresponding to the previous stage of the transaction, the InMPT structure after transaction division adopts the MPT structure, the InMPT structure after transaction division includes a root node, a stage branch node, an expansion node, a branch node and a leaf node, the root node is connected with the stage branch node, one stage branch corresponds to one stage in the manufacturing full life cycle, the stage branch node is connected with the expansion node in the multiple nodes containing the index information of all transactions of the corresponding stage, the multiple nodes containing the index information of all transactions of the corresponding stage include the expansion node, the branch node and the leaf node.
[0061] Step 3 is specifically implemented by the following steps:
[0062] Step 3.1: For each current transaction index of the current stage, a hash value of each current index is calculated by a hash algorithm, and then a current search request is generated, and the current search request is sent to the blockchain. After receiving the current search request, the blockchain calculates the target group number of the blockchain node group for implementing the current search request in the pre-divided multiple node groups of the blockchain and the group numbers of the node groups according to the hash value of the transaction index in the current search request;
[0063] The pre-division of the multiple node groups of the blockchain and the group numbers of the node groups is achieved by the following steps:
[0064] Step B1: Determine the total number of groups for grouping all nodes of the blockchain;
[0065] Specifically, step B1 includes:
[0066] A formula for the total number of groups is established, which is specifically represented by formula (2):
[0067]
[0068] Wherein, m represents the total number of groups of blockchain nodes; c represents the communication time of nodes in each group of blockchain with nodes in other groups of blockchain; o represents the time required to respond to the current data search request in the InMPT structure before the grouping of blockchain nodes; T is the optimization target, T represents the time required to respond to the current search request when the total number of groups is m; s.t. is the constraint condition, N + is a positive integer, min m T minimizes T when the total number of groups is m;
[0069] The derivative of formula (2) is obtained as:
[0070] dT / dm=c-o / m 2 (3)
[0071] Let the derivative be 0, and get
[0072]
[0073] Since m∈N + The optimal solution of formula (2) is:
[0074]
[0075] Thus, the value of the total number of groups m of the blockchain node groups is formula (5).
[0076] Step B2: According to the total number of groups, divide all nodes in the blockchain to determine the group number to which each node belongs, so as to obtain the multiple node groups of the blockchain and the group numbers of the node groups.
[0077] wherein, step B2 specifically comprises:
[0078] For the address of the node in the blockchain, the hash value is obtained through the hash algorithm, the hash value is divided by the total number of groups, and the modulo operation is performed to obtain the group number to which the node in the blockchain is allocated, which is specifically realized by the following formula:
[0079] G i = Hash(Ad i )(mod m)(6)
[0080] wherein, Adi represents the address of node i, m represents the total number of groups of blockchain nodes, and Gi represents the group number of node i.
[0081] After the nodes in the blockchain are divided, step 4.1 can determine the target group number of the blockchain node group for implementing the current retrieval request in the blockchain, which is specifically realized by the following way:
[0082] The hash value of the index of the current transaction is divided by the total number of groups of blockchain nodes, and the modulo operation is performed to obtain the target group number of the blockchain node group for implementing the current retrieval request corresponding to the hash value of the index of the current transaction, which is specifically realized by the following formula:
[0083] R j = I j mod m(1)
[0084] wherein, I j represents the hash value of the index of the current transaction in the current retrieval request j, m represents the total number of groups of blockchain nodes, and R j represents the target group number of the blockchain node group for implementing the current retrieval request j.
[0085] Step 3.2: For each current transaction, through the nodes in the target group number corresponding blockchain node group, according to the hash value of the index of the current transaction, in the pre-constructed transaction divided InMPT structure, find the leaf node corresponding to the hash value of the index of the current transaction, in the value of the leaf node corresponding to the hash value of the index of the current transaction, obtain the hash value of the index of all transactions in the previous stage of the current stage.
[0086] wherein, the transaction divided InMPT structure is constructed by the following steps:
[0087] Step A1: Obtain the index of all transactions in all stages of the full life cycle of large-scale manufacturing, for each transaction index, calculate the index through a hash algorithm to obtain the hash value of the transaction index, that is, the key of the transaction, obtain the hash value of the transaction index of the previous stage of the transaction, and the off-chain storage location of the complete information of the transaction, obtain the value of the transaction, the key of the transaction and the value of the transaction constitute the index information of the transaction, and then obtain the index information of all transactions;
[0088] In Table 1, which is an example of InMPT data, that is, an example of index information, the example stages involved are raw material storage, part production and part storage in the automobile supply chain. The first column in the table is the stage and transaction index. Based on the hash value of the transaction index, the key in the second column can be calculated. Based on the stage order of the automobile supply chain, the hash value of the previous stage index in the third column in the table can be obtained. For example, the previous stage of part storage is part production, and the hash value of the previous stage index of part1 in the part storage stage is the key of part1 in the part production stage. Since there are multiple production raw materials in a stage, there are multiple previous stage indexes for a transaction index. At this time, the hash values of multiple previous stage indexes are separated by "+". For example, part1 is produced by bulk11 and bulk12, so the hash value of the previous stage index in the value of part1 in the part production stage includes the hash value of the index in the raw material storage stage bulk11 and the hash value of the index in the raw material storage stage bulk12. The hash values of the two indexes are separated by "+". Part2 is produced by bulk21 and bulk22, and the hash value of the previous stage index in the value of part2 in the part production stage is the same.
[0089] Table 1 InMPT data example
[0090]
[0091] It should be noted that the address in the value is the off-chain address of the complete information of the transaction. Based on the off-chain address, the complete information of the transaction can be queried off-chain. In Table 1, the previous stage index of bulk11, bulk12, bulk21 and bulk22 in the raw material storage stage is null. Since the raw material storage is the first stage for the automobile supply chain, there is no previous stage, so the previous stage here is empty.
[0092] Step A2: According to the MPT structure and the index information of all transactions, an initial InMPT structure is constructed, which contains the index information of all transactions of all stages, and the initial InMPT structure includes one root node, multiple extension nodes, multiple branch nodes and multiple leaf nodes. For each transaction, the key of the index of the transaction is composed of the extension node of the transaction, the branch node of the transaction and the leaf node of the transaction, and the value of the transaction is stored in the leaf node of the transaction.
[0093] In the initial InMPT structure, the root node is connected to 0 to f, which are branch nodes, and a7 and 1 and d, which are extension nodes, and the leaf node at the tail end of the structure, such as 8 and {null, address012} in the lower left corner of the figure, together constitute a leaf node. Figure 3 , Figure 3 The initial InMPT structure is constructed based on the index information in Table 1, and this figure is only used for example understanding. In the figure, 0 to f are branch nodes, a7 and 1 and d are extension nodes, and the leaf node at the tail end of the structure, such as 8 and {null, address012} in the lower left corner of the figure, together constitute a leaf node.
[0094] Step A3: According to the stages of the whole life cycle of mass production, stage branch nodes are set between the root node and the extension node in the initial InMPT structure, and the transaction index information in the initial InMPT structure is divided according to the stages, and then the InMPT structure after transaction division is obtained based on the stages corresponding to the stage branch nodes and the structure corresponding to the stages after the transaction index information in the initial InMPT structure is divided.
[0095] In the InMPT structure after transaction division, the root node is connected to 0 to a, which are stage branch nodes. Figure 4 In the construction of the InMPT structure after transaction division, for the InMPT structure of Figure 3 , based on the stages, it is divided and arranged, for example, 0 is the raw material storage stage, then the Figure 3 is divided and arranged to obtain the structure composed of the transaction index information of the raw material storage, that is, the structure composed of bulk11, bulk12, bulk21 and bulk22 information of the raw material storage stage, and the stage branch structure corresponding to the raw material storage is obtained. The stage branch structure corresponding to the raw material storage is inserted into the branch corresponding to the stage node 0, and other stages are the same. Thus, the InMPT structure after transaction division can be constructed.
[0096] It should be noted that Figure 3 0 to f in the above-mentioned InMPT structure represent branch nodes, Figure 4 0 to a in the above-mentioned InMPT structure represent stage branch nodes, and the meanings of the two are different.
[0097] Step 4: judging whether the current stage is the first stage in the whole life cycle of mass production, if the current stage is the first stage in the whole life cycle of mass production, the process ends; if the current stage is not the first stage in the whole life cycle of mass production, step 5 is executed;
[0098] It should be noted that the present application is to realize the traceability of products, so this step judges whether the current stage is the first stage in the whole life cycle of mass production.
[0099] Wherein, the current stage is the first stage in the whole life cycle of mass production, indicating that the traceability ends, so the process ends.
[0100] Step 5: taking the previous stage of the current stage as a new current stage, taking the hash value of the index of each transaction of the previous stage as the hash value of the index of a current transaction, and returning to step 3.
[0101] In combination Figure 5 , the present application in the traceability of problem automobile products, specifically includes: converting the information "automobile sales: automobile batch number" into a hash value hashA, and then in the automobile sales branch, using the allocated node group, retrieving the hashA and the hash value hashB of the index of the previous stage, in the automobile delivery branch, using the allocated node group, retrieving the hashB and the hash value hashC of the index of the previous stage, in accordance with the stage order of the automobile supply chain, combining table 1, in the part warehouse branch, using the allocated node group, retrieving the hashI(a7fd046) and the hash value hashJ(a7c2453) of the index of the previous stage, in the part production branch, using the allocated node group, retrieving the hashJ(a7c2453) and the hash value hashK1+hashK2+…(i.e.a749265+a701b38) of the index of all previous stages, in the partProduce branch, using the allocated node group, retrieving hashK1, hashK2, …(i.e.a749265, a701b38) respectively, wherein a749265, a701b38 both correspond to the raw material warehouse stage, which is the last stage of the automobile supply chain, so the traceability ends.
[0102] The PRIMPT method (i.e. the InMPT structure realizing transaction and node division), the InMPT structure realizing only the transaction division, the InMPT structure realizing only the node division, the InMPT structure alone (without the transaction division and the node division), and the traditional on-chain and off-chain mode are implemented on the Ubuntu virtual machine system by means of the Hyperledger Fabric platform to build a 48-node consortium chain.
[0103] The five methods are respectively used to perform 10, 50 and 100 full life cycle traceability operations on the first group and the second group of original data, and the average processing time per unit number of operations is shown in Tables 2 and 3.
[0104] Table 2: Average execution time per unit number of full life cycle traceability operations under the first group of original data
[0105]
[0106] Table 3: Average execution time per unit number of full life cycle traceability operations under the second group of original data
[0107]
[0108] Among them, the node group number of the PRIMPT method and the InMPT structure of the node division is the most efficient group number. Under the first group of original data, the node group number of the PRIMPT method and the InMPT structure of the node division is shown in Table 4; under the second group of original data, the node group number of the PRIMPT method and the InMPT structure of the node division is shown in Table 5.
[0109] Table 4: Node group number under the first group of original data
[0110]
[0111] Table 5: Node group number under the second group of original data
[0112]
[0113] (1) Efficiency advantages of the InMPT structure: A comparison of the full lifecycle traceability efficiency of the InMPT structure and traditional on-chain and off-chain methods is attached. Figure 6 As shown in the figure. The results indicate that, with the same number of tracing operations throughout the entire lifecycle, the average execution time of the InMPT structure is shorter than that of traditional on-chain and off-chain methods;
[0114] (2) The InMPT structure for transaction partitioning: A comparison of the full lifecycle traceability efficiency of the InMPT structure for transaction partitioning and traditional on-chain and off-chain methods is attached. Figure 7 As shown. From the appendix Figure 6 and attached Figure 7 It can be seen that when the number of lifecycle tracing operations is the same, the average tracing execution time of the InMPT structure divided by the transaction is shorter than that of the traditional on-chain and off-chain methods. The former has a greater efficiency advantage than the latter than the InMPT alone. When the size of the original data increases significantly, the increase time of the InMPT structure divided by the transaction is significantly shortened compared with the traditional on-chain and off-chain methods.
[0115] (3) The efficiency advantages of the InMPT structure with node partitioning: A comparison of the full lifecycle traceability efficiency of the InMPT structure with node partitioning and traditional on-chain and off-chain methods is attached. Figure 8 As shown. From the appendix Figure 6 and attached Figure 8 It can be seen that, under the same conditions, compared with traditional on-chain and off-chain methods, the InMPT structure partitioned by the nodes has a shorter average tracing execution time, and the former has a greater efficiency advantage than the latter than the InMPT structure alone. As the number of operations increases, the efficiency gap between the InMPT structure partitioned by the nodes and traditional on-chain and off-chain methods becomes more pronounced.
[0116] (4) Efficiency advantages of the PRIMPT method: In summary, the design of the InMPT structure, the transaction partitioning and the node partitioning in the PRIMPT method have efficiency advantages. As can be seen from the experimental results in Tables 4 and 5, the PRIMPT algorithm, which combines the InMPT architecture, the transaction partitioning and the node partitioning, has the shortest average execution time for full lifecycle traceability, which is about 1233% more efficient than the traditional on-chain and off-chain methods.
[0117] In large-scale manufacturing supply chains, there is an urgent need for full lifecycle traceability of defective products. The PRIMPT method, compared to traditional on-chain and off-chain methods, better meets users' efficiency requirements.
[0118] The above description is merely that of the preferred embodiments of the present disclosure and a description of the technical principles of the present disclosure. It should be understood by those skilled in the art that the inventive scope of the embodiments of the present disclosure is not limited to the technical solutions formed by the specific combinations of the above technical features, and should also cover other technical solutions formed by the combinations of the above technical features or equivalent features without departing from the above inventive concept. For example, the technical solutions formed by the mutual replacement of the above features and the technical features with similar functions disclosed in the embodiments of the present disclosure (but not limited to) form the technical solutions.
Claims
1. A blockchain-based efficient traceability method for the whole life cycle of mass production, characterized in that, Comprise: Step 1: for the product to be traced in the whole life cycle of manufacturing, obtain the batch number of the product to be traced, and determine the last stage in the whole life cycle of mass manufacturing for a plurality of stages in the whole life cycle of mass manufacturing; Step 2: take the last stage in the whole life cycle of mass manufacturing as the current stage, and take the batch number as the index of the current transaction; Step 3: for the hash value of each current transaction index of the current stage, in the plurality of node groups of the pre-divided blockchain and the group number of the node group, determine the target group number of the blockchain for implementing the current retrieval request, for each current transaction, through the nodes in the node group corresponding to the target group number, according to the hash value of the index of the current transaction, in the pre-constructed InMPT structure after transaction division, obtain the hash value of the index of all transactions of the previous stage of the current stage, wherein all blockchain node groups corresponding to the target group number are executed in parallel when obtaining the hash value of the index of all transactions of the previous stage of the current stage; Wherein, the InMPT structure after transaction division, i.e. Index Merkle Patricia Trie structure, comprises index information of all transactions of all stages in the whole life cycle of manufacturing, the index information of the transaction comprises key and value, the key is the hash value of the index of the transaction, the value comprises the off-chain storage location of the complete information of the transaction, and the hash value of the index of all transactions corresponding to the previous stage of the transaction, the InMPT structure after transaction division adopts MPT structure, the InMPT structure after transaction division comprises root node, stage branch node, expansion node, branch node and leaf node, the root node is connected with the stage branch node, one stage branch corresponds to one stage in the whole life cycle of manufacturing, the stage branch node is connected with the expansion node in the plurality of nodes comprising the index information of all transactions of the corresponding stage, the plurality of nodes comprising the index information of all transactions of the corresponding stage comprise expansion node, branch node and leaf node; Step 4: determine whether the current stage is the first stage in the whole life cycle of mass manufacturing, if the current stage is the first stage in the whole life cycle of mass manufacturing, the process ends; if the current stage is not the first stage in the whole life cycle of mass manufacturing, execute step 5; Step 5: take the previous stage of the current stage as a new current stage, and take the hash value of the index of each transaction of the previous stage as the hash value of a current transaction index, and return to execute step 3.
2. The blockchain-based mass manufacturing full life cycle efficient traceability method according to claim 1, characterized in that, The InMPT structure after transaction division is constructed by the following steps: Step A1: Obtain the index of all transactions in all stages of the full life cycle of mass production, for each transaction index, calculate the index through a hash algorithm to obtain the hash value of the index of the transaction, that is, the key of the transaction, obtain the hash value of the transaction index of the previous stage of the transaction, and the off-chain storage location of the complete information of the transaction, obtain the value of the transaction, the key of the transaction and the value of the transaction constitute the index information of the transaction, and then obtain the index information of all transactions; Step A2: According to the MPT structure and the index information of all transactions, an initial InMPT structure is constructed, which contains the index information of all transactions in all stages, and the initial InMPT structure includes a root node, multiple extension nodes, multiple branch nodes and multiple leaf nodes, for each transaction, the key of the index of the transaction is composed of the extension node of the transaction, the branch node of the transaction and the leaf node of the transaction, and the value of the transaction is stored in the leaf node of the transaction; Step A3: According to the stages of the full life cycle of mass production, stage branch nodes are set between the root node and the extension node in the initial InMPT structure, and the transaction index information in the initial InMPT structure is divided according to the stages, and then based on the stage corresponding to the stage branch node and the structure corresponding to the stage after the transaction index information in the initial InMPT structure is divided, the InMPT structure after the transaction is divided is obtained.
3. The blockchain-based mass manufacturing full life cycle efficient traceability method of claim 1, wherein, Step 3 specifically includes: Step 3.1: For each current transaction index of the current stage, calculate the hash value of each current index through a hash algorithm, and then generate a current search request, and send the current search request to the blockchain. After receiving the current search request, in the pre-divided multiple node groups of the blockchain and the group number of the node group, according to the hash value of the index of the transaction in the current search request, the target group number of the blockchain node group for realizing the current search request in the blockchain is calculated; Step 3.2: For each current transaction, through the node in the target group number corresponding to the blockchain node group, according to the hash value of the index of the current transaction, in the pre-constructed InMPT structure after the transaction is divided, the leaf node corresponding to the hash value of the index of the current transaction is found, and in the value of the leaf node corresponding to the hash value of the index of the current transaction, the hash value of the index of all transactions of the previous stage of the current stage is obtained.
4. The blockchain-based mass manufacturing full life cycle efficient traceability method of claim 3, wherein, In step 3.1, the target group number of the blockchain node group for realizing the current search request in the blockchain is calculated according to the hash value of the index of the transaction in the current search request, which is specifically realized by the following way: R j =I j modm(1) wherein I j represents the hash value of the index of the current transaction in the current search request j, m represents the total number of groups of the blockchain nodes, R j represents the target group number of the group of the blockchain nodes for implementing the current search request j.
5. The blockchain-based mass manufacturing full life cycle efficient traceability method of claim 1, wherein, The pre-division of the plurality of node groups of the blockchain and the group numbers of the node groups is achieved by the following steps: Step B1: determining the total number of groups for grouping for all nodes of the blockchain; Step B2: dividing all nodes in the blockchain according to the total number of groups to determine the group number to which each node belongs, so as to obtain the plurality of node groups of the blockchain and the group numbers of the node groups.
6. The PRIMPT method in blockchain-based mass production full life cycle traceability according to claim 5, characterized in that, Step B1 specifically comprises: A formula for the total number of groups is established, which is specifically represented by formula (2): Wherein, m represents the total number of groups of blockchain nodes; c represents the communication time of nodes in each group of blockchain with nodes in other groups of blockchain; o represents the time required to respond to the current data retrieval request in the InMPT structure before the grouping of blockchain nodes; T is the optimization target, T represents the time required to respond to the current retrieval request when the total number of groups is m; s.t. is the constraint condition, N + is a positive integer, min m T minimizes T when the total number of groups is m; Derivation is performed on formula (2) to obtain: dT / dm = c - o / m 2 (3) Let the derivative be 0 to obtain Since m e N + The optimal solution of formula (2) is: Thus, the value of the total number of groups m of the blockchain node groups is formula (5).
7. The PRIMPT method in blockchain-based mass production full life cycle traceability according to claim 5, characterized in that, Step B2 specifically comprises: The address of a node in the blockchain is subjected to a hash algorithm to obtain a hash value, the hash value is divided by the total number of groups, and a modulo operation is performed to obtain the group number to which the node in the blockchain is allocated, which is specifically achieved by the following formula: G i = Hash (Ad i )(mod m) (6) Wherein, Adi represents the address of node i, m represents the total number of groups of the blockchain nodes, and Gi represents the group number of node i.
Citation Information
Patent Citations
Block chain-based Chinese-European land-sea fast line transnational supply chain information tracing system and method
CN112950227A
Efficient traceability query method for multi-chain data relevance
CN113157733A
Block chain-based data query method for large-scale manufacturing full-life-cycle traceability
CN117194518A
Food and drug tracing method and system based on blockchain
CN112488734A
Verifiable traceability method and device based on block chain
CN116894047A