Task computing method and apparatus, node device, and computer readable storage medium

By introducing task numbers and preset merging conditions into the blockchain network, the problem of data leakage of the master computing node is solved, and the security and privacy protection of task computing are achieved, ensuring that data leakage will not occur even if the node is attacked.

CN116781386BActive Publication Date: 2026-07-24GUANGZHOU YIBIT BLOCKCHAIN TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GUANGZHOU YIBIT BLOCKCHAIN TECH CO LTD
Filing Date
2023-07-14
Publication Date
2026-07-24

AI Technical Summary

Technical Problem

When performing task computation in a blockchain, the security of task computation is low because the master computing node has all the computation task data, process data, and final computation results. If the master node is attacked, there is a risk of data leakage.

Method used

By introducing task numbers and preset merging conditions into the blockchain network, computing nodes receive task data packets and determine whether the merging conditions are met based on the task number. If the conditions are met, the nodes perform data processing result merging operations until the conditions are no longer met, at which point the results are uploaded to the blockchain network, ensuring that no node can hold all the data in the task computation process at the same time.

Benefits of technology

It improves the security of task computation in the blockchain network, ensuring that even if a node is attacked, not all data will be stolen, thus enhancing data security and privacy protection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116781386B_ABST
    Figure CN116781386B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a task computing method and device, a node device and a computer readable storage medium, relating to the technical field of blockchain. A task data packet sent by a communication node is received; if it is determined according to a task number that a preset merging condition is met, a data processing result merging operation is performed according to the task number; the task number is updated, it is determined according to the updated task number whether the preset merging condition is met, and in the case that the preset merging condition is met, the data processing result merging operation is performed according to the updated task number until it is determined according to the updated task number that the preset merging condition is not met; if it is determined according to the task number that the preset merging condition is not met, the task number and the computing result corresponding to the task number, or the updated task number and the first merging result corresponding to the updated task number are uploaded to a blockchain network. The method can improve the security of task computing in the blockchain network.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of blockchain technology, and more specifically, to a task computing method, apparatus, node device, and computer-readable storage medium. Background Technology

[0002] Currently, when performing task computation in a blockchain, the master computing node often distributes the computation task to multiple slave computing nodes. After the multiple slave computing nodes have performed their computations, the master computing node can obtain the computation results from the multiple slave computing nodes and merge them to obtain the final computation result.

[0003] However, in this method, since the master computing node is the key node and has all the computing task data, process data and final computing results, if the master node is attacked and a data leakage problem occurs, it means that all the data will be stolen, thus resulting in a low security problem for task computing. Summary of the Invention

[0004] In view of this, the purpose of the present invention is to provide a task computing method, apparatus, node device and computer-readable storage medium to solve the problem of low security in task computing in the prior art.

[0005] To achieve the above objectives, the technical solutions adopted in the embodiments of the present invention are as follows:

[0006] In a first aspect, the present invention provides a task computation method, applied to any node device in a blockchain network, the method comprising:

[0007] Receive a task data packet sent by a communication node; the task data packet includes data to be calculated, a calculation program, and a task number.

[0008] The communication node is a node in the blockchain network that communicates with the user, and the node that receives the task data packet is a computing node in the blockchain network. The communication node is used to forward multiple task data packets corresponding to the task to be computed to different computing nodes, and each computing node receives a different task data packet.

[0009] Determine whether the preset merging conditions are met based on the task number;

[0010] If the preset merging conditions are met, a data processing result merging operation is performed according to the task number; the data processing result merging operation includes calculating the task number to be merged according to the task number, merging the data processing result corresponding to the task number and the data processing result corresponding to the task number to be merged to obtain a first merging result; the data processing result is a calculation result obtained by performing calculations on the data to be calculated according to the calculation program, or a second merging result obtained by performing at least one merging based on the calculation result;

[0011] The task number is updated, and it is determined whether the preset merging condition is met based on the updated task number. If the preset merging condition is met, the data processing result merging operation is performed based on the updated task number until it is determined that the preset merging condition is not met based on the updated task number.

[0012] If the preset merging conditions are not met, the task number and the calculation result corresponding to the task number, or the updated task number and the first merging result corresponding to the updated task number, are uploaded to the blockchain network so that other computing nodes in the blockchain network can obtain the calculation result corresponding to the task number or the first merging result corresponding to the updated task number.

[0013] In an optional implementation, the task number includes a first task number and a second task number, wherein the first task number represents the current number of data processing operations, and the second task number is obtained based on the current number of data processing operations and the node number of the computing node receiving the task data packet;

[0014] The step of determining whether the preset merging conditions are met based on the task number includes:

[0015] If the second task number is even, then the preset merging condition is satisfied.

[0016] In an optional implementation, the first task number to be merged is the same as the first task number, and the second task number to be merged is the second task number minus 1.

[0017] Updating the task number includes:

[0018] Add 1 to the first task number to obtain a new first task number, divide the second task number by 2 to obtain a new second task number, and obtain a new task number based on the new first task number and the new second task number.

[0019] In an optional implementation, the method further includes:

[0020] Upon receiving task information sent by the user, multiple computing nodes are determined based on the task information, each computing node is assigned a number, and the node number and node information corresponding to each computing node are sent to the user.

[0021] The system receives multiple task data packets sent by the user according to the task to be computed, and forwards each task data packet to the corresponding computing node according to the node number in each task data packet.

[0022] In an optional implementation, the task information includes shard array information and the number of tasks, and determining multiple computing nodes based on the task information includes:

[0023] The number of computing nodes is determined based on the number of tasks; the number of computing nodes is greater than or equal to the number of tasks and is a power of 2.

[0024] Based on the number of computing nodes and the sharding array information, multiple computing nodes are determined.

[0025] In an optional implementation, the shard array information includes information about at least one shard array; determining multiple computing nodes based on the number of computing nodes and the shard array information includes:

[0026] Based on the number of the shard arrays and the number of computing nodes, the number of sub-computing nodes corresponding to each shard array is calculated; wherein, the number of sub-computing nodes corresponding to each shard array is equal.

[0027] Based on the number of sub-computation nodes corresponding to each of the shard arrays, a number of nodes are randomly selected from each of the shard arrays as the computation nodes.

[0028] In an optional implementation, forwarding each task data packet to its corresponding computing node based on the node number in each task data packet includes:

[0029] If the number of computing nodes is equal to the number of tasks, then each task data packet is forwarded to the corresponding computing node according to the node number in each task data packet;

[0030] If the number of computing nodes is greater than the number of tasks, then each task data packet is forwarded to the corresponding computing node according to the node number in each task data packet, and zero-value computing tasks are assigned to the remaining computing nodes; the zero-value computing task indicates that the remaining computing nodes do not participate in task computing.

[0031] The method further includes:

[0032] Calculate the target task number based on the number of tasks in the task information; the target task number corresponds to the task calculation result corresponding to the task to be calculated.

[0033] At preset intervals, the system queries the blockchain network to see if there is a task calculation result corresponding to the target task number.

[0034] If it exists, the task calculation result will be sent to the user.

[0035] Secondly, the present invention provides a task computing device, applied to any node device in a blockchain network, the device comprising:

[0036] The receiving module is used to receive task data packets sent by the communication node; the task data packet includes data to be calculated, a calculation program, and a task number.

[0037] The communication node is a node in the blockchain network that communicates with the user, and the node that receives the task data packet is a computing node in the blockchain network. The communication node is used to forward multiple task data packets corresponding to the task to be computed to different computing nodes, and each computing node receives a different task data packet.

[0038] The determination module is used to determine whether preset merging conditions are met based on the task number;

[0039] The determining module is further configured to perform a data processing result merging operation based on the task number if the preset merging condition is met; the data processing result merging operation includes calculating the task number to be merged based on the task number, merging the data processing result corresponding to the task number and the data processing result corresponding to the task number to be merged to obtain a first merging result; the data processing result is a calculation result obtained by performing calculations on the data to be calculated according to the calculation program, or a second merging result obtained by performing at least one merging based on the calculation result;

[0040] The determining module is further configured to update the task number, determine whether the preset merging condition is met based on the updated task number, and if the preset merging condition is met, perform the data processing result merging operation based on the updated task number until it is determined based on the updated task number that the preset merging condition is not met.

[0041] The determining module is further configured to, if the preset merging condition is not met, upload the task number and the calculation result corresponding to the task number, or the updated task number and the first merging result corresponding to the updated task number, to the blockchain network so that other computing nodes in the blockchain network can obtain the calculation result corresponding to the task number or the first merging result corresponding to the updated task number.

[0042] Thirdly, the present invention provides a node device including a processor and a memory, the memory storing a computer program executable by the processor, the processor being able to execute the computer program to implement the method described in any of the foregoing embodiments.

[0043] Fourthly, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in any of the foregoing embodiments.

[0044] The task computation method, apparatus, node device, and computer-readable storage medium provided in this invention allow a computing node to receive task data packets sent by a communication node. Based on the task number in the task data packet, the node determines whether a preset merging condition is met. If the preset merging condition is met, a data processing result merging operation is performed, merging the data processing result corresponding to the task number with the data processing result corresponding to the task number to be merged, obtaining a first merging result. The task number is then updated. Based on the updated task number, the node determines whether the preset merging condition is met again. If the preset merging condition is met, the node performs the data processing result merging operation based on the updated task number until the updated task number determines that the preset merging condition is not met. If the preset merging condition is not met, the task number and its corresponding computation result, or the updated task number and its corresponding first merging result, are uploaded to the blockchain network. Other computing nodes in the blockchain network can then obtain this computation result or the first merging result. Through this solution, during task computation, neither the communication node nor any computing node can simultaneously hold all the data during the task computation process. Therefore, even if a node is attacked, not all data will be stolen, thus improving the security of task computation in the blockchain network.

[0045] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0046] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0047] Figure 1 A block diagram of a node device provided in an embodiment of the present invention is shown;

[0048] Figure 2 This invention illustrates a flowchart of a task calculation method provided in an embodiment of the present invention.

[0049] Figure 3 An example diagram illustrating the computation process of a computing node is shown;

[0050] Figure 4 This diagram illustrates another flowchart of the task calculation method provided in an embodiment of the present invention.

[0051] Figure 5 This diagram illustrates a functional block diagram of a task computing device provided in an embodiment of the present invention.

[0052] Figure 6 Another functional block diagram of the task computing device provided in an embodiment of the present invention is shown.

[0053] Icons: 10-Node device; 100-Memory; 110-Processor; 120-Communication module; 200-Receive module; 210-Determine module; 220-Transmit module. Detailed Implementation

[0054] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.

[0055] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.

[0056] It should be noted that relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes the element.

[0057] Blockchain is a decentralized, distributed database technology that can record transactions, events, or data while ensuring that these records are immutable and transparent.

[0058] The core idea of ​​blockchain is to ensure the security and reliability of transactions and data by using cryptographic techniques and distributed consensus algorithms, without relying on centralized institutions or third-party intermediaries. The basic building blocks of a blockchain are "blocks," each containing some transactions or data, along with metadata such as timestamps and the hash of the previous block. These blocks are chained together to form a continuously growing chain, hence the name "blockchain."

[0059] Currently, blockchain often requires task computation, such as privacy computation.

[0060] Privacy-preserving computation is a computational approach designed to protect the privacy and confidentiality of personal data while allowing meaningful computation and analysis during data processing. The goal of privacy-preserving computation is to extract useful information from data without disclosing personal data.

[0061] Privacy-preserving computation encompasses various technologies and protocols, such as Secure Multi-Party Computation (SMPC), Homomorphic Encryption, and Differential Privacy. These technologies allow multiple parties to perform computations and data analysis without exposing sensitive data, while simultaneously protecting the privacy and confidentiality of the data.

[0062] In existing technologies, when performing task calculations, the master computing node often distributes the calculation tasks to multiple slave computing nodes. After the multiple slave computing nodes have performed their calculations, the master computing node can obtain the calculation results obtained by the multiple slave computing nodes and merge them to obtain the final calculation result.

[0063] However, in this method, since the master computing node is the key node and has all the computing task data, process data and final computing results, if the master node is attacked and a data leakage problem occurs, it means that all the data will be stolen, thus resulting in a low security problem for task computing.

[0064] Based on this, embodiments of this application provide a task calculation method to solve the above problems.

[0065] Figure 1 For a block diagram of the node device 10 provided in the embodiments of this application, please refer to [link / reference]. Figure 1 The node device 10 includes a memory 100, a processor 110, and a communication module 120. The memory 100, processor 110, and communication module 120 are electrically connected directly or indirectly to enable data transmission or interaction. For example, these components can be electrically connected to each other via one or more communication buses or signal lines.

[0066] The memory 100 is used to store programs or data. The memory 100 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.

[0067] The processor 110 is used to read / write data or programs stored in memory and to perform corresponding functions.

[0068] The communication module 120 is used to establish a communication connection between the node device and other communication terminals through the network, and to send and receive data through the network.

[0069] Optionally, the blockchain network includes multiple node devices, which may be servers.

[0070] It should be understood that, Figure 1 The structure shown is only a schematic diagram of the node device 10. The node device 10 may also include components that are larger than... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown. Figure 1The components shown can be implemented using hardware, software, or a combination thereof.

[0071] The following is based on the above. Figure 1 The node device 10 in this application is the execution entity. The task calculation method provided in this embodiment is illustrated with reference to the flowchart. Specifically, Figure 2 For a flowchart illustrating a task calculation method provided in an embodiment of this application, please refer to [link / reference]. Figure 2 The method includes:

[0072] Step S20: Receive the task data packet sent by the communication node;

[0073] The task data package includes the data to be calculated, the calculation program, and the task number.

[0074] In this context, communication nodes are nodes in the blockchain network that communicate with users, while nodes that receive task data packets are computing nodes in the blockchain network. Communication nodes are used to forward multiple task data packets corresponding to the task to be computed to different computing nodes, and each computing node receives different task data packets.

[0075] Optionally, the communication node is a node in the blockchain network that receives information sent by the user.

[0076] Optionally, if a node device receives a task data packet sent by a communication node, then the node device can be identified as a computing node.

[0077] In this embodiment, the communication node can receive multiple task data packets corresponding to the task to be computed sent by the user, and forward the multiple task data packets to different computing nodes, so that each computing node can perform task computing operations based on different task data packets.

[0078] Understandably, each computing node receives a different task number in the task data packet, and the data to be computed and the computing program may both be different, or one of them may be different, depending on the specific computing requirements.

[0079] Step S21: Determine whether the preset merging conditions are met based on the task number;

[0080] Step S22: If the preset merging conditions are met, perform the data processing result merging operation according to the task number;

[0081] The data processing result merging operation includes calculating the task number to be merged based on the task number, merging the data processing result corresponding to the task number and the data processing result corresponding to the task number to be merged to obtain a first merging result; the data processing result is the calculation result obtained by performing calculations on the data to be calculated according to the calculation program, or the second merging result obtained by merging at least once based on the calculation result.

[0082] Step S23: Update the task number, determine whether the preset merging conditions are met based on the updated task number, and if the preset merging conditions are met, perform the data processing result merging operation based on the updated task number until it is determined that the preset merging conditions are not met based on the updated task number.

[0083] In this embodiment, if the task number meets the preset merging conditions, the computing node can calculate the task number to be merged based on the task number, and merge the data processing result corresponding to the task number to be merged with the data processing result corresponding to the task number to obtain the first merging result.

[0084] Understandably, if a computing node determines that the preset merging conditions are met based on the task number, it will merge the data processing results it obtained with the data processing results obtained by another computing node.

[0085] Optionally, the data processing result refers to the data that currently needs to be merged.

[0086] In this embodiment, after obtaining the first merging result, the computing node can update the task number, and then determine whether the preset merging conditions are met again based on the updated task number.

[0087] Optionally, after the computing node receives the task data packet, it can perform the first data processing, that is, perform calculations on the data to be calculated according to the calculation program in the task data packet, so as to obtain the calculation result.

[0088] Understandably, if the preset merging conditions are met based on the task number, the computing node can merge the calculation result corresponding to the task number (i.e., the calculation result it obtained itself) with the calculation result obtained from the task number to be merged, obtain the first merging result, and update the task number.

[0089] Optionally, the computing node can determine again whether the preset merging conditions are met based on the updated task number. If they are met, the computing node can determine a new task number to be merged based on the updated task number, and use the first merging result as the second merging result for a second data processing. That is, the second merging result corresponding to the updated task number is merged with the second merging result corresponding to the new task number to be merged to obtain a new first merging result. This process continues until it is determined that the preset merging conditions are not met based on the updated task number.

[0090] Step S24: If the preset merging conditions are not met, the task number and the calculation result corresponding to the task number, or the updated task number and the first merging result corresponding to the updated task number, are uploaded to the blockchain network so that other computing nodes in the blockchain network can obtain the calculation result corresponding to the task number or the first merging result corresponding to the updated task number.

[0091] Optionally, after receiving the task data packet, the computing node may perform initial data processing to obtain a calculation result. If, based on the task number, it is determined that the preset merging conditions are not met, the computing node may directly upload the task number and its corresponding calculation result to the blockchain network. Other computing nodes that determine the preset merging conditions are met may then retrieve the calculation result from the blockchain network for merging. Optionally, if, based on the updated task number, the computing node determines that the preset merging conditions are not met, it may upload the updated task number and its corresponding first merging result to the blockchain network. Other computing nodes that determine the preset merging conditions are met may then retrieve the first merging result from the blockchain network and use it as the second merging result for merging.

[0092] Understandably, in this embodiment, for any computing node, the task data packet it receives is one of multiple task data packets corresponding to the task to be computed, and each computing node receives different task data packets. Therefore, each computing node can only obtain a portion of the task to be computed. In order to compute a task to be computed, each computing node needs to first perform calculations on the data to be computed according to the calculation program in the task data packet to obtain the calculation result. Then, at least one round of merging processing is required based on multiple calculation results to obtain the final task calculation result.

[0093] Obviously, in this process, since each merge is only performed by the computing node that meets the preset merge conditions, and each computing node that meets the preset merge conditions only merges the two data processing results, no computing node can obtain the complete data of the task to be calculated and the complete data of the calculation process at the same time during the entire task calculation process. While the communication node can obtain all the data of the task to be calculated, it cannot obtain the data of the calculation process.

[0094] Therefore, whether a communication node or any computing node is attacked, it will not lead to the leakage of all data, thereby improving the security of task computing in the blockchain network.

[0095] The task computation method provided in this invention allows a computing node to receive task data packets sent by a communication node. Based on the task number in the task data packet, it determines whether a preset merging condition is met. If the preset merging condition is met, a data processing result merging operation is performed, merging the data processing result corresponding to the task number with the data processing result corresponding to the task number to be merged, obtaining a first merging result. The task number is then updated, and the updated task number is used to determine whether the preset merging condition is met. If the preset merging condition is met, the data processing result merging operation is performed again based on the updated task number until the updated task number determines that the preset merging condition is not met. If the preset merging condition is not met, the task number and its corresponding computation result, or the updated task number and its corresponding first merging result, are uploaded to the blockchain network, where other computing nodes in the blockchain network can obtain the computation result or the first merging result. Through this solution, neither the communication node nor any computing node can simultaneously hold all the data during task computation. Therefore, even if a node is attacked, not all data will be stolen, thus improving the security of task computation in the blockchain network.

[0096] Optionally, the task number may include a first task number and a second task number, represented as (first task number, second task number), wherein the first task number may represent the current number of data processing operations, and the second task number may be calculated based on the current number of data processing operations and the node number of the computing node that receives the task data packet.

[0097] Optionally, the node number can be a positive integer starting from 1 and incrementing. During the first data processing, the second task number can be the same as the node number.

[0098] In this case, if the second task number is even, it can be determined that the preset merging condition is met.

[0099] For example, if the task number is (2, 2), it can be determined that the current data processing count is two, and the preset merging condition is met.

[0100] Optionally, for a computing node that meets the preset merging conditions, it can merge the data processing results corresponding to adjacent task numbers and the data processing results calculated by the computing node. That is, the first task number to be merged of the task number to be merged is the same as the first task number, and the second task number to be merged of the task number to be merged is the second task number minus 1.

[0101] In one example, if the task number of the first computing node is (2, 1) and the task number of the second computing node is (2, 2), then the first computing node can determine that the preset merging condition is not met based on the task number (2, 1), and the second computing node can determine that the preset merging condition is met based on the task number (2, 2), and the task number to be merged is (2, 1).

[0102] In this embodiment, after determining the task number to be merged, the computing node can obtain the corresponding data processing result from the blockchain network, merge it with the data processing result it has calculated, and update the task number.

[0103] Optionally, the computing node can obtain a new first task number and a new second task number by adding 1 to the first task number and dividing the second task number by 2, and then obtain a new task number based on the new first task number and the new second task number.

[0104] Understandably, since another data processing was performed at this time, the first task number can be incremented by 1 to indicate that the current task has been processed one more time.

[0105] Alternatively, the second task number can be calculated using the following formula:

[0106] rank = x × 2 y-1 ;y∈[1,h],x∈[1,2] h-1 ]

[0107] Where rank represents the node number of the computing node that receives the task data packet, x represents the second task number, y represents the current number of data processing (first task number), and h represents the total number of data processing.

[0108] Optionally, during the first data processing, each task number can be set to (1, rank), that is, the second task number can be set to the node number of the computing node that receives the data packet of that task.

[0109] Next, combine Figure 3The computation process of a computing node is illustrated with an example. See [example example here]. Figure 3 If there are 4 computing nodes in the blockchain network at this time, and the node numbers and ranks of these 4 computing nodes are 1, 2, 3 and 4 respectively, and the communication node obtains four task data packets, and the task numbers in these four task data packets are (1,1), (1,2), (1,3) and (1,4) respectively, then the communication node...

[0110] In this example, the communication node can send the task data packet with task number (1,1) to the computing node with rank 1, the task data packet with task number (1,2) to the computing node with rank 2, the task data packet with task number (1,3) to the computing node with rank 3, and the task data packet with task number (1,4) to the computing node with rank 4.

[0111] In this example, each computing node can perform calculations on the data to be calculated according to the calculation program in the task data packet after receiving the task data packet, thereby obtaining 4 calculation results. Then, it can determine whether the preset merging conditions are met based on the task number.

[0112] Since the preset merging condition is that the second task number is even, it can be determined that the computing nodes with rank 2 and rank 4 both meet the preset merging condition and can perform the data processing result merging operation. However, the computing nodes with rank 1 and rank 3 do not meet the preset merging condition, so they need to upload the task number and calculation result to the blockchain network. In this example, the computing node with rank 2 can determine the task number to be merged as (1,1) based on the task number (1,2), and the computing node with rank 4 can determine the task number to be merged as (1,3) based on the task number (1,4). Therefore, the computing nodes with rank 2 and rank 4 can obtain the calculation result corresponding to (1,1) and (1,3) respectively from the blockchain network.

[0113] In this example, the computing node with rank 2 can merge the calculation results corresponding to (1,1) and (1,2) to obtain the first merged result; the computing node with rank 4 can merge the calculation results corresponding to (1,3) and (1,4) to obtain the first merged result.

[0114] Understandably, this is the second data processing step. The compute nodes with rank 2 and rank 4 need to update the task numbers. The updated task number for the compute node with rank 2 is (2,1), while the updated task number for the compute node with rank 4 is (2,2).

[0115] In this example, the computing node with rank 4 meets the preset merging conditions, while the computing node with rank 2 does not. Therefore, the computing node with rank 2 needs to upload the task number (2,1) and the first merging result to the blockchain network, while the computing node with rank 4 determines the task number to be merged based on the task number (2,2).

[0116] In this example, the computing node with rank 4 determines the task number to be merged as (2,1) based on the task number (2,2). Therefore, the computing node with rank 4 can obtain the first merge result corresponding to (2,1) from the blockchain network and use this first merge result as the second merge result corresponding to the task number to be merged. The first merge result corresponding to the task number (2,2) is used as the second merge result, and the two are merged to obtain the first merge result. At the same time, this is the third data processing, so the computing node with rank 4 can update the task number (2,2) to obtain the updated task number (3,1).

[0117] Understandably, the computing node with rank 4 also does not meet the preset merging conditions at this time, so (3,1) and the corresponding first merging result can be uploaded to the blockchain network.

[0118] Optionally, to facilitate user queries of process data, computing nodes may also upload the task number and the corresponding calculation result, or the updated task number and the first merge result corresponding to the updated task number, to the blockchain network if the preset merging conditions are met.

[0119] For example, a computing node with a rank of 2 can also upload the task number (1,2) and its corresponding calculation result to the blockchain network.

[0120] Optionally, any node device in the blockchain may also participate in task computation as a communication node; specifically, in Figure 2 On this basis, Figure 4 For another flowchart illustrating the task calculation method provided in this application embodiment, please refer to [link / reference]. Figure 4 The method also includes:

[0121] Step S10: Upon receiving the task information sent by the user, determine multiple computing nodes based on the task information, assign numbers to each computing node, and send the node number and node information corresponding to each computing node to the user.

[0122] In this embodiment, if a node device receives task information sent by a user, it can be identified as a communication node.

[0123] Optionally, users can send task information to the communication node through client software.

[0124] In one possible implementation, the software could be an SDK (Software Development Kit).

[0125] Optionally, the communication node can determine multiple computing nodes based on the task information sent by the user, and assign numbers to each computing node, and then send the node number and node information corresponding to each computing node to the client.

[0126] Optionally, the node information may include, but is not limited to, the computing node's ID and IP address in the blockchain network.

[0127] Optionally, after receiving the node number and node information, the user can set up multiple task data packets according to the task to be calculated and send them to the communication node through the client software.

[0128] Step S11: Receive multiple task data packets sent by the user according to the task to be computed, and forward each task data packet to the corresponding computing node according to the node number in each task data packet.

[0129] Optionally, in addition to the data to be calculated, the calculation program, and the task number, the task data package also includes the node number.

[0130] Understandably, a communication node can send a task data packet to the corresponding computing node based on the node number in the task data packet.

[0131] Optionally, to ensure the reliability of the calculation, the user can specify at least one shard array for task calculation. Based on this, the task information includes shard array information and the number of tasks.

[0132] Optionally, the blockchain network includes node devices set up by multiple companies, and each company's node devices can form a shard array.

[0133] Based on this, the node can determine multiple computing nodes according to task information in step S10 above through the following steps:

[0134] The number of computing nodes is determined based on the number of tasks; the number of computing nodes is greater than or equal to the number of tasks and is a power of 2; multiple computing nodes are determined based on the number of computing nodes and the sharding array information.

[0135] Alternatively, the number of computing nodes can be determined by the communication nodes using the following formula:

[0136]

[0137] M=2 n

[0138] Where N represents the number of tasks and M represents the number of computing nodes.

[0139] Optionally, n can reflect the total number of times the data processing results were merged.

[0140] Understandably, n is a positive integer. If log2N is a decimal, then n needs to be calculated by rounding up.

[0141] In one example, if N=7, then n needs to be 3 and M=8, meaning that the number of computing nodes is greater than the number of tasks.

[0142] In this embodiment, the communication node needs to select an exponential number of computing nodes to ensure that the merging process is executed smoothly.

[0143] In this embodiment, after calculating the number of computing nodes, the communication node can determine multiple computing nodes based on the number of computing nodes and the sharding array information.

[0144] Specifically, the sharding array information includes information about at least one sharding array. The communication node can calculate the number of sub-computing nodes corresponding to each sharding array based on the number of sharding arrays and the number of computing nodes. The number of sub-computing nodes corresponding to each sharding array is equal. Based on the number of sub-computing nodes corresponding to each sharding array, a certain number of sub-computing nodes are randomly selected from each sharding array as computing nodes.

[0145] Alternatively, the communication node can calculate the number of computing nodes by averaging the number of shard arrays, thereby determining the number of sub-computing nodes corresponding to each shard array.

[0146] It is understandable that the number of sub-computation nodes corresponding to each slice array is equal.

[0147] Optionally, considering the possibility that the distribution may not be perfectly even, it is necessary to ensure that the number of sub-computation nodes corresponding to most of the shard arrays is equal.

[0148] For example, if the number of computation nodes is 8 and the number of shard arrays is 3, then the number of child nodes corresponding to these three shard arrays can be 3, 3, and 2 respectively.

[0149] In this embodiment, the communication node can randomly select a number of sub-computation nodes from each shard array as computation nodes.

[0150] Optionally, after the computing node is determined, the node device can forward each task data packet to the corresponding computing node according to the node number in each task data packet.

[0151] In one possible implementation, if the number of computing nodes equals the number of tasks, the node device can directly forward each task data packet to the corresponding computing node based on the node number in each task data packet.

[0152] Understandably, in this scenario, each computing node can receive a task data packet corresponding to the task to be computed.

[0153] In another possible implementation, if the number of computing nodes is greater than the number of tasks, each task data packet is forwarded to the corresponding computing node according to the node number in each task data packet, and zero-value computing tasks are assigned to the remaining computing nodes; zero-value computing tasks indicate that the remaining computing nodes do not participate in task computing.

[0154] Understandably, in this scenario, some computing nodes can receive a task data packet corresponding to the task to be computed, while the remaining computing nodes can only receive zero-value computation tasks.

[0155] Optionally, a task number is also set in this zero-value calculation task.

[0156] Optionally, the remaining computing nodes that receive the zero-value calculation task do not participate in the task calculation, that is, they will not obtain the calculation result during the first data processing. However, the remaining computing nodes need to determine whether the preset merging conditions are met based on the task number, and if the preset merging conditions are met, they perform the data processing result merging operation based on the task number.

[0157] Optionally, the communication node also needs to send the final task calculation result corresponding to the task to be calculated to the user. Since each computing node will upload its calculation result to the blockchain network, the communication node can obtain the final task calculation result from the blockchain network.

[0158] Specifically, the communication node can calculate the target task number based on the number of tasks in the task information; the target task number corresponds to the task calculation result corresponding to the task to be calculated.

[0159] Optionally, the result of this task calculation is the final calculation result corresponding to the task to be calculated.

[0160] Optionally, the second target task number in the target task number should be 1, therefore it is necessary to determine the first target task number in the target task number.

[0161] Understandably, the first target task number should be h, which represents the total number of data processing operations.

[0162] Alternatively, the first target task number h can be calculated using the following formula:

[0163]

[0164] h = n + 1

[0165] Where N represents the number of tasks.

[0166] At preset intervals, the system checks the blockchain network to see if there is a task calculation result corresponding to the target task number; if so, the task calculation result is sent to the user.

[0167] Optionally, the communication node can query the blockchain network at preset intervals to see if any computing node has already uploaded the target task number and the corresponding task calculation result.

[0168] Optionally, the preset duration can be set according to the actual application.

[0169] In one possible implementation, if a communication node finds the task calculation result corresponding to the target task number in the blockchain network, it can send the task calculation result to the user.

[0170] In another possible implementation, the communication node can also notify the user that the calculation has been completed when it can find the task calculation result corresponding to the target task number in the blockchain network, and the user can check the task calculation result himself.

[0171] Optionally, in order to enable computing nodes to know whether the data calculated at this time is the final task calculation result, the task data packet sent to the computing nodes may also include the number of computing nodes or the number of tasks, so that the computing nodes can also calculate the target task number based on the number of computing nodes or the number of tasks.

[0172] Understandably, if the updated task number obtained by the computing node is the target task number, then the computing node can determine that the first merge result obtained by the current calculation is the task calculation result corresponding to the task to be calculated.

[0173] To perform the corresponding steps in the above embodiments and various possible methods, an implementation of a task computing device is given below. Further, please refer to... Figure 5 , Figure 5This is a functional block diagram of a task computing device provided in an embodiment of the present invention. It should be noted that the task computing device provided in this embodiment has the same basic principle and technical effects as those in the above embodiments. For the sake of brevity, any parts not mentioned in this embodiment can be referred to the corresponding content in the above embodiments. The task computing device includes: a receiving module 200 and a determining module 210.

[0174] The receiving module 200 is used to receive task data packets sent by the communication node. The task data packet includes data to be calculated, a calculation program, and a task number. The communication node is a node in the blockchain network that communicates with the user, and the node that receives the task data packet is a computing node in the blockchain network. The communication node is used to forward multiple task data packets corresponding to the task to be calculated to different computing nodes, and each computing node receives a different task data packet.

[0175] Understandably, the receiving module 200 can also be used to perform the above step S20.

[0176] The determining module 210 is used to determine whether the preset merging conditions are met based on the task number;

[0177] Understandably, the determining module 210 can also be used to perform the above step S21.

[0178] The determining module 210 is further configured to perform a data processing result merging operation based on the task number if the preset merging conditions are met; the data processing result merging operation includes calculating the task number to be merged based on the task number, merging the data processing result corresponding to the task number and the data processing result corresponding to the task number to be merged to obtain a first merging result; the data processing result is a calculation result obtained by performing calculations on the data to be calculated according to the calculation program, or a second merging result obtained by performing at least one merging based on the calculation result.

[0179] Understandably, the determining module 210 can also be used to perform the above step S22.

[0180] The determining module 210 is also used to update the task number, determine whether the preset merging conditions are met based on the updated task number, and perform a data processing result merging operation based on the updated task number if the preset merging conditions are met, until it is determined based on the updated task number that the preset merging conditions are not met.

[0181] Understandably, the determining module 210 can also be used to perform the above step S23.

[0182] The determining module 210 is also used to upload the task number and the calculation result corresponding to the task number, or the updated task number and the first merge result corresponding to the updated task number, to the blockchain network if the preset merging conditions are not met, so that other computing nodes in the blockchain network can obtain the calculation result corresponding to the task number or the first merge result corresponding to the updated task number.

[0183] Understandably, the determining module 210 can also be used to perform the above step S24.

[0184] Optionally, the task number includes a first task number and a second task number. The first task number represents the current number of data processing operations, and the second task number is obtained based on the current number of data processing operations and the node number of the computing node receiving the task data packet. The determining module 210 is also used to determine that the preset merging condition is met if the second task number is even.

[0185] Optionally, the first task number to be merged is the same as the first task number, and the second task number to be merged is the second task number minus 1. The determining module 210 is also used to add 1 to the first task number to obtain a new first task number, divide the second task number by 2 to obtain a new second task number, and obtain a new task number based on the new first task number and the new second task number.

[0186] Optionally, in Figure 5 On this basis, Figure 6 For another functional block diagram of the task computing device provided in the embodiments of the present invention, please refer to [link / reference]. Figure 6 The task computing device also includes a sending module 220.

[0187] The sending module 220 is used to, upon receiving task information sent by the user, determine multiple computing nodes based on the task information, assign numbers to each computing node, and send the node number and node information corresponding to each computing node to the user; receive multiple task data packets sent by the user based on the task to be computed, and forward each task data packet to the corresponding computing node according to the node number in each task data packet.

[0188] Understandably, the sending module 220 can also be used to perform the above steps S10 to S11.

[0189] Optionally, the task information includes shard array information and the number of tasks. The sending module 220 is also used to determine the number of computing nodes based on the number of tasks; the number of computing nodes is greater than or equal to the number of tasks and is a power of 2; and multiple computing nodes are determined based on the number of computing nodes and the shard array information.

[0190] Optionally, the shard array information includes information about at least one shard array; the sending module 220 is further configured to calculate the number of sub-computing nodes corresponding to each shard array based on the number of shard arrays and the number of computing nodes; wherein the number of sub-computing nodes corresponding to each shard array is equal; and randomly select a number of sub-computing nodes as computing nodes in each shard array based on the number of sub-computing nodes corresponding to each shard array.

[0191] Optionally, the sending module 220 is further configured to, if the number of computing nodes equals the number of tasks, forward each task data packet to the corresponding computing node according to the node number in each task data packet; if the number of computing nodes is greater than the number of tasks, forward each task data packet to the corresponding computing node according to the node number in each task data packet, and assign zero-value computing tasks to the remaining computing nodes; the zero-value computing task indicates that the remaining computing nodes do not participate in task computing.

[0192] Optionally, the sending module 220 is further configured to calculate the target task number based on the number of tasks in the task information; the target task number corresponds to the task calculation result of the task to be calculated; at preset intervals, it queries the blockchain network to see if there is a task calculation result corresponding to the target task number; if so, it sends the task calculation result to the user.

[0193] The task computing device provided in this application embodiment receives task data packets sent by a communication node through a receiving module. The task data packet includes data to be computed, a computation program, and a task number. The communication node is a node in the blockchain network that communicates with the user, and the node receiving the task data packet is a computing node in the blockchain network. The communication node forwards multiple task data packets corresponding to the task to be computed to different computing nodes, and each computing node receives a different task data packet. A determining module determines whether a preset merging condition is met based on the task number. If the preset merging condition is met, a data processing result merging operation is performed based on the task number. The data processing result merging operation includes calculating the task number to be merged based on the task number, and merging the data processing result corresponding to the task number and the data processing result corresponding to the task number to be merged. The process involves several steps: first, a first merge result; second, a second merge result obtained by performing calculations on the data to be calculated according to the computational program, or by performing at least one merge based on the calculation result; third, updating the task number; determining whether a preset merge condition is met based on the updated task number; and if the preset merge condition is met, performing a data processing result merge operation based on the updated task number until it is determined that the preset merge condition is not met based on the updated task number; if the preset merge condition is not met, uploading the task number and its corresponding calculation result, or the updated task number and its corresponding first merge result, to the blockchain network so that other computing nodes in the blockchain network can obtain the calculation result corresponding to the task number or the first merge result corresponding to the updated task number. This device can improve the security of task computation in the blockchain network.

[0194] Optionally, the above modules can be stored in the form of software or firmware. Figure 1 The memory shown is either stored in or embedded in the operating system (OS) of the node device, and can be accessed by... Figure 1 The processor executes the commands. Meanwhile, the data and program code required to execute these modules can be stored in memory.

[0195] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, can implement the task calculation method provided in this application.

[0196] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative; for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0197] In addition, the functional modules in the various embodiments of the present invention can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0198] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0199] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A task calculation method, characterized in that, The method, applied to any node device in a blockchain network, includes: Receive a task data packet sent by a communication node; the task data packet includes data to be calculated, a calculation program, and a task number. The communication node is a node in the blockchain network that communicates with the user, and the node that receives the task data packet is a computing node in the blockchain network. The communication node is used to forward multiple task data packets corresponding to the task to be computed to different computing nodes, and each computing node receives a different task data packet. Determine whether the preset merging conditions are met based on the task number; The task number includes a first task number and a second task number. The first task number represents the current number of data processing operations, and the second task number is obtained based on the current number of data processing operations and the node number of the computing node that receives the task data packet. The step of determining whether the preset merging condition is met based on the task number includes: if the second task number is even, then it is determined that the preset merging condition is met. If the preset merging conditions are met, a data processing result merging operation is performed according to the task number. The data processing result merging operation includes calculating the task number to be merged based on the task number, merging the data processing result corresponding to the task number and the data processing result corresponding to the task number to be merged to obtain a first merging result. The data processing result is a calculation result obtained by performing calculations on the data to be calculated according to the calculation program, or a second merging result obtained by performing at least one merging based on the calculation result. The task number to be merged is an adjacent number of the task number, the first task number to be merged of the task number to be merged is the same as the first task number, and the second task number to be merged of the task number to be merged is the value of the second task number minus 1. The first task number is incremented by 1 to obtain a new first task number, and the second task number is divided by 2 to obtain a new second task number. A new task number is obtained based on the new first task number and the new second task number. It is determined whether the preset merging condition is met based on the updated task number. If the preset merging condition is met, the data processing result merging operation is performed based on the updated task number until it is determined that the preset merging condition is not met based on the updated task number. If the preset merging conditions are not met, the task number and the calculation result corresponding to the task number, or the updated task number and the first merging result corresponding to the updated task number, are uploaded to the blockchain network so that other computing nodes in the blockchain network can obtain the calculation result corresponding to the task number or the first merging result corresponding to the updated task number.

2. The method according to claim 1, characterized in that, The method further includes: Upon receiving task information sent by the user, multiple computing nodes are determined based on the task information, each computing node is assigned a number, and the node number and node information corresponding to each computing node are sent to the user. The system receives multiple task data packets sent by the user according to the task to be computed, and forwards each task data packet to the corresponding computing node according to the node number in each task data packet.

3. The method according to claim 2, characterized in that, The task information includes shard array information and the number of tasks. Determining multiple computing nodes based on the task information includes: The number of computing nodes is determined based on the number of tasks; the number of computing nodes is greater than or equal to the number of tasks and is a power of 2. Based on the number of computing nodes and the sharding array information, multiple computing nodes are determined.

4. The method according to claim 3, characterized in that, The fragment array information includes information about at least one fragment array; The step of determining multiple computing nodes based on the number of computing nodes and the sharding array information includes: Based on the number of the shard arrays and the number of computing nodes, the number of sub-computing nodes corresponding to each shard array is calculated; wherein, the number of sub-computing nodes corresponding to each shard array is equal. Based on the number of sub-computation nodes corresponding to each of the shard arrays, a number of nodes are randomly selected from each of the shard arrays as the computation nodes.

5. The method according to claim 3, characterized in that, The step of forwarding each task data packet to its corresponding computing node based on the node number in each task data packet includes: If the number of computing nodes is equal to the number of tasks, then each task data packet is forwarded to the corresponding computing node according to the node number in each task data packet; If the number of computing nodes is greater than the number of tasks, then each task data packet is forwarded to the corresponding computing node according to the node number in each task data packet, and zero-value computing tasks are assigned to the remaining computing nodes; the zero-value computing task indicates that the remaining computing nodes do not participate in task computing. The method further includes: Calculate the target task number based on the number of tasks in the task information; the target task number corresponds to the task calculation result corresponding to the task to be calculated. At preset intervals, the system queries the blockchain network to see if there is a task calculation result corresponding to the target task number. If it exists, the task calculation result will be sent to the user.

6. A task computing device, characterized in that, The device is used in any node device in a blockchain network, and the device includes: The receiving module is used to receive task data packets sent by the communication node; the task data packets include data to be calculated, a calculation program, and a task number. The communication node is a node in the blockchain network that communicates with the user, and the node that receives the task data packet is a computing node in the blockchain network. The communication node is used to forward multiple task data packets corresponding to the task to be computed to different computing nodes, and each computing node receives a different task data packet. The determination module is used to determine whether a preset merging condition is met based on the task number; the task number includes a first task number and a second task number, the first task number represents the current number of data processing, and the second task number is obtained based on the current number of data processing and the node number of the computing node that receives the task data packet; The determining module is further configured to determine that the preset merging condition is met if the second task number is even. The determining module is further configured to perform a data processing result merging operation based on the task number if the preset merging condition is met; the data processing result merging operation includes calculating the task number to be merged based on the task number, merging the data processing result corresponding to the task number and the data processing result corresponding to the task number to be merged to obtain a first merging result; the data processing result is a calculation result obtained by performing calculations on the data to be calculated according to the calculation program, or a second merging result obtained by performing at least one merging based on the calculation result; the task number to be merged is an adjacent number of the task number, the first task number to be merged of the task number to be merged is the same as the first task number, and the second task number to be merged of the task number to be merged is the value of the second task number minus 1; The determining module is further configured to add 1 to the first task number to obtain a new first task number, divide the second task number by 2 to obtain a new second task number, obtain a new task number based on the new first task number and the new second task number, determine whether the preset merging condition is met based on the updated task number, and if the preset merging condition is met, perform the data processing result merging operation based on the updated task number until it is determined based on the updated task number that the preset merging condition is not met. The determining module is further configured to, if the preset merging condition is not met, upload the task number and the calculation result corresponding to the task number, or the updated task number and the first merging result corresponding to the updated task number, to the blockchain network so that other computing nodes in the blockchain network can obtain the calculation result corresponding to the task number or the first merging result corresponding to the updated task number.

7. A node device, characterized in that, It includes a processor and a memory, the memory storing a computer program executable by the processor, the processor being able to execute the computer program to implement the method of any one of claims 1-5.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-5.